Skip to content

Commit

Permalink
ClassType: namespace is passed to methods immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Sep 1, 2015
1 parent 42e818c commit ed06e30
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/PhpGenerator/ClassType.php
Expand Up @@ -83,7 +83,7 @@ public static function from($from)
}
foreach ($from->getMethods() as $method) {
if ($method->getDeclaringClass() == $from) { // intentionally ==
$class->methods[$method->getName()] = Method::from($method);
$class->methods[$method->getName()] = Method::from($method)->setNamespace($class->namespace);
}
}
return $class;
Expand Down Expand Up @@ -120,10 +120,6 @@ public function __toString()
return array_map([$this->namespace ?: new PhpNamespace, 'unresolveName'], $arr);
};

foreach ($this->methods as $method) {
$method->setNamespace($this->namespace);
}

return Strings::normalize(
($this->comment ? str_replace("\n", "\n * ", "/**\n" . $this->comment) . "\n */\n" : '')
. ($this->abstract ? 'abstract ' : '')
Expand Down Expand Up @@ -472,7 +468,7 @@ public function setMethods(array $methods)
if (!$v instanceof Method) {
throw new Nette\InvalidArgumentException('Argument must be Nette\PhpGenerator\Method[].');
}
$this->methods[$v->getName()] = $v;
$this->methods[$v->getName()] = $v->setNamespace($this->namespace);
}
return $this;
}
Expand Down Expand Up @@ -505,7 +501,7 @@ public function getMethod($name)
*/
public function addMethod($name)
{
$method = new Method($name);
$method = (new Method($name))->setNamespace($this->namespace);
if ($this->type === 'interface') {
$method->setVisibility(NULL)->setBody(FALSE);
} else {
Expand Down

0 comments on commit ed06e30

Please sign in to comment.