Changed CodeDoc/Parser.phpCodeDoc/Parser/Comment.phpCodeDoc/Parser/Method.phpCodeDoc...
[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     static function read (PHP_CodeDoc_Parser $thiz, $inclass) {
18         if (!$inclass) {
19             return;
20         }
21         if ($c = PHP_CodeDoc_Parser_Var::parse($thiz)) {
22              
23             $c->activeFile = $thiz->activeFile;
24             $thiz->classes[$thiz->_active_class]->Attributes[$c->name] = $c;
25             $thiz->classes[$thiz->_active_class]->Attributes[$c->name]->class =
26                     $thiz->classes[$thiz->_active_class]->name;
27         }
28     }
29     
30     
31     function parse(PHP_CodeDoc_Parser $thiz)
32     { //  read var declares in a class
33         $flags= array($thiz->look_nws(-1), $thiz->look_nws(-2), $thiz->look_nws(-3), $thiz->look_nws(-4));
34        
35         
36         $startpos = $thiz->pos;
37         
38         $var = new PHP_CodeDoc_Data_Var;
39         $var->name  = $thiz->tokens[$thiz->pos+2][1];
40         $var->type = "Public";
41         $var->isPublic = 1;
42         $var->isStatic = 0;
43         $var->visibility = 1;
44         $var->isConstant = $thiz->tokens[$thiz->pos][0] == T_CONST;
45         
46         if (in_array(T_PRIVATE, $flags)) {
47             $var->type = "Private";
48             $var->isPublic = 0;
49             $var->visibility = 0;
50         }
51         if (in_array(T_PROTECTED, $flags)) {
52             $var->type = "Protected";
53             $var->isPublic = 0;
54             $var->visibility = 0;
55         }
56         if (in_array(T_STATIC, $flags)) {
57             $var->isStatic = 1;
58         }
59         
60         $var->visibility = 1;
61         
62         PHP_CodeDoc_Parser_Var::_store_tokens($thiz, $var);
63         
64         if ($v = PHP_CodeDoc_Parser_Comment::parse($thiz)) {
65             $var->description = $v;
66         }
67         $thiz->pos = $startpos;
68            
69         return $var;
70     
71     }
72     
73     /* 
74     remember the tokens for a var.. (for printing later)
75     */
76     function _store_tokens(PHP_CodeDoc_Parser $thiz, &$var) { 
77         //return;
78         $var->tokenStart=$thiz->pos;
79         $n=0;
80         $in_method =0;
81         $inbrak =0;
82         $level=0;
83         $pos = $thiz->pos;
84         while ($pos < $thiz->total) {
85             $v = $thiz->tokens[$pos];
86             if (!is_array($v)) {
87                 if (trim($v) == ";") {
88                     $var->tokenEnd = $pos;
89                     return;
90                 }
91             }
92              
93             $var->tokens[$n] = $v;
94             $pos++;
95             $n++;
96         }
97         $var->tokenEnd = $pos;
98     }
99     
100     
101 }
102  
103