@@ -32,11 +32,15 @@ private static function helperSortByLine($a, $b) {
3232 return $ a ['line ' ] > $ b ['line ' ] ? 1 : 0 ;
3333 }
3434
35- private function struct ($ node , $ parent =array ())
35+ private function struct ($ node , $ reset = FALSE , $ parent =array ())
3636 {
3737 static $ scope = array ();
3838 static $ structs = array ();
3939
40+ if ($ reset ) {
41+ $ structs = array ();
42+ }
43+
4044 $ kind = $ name = $ line = $ access = '' ;
4145
4246 if (!empty ($ parent )) array_push ($ scope , $ parent );
@@ -50,7 +54,7 @@ private function struct($node, $parent=array())
5054 $ name = $ node ->name ;
5155 $ line = $ node ->getLine ();
5256 foreach ($ node as $ subNode ) {
53- $ this ->struct ($ subNode , array ('class ' => $ name ));
57+ $ this ->struct ($ subNode , FALSE , array ('class ' => $ name ));
5458 }
5559 } elseif ($ node instanceof PHPParser_Node_Stmt_Property) {
5660 $ kind = 'p ' ;
@@ -69,7 +73,7 @@ private function struct($node, $parent=array())
6973 $ line = $ node ->getLine ();
7074 $ access = $ this ->getNodeAccess ($ node );
7175 foreach ($ node as $ subNode ) {
72- $ this ->struct ($ subNode , array ('method ' => $ name ));
76+ $ this ->struct ($ subNode , FALSE , array ('method ' => $ name ));
7377 }
7478 } elseif ($ node instanceof PHPParser_Node_Stmt_Const) {
7579 $ kind = 'd ' ;
@@ -90,7 +94,7 @@ private function struct($node, $parent=array())
9094 $ name = $ node ->name ;
9195 $ line = $ node ->getLine ();
9296 foreach ($ node as $ subNode ) {
93- $ this ->struct ($ subNode , array ('function ' => $ name ));
97+ $ this ->struct ($ subNode , FALSE , array ('function ' => $ name ));
9498 }
9599 } elseif ($ node instanceof PHPParser_Node_Stmt_Trait) {
96100 //@todo
@@ -99,7 +103,7 @@ private function struct($node, $parent=array())
99103 $ name = $ node ->name ;
100104 $ line = $ node ->getLine ();
101105 foreach ($ node as $ subNode ) {
102- $ this ->struct ($ subNode , array ('interface ' => $ name ));
106+ $ this ->struct ($ subNode , FALSE , array ('interface ' => $ name ));
103107 }
104108 } elseif ($ node instanceof PHPParser_Node_Stmt_Namespace) {
105109 //@todo
@@ -214,7 +218,7 @@ public function export($file, $options)
214218 {
215219 //@todo Check for existence
216220 $ this ->mFile = $ file ;
217- $ structs = $ this ->struct ($ this ->mParser ->parse (file_get_contents ($ this ->mFile )));
218- echo $ this ->render ($ structs ,$ options );
221+ $ structs = $ this ->struct ($ this ->mParser ->parse (file_get_contents ($ this ->mFile )), TRUE );
222+ echo $ this ->render ($ structs , $ options );
219223 }
220224}
0 commit comments