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 = [];
26
26
27
27
/** @var string|FALSE */
28
- private $ body ;
28
+ private $ body = '' ;
29
29
30
30
/** @var bool */
31
31
private $ static = FALSE ;
@@ -45,13 +45,13 @@ class Method extends Nette\Object
45
45
/** @var bool */
46
46
private $ variadic = FALSE ;
47
47
48
- /** @var array of string */
48
+ /** @var string[] */
49
49
private $ documents = [];
50
50
51
51
/** @var PhpNamespace|NULL */
52
52
private $ namespace ;
53
53
54
- /** @var string */
54
+ /** @var string|NULL */
55
55
private $ returnType ;
56
56
57
57
@@ -67,7 +67,7 @@ public static function from($from)
67
67
$ method ->parameters [$ param ->getName ()] = Parameter::from ($ param );
68
68
}
69
69
$ method ->static = $ from ->isStatic ();
70
- $ method ->visibility = $ from ->isPrivate () ? 'private ' : ($ from ->isProtected () ? 'protected ' : '' );
70
+ $ method ->visibility = $ from ->isPrivate () ? 'private ' : ($ from ->isProtected () ? 'protected ' : NULL );
71
71
$ method ->final = $ from ->isFinal ();
72
72
$ method ->abstract = $ from ->isAbstract () && !$ from ->getDeclaringClass ()->isInterface ();
73
73
$ method ->body = $ from ->isAbstract () ? FALSE : '' ;
@@ -87,7 +87,7 @@ public static function from($from)
87
87
*/
88
88
public function __toString ()
89
89
{
90
- static $ builtinTypes = ['array ' , 'self ' , 'parent ' , 'callable ' , 'string ' , 'bool ' , 'float ' , 'int ' , '' ];
90
+ static $ builtinTypes = ['array ' , 'self ' , 'parent ' , 'callable ' , 'string ' , 'bool ' , 'float ' , 'int ' , NULL ];
91
91
$ parameters = [];
92
92
foreach ($ this ->parameters as $ param ) {
93
93
$ variadic = $ this ->variadic && $ param === end ($ this ->parameters );
@@ -105,7 +105,7 @@ public function __toString()
105
105
foreach ($ this ->uses as $ param ) {
106
106
$ uses [] = ($ param ->isReference () ? '& ' : '' ) . '$ ' . $ param ->getName ();
107
107
}
108
- $ returnType = !$ this ->namespace || in_array ($ this ->returnType , $ builtinTypes )
108
+ $ returnType = !$ this ->namespace || in_array ($ this ->returnType , $ builtinTypes, TRUE )
109
109
? $ this ->returnType
110
110
: $ this ->namespace ->unresolveName ($ this ->returnType );
111
111
return ($ this ->documents ? str_replace ("\n" , "\n * " , "/** \n" . implode ("\n" , $ this ->documents )) . "\n */ \n" : '' )
@@ -125,18 +125,18 @@ public function __toString()
125
125
126
126
127
127
/**
128
- * @param string
128
+ * @param string|NULL
129
129
* @return self
130
130
*/
131
131
public function setName ($ name )
132
132
{
133
- $ this ->name = (string ) $ name ;
133
+ $ this ->name = $ name ? (string ) $ name : NULL ;
134
134
return $ this ;
135
135
}
136
136
137
137
138
138
/**
139
- * @return string
139
+ * @return string|NULL
140
140
*/
141
141
public function getName ()
142
142
{
@@ -270,7 +270,7 @@ public function setVisibility($val)
270
270
if (!in_array ($ val , ['public ' , 'protected ' , 'private ' , NULL ], TRUE )) {
271
271
throw new Nette \InvalidArgumentException ('Argument must be public|protected|private|NULL. ' );
272
272
}
273
- $ this ->visibility = (string ) $ val ;
273
+ $ this ->visibility = $ val ? (string ) $ val : NULL ;
274
274
return $ this ;
275
275
}
276
276
@@ -405,18 +405,18 @@ public function setNamespace(PhpNamespace $val = NULL)
405
405
}
406
406
407
407
/**
408
- * @param string
408
+ * @param string|NULL
409
409
* @return self
410
410
*/
411
411
public function setReturnType ($ val )
412
412
{
413
- $ this ->returnType = (string ) $ val ;
413
+ $ this ->returnType = $ val ? (string ) $ val : NULL ;
414
414
return $ this ;
415
415
}
416
416
417
417
418
418
/**
419
- * @return string
419
+ * @return string|NULL
420
420
*/
421
421
public function getReturnType ()
422
422
{
0 commit comments