@@ -83,7 +83,7 @@ public static function from($from)
83
83
}
84
84
foreach ($ from ->getMethods () as $ method ) {
85
85
if ($ method ->getDeclaringClass () == $ from ) { // intentionally ==
86
- $ class ->methods [$ method ->getName ()] = Method::from ($ method );
86
+ $ class ->methods [$ method ->getName ()] = Method::from ($ method )-> setNamespace ( $ class -> namespace ) ;
87
87
}
88
88
}
89
89
return $ class ;
@@ -120,10 +120,6 @@ public function __toString()
120
120
return array_map ([$ this ->namespace ?: new PhpNamespace , 'unresolveName ' ], $ arr );
121
121
};
122
122
123
- foreach ($ this ->methods as $ method ) {
124
- $ method ->setNamespace ($ this ->namespace );
125
- }
126
-
127
123
return Strings::normalize (
128
124
($ this ->comment ? str_replace ("\n" , "\n * " , "/** \n" . $ this ->comment ) . "\n */ \n" : '' )
129
125
. ($ this ->abstract ? 'abstract ' : '' )
@@ -472,7 +468,7 @@ public function setMethods(array $methods)
472
468
if (!$ v instanceof Method) {
473
469
throw new Nette \InvalidArgumentException ('Argument must be Nette\PhpGenerator\Method[]. ' );
474
470
}
475
- $ this ->methods [$ v ->getName ()] = $ v ;
471
+ $ this ->methods [$ v ->getName ()] = $ v-> setNamespace ( $ this -> namespace ) ;
476
472
}
477
473
return $ this ;
478
474
}
@@ -505,7 +501,7 @@ public function getMethod($name)
505
501
*/
506
502
public function addMethod ($ name )
507
503
{
508
- $ method = new Method ($ name );
504
+ $ method = ( new Method ($ name))-> setNamespace ( $ this -> namespace );
509
505
if ($ this ->type === 'interface ' ) {
510
506
$ method ->setVisibility (NULL )->setBody (FALSE );
511
507
} else {
0 commit comments