@@ -88,7 +88,7 @@ Assert::true($p->isPublic());
88
88
$ m = $ class ->addMethod ('getHandle ' )
89
89
->addComment ('Returns file handle. ' )
90
90
->addComment ('@return resource ' )
91
- ->setFinal (true )
91
+ ->setFinal ()
92
92
->setBody ('return $this->?; ' , ['handle ' ]);
93
93
94
94
Assert::same ($ m , $ class ->getMethod ('getHandle ' ));
@@ -102,9 +102,9 @@ Assert::same('public', $m->getVisibility());
102
102
Assert::same ('return $this->handle; ' , $ m ->getBody ());
103
103
104
104
$ m = $ class ->addMethod ('getSections ' )
105
- ->setStatic (true )
105
+ ->setStatic ()
106
106
->setVisibility ('protected ' )
107
- ->setReturnReference (true )
107
+ ->setReturnReference ()
108
108
->addBody ('$mode = ?; ' , [123 ])
109
109
->addBody ('return self::$sections; ' );
110
110
$ m ->addParameter ('mode ' , new Literal ('self::ORDER ' ));
@@ -120,19 +120,19 @@ Assert::true($m->isProtected());
120
120
Assert::false ($ m ->isPublic ());
121
121
122
122
$ method = $ class ->addMethod ('show ' )
123
- ->setAbstract (true );
123
+ ->setAbstract ();
124
124
125
125
$ method ->addParameter ('foo ' );
126
126
$ method ->removeParameter ('foo ' );
127
127
128
128
$ method ->addParameter ('item ' );
129
129
130
130
$ method ->addParameter ('res ' , null )
131
- ->setReference (true )
131
+ ->setReference ()
132
132
->setType (Type::union (Type::Array, 'null ' ));
133
133
134
134
$ method ->addParameter ('bar ' , null )
135
- ->setNullable (true )
135
+ ->setNullable ()
136
136
->setType ('stdClass|string ' );
137
137
138
138
$ class ->addTrait ('foo ' );
@@ -168,37 +168,48 @@ $method->setParameters(array_values($parameters));
168
168
Assert::same ($ parameters , $ method ->getParameters ());
169
169
170
170
171
- Assert::exception (function () {
172
- $ class = new ClassType ;
173
- $ class ->addMethod ('method ' )->setVisibility ('unknown ' );
174
- }, Nette \InvalidArgumentException::class, 'Argument must be public|protected|private. ' );
171
+ Assert::exception (
172
+ fn () => (new ClassType )->addMethod ('method ' )->setVisibility ('unknown ' ),
173
+ Nette \InvalidArgumentException::class,
174
+ 'Argument must be public|protected|private. ' ,
175
+ );
175
176
176
177
177
178
// duplicity
178
179
$ class = new ClassType ('Example ' );
179
180
$ class ->addConstant ('a ' , 1 );
180
- Assert::exception (function () use ($ class ) {
181
- $ class ->addConstant ('a ' , 1 );
182
- }, Nette \InvalidStateException::class, "Cannot add constant 'a', because it already exists. " );
181
+ Assert::exception (
182
+ fn () => $ class ->addConstant ('a ' , 1 ),
183
+ Nette \InvalidStateException::class,
184
+ "Cannot add constant 'a', because it already exists. " ,
185
+ );
183
186
184
187
$ class ->addProperty ('a ' );
185
- Assert::exception (function () use ($ class ) {
186
- $ class ->addProperty ('a ' );
187
- }, Nette \InvalidStateException::class, "Cannot add property 'a', because it already exists. " );
188
+ Assert::exception (
189
+ fn () => $ class ->addProperty ('a ' ),
190
+ Nette \InvalidStateException::class,
191
+ "Cannot add property 'a', because it already exists. " ,
192
+ );
188
193
189
194
$ class ->addMethod ('a ' );
190
- Assert::exception (function () use ($ class ) {
191
- $ class ->addMethod ('a ' );
192
- }, Nette \InvalidStateException::class, "Cannot add method 'a', because it already exists. " );
193
-
194
- Assert::exception (function () use ($ class ) {
195
- $ class ->addMethod ('A ' );
196
- }, Nette \InvalidStateException::class, "Cannot add method 'A', because it already exists. " );
195
+ Assert::exception (
196
+ fn () => $ class ->addMethod ('a ' ),
197
+ Nette \InvalidStateException::class,
198
+ "Cannot add method 'a', because it already exists. " ,
199
+ );
200
+
201
+ Assert::exception (
202
+ fn () => $ class ->addMethod ('A ' ),
203
+ Nette \InvalidStateException::class,
204
+ "Cannot add method 'A', because it already exists. " ,
205
+ );
197
206
198
207
$ class ->addTrait ('A ' );
199
- Assert::exception (function () use ($ class ) {
200
- $ class ->addTrait ('A ' );
201
- }, Nette \InvalidStateException::class, "Cannot add trait 'A', because it already exists. " );
208
+ Assert::exception (
209
+ fn () => $ class ->addTrait ('A ' ),
210
+ Nette \InvalidStateException::class,
211
+ "Cannot add trait 'A', because it already exists. " ,
212
+ );
202
213
203
214
204
215
// remove members
0 commit comments