15
15
*/
16
16
class Method extends Nette \Object
17
17
{
18
- /** @var string */
18
+ /** @var string|NULL */
19
19
private $ name ;
20
20
21
21
/** @var array of name => Parameter */
@@ -25,7 +25,7 @@ class Method extends Nette\Object
25
25
private $ uses = array ();
26
26
27
27
/** @var string|FALSE */
28
- private $ body ;
28
+ private $ body = '' ;
29
29
30
30
/** @var bool */
31
31
private $ static = FALSE ;
@@ -64,7 +64,7 @@ public static function from($from)
64
64
$ method ->parameters [$ param ->getName ()] = Parameter::from ($ param );
65
65
}
66
66
$ method ->static = $ from ->isStatic ();
67
- $ method ->visibility = $ from ->isPrivate () ? 'private ' : ($ from ->isProtected () ? 'protected ' : '' );
67
+ $ method ->visibility = $ from ->isPrivate () ? 'private ' : ($ from ->isProtected () ? 'protected ' : NULL );
68
68
$ method ->final = $ from ->isFinal ();
69
69
$ method ->abstract = $ from ->isAbstract () && !$ from ->getDeclaringClass ()->isInterface ();
70
70
$ method ->body = $ from ->isAbstract () ? FALSE : '' ;
@@ -80,7 +80,7 @@ public static function from($from)
80
80
*/
81
81
public function __toString ()
82
82
{
83
- static $ builtinTypes = array ('array ' , 'self ' , 'parent ' , 'callable ' , '' );
83
+ static $ builtinTypes = array ('array ' , 'self ' , 'parent ' , 'callable ' , NULL );
84
84
$ parameters = array ();
85
85
foreach ($ this ->parameters as $ param ) {
86
86
$ variadic = $ this ->variadic && $ param === end ($ this ->parameters );
@@ -114,18 +114,18 @@ public function __toString()
114
114
115
115
116
116
/**
117
- * @param string
117
+ * @param string|NULL
118
118
* @return self
119
119
*/
120
120
public function setName ($ name )
121
121
{
122
- $ this ->name = (string ) $ name ;
122
+ $ this ->name = $ name ? (string ) $ name : NULL ;
123
123
return $ this ;
124
124
}
125
125
126
126
127
127
/**
128
- * @return string
128
+ * @return string|NULL
129
129
*/
130
130
public function getName ()
131
131
{
@@ -259,7 +259,7 @@ public function setVisibility($val)
259
259
if (!in_array ($ val , array ('public ' , 'protected ' , 'private ' , NULL ), TRUE )) {
260
260
throw new Nette \InvalidArgumentException ('Argument must be public|protected|private|NULL. ' );
261
261
}
262
- $ this ->visibility = (string ) $ val ;
262
+ $ this ->visibility = $ val ? (string ) $ val : NULL ;
263
263
return $ this ;
264
264
}
265
265
0 commit comments