CodeDoc/Parser/Var.php
authorAlan Knowles <alan@roojs.com>
Fri, 28 Oct 2016 08:23:26 +0000 (16:23 +0800)
committerAlan Knowles <alan@roojs.com>
Fri, 28 Oct 2016 08:23:26 +0000 (16:23 +0800)
CodeDoc/Parser/Method.php

CodeDoc/Parser/Method.php
CodeDoc/Parser/Var.php [new file with mode: 0644]

index 6f2b61c..3fc4f2a 100644 (file)
@@ -63,7 +63,7 @@ class PHP_CodeDoc_Parser_Method {
         
         // 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($this->look_nws(-1), $this->look_nws(-2), $this->look_nws(-3), $this->look_nws(-4));
          
         
         $startpos = $this->pos;
diff --git a/CodeDoc/Parser/Var.php b/CodeDoc/Parser/Var.php
new file mode 100644 (file)
index 0000000..dcf052b
--- /dev/null
@@ -0,0 +1,90 @@
+<?php
+/*
+*@package PHP_CodeDoc
+*/
+/*
+
+var parser -  very simple!
+uses parent (master codedoc object) which contains the active tokens
+
+*/
+
+class PHP_CodeDoc_Parser_Var {
+
+    
+    var $var; // current return value;
+    function read ($inclass) {
+        if (!$inclass) {
+            return;
+        }
+        if ($c = PHP_CodeDoc_Parser_Var::parse()) {
+             
+            $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;
+        }
+    }
+    
+    
+    function parse()
+    { //  read var declares in a class
+        $flags= array($this->look_nws(-1), $this->look_nws(-2), $this->look_nws(-3), $this->look_nws(-4));
+       
+        
+        $startpos = $this->pos;
+        
+        $var = new PHP_CodeDoc_Data_Var;
+        $var->name  = $this->tokens[$this->pos+2][1];
+        $var->type = "Public";
+        $var->isPublic = 1;
+        if ($var->name{1} == "_") {
+            $var->type = "Private";
+            $var->isPublic = 0;
+        }
+        $var->visibility = 1;
+        
+        PHP_CodeDoc_Parser_Var::_store_tokens($var);
+        
+        if ($v = PHP_CodeDoc_Parser_Comment::parse()) {
+            $var->description = $v;
+        }
+        $this->pos = $startpos;
+           
+        return $var;
+    
+    }
+    
+    /* 
+    remember the tokens for a var.. (for printing later)
+    */
+    function _store_tokens(&$var) { 
+        //return;
+        $var->tokenStart=$this->pos;
+        $n=0;
+        $in_method =0;
+        $inbrak =0;
+        $level=0;
+        $pos = $this->pos;
+        while ($pos < $this->total) {
+            $v = $this->tokens[$pos];
+            if (!is_array($v)) {
+                if (trim($v) == ";") {
+                    $var->tokenEnd = $pos;
+                    return;
+                }
+            }
+             
+            $var->tokens[$n] = $v;
+            $pos++;
+            $n++;
+        }
+        $var->tokenEnd = $pos;
+    }
+    
+    
+}
+?>
+   
+   
\ No newline at end of file