Skip to content

Commit db1db55

Browse files
committed
fixed inconsistencies between 'nullable string' and 'string' properties
1 parent 8a12109 commit db1db55

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/PhpGenerator/Method.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
class Method extends Nette\Object
1717
{
18-
/** @var string */
18+
/** @var string|NULL */
1919
private $name;
2020

2121
/** @var array of name => Parameter */
@@ -25,7 +25,7 @@ class Method extends Nette\Object
2525
private $uses = array();
2626

2727
/** @var string|FALSE */
28-
private $body;
28+
private $body = '';
2929

3030
/** @var bool */
3131
private $static = FALSE;
@@ -64,7 +64,7 @@ public static function from($from)
6464
$method->parameters[$param->getName()] = Parameter::from($param);
6565
}
6666
$method->static = $from->isStatic();
67-
$method->visibility = $from->isPrivate() ? 'private' : ($from->isProtected() ? 'protected' : '');
67+
$method->visibility = $from->isPrivate() ? 'private' : ($from->isProtected() ? 'protected' : NULL);
6868
$method->final = $from->isFinal();
6969
$method->abstract = $from->isAbstract() && !$from->getDeclaringClass()->isInterface();
7070
$method->body = $from->isAbstract() ? FALSE : '';
@@ -80,7 +80,7 @@ public static function from($from)
8080
*/
8181
public function __toString()
8282
{
83-
static $builtinTypes = array('array', 'self', 'parent', 'callable', '');
83+
static $builtinTypes = array('array', 'self', 'parent', 'callable', NULL);
8484
$parameters = array();
8585
foreach ($this->parameters as $param) {
8686
$variadic = $this->variadic && $param === end($this->parameters);
@@ -114,18 +114,18 @@ public function __toString()
114114

115115

116116
/**
117-
* @param string
117+
* @param string|NULL
118118
* @return self
119119
*/
120120
public function setName($name)
121121
{
122-
$this->name = (string) $name;
122+
$this->name = $name ? (string) $name : NULL;
123123
return $this;
124124
}
125125

126126

127127
/**
128-
* @return string
128+
* @return string|NULL
129129
*/
130130
public function getName()
131131
{
@@ -259,7 +259,7 @@ public function setVisibility($val)
259259
if (!in_array($val, array('public', 'protected', 'private', NULL), TRUE)) {
260260
throw new Nette\InvalidArgumentException('Argument must be public|protected|private|NULL.');
261261
}
262-
$this->visibility = (string) $val;
262+
$this->visibility = $val ? (string) $val : NULL;
263263
return $this;
264264
}
265265

src/PhpGenerator/Parameter.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Parameter extends Nette\Object
2121
/** @var bool */
2222
private $reference = FALSE;
2323

24-
/** @var string */
24+
/** @var string|NULL */
2525
private $typeHint;
2626

2727
/** @var bool */
@@ -45,7 +45,7 @@ public static function from(\ReflectionParameter $from)
4545
$param->typeHint = 'callable';
4646
} else {
4747
try {
48-
$param->typeHint = $from->getClass() ? '\\' . $from->getClass()->getName() : '';
48+
$param->typeHint = $from->getClass() ? '\\' . $from->getClass()->getName() : NULL;
4949
} catch (\ReflectionException $e) {
5050
if (preg_match('#Class (.+) does not exist#', $e->getMessage(), $m)) {
5151
$param->typeHint = '\\' . $m[1];
@@ -107,18 +107,18 @@ public function isReference()
107107

108108

109109
/**
110-
* @param string
110+
* @param string|NULL
111111
* @return self
112112
*/
113113
public function setTypeHint($hint)
114114
{
115-
$this->typeHint = (string) $hint;
115+
$this->typeHint = $hint ? (string) $hint : NULL;
116116
return $this;
117117
}
118118

119119

120120
/**
121-
* @return string
121+
* @return string|NULL
122122
*/
123123
public function getTypeHint()
124124
{

0 commit comments

Comments
 (0)