Skip to content

Commit 9dac8e0

Browse files
committed
ClassType: namespace is passed to methods immediately
1 parent 726e022 commit 9dac8e0

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/PhpGenerator/ClassType.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)