@@ -91,7 +91,7 @@ private function cacheKey(array $options): string
9191 if ([] !== $ extra ) {
9292 \array_walk_recursive ($ extra , static function (mixed &$ v ): void {
9393 if (\is_object ($ v )) {
94- $ v = \get_class ( $ v ) .'# ' .\spl_object_id ($ v );
94+ $ v = $ v ::class .'# ' .\spl_object_id ($ v );
9595 } elseif (\is_callable ($ v ) && !\is_string ($ v )) {
9696 $ v = 'fn# ' .\spl_object_id (\Closure::fromCallable ($ v ));
9797 }
@@ -113,14 +113,14 @@ private function configureOptions(OptionsResolver $resolver): void
113113 ->info ('The controller class ' )
114114 ->required ()
115115 ->allowedTypes ('string ' )
116- ->allowedValues (fn (string $ v ): bool => \class_exists ($ v ));
116+ ->allowedValues (static fn (string $ v ): bool => \class_exists ($ v ));
117117
118118 $ resolver
119119 ->define ('parent_controller_class ' )
120120 ->info ('The parent controller class ' )
121121 ->allowedTypes ('null ' , 'string ' )
122122 ->default (null )
123- ->allowedValues (fn (?string $ v ): bool => null === $ v || \class_exists ($ v ));
123+ ->allowedValues (static fn (?string $ v ): bool => null === $ v || \class_exists ($ v ));
124124
125125 $ resolver
126126 ->define ('parent_controller ' )
@@ -134,7 +134,7 @@ private function configureOptions(OptionsResolver $resolver): void
134134 ->info ('The class which is controlled ' )
135135 ->required ()
136136 ->allowedTypes ('string ' )
137- ->allowedValues (fn (string $ v ): bool => \class_exists ($ v ));
137+ ->allowedValues (static fn (string $ v ): bool => \class_exists ($ v ));
138138
139139 $ resolver
140140 ->define ('parent ' )
@@ -147,7 +147,7 @@ private function configureOptions(OptionsResolver $resolver): void
147147 ->info ('The parent object of the controlled class ' )
148148 ->allowedTypes ('null ' , 'object ' , 'callable ' , 'string ' )
149149 ->default (null )
150- ->normalize (function (Options $ o , object |callable |string |null $ v ): object |callable |null {
150+ ->normalize (static function (Options $ o , object |callable |string |null $ v ): object |callable |null {
151151 if ($ o ['parent ' ]) {
152152 /** @var object $parent */
153153 $ parent = $ o ['parent ' ];
@@ -165,7 +165,7 @@ private function configureOptions(OptionsResolver $resolver): void
165165 $ class = new \ReflectionClass ($ entityClass );
166166 $ property = $ class ->getProperty ($ v );
167167
168- return fn (object $ entity ) => $ property ->getValue ($ entity );
168+ return static fn (object $ entity ) => $ property ->getValue ($ entity );
169169 }
170170
171171 /** @var AbstractCrudController|null $controller */
@@ -174,10 +174,10 @@ private function configureOptions(OptionsResolver $resolver): void
174174 $ parentClass = $ controller ->resolve ()['class ' ];
175175 /** @var class-string $childClass */
176176 $ childClass = $ o ['class ' ];
177- foreach (( new \ReflectionClass ($ childClass) )->getProperties () as $ property ) {
177+ foreach (new \ReflectionClass ($ childClass )->getProperties () as $ property ) {
178178 if (($ type = $ property ->getType ()) && $ type instanceof \ReflectionNamedType) {
179179 if ($ type ->getName () === $ parentClass ) {
180- return fn (object $ entity ) => $ property ->getValue ($ entity );
180+ return static fn (object $ entity ) => $ property ->getValue ($ entity );
181181 }
182182 }
183183 }
@@ -229,15 +229,13 @@ private function configureNav(OptionsResolver $resolver): void
229229 ->define ('nav ' )
230230 ->default (null )
231231 ->allowedTypes ('null ' , 'bool ' , 'callable ' , 'string ' )
232- ->normalize (function (Options $ options , bool |callable |string |null $ value ): bool |callable |object |null {
233- return \is_string ($ value ) ? new $ value () : $ value ;
234- });
232+ ->normalize (static fn (Options $ options , bool |callable |string |null $ value ): bool |callable |object |null => \is_string ($ value ) ? new $ value () : $ value );
235233
236234 $ resolver
237235 ->define ('breadcrumbs ' )
238236 ->default (null )
239237 ->allowedTypes ('null ' , 'bool ' , 'string ' , 'callable ' )
240- ->normalize (function (Options $ options , bool |callable |string |null $ value ): bool |callable |object |null {
238+ ->normalize (static function (Options $ options , bool |callable |string |null $ value ): bool |callable |object |null {
241239 if (null === $ value ) {
242240 return null ;
243241 }
@@ -259,22 +257,22 @@ private function configureForms(OptionsResolver $resolver): void
259257 ->info ('Form Data class. ' )
260258 ->default (null )
261259 ->allowedTypes ('callable ' , 'string ' , 'null ' )
262- ->allowedValues (function (mixed $ value ): bool {
260+ ->allowedValues (static function (mixed $ value ): bool {
263261 if (\is_string ($ value )) {
264262 return \class_exists ($ value ) && \in_array (DtoInterface::class, \class_implements ($ value ) ?: [], true );
265263 }
266264
267265 return true ;
268266 })
269- ->normalize (function (Options $ options , callable |string |null $ value ): ?callable {
267+ ->normalize (static function (Options $ options , callable |string |null $ value ): ?callable {
270268 if (\is_string ($ value )) {
271- return function (string $ dataClass , array $ options = []) use ($ value ) {
269+ return static function (string $ dataClass , array $ options = []) use ($ value ) {
272270 $ defined = [
273271 'entityClass ' => $ dataClass ,
274272 'parent ' => $ options ['parent ' ],
275273 ];
276274
277- return ( new Instantiator () )->instantiate ($ value , $ defined );
275+ return new Instantiator ()->instantiate ($ value , $ defined );
278276 };
279277 }
280278
@@ -296,14 +294,14 @@ private function configureRoutes(OptionsResolver $resolver): void
296294 ->define ('route_prefix ' )
297295 ->default (null )
298296 ->allowedTypes ('null ' , 'string ' )
299- ->normalize (function (Options $ options , ?string $ value ): string {
297+ ->normalize (static function (Options $ options , ?string $ value ): string {
300298 if (null !== $ value ) {
301299 return \rtrim ($ value , '_ ' );
302300 }
303301
304302 /** @var class-string $controllerClass */
305303 $ controllerClass = $ options ['controller_class ' ];
306- if (null !== ($ attr = \current (( new \ReflectionClass ($ controllerClass) )->getAttributes (Route::class)) ?: null )) {
304+ if (null !== ($ attr = \current (new \ReflectionClass ($ controllerClass )->getAttributes (Route::class)) ?: null )) {
307305 return \rtrim ((string ) $ attr ->newInstance ()->name , '_ ' );
308306 }
309307
@@ -324,7 +322,7 @@ private function configureRoutes(OptionsResolver $resolver): void
324322 ->define ('route_params ' )
325323 ->default ([])
326324 ->allowedTypes ('array ' )
327- ->normalize (function (Options $ options , array $ value ): array {
325+ ->normalize (static function (Options $ options , array $ value ): array {
328326 /** @var object|null $parent */
329327 $ parent = $ options ['parent ' ];
330328 /** @var string $parentRouteParam */
@@ -340,15 +338,13 @@ private function configureView(OptionsResolver $resolver): void
340338 ->define ('view_prefix ' )
341339 ->allowedTypes ('null ' , 'string ' )
342340 ->default (null )
343- ->normalize (function (Options $ options , ?string $ value ): ?string {
344- return null !== $ value ? \rtrim ($ value , '/ ' ) : null ;
345- });
341+ ->normalize (static fn (Options $ options , ?string $ value ): ?string => null !== $ value ? \rtrim ($ value , '/ ' ) : null );
346342
347343 $ resolver
348344 ->define ('view_params ' )
349345 ->default ([])
350346 ->allowedTypes ('array ' )
351- ->normalize (function (Options $ options , array $ value ): array {
347+ ->normalize (static function (Options $ options , array $ value ): array {
352348 /** @var array<string, mixed> $defined */
353349 $ defined = [];
354350 $ default = [
@@ -371,7 +367,7 @@ private function configureView(OptionsResolver $resolver): void
371367 ->define ('title ' )
372368 ->default (null )
373369 ->allowedTypes ('null ' , 'string ' )
374- ->normalize (function (Options $ options , ?string $ value ): string {
370+ ->normalize (static function (Options $ options , ?string $ value ): string {
375371 if (null !== $ value ) {
376372 return $ value ;
377373 }
@@ -414,7 +410,7 @@ private function configureActions(OptionsResolver $resolver): void
414410 ->define ('fields ' )
415411 ->default ([])
416412 ->allowedTypes ('null ' , 'array ' )
417- ->normalize (function (Options $ options , ?array $ value ): ?array {
413+ ->normalize (static function (Options $ options , ?array $ value ): ?array {
418414 if (null === $ value ) {
419415 return null ;
420416 }
@@ -459,32 +455,31 @@ private function configureActions(OptionsResolver $resolver): void
459455 ->define ('actions ' )
460456 ->default (null )
461457 ->allowedTypes ('null ' , 'callable ' )
462- ->normalize (function (Options $ options , ?callable $ value ): ?callable {
458+ ->normalize (static function (Options $ options , ?callable $ value ): ?callable {
463459 if (null === $ value ) {
464460 return null ;
465461 }
466462
467- return function (object $ entity , ?object $ parent = null ) use ($ value ): NavigationInterface {
463+ return static function (object $ entity , ?object $ parent = null ) use ($ value ): NavigationInterface {
468464 return new ClosureNavigation (
469- function (MenuBuilder $ builder ) use ($ value , $ entity , $ parent ): void {
465+ static function (MenuBuilder $ builder ) use ($ value , $ entity , $ parent ): void {
470466 \call_user_func ($ value , $ builder , $ entity , $ parent );
471- });
467+ }
468+ );
472469 };
473470 });
474471
475472 $ resolver ->setAllowedTypes ('view_params ' , []);
476- $ resolver ->setNormalizer ('view_params ' , function (Options $ options , array $ value ): array {
477- return \array_merge ([
478- 'fields ' => $ options ['fields ' ],
479- 'actions ' => $ options ['actions ' ],
480- 'alias ' => $ options ['alias ' ],
481- ], $ value );
482- });
473+ $ resolver ->setNormalizer ('view_params ' , static fn (Options $ options , array $ value ): array => \array_merge ([
474+ 'fields ' => $ options ['fields ' ],
475+ 'actions ' => $ options ['actions ' ],
476+ 'alias ' => $ options ['alias ' ],
477+ ], $ value ));
483478
484479 $ resolver
485480 ->define ('filter ' )
486481 ->default (null )
487- ->allowedValues (function (mixed $ value ): bool {
482+ ->allowedValues (static function (mixed $ value ): bool {
488483 if (null === $ value ) {
489484 return true ;
490485 }
@@ -523,7 +518,7 @@ function (MenuBuilder $builder) use ($value, $entity, $parent): void {
523518 ->define ('order_by ' )
524519 ->default ([])
525520 ->allowedTypes ('array ' )
526- ->normalize (function (Options $ options , array $ value ): array {
521+ ->normalize (static function (Options $ options , array $ value ): array {
527522 /** @var array<string, mixed> $orderBy */
528523 $ orderBy = $ options ['orderBy ' ];
529524
@@ -540,7 +535,7 @@ function (MenuBuilder $builder) use ($value, $entity, $parent): void {
540535 ->define ('order_by_mapping ' )
541536 ->default ([])
542537 ->allowedTypes ('array ' , 'null ' )
543- ->normalize (function (Options $ options , ?array $ value ): array {
538+ ->normalize (static function (Options $ options , ?array $ value ): array {
544539 if (null === $ value ) {
545540 return [];
546541 }
@@ -549,7 +544,7 @@ function (MenuBuilder $builder) use ($value, $entity, $parent): void {
549544 $ fields = $ options ['fields ' ];
550545 $ defaults = \array_keys ($ fields );
551546 /** @var \Closure(array<int|string, mixed>): array<string, mixed> $normalise */
552- $ normalise = function (array $ values ): array {
547+ $ normalise = static function (array $ values ): array {
553548 $ normalised = [];
554549 foreach ($ values as $ k => $ v ) {
555550 if (\is_numeric ($ k )) {
@@ -610,7 +605,7 @@ function (MenuBuilder $builder) use ($value, $entity, $parent): void {
610605 ->define ('bulk_nav ' )
611606 ->default (null )
612607 ->allowedTypes ('null ' , 'callable ' )
613- ->normalize (function (Options $ options , ?callable $ value ): ?callable {
608+ ->normalize (static function (Options $ options , ?callable $ value ): ?callable {
614609 /** @var bool $bulkOperation */
615610 $ bulkOperation = $ options ['bulk_operation ' ];
616611
@@ -627,9 +622,7 @@ function (MenuBuilder $builder) use ($value, $entity, $parent): void {
627622 ->define ($ action )
628623 ->default ([])
629624 ->allowedTypes ('null ' , 'array ' )
630- ->normalize (function (Options $ options , ?array $ value ) use ($ action , $ createDefaultActionOptions ): ?array {
631- return null !== $ value ? \array_replace_recursive ($ createDefaultActionOptions ($ action , $ options ), $ value ) : null ;
632- });
625+ ->normalize (static fn (Options $ options , ?array $ value ): ?array => null !== $ value ? \array_replace_recursive ($ createDefaultActionOptions ($ action , $ options ), $ value ) : null );
633626 }
634627
635628 /**
@@ -638,7 +631,7 @@ function (MenuBuilder $builder) use ($value, $entity, $parent): void {
638631 $ actions = ['move ' , 'delete ' , 'bulk_delete ' , 'toggle ' , 'copy ' ];
639632
640633 // configure actions without view
641- $ createDefaultActionOptions = function (string $ prefix , Options $ options ): array {
634+ $ createDefaultActionOptions = static function (string $ prefix , Options $ options ): array {
642635 /** @var string $routePrefix */
643636 $ routePrefix = $ options ['route_prefix ' ];
644637 /** @var array<string, mixed> $routeParams */
@@ -655,7 +648,7 @@ function (MenuBuilder $builder) use ($value, $entity, $parent): void {
655648 ->define ($ action )
656649 ->default ([])
657650 ->allowedTypes ('null ' , 'array ' )
658- ->normalize (function (Options $ options , ?array $ value ) use ($ action , $ createDefaultActionOptions ): ?array {
651+ ->normalize (static function (Options $ options , ?array $ value ) use ($ action , $ createDefaultActionOptions ): ?array {
659652 if ('bulk_delete ' === $ action ) {
660653 /** @var array<string, mixed> $index */
661654 $ index = $ options ['index ' ];
0 commit comments