Changed CodeDoc/Parser.phpCodeDoc/Parser/Comment.phpCodeDoc/Parser/Method.phpCodeDoc...
authorAlan Knowles <alan@roojs.com>
Wed, 28 Apr 2021 05:13:01 +0000 (13:13 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 28 Apr 2021 05:13:01 +0000 (13:13 +0800)
CodeDoc/Parser.php
CodeDoc/Parser/Comment.php
CodeDoc/Parser/Method.php
CodeDoc/Parser/Var.php

index d51bdc6..098aa9c 100644 (file)
@@ -257,19 +257,19 @@ class PHP_CodeDoc_Parser {
               //  $this->debug(__METHOD__, "{$this->pos}:" .token_name($v[0]) . ":". $v[1]);
                 switch ($v[0]) {
                     case T_CLASS:
-                        PHP_CodeDoc_Parser_Class::read();
+                        PHP_CodeDoc_Parser_Class::read($this);
                         $class_found=1;
                         $inclass =1;
                         break;
                     case T_FUNCTION:
-                        PHP_CodeDoc_Parser_Method::read($inclass);
+                        PHP_CodeDoc_Parser_Method::read($this, $inclass);
                         break;
                     case T_CONST:
                     case T_VAR:
-                        PHP_CodeDoc_Parser_Var::read($inclass);
+                        PHP_CodeDoc_Parser_Var::read($this, $inclass);
                         break;
                     case T_STRING:
-                        PHP_CodeDoc_Parser_Define::read($v[1]);
+                        PHP_CodeDoc_Parser_Define::read($this, $v[1]);
                         break;
                     case T_DOC_COMMENT:
                     case T_COMMENT:
index 34e394a..8fcd601 100644 (file)
@@ -15,21 +15,21 @@ require_once 'PHP/CodeDoc/Data/Param.php';
 class PHP_CodeDoc_Parser_Comment {
 
     
-    function parse() { // static method !!!! returns a Phpdoc data object
-        if ($r = PHP_CodeDoc_Parser_Comment::phpDocParse()) {
+    function parse(PHP_CodeDoc_Parser $thiz) { // static method !!!! returns a Phpdoc data object
+        if ($r = PHP_CodeDoc_Parser_Comment::phpDocParse($thiz)) {
             return $r;
         }
-        return PHP_CodeDoc_Parser_Comment::shortDocParse();
+        return PHP_CodeDoc_Parser_Comment::shortDocParse($thiz);
     } 
     
     
-    function phpDocParse() { // parse normal phpdoc comments
+    static function phpDocParse(PHP_CodeDoc_Parser $thiz) { // parse normal phpdoc comments
         $desc = new PHP_CodeDoc_Data_PhpDoc;   
-        if (!$this->last_comment_block) 
+        if (!$thiz->last_comment_block) 
             return;
         // clear last comment
-        $comment  = $this->last_comment_block;
-        $this->last_comment_block = "";
+        $comment  = $thiz->last_comment_block;
+        $thiz->last_comment_block = "";
         if (substr(trim($comment),0,2) != "/*") 
             return;
         
@@ -160,7 +160,7 @@ class PHP_CodeDoc_Parser_Comment {
                         $flags['rawdata'] = TRUE;
                         break;
                     default:
-                        $desc->$key = $linedata[2];\r
+                        $desc->$key = $linedata[2];\r\r
                 }
                 continue;
             }
@@ -190,12 +190,12 @@ class PHP_CodeDoc_Parser_Comment {
     } 
     
     
-    function shortDocParse() { // parse short comments
+    function shortDocParse(PHP_CodeDoc_Parser $thiz) { // parse short comments
         $desc = new PHP_CodeDoc_Data_PhpDoc;    
-        $pos = $this->pos+1;
+        $pos = $thiz->pos+1;
         //echo "LOOKING FOR SHORT";
-        while($pos < $this->total) {
-            $v = $this->tokens[$pos];
+        while($pos < $thiz->total) {
+            $v = $thiz->tokens[$pos];
             
             if (is_array($v)) {
                 
index 3fc4f2a..89406ba 100644 (file)
@@ -20,17 +20,17 @@ inherit $this from the parser!!!!!!!
 class PHP_CodeDoc_Parser_Method {
  
  
-    function read($inclass) {
+    static function read(PHP_CodeDoc_Parser $thiz, $inclass) {
         
-        if ($c = PHP_CodeDoc_Parser_Method::parse()) {
-            $this->debug(__METHOD__,$c->name);
+        if ($c = PHP_CodeDoc_Parser_Method::parse($thiz)) {
+            $thiz->debug(__METHOD__,$c->name);
             if ($inclass) {
                 
-                $c->rfilename = $this->rfilename;
-                $c->activeFile = $this->activeFile;
+                $c->rfilename = $thiz->rfilename;
+                $c->activeFile = $thiz->activeFile;
                
-                $this->classes[$this->_active_class]->Operations[$c->name] = $c;
-                $this->classes[$this->_active_class]->Operations[$c->name]->class = $this->classes[$this->_active_class]->name;
+                $thiz->classes[$thiz->_active_class]->Operations[$c->name] = $c;
+                $thiz->classes[$thiz->_active_class]->Operations[$c->name]->class = $thiz->classes[$thiz->_active_class]->name;
                 
                 
                 // silly stuff :)
@@ -38,42 +38,42 @@ class PHP_CodeDoc_Parser_Method {
                 // hey this is a cool use of all those array functions!
                 
                
-                if (@$a = $this->classes[$this->_active_class]->Operations[$c->name]->description->author) 
-                      $this->classes[$this->_active_class]->description->author 
+                if (@$a = $thiz->classes[$thiz->_active_class]->Operations[$c->name]->description->author) 
+                      $thiz->classes[$thiz->_active_class]->description->author 
                         = array_reverse(array_values( array_unique (array_reverse(array_merge(
-                            $this->classes[$this->_active_class]->description->author, $a)))));
+                            $thiz->classes[$thiz->_active_class]->description->author, $a)))));
                 
-                // echo $this->methods++;
+                // echo $thiz->methods++;
             } else {
-                $c->active_package = &$this->packages[$this->active_package->name];
-                $c->rfilename = $this->rfilename;
-                $c->activeFile = $this->activeFile;
+                $c->active_package = &$thiz->packages[$thiz->active_package->name];
+                $c->rfilename = $thiz->rfilename;
+                $c->activeFile = $thiz->activeFile;
                
-                $this->active_directory->functions[] = $c;
+                $thiz->active_directory->functions[] = $c;
                 //$c->active_package->functions[$c->name] = $c;
             }
-            $this->pos = $c->endpos;
+            $thiz->pos = $c->endpos;
         }
     }
                                  
 
     var $_active_method; // return object (PHP_CodeDoc_MethodParser)
     
-    function parse() { // really parse
+    function parse(PHP_CodeDoc_Parser $thiz) { // really parse
         
         // before pos... 2 points...
         /// probably need to look back for 'string'?
-        $flags= array($this->look_nws(-1), $this->look_nws(-2), $this->look_nws(-3), $this->look_nws(-4));
+        $flags= array($thiz->look_nws(-1), $thiz->look_nws(-2), $thiz->look_nws(-3), $thiz->look_nws(-4));
          
         
-        $startpos = $this->pos;
-        if ($npos = $this->find_token_pos($startpos,array(T_STRING),'(')) {
-            $n = @$this->tokens[$npos][1];
+        $startpos = $thiz->pos;
+        if ($npos = $thiz->find_token_pos($startpos,array(T_STRING),'(')) {
+            $n = @$thiz->tokens[$npos][1];
         } else {
             return;
         }
         
-        $this->pos = $this->pos + 4;
+        $thiz->pos = $thiz->pos + 4;
         $method = new PHP_CodeDoc_Data_Method;
         $method->name = $n;
         $method->type = "Public";
@@ -93,18 +93,18 @@ class PHP_CodeDoc_Parser_Method {
         }
         
         
-        $method->Param = PHP_CodeDoc_Parser_Method::_get_args($method);
+        $method->Param = PHP_CodeDoc_Parser_Method::_get_args($thiz,$method);
         
-        if ($v = PHP_CodeDoc_Parser_Comment::parse()) {
+        if ($v = PHP_CodeDoc_Parser_Comment::parse($thiz)) {
             $method->description = $v;
         }
         
-        $this->pos = $startpos;
-        PHP_CodeDoc_Parser_Method::_store_method_tokens($method);
+        $thiz->pos = $startpos;
+        PHP_CodeDoc_Parser_Method::_store_method_tokens($thiz,$method);
         // store the array of objects so It can be printed out!
-        $this->pos = $startpos;
+        $thiz->pos = $startpos;
         
-        $method->endpos = $this->endpos;
+        $method->endpos = $thiz->endpos;
         return $method;
         
     }
@@ -112,18 +112,18 @@ class PHP_CodeDoc_Parser_Method {
             
         
     
-    function _store_method_tokens(&$method) { //remember the tokens for a method.. (for printing later)
+    function _store_method_tokens(PHP_CodeDoc_Parser $thiz, &$method) { //remember the tokens for a method.. (for printing later)
         //return;
         $tokens=array();
         $n=0;
         $in_method =0;
         $inbrak =0;
         $level=0;
-        $pos = $this->pos;
-        $method->tokenStart = $this->pos;
-        $startpos = $this->pos;
-        while ($pos < $this->total) {
-            $v = $this->tokens[$pos];
+        $pos = $thiz->pos;
+        $method->tokenStart = $thiz->pos;
+        $startpos = $thiz->pos;
+        while ($pos < $thiz->total) {
+            $v = $thiz->tokens[$pos];
             if (is_array($v)) {
                 if (!$inbrak && $v[0] == T_CURLY_OPEN) {
                     if ($level ==0) 
@@ -149,7 +149,7 @@ class PHP_CodeDoc_Parser_Method {
              
             $tokens[$n] = $v;
             if ($in_method && !$level) {
-                $this->endpos = $pos;
+                $thiz->endpos = $pos;
                 $method->tokenEnd = $pos;
                 
                 return;
@@ -157,21 +157,21 @@ class PHP_CodeDoc_Parser_Method {
             $pos++;
             $n++;
         }
-        $this->endpos = $this->pos+1;
-        $method->tokenEnd = $this->pos+1;
+        $thiz->endpos = $thiz->pos+1;
+        $method->tokenEnd = $thiz->pos+1;
     }
     
     
     
-    function _get_args (&$method) {// read arguments of a method call
+    function _get_args (PHP_CodeDoc_Parser $thiz, &$method) {// read arguments of a method call
         $Param= array();
         $level =0;
         $p = -1;
-        while ($this->pos < $this->total) {
-            $v = $this->tokens[$this->pos];
+        while ($thiz->pos < $thiz->total) {
+            $v = $thiz->tokens[$thiz->pos];
             if (is_array($v)) {
                 if ($v[0] == T_WHITESPACE) { 
-                    $this->pos++;
+                    $thiz->pos++;
                     continue 1;
                 }
                 switch ($v[0]) {
@@ -192,15 +192,15 @@ class PHP_CodeDoc_Parser_Method {
                         $Param[$p]->Value  = "array()";
                         break;
                 }
-                //echo "XXX:{$this->pos}:" .token_name($v[0]) . ":{$this->level}:". $v[1] .":\n";
+                //echo "XXX:{$thiz->pos}:" .token_name($v[0]) . ":{$thiz->level}:". $v[1] .":\n";
             } else {
                 //if ($v == "(") $level++;
                 if ($v == "{") return $Param;
                 
                 //if ($v == ",") $current_var = "";
-                //echo "XXX:{$this->pos}:RAW:{$v}\n";
+                //echo "XXX:{$thiz->pos}:RAW:{$v}\n";
             }
-            $this->pos++;
+            $thiz->pos++;
         }        
         return $Param; // shouldnt really get here
     }
index e5a025d..9fcf56d 100644 (file)
@@ -14,34 +14,34 @@ class PHP_CodeDoc_Parser_Var {
 
     
     var $var; // current return value;
-    function read ($inclass) {
+    static function read (PHP_CodeDoc_Parser $thiz, $inclass) {
         if (!$inclass) {
             return;
         }
-        if ($c = PHP_CodeDoc_Parser_Var::parse()) {
+        if ($c = PHP_CodeDoc_Parser_Var::parse($thiz)) {
              
-            $c->activeFile = $this->activeFile;
-            $this->classes[$this->_active_class]->Attributes[$c->name] = $c;
-            $this->classes[$this->_active_class]->Attributes[$c->name]->class =
-                    $this->classes[$this->_active_class]->name;
+            $c->activeFile = $thiz->activeFile;
+            $thiz->classes[$thiz->_active_class]->Attributes[$c->name] = $c;
+            $thiz->classes[$thiz->_active_class]->Attributes[$c->name]->class =
+                    $thiz->classes[$thiz->_active_class]->name;
         }
     }
     
     
-    function parse()
+    function parse(PHP_CodeDoc_Parser $thiz)
     { //  read var declares in a class
-        $flags= array($this->look_nws(-1), $this->look_nws(-2), $this->look_nws(-3), $this->look_nws(-4));
+        $flags= array($thiz->look_nws(-1), $thiz->look_nws(-2), $thiz->look_nws(-3), $thiz->look_nws(-4));
        
         
-        $startpos = $this->pos;
+        $startpos = $thiz->pos;
         
         $var = new PHP_CodeDoc_Data_Var;
-        $var->name  = $this->tokens[$this->pos+2][1];
+        $var->name  = $thiz->tokens[$thiz->pos+2][1];
         $var->type = "Public";
         $var->isPublic = 1;
         $var->isStatic = 0;
         $var->visibility = 1;
-        $var->isConstant = $this->tokens[$this->pos][0] == T_CONST;
+        $var->isConstant = $thiz->tokens[$thiz->pos][0] == T_CONST;
         
         if (in_array(T_PRIVATE, $flags)) {
             $var->type = "Private";
@@ -59,12 +59,12 @@ class PHP_CodeDoc_Parser_Var {
         
         $var->visibility = 1;
         
-        PHP_CodeDoc_Parser_Var::_store_tokens($var);
+        PHP_CodeDoc_Parser_Var::_store_tokens($thiz, $var);
         
-        if ($v = PHP_CodeDoc_Parser_Comment::parse()) {
+        if ($v = PHP_CodeDoc_Parser_Comment::parse($thiz)) {
             $var->description = $v;
         }
-        $this->pos = $startpos;
+        $thiz->pos = $startpos;
            
         return $var;
     
@@ -73,16 +73,16 @@ class PHP_CodeDoc_Parser_Var {
     /* 
     remember the tokens for a var.. (for printing later)
     */
-    function _store_tokens(&$var) { 
+    function _store_tokens(PHP_CodeDoc_Parser $thiz, &$var) { 
         //return;
-        $var->tokenStart=$this->pos;
+        $var->tokenStart=$thiz->pos;
         $n=0;
         $in_method =0;
         $inbrak =0;
         $level=0;
-        $pos = $this->pos;
-        while ($pos < $this->total) {
-            $v = $this->tokens[$pos];
+        $pos = $thiz->pos;
+        while ($pos < $thiz->total) {
+            $v = $thiz->tokens[$pos];
             if (!is_array($v)) {
                 if (trim($v) == ";") {
                     $var->tokenEnd = $pos;
@@ -99,6 +99,5 @@ class PHP_CodeDoc_Parser_Var {
     
     
 }
-?>
-   
    
\ No newline at end of file