f3581ebd61182483850202b63ba5179692b3b486
[PHP_CodeDoc] / CodeDoc / Parser / Var.php
1 <?php
2 /*
3 *@package PHP_CodeDoc
4 */
5 /*
6
7 var parser -  very simple!
8 uses parent (master codedoc object) which contains the active tokens
9
10 */
11
12  
13 class PHP_CodeDoc_Parser_Var {
14
15     
16     var $var; // current return value;
17     function read ($inclass) {
18         if (!$inclass) {
19             return;
20         }
21         if ($c = PHP_CodeDoc_Parser_Var::parse()) {
22              
23             $c->activeFile = $this->activeFile;
24             $this->classes[$this->_active_class]->Attributes[$c->name] = $c;
25             $this->classes[$this->_active_class]->Attributes[$c->name]->class =
26             $this->classes[$this->_active_class]->name;
27         }
28     }
29     
30     
31     function parse()
32     { //  read var declares in a class
33         $flags= array($this->look_nws(-1), $this->look_nws(-2), $this->look_nws(-3), $this->look_nws(-4));
34        
35         
36         $startpos = $this->pos;
37         
38         $var = new PHP_CodeDoc_Data_Var;
39         $var->name  = $this->tokens[$this->pos+2][1];
40         $var->type = "Public";
41         $var->isPublic = 1;
42         $var->isStatic = 0;
43         if (in_array(T_PRIVATE, $flags)) {
44             $var->type = "Private";
45             $var->isPublic = 0;
46             $var->visibility = 0;
47         }
48         if (in_array(T_PROTECTED, $flags)) {
49             $var->type = "Protected";
50             $var->isPublic = 0;
51             $var->visibility = 0;
52         }
53         if (in_array(T_STATIC, $flags)) {
54             $var->isStatic = 1;
55         }
56         
57         $var->visibility = 1;
58         
59         PHP_CodeDoc_Parser_Var::_store_tokens($var);
60         
61         if ($v = PHP_CodeDoc_Parser_Comment::parse()) {
62             $var->description = $v;
63         }
64         $this->pos = $startpos;
65            
66         return $var;
67     
68     }
69     
70     /* 
71     remember the tokens for a var.. (for printing later)
72     */
73     function _store_tokens(&$var) { 
74         //return;
75         $var->tokenStart=$this->pos;
76         $n=0;
77         $in_method =0;
78         $inbrak =0;
79         $level=0;
80         $pos = $this->pos;
81         while ($pos < $this->total) {
82             $v = $this->tokens[$pos];
83             if (!is_array($v)) {
84                 if (trim($v) == ";") {
85                     $var->tokenEnd = $pos;
86                     return;
87                 }
88             }
89              
90             $var->tokens[$n] = $v;
91             $pos++;
92             $n++;
93         }
94         $var->tokenEnd = $pos;
95     }
96     
97     
98 }
99 ?>
100    
101