@@ -83,7 +83,7 @@ public static function from($from)
8383 }
8484 foreach ($ from ->getMethods () as $ method ) {
8585 if ($ method ->getDeclaringClass () == $ from ) { // intentionally ==
86- $ class ->methods [$ method ->getName ()] = Method::from ($ method );
86+ $ class ->methods [$ method ->getName ()] = Method::from ($ method )-> setNamespace ( $ class -> namespace ) ;
8787 }
8888 }
8989 return $ class ;
@@ -121,10 +121,6 @@ public function __toString()
121121 return array_map (array ($ namespace , 'unresolveName ' ), $ arr );
122122 };
123123
124- foreach ($ this ->methods as $ method ) {
125- $ method ->setNamespace ($ this ->namespace );
126- }
127-
128124 return Strings::normalize (
129125 ($ this ->documents ? str_replace ("\n" , "\n * " , "/** \n" . implode ("\n" , $ this ->documents )) . "\n */ \n" : '' )
130126 . ($ this ->abstract ? 'abstract ' : '' )
@@ -456,7 +452,7 @@ public function setMethods(array $methods)
456452 if (!$ v instanceof Method) {
457453 throw new Nette \InvalidArgumentException ('Argument must be Nette\PhpGenerator\Method[]. ' );
458454 }
459- $ this ->methods [$ v ->getName ()] = $ v ;
455+ $ this ->methods [$ v ->getName ()] = $ v-> setNamespace ( $ this -> namespace ) ;
460456 }
461457 return $ this ;
462458 }
@@ -495,7 +491,7 @@ public function addMethod($name)
495491 } else {
496492 $ method ->setVisibility ('public ' );
497493 }
498- return $ this ->methods [$ name ] = $ method ;
494+ return $ this ->methods [$ name ] = $ method-> setNamespace ( $ this -> namespace ) ;
499495 }
500496
501497}
0 commit comments