@@ -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 ;
@@ -121,10 +121,6 @@ public function __toString()
121
121
return array_map (array ($ namespace , 'unresolveName ' ), $ arr );
122
122
};
123
123
124
- foreach ($ this ->methods as $ method ) {
125
- $ method ->setNamespace ($ this ->namespace );
126
- }
127
-
128
124
return Strings::normalize (
129
125
($ this ->documents ? str_replace ("\n" , "\n * " , "/** \n" . implode ("\n" , $ this ->documents )) . "\n */ \n" : '' )
130
126
. ($ this ->abstract ? 'abstract ' : '' )
@@ -456,7 +452,7 @@ public function setMethods(array $methods)
456
452
if (!$ v instanceof Method) {
457
453
throw new Nette \InvalidArgumentException ('Argument must be Nette\PhpGenerator\Method[]. ' );
458
454
}
459
- $ this ->methods [$ v ->getName ()] = $ v ;
455
+ $ this ->methods [$ v ->getName ()] = $ v-> setNamespace ( $ this -> namespace ) ;
460
456
}
461
457
return $ this ;
462
458
}
@@ -495,7 +491,7 @@ public function addMethod($name)
495
491
} else {
496
492
$ method ->setVisibility ('public ' );
497
493
}
498
- return $ this ->methods [$ name ] = $ method ;
494
+ return $ this ->methods [$ name ] = $ method-> setNamespace ( $ this -> namespace ) ;
499
495
}
500
496
501
497
}
0 commit comments