@@ -88,7 +88,7 @@ Assert::true($p->isPublic());
8888$ m = $ class ->addMethod ('getHandle ' )
8989 ->addComment ('Returns file handle. ' )
9090 ->addComment ('@return resource ' )
91- ->setFinal (true )
91+ ->setFinal ()
9292 ->setBody ('return $this->?; ' , ['handle ' ]);
9393
9494Assert::same ($ m , $ class ->getMethod ('getHandle ' ));
@@ -102,9 +102,9 @@ Assert::same('public', $m->getVisibility());
102102Assert::same ('return $this->handle; ' , $ m ->getBody ());
103103
104104$ m = $ class ->addMethod ('getSections ' )
105- ->setStatic (true )
105+ ->setStatic ()
106106 ->setVisibility ('protected ' )
107- ->setReturnReference (true )
107+ ->setReturnReference ()
108108 ->addBody ('$mode = ?; ' , [123 ])
109109 ->addBody ('return self::$sections; ' );
110110$ m ->addParameter ('mode ' , new Literal ('self::ORDER ' ));
@@ -120,19 +120,19 @@ Assert::true($m->isProtected());
120120Assert::false ($ m ->isPublic ());
121121
122122$ method = $ class ->addMethod ('show ' )
123- ->setAbstract (true );
123+ ->setAbstract ();
124124
125125$ method ->addParameter ('foo ' );
126126$ method ->removeParameter ('foo ' );
127127
128128$ method ->addParameter ('item ' );
129129
130130$ method ->addParameter ('res ' , null )
131- ->setReference (true )
131+ ->setReference ()
132132 ->setType (Type::union (Type::Array, 'null ' ));
133133
134134$ method ->addParameter ('bar ' , null )
135- ->setNullable (true )
135+ ->setNullable ()
136136 ->setType ('stdClass|string ' );
137137
138138$ class ->addTrait ('foo ' );
@@ -168,37 +168,48 @@ $method->setParameters(array_values($parameters));
168168Assert::same ($ parameters , $ method ->getParameters ());
169169
170170
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+ );
175176
176177
177178// duplicity
178179$ class = new ClassType ('Example ' );
179180$ 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+ );
183186
184187$ 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+ );
188193
189194$ 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+ );
197206
198207$ 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+ );
202213
203214
204215// remove members
0 commit comments