@@ -182,9 +182,11 @@ private function struct($node, $reset=FALSE, $parent=array())
182182 $ this ->struct ($ subNode , FALSE , array ('interface ' => $ name ));
183183 }
184184 } elseif ($ node instanceof PHPParser_Node_Stmt_Namespace) {
185- //@todo
185+ $ kind = 'n ' ;
186+ $ name = $ node ->name ;
187+ $ line = $ node ->getLine ();
186188 foreach ($ node as $ subNode ) {
187- $ this ->struct ($ subNode );
189+ $ this ->struct ($ subNode, FALSE , array ( ' namespace ' => $ name ) );
188190 }
189191 } elseif ($ node instanceof PHPParser_Node_Expr_Assign) {
190192 if (is_string ($ node ->var ->name )) {
@@ -283,19 +285,39 @@ private function render()
283285
284286 #field=s
285287 if (in_array ('s ' , $ this ->mOptions ['fields ' ]) && !empty ($ struct ['scope ' ])) {
288+ // $scope, $type, $name are current scope variables
286289 $ scope = array_pop ($ struct ['scope ' ]);
287290 list ($ type , $ name ) = each ($ scope );
288291 switch ($ type ) {
292+ case 'class ' :
293+ // n_* stuffs are namespace related scope variables
294+ // current > class > namespace
295+ $ n_scope = array_pop ($ struct ['scope ' ]);
296+ if (!empty ($ n_scope )) {
297+ list ($ n_type , $ n_name ) = each ($ n_scope );
298+ $ s_str = 'class: ' . $ n_name . '\\' . $ name ;
299+ } else {
300+ $ s_str = 'class: ' . $ name ;
301+ }
302+ break ;
289303 case 'method ' :
290- $ scope = array_pop ($ struct ['scope ' ]);
291- list ($ p_type , $ p_name ) = each ($ scope );
292- $ scope = 'method: ' . $ p_name . ':: ' . $ name ;
304+ // c_* stuffs are class related scope variables
305+ // current > method > class > namespace
306+ $ c_scope = array_pop ($ struct ['scope ' ]);
307+ list ($ c_type , $ c_name ) = each ($ c_scope );
308+ $ n_scope = array_pop ($ struct ['scope ' ]);
309+ if (!empty ($ n_scope )) {
310+ list ($ n_type , $ n_name ) = each ($ n_scope );
311+ $ s_str = 'method: ' . $ n_name . '\\' . $ c_name . ':: ' . $ name ;
312+ } else {
313+ $ s_str = 'method: ' . $ c_name . ':: ' . $ name ;
314+ }
293315 break ;
294316 default :
295- $ scope = $ type . ': ' . $ name ;
317+ $ s_str = $ type . ': ' . $ name ;
296318 break ;
297319 }
298- $ str .= "\t" . $ scope ;
320+ $ str .= "\t" . $ s_str ;
299321 }
300322
301323 #field=a
0 commit comments