@@ -74,7 +74,7 @@ public function getConfigTreeBuilder(): TreeBuilder
74
74
75
75
$ rootNode
76
76
->beforeNormalization ()
77
- ->ifTrue (function ($ v ) { return !isset ($ v ['assets ' ]) && isset ($ v ['templating ' ]) && class_exists (Package::class); } )
77
+ ->ifTrue (fn ($ v ) => !isset ($ v ['assets ' ]) && isset ($ v ['templating ' ]) && class_exists (Package::class))
78
78
->then (function ($ v ) {
79
79
$ v ['assets ' ] = [];
80
80
@@ -119,15 +119,15 @@ public function getConfigTreeBuilder(): TreeBuilder
119
119
->prototype ('scalar ' )->end ()
120
120
->end ()
121
121
->arrayNode ('trusted_hosts ' )
122
- ->beforeNormalization ()->ifString ()->then (function ($ v ) { return [$ v ]; } )->end ()
122
+ ->beforeNormalization ()->ifString ()->then (fn ($ v ) => [$ v ])->end ()
123
123
->prototype ('scalar ' )->end ()
124
124
->end ()
125
125
->scalarNode ('trusted_proxies ' )->end ()
126
126
->arrayNode ('trusted_headers ' )
127
127
->fixXmlConfig ('trusted_header ' )
128
128
->performNoDeepMerging ()
129
129
->defaultValue (['x-forwarded-for ' , 'x-forwarded-port ' , 'x-forwarded-proto ' ])
130
- ->beforeNormalization ()->ifString ()->then (function ($ v ) { return $ v ? array_map ('trim ' , explode (', ' , $ v )) : []; } )->end ()
130
+ ->beforeNormalization ()->ifString ()->then (fn ($ v ) => $ v ? array_map ('trim ' , explode (', ' , $ v )) : [])->end ()
131
131
->enumPrototype ()
132
132
->values ([
133
133
'forwarded ' ,
@@ -149,7 +149,7 @@ public function getConfigTreeBuilder(): TreeBuilder
149
149
return ContainerBuilder::willBeAvailable ($ package , $ class , $ parentPackages );
150
150
};
151
151
152
- $ enableIfStandalone = static fn (string $ package , string $ class ) => !class_exists (FullStack::class) && $ willBeAvailable ($ package , $ class ) ? 'canBeDisabled ' : 'canBeEnabled ' ;
152
+ $ enableIfStandalone = fn (string $ package , string $ class ) => !class_exists (FullStack::class) && $ willBeAvailable ($ package , $ class ) ? 'canBeDisabled ' : 'canBeEnabled ' ;
153
153
154
154
$ this ->addCsrfSection ($ rootNode );
155
155
$ this ->addFormSection ($ rootNode , $ enableIfStandalone );
@@ -416,12 +416,12 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode): void
416
416
->arrayNode ('supports ' )
417
417
->beforeNormalization ()
418
418
->ifString ()
419
- ->then (function ($ v ) { return [$ v ]; } )
419
+ ->then (fn ($ v ) => [$ v ])
420
420
->end ()
421
421
->prototype ('scalar ' )
422
422
->cannotBeEmpty ()
423
423
->validate ()
424
- ->ifTrue (function ($ v ) { return !class_exists ($ v ) && !interface_exists ($ v , false ); } )
424
+ ->ifTrue (fn ($ v ) => !class_exists ($ v ) && !interface_exists ($ v , false ))
425
425
->thenInvalid ('The supported class or interface "%s" does not exist. ' )
426
426
->end ()
427
427
->end ()
@@ -550,7 +550,7 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode): void
550
550
->arrayNode ('from ' )
551
551
->beforeNormalization ()
552
552
->ifString ()
553
- ->then (function ($ v ) { return [$ v ]; } )
553
+ ->then (fn ($ v ) => [$ v ])
554
554
->end ()
555
555
->requiresAtLeastOneElement ()
556
556
->prototype ('scalar ' )
@@ -560,7 +560,7 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode): void
560
560
->arrayNode ('to ' )
561
561
->beforeNormalization ()
562
562
->ifString ()
563
- ->then (function ($ v ) { return [$ v ]; } )
563
+ ->then (fn ($ v ) => [$ v ])
564
564
->end ()
565
565
->requiresAtLeastOneElement ()
566
566
->prototype ('scalar ' )
@@ -782,8 +782,8 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode, callable $enabl
782
782
->scalarNode ('version_strategy ' )->defaultNull ()->end ()
783
783
->scalarNode ('version ' )
784
784
->beforeNormalization ()
785
- ->ifTrue (function ($ v ) { return '' === $ v; } )
786
- ->then (function ( $ v ) { return ; } )
785
+ ->ifTrue (fn ($ v ) => '' === $ v )
786
+ ->then (fn () => null )
787
787
->end ()
788
788
->end ()
789
789
->scalarNode ('version_format ' )->defaultNull ()->end ()
@@ -932,7 +932,7 @@ private function addTranslatorSection(ArrayNodeDefinition $rootNode, callable $e
932
932
->children ()
933
933
->arrayNode ('fallbacks ' )
934
934
->info ('Defaults to the value of "default_locale". ' )
935
- ->beforeNormalization ()->ifString ()->then (function ($ v ) { return [$ v ]; } )->end ()
935
+ ->beforeNormalization ()->ifString ()->then (fn ($ v ) => [$ v ])->end ()
936
936
->prototype ('scalar ' )->end ()
937
937
->defaultValue ([])
938
938
->end ()
@@ -1197,7 +1197,7 @@ private function addCacheSection(ArrayNodeDefinition $rootNode, callable $willBe
1197
1197
->prototype ('array ' )
1198
1198
->fixXmlConfig ('adapter ' )
1199
1199
->beforeNormalization ()
1200
- ->ifTrue (function ($ v ) { return isset ($ v ['provider ' ]) && \is_array ($ v ['adapters ' ] ?? $ v ['adapter ' ] ?? null ) && 1 < \count ($ v ['adapters ' ] ?? $ v ['adapter ' ]); } )
1200
+ ->ifTrue (fn ($ v ) => isset ($ v ['provider ' ]) && \is_array ($ v ['adapters ' ] ?? $ v ['adapter ' ] ?? null ) && 1 < \count ($ v ['adapters ' ] ?? $ v ['adapter ' ]))
1201
1201
->thenInvalid ('Pool cannot have a "provider" while more than one adapter is defined ' )
1202
1202
->end ()
1203
1203
->children ()
@@ -1245,7 +1245,7 @@ private function addCacheSection(ArrayNodeDefinition $rootNode, callable $willBe
1245
1245
->end ()
1246
1246
->end ()
1247
1247
->validate ()
1248
- ->ifTrue (function ($ v ) { return isset ($ v ['cache.app ' ]) || isset ($ v ['cache.system ' ]); } )
1248
+ ->ifTrue (fn ($ v ) => isset ($ v ['cache.app ' ]) || isset ($ v ['cache.system ' ]))
1249
1249
->thenInvalid ('"cache.app" and "cache.system" are reserved names ' )
1250
1250
->end ()
1251
1251
->end ()
@@ -1386,7 +1386,7 @@ private function addLockSection(ArrayNodeDefinition $rootNode, callable $enableI
1386
1386
->end ()
1387
1387
->addDefaultsIfNotSet ()
1388
1388
->validate ()
1389
- ->ifTrue (static fn (array $ config ) => $ config ['enabled ' ] && !$ config ['resources ' ])
1389
+ ->ifTrue (fn ($ config ) => $ config ['enabled ' ] && !$ config ['resources ' ])
1390
1390
->thenInvalid ('At least one resource must be defined. ' )
1391
1391
->end ()
1392
1392
->fixXmlConfig ('resource ' )
@@ -1501,12 +1501,12 @@ private function addMessengerSection(ArrayNodeDefinition $rootNode, callable $en
1501
1501
->fixXmlConfig ('transport ' )
1502
1502
->fixXmlConfig ('bus ' , 'buses ' )
1503
1503
->validate ()
1504
- ->ifTrue (function ($ v ) { return isset ($ v ['buses ' ]) && \count ($ v ['buses ' ]) > 1 && null === $ v ['default_bus ' ]; } )
1504
+ ->ifTrue (fn ($ v ) => isset ($ v ['buses ' ]) && \count ($ v ['buses ' ]) > 1 && null === $ v ['default_bus ' ])
1505
1505
->thenInvalid ('You must specify the "default_bus" if you define more than one bus. ' )
1506
1506
->end ()
1507
1507
->validate ()
1508
- ->ifTrue (static function ($ v ): bool { return isset ($ v ['buses ' ]) && null !== $ v ['default_bus ' ] && !isset ($ v ['buses ' ][$ v ['default_bus ' ]]); } )
1509
- ->then (static function ( array $ v ): void { throw new InvalidConfigurationException (sprintf ('The specified default bus "%s" is not configured. Available buses are "%s". ' , $ v ['default_bus ' ], implode ('", " ' , array_keys ($ v ['buses ' ])))); } )
1508
+ ->ifTrue (fn ($ v ) => isset ($ v ['buses ' ]) && null !== $ v ['default_bus ' ] && !isset ($ v ['buses ' ][$ v ['default_bus ' ]]))
1509
+ ->then (fn ( $ v ) => throw new InvalidConfigurationException (sprintf ('The specified default bus "%s" is not configured. Available buses are "%s". ' , $ v ['default_bus ' ], implode ('", " ' , array_keys ($ v ['buses ' ])))))
1510
1510
->end ()
1511
1511
->children ()
1512
1512
->arrayNode ('routing ' )
@@ -1633,7 +1633,7 @@ function ($a) {
1633
1633
->info ('Reset container services after each message. ' )
1634
1634
->setDeprecated ('symfony/framework-bundle ' , '6.1 ' , 'Option "%node%" at "%path%" is deprecated. It does nothing and will be removed in version 7.0. ' )
1635
1635
->validate ()
1636
- ->ifTrue (static fn ($ v ) => true !== $ v )
1636
+ ->ifTrue (fn ($ v ) => true !== $ v )
1637
1637
->thenInvalid ('The "framework.messenger.reset_on_message" configuration option can be set to "true" only. To prevent services resetting after each message you can set the "--no-reset" option in "messenger:consume" command. ' )
1638
1638
->end ()
1639
1639
->end ()
@@ -1652,22 +1652,12 @@ function ($a) {
1652
1652
->children ()
1653
1653
->arrayNode ('default_middleware ' )
1654
1654
->beforeNormalization ()
1655
- ->ifTrue (function ($ defaultMiddleware ) { return \is_string ($ defaultMiddleware ) || \is_bool ($ defaultMiddleware ); })
1656
- ->then (function ($ defaultMiddleware ): array {
1657
- if (\is_string ($ defaultMiddleware ) && 'allow_no_handlers ' === $ defaultMiddleware ) {
1658
- return [
1659
- 'enabled ' => true ,
1660
- 'allow_no_handlers ' => true ,
1661
- 'allow_no_senders ' => true ,
1662
- ];
1663
- }
1664
-
1665
- return [
1666
- 'enabled ' => $ defaultMiddleware ,
1667
- 'allow_no_handlers ' => false ,
1668
- 'allow_no_senders ' => true ,
1669
- ];
1670
- })
1655
+ ->ifTrue (fn ($ v ) => \is_string ($ v ) || \is_bool ($ v ))
1656
+ ->then (fn ($ v ) => [
1657
+ 'enabled ' => 'allow_no_handlers ' === $ v ? true : $ v ,
1658
+ 'allow_no_handlers ' => 'allow_no_handlers ' === $ v ,
1659
+ 'allow_no_senders ' => true ,
1660
+ ])
1671
1661
->end ()
1672
1662
->canBeDisabled ()
1673
1663
->children ()
@@ -1678,8 +1668,8 @@ function ($a) {
1678
1668
->arrayNode ('middleware ' )
1679
1669
->performNoDeepMerging ()
1680
1670
->beforeNormalization ()
1681
- ->ifTrue (function ($ v ) { return \is_string ($ v ) || (\is_array ($ v ) && !\is_int (key ($ v ))); } )
1682
- ->then (function ($ v ) { return [$ v ]; } )
1671
+ ->ifTrue (fn ($ v ) => \is_string ($ v ) || (\is_array ($ v ) && !\is_int (key ($ v ))))
1672
+ ->then (fn ($ v ) => [$ v ])
1683
1673
->end ()
1684
1674
->defaultValue ([])
1685
1675
->arrayPrototype ()
@@ -1894,11 +1884,11 @@ private function addHttpClientSection(ArrayNodeDefinition $rootNode, callable $e
1894
1884
})
1895
1885
->end ()
1896
1886
->validate ()
1897
- ->ifTrue (function ($ v ) { return !isset ($ v ['scope ' ]) && !isset ($ v ['base_uri ' ]); } )
1887
+ ->ifTrue (fn ($ v ) => !isset ($ v ['scope ' ]) && !isset ($ v ['base_uri ' ]))
1898
1888
->thenInvalid ('Either "scope" or "base_uri" should be defined. ' )
1899
1889
->end ()
1900
1890
->validate ()
1901
- ->ifTrue (function ($ v ) { return !empty ($ v ['query ' ]) && !isset ($ v ['base_uri ' ]); } )
1891
+ ->ifTrue (fn ($ v ) => !empty ($ v ['query ' ]) && !isset ($ v ['base_uri ' ]))
1902
1892
->thenInvalid ('"query" applies to "base_uri" but no base URI is defined. ' )
1903
1893
->end ()
1904
1894
->children ()
@@ -2184,7 +2174,7 @@ private function addNotifierSection(ArrayNodeDefinition $rootNode, callable $ena
2184
2174
->arrayNode ('channel_policy ' )
2185
2175
->useAttributeAsKey ('name ' )
2186
2176
->prototype ('array ' )
2187
- ->beforeNormalization ()->ifString ()->then (function ( string $ v ) { return [$ v ]; } )->end ()
2177
+ ->beforeNormalization ()->ifString ()->then (fn ( $ v ) => [$ v ])->end ()
2188
2178
->prototype ('scalar ' )->end ()
2189
2179
->end ()
2190
2180
->end ()
@@ -2456,7 +2446,7 @@ private function addHtmlSanitizerSection(ArrayNodeDefinition $rootNode, callable
2456
2446
->info ('Allows only a given list of hosts to be used in links href attributes. ' )
2457
2447
->defaultValue (null )
2458
2448
->validate ()
2459
- ->ifTrue (function ($ v ) { return !\is_array ($ v ) && null !== $ v; } )
2449
+ ->ifTrue (fn ($ v ) => !\is_array ($ v ) && null !== $ v )
2460
2450
->thenInvalid ('The "allowed_link_hosts" parameter must be an array or null ' )
2461
2451
->end ()
2462
2452
->end ()
@@ -2472,7 +2462,7 @@ private function addHtmlSanitizerSection(ArrayNodeDefinition $rootNode, callable
2472
2462
->info ('Allows only a given list of hosts to be used in media source attributes (img, audio, video, ...). ' )
2473
2463
->defaultValue (null )
2474
2464
->validate ()
2475
- ->ifTrue (function ($ v ) { return !\is_array ($ v ) && null !== $ v; } )
2465
+ ->ifTrue (fn ($ v ) => !\is_array ($ v ) && null !== $ v )
2476
2466
->thenInvalid ('The "allowed_media_hosts" parameter must be an array or null ' )
2477
2467
->end ()
2478
2468
->end ()
0 commit comments