11
11
12
12
13
13
/**
14
- * Method or function description .
14
+ * Class method .
15
15
*
16
16
* @property string|FALSE $body
17
17
*/
@@ -23,12 +23,6 @@ class Method
23
23
use Traits \VisibilityAware;
24
24
use Traits \CommentAware;
25
25
26
- /** @var Parameter[] */
27
- private $ uses = [];
28
-
29
- /** @var string|FALSE */
30
- private $ body = '' ;
31
-
32
26
/** @var bool */
33
27
private $ static = FALSE ;
34
28
@@ -51,15 +45,23 @@ public static function from($method)
51
45
}
52
46
53
47
48
+ /**
49
+ * @param string
50
+ */
51
+ public function __construct ($ name = NULL )
52
+ {
53
+ if ($ name === NULL ) {
54
+ throw new Nette \DeprecatedException ('For closures use Nette\PhpGenerator\GlobalFunction instead of Nette\PhpGenerator\Method. ' );
55
+ }
56
+ $ this ->setName ($ name );
57
+ }
58
+
59
+
54
60
/**
55
61
* @return string PHP code
56
62
*/
57
63
public function __toString ()
58
64
{
59
- $ uses = [];
60
- foreach ($ this ->uses as $ param ) {
61
- $ uses [] = ($ param ->isReference () ? '& ' : '' ) . '$ ' . $ param ->getName ();
62
- }
63
65
return Helpers::formatDocComment ($ this ->comment . "\n" )
64
66
. ($ this ->abstract ? 'abstract ' : '' )
65
67
. ($ this ->final ? 'final ' : '' )
@@ -69,38 +71,10 @@ public function __toString()
69
71
. ($ this ->returnReference ? '& ' : '' )
70
72
. $ this ->name
71
73
. $ this ->parametersToString ()
72
- . ($ this ->uses ? ' use ( ' . implode (', ' , $ uses ) . ') ' : '' )
73
74
. $ this ->returnTypeToString ()
74
- . ($ this ->abstract || $ this ->body === FALSE ? '; '
75
- : ($ this ->name ? "\n" : ' ' ) . "{ \n" . Nette \Utils \Strings::indent (ltrim (rtrim ($ this ->body ) . "\n" ), 1 ) . '} ' );
76
- }
77
-
78
-
79
- /**
80
- * @return static
81
- */
82
- public function setUses (array $ val )
83
- {
84
- $ this ->uses = $ val ;
85
- return $ this ;
86
- }
87
-
88
-
89
- /**
90
- * @return array
91
- */
92
- public function getUses ()
93
- {
94
- return $ this ->uses ;
95
- }
96
-
97
-
98
- /**
99
- * @return Parameter
100
- */
101
- public function addUse ($ name )
102
- {
103
- return $ this ->uses [] = new Parameter ($ name );
75
+ . ($ this ->abstract || $ this ->body === FALSE
76
+ ? '; '
77
+ : "\n{ \n" . Nette \Utils \Strings::indent (ltrim (rtrim ($ this ->body ) . "\n" ), 1 ) . '} ' );
104
78
}
105
79
106
80
@@ -124,17 +98,6 @@ public function getBody()
124
98
}
125
99
126
100
127
- /**
128
- * @param string
129
- * @return static
130
- */
131
- public function addBody ($ code , array $ args = NULL )
132
- {
133
- $ this ->body .= ($ args === NULL ? $ code : Helpers::formatArgs ($ code , $ args )) . "\n" ;
134
- return $ this ;
135
- }
136
-
137
-
138
101
/**
139
102
* @param bool
140
103
* @return static
0 commit comments