Skip to content

Commit 5abae40

Browse files
committed
FunctionLike: removed setNamespace() (BC break)
It is not needed anymore, thanks to new Printer
1 parent b163fa9 commit 5abae40

File tree

5 files changed

+8
-12
lines changed

5 files changed

+8
-12
lines changed

src/PhpGenerator/ClassType.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public function addMember($member): self
289289
if ($this->type === self::TYPE_INTERFACE) {
290290
$member->setBody(null);
291291
}
292-
$this->methods[$member->getName()] = $member->setNamespace($this->namespace);
292+
$this->methods[$member->getName()] = $member;
293293

294294
} elseif ($member instanceof Property) {
295295
$this->properties[$member->getName()] = $member;
@@ -411,7 +411,7 @@ public function setMethods(array $methods): self
411411
if (!$v instanceof Method) {
412412
throw new Nette\InvalidArgumentException('Argument must be Nette\PhpGenerator\Method[].');
413413
}
414-
$this->methods[$v->getName()] = $v->setNamespace($this->namespace);
414+
$this->methods[$v->getName()] = $v;
415415
}
416416
return $this;
417417
}
@@ -437,7 +437,7 @@ public function getMethod(string $name): Method
437437

438438
public function addMethod(string $name): Method
439439
{
440-
$method = (new Method($name))->setNamespace($this->namespace);
440+
$method = new Method($name);
441441
if ($this->type === self::TYPE_INTERFACE) {
442442
$method->setBody(null);
443443
} else {

src/PhpGenerator/Factory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function fromClassReflection(\ReflectionClass $from): ClassType
5050
$class->setProperties($props);
5151
foreach ($from->getMethods() as $method) {
5252
if ($method->getDeclaringClass()->getName() === $from->getName()) {
53-
$methods[] = $this->fromMethodReflection($method)->setNamespace($class->getNamespace());
53+
$methods[] = $this->fromMethodReflection($method);
5454
}
5555
}
5656
$class->setMethods($methods);

src/PhpGenerator/GlobalFunction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ public static function from(string $function): self
3535

3636
public function __toString(): string
3737
{
38-
return (new Printer)->printFunction($this, $this->namespace);
38+
return (new Printer)->printFunction($this);
3939
}
4040
}

src/PhpGenerator/Method.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static function from($method): self
5050

5151
public function __toString(): string
5252
{
53-
return (new Printer)->printMethod($this, $this->namespace);
53+
return (new Printer)->printMethod($this);
5454
}
5555

5656

src/PhpGenerator/Traits/FunctionLike.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Nette;
1313
use Nette\PhpGenerator\Helpers;
1414
use Nette\PhpGenerator\Parameter;
15-
use Nette\PhpGenerator\PhpNamespace;
1615

1716

1817
/**
@@ -38,9 +37,6 @@ trait FunctionLike
3837
/** @var bool */
3938
private $returnNullable = false;
4039

41-
/** @var PhpNamespace|null */
42-
private $namespace;
43-
4440

4541
/**
4642
* @return static
@@ -183,11 +179,11 @@ public function getReturnNullable(): bool
183179

184180

185181
/**
186-
* @return static
182+
* @deprecated
187183
*/
188184
public function setNamespace(PhpNamespace $val = null): self
189185
{
190-
$this->namespace = $val;
186+
trigger_error(__METHOD__ . '() is deprecated', E_USER_DEPRECATED);
191187
return $this;
192188
}
193189
}

0 commit comments

Comments
 (0)