Skip to content

Commit 392139b

Browse files
committed
name validation moved from setName() to __construct()
1 parent 2679627 commit 392139b

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/PhpGenerator/Method.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ public static function from($method)
5151
/**
5252
* @param string
5353
*/
54-
public function __construct($name = NULL)
54+
public function __construct($name)
5555
{
5656
if ($name === NULL) {
5757
throw new Nette\DeprecatedException('For closures use Nette\PhpGenerator\Closure instead of Nette\PhpGenerator\Method.');
5858
}
59-
$this->setName($name);
59+
$this->name = (string) $name;
6060
}
6161

6262

src/PhpGenerator/PhpNamespace.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ class PhpNamespace
4242
*/
4343
public function __construct($name = NULL)
4444
{
45-
$this->setName($name);
45+
$this->name = (string) $name;
4646
}
4747

4848

4949
/** @deprecated */
5050
public function setName($name)
5151
{
52-
$this->name = (string) $name;
52+
$this->__construct($name);
5353
return $this;
5454
}
5555

src/PhpGenerator/Traits/NameAware.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ trait NameAware
2020
/**
2121
* @param string
2222
*/
23-
public function __construct($name = '')
23+
public function __construct($name)
2424
{
25-
$this->setName($name);
25+
$this->name = (string) $name;
2626
}
2727

2828

2929
/** @deprecated */
3030
public function setName($name)
3131
{
32-
$this->name = (string) $name;
32+
$this->__construct($name);
3333
return $this;
3434
}
3535

0 commit comments

Comments
 (0)