Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e07ed22

Browse files
committed
minor #32322 [FrameworkBundle] Simplified some code in the DI configuration (javiereguiluz)
This PR was submitted for the 3.4 branch but it was merged into the 4.4 branch instead (closes #32322). Discussion ---------- [FrameworkBundle] Simplified some code in the DI configuration | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | - | License | MIT | Doc PR | not needed Commits ------- e6d76ba [FrameworkBundle] Simplified some code in the DI configuration
2 parents 70318b4 + e6d76ba commit e07ed22

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -585,10 +585,7 @@ private function addRequestSection(ArrayNodeDefinition $rootNode)
585585
->ifTrue(function ($v) { return \is_array($v) && isset($v['mime_type']); })
586586
->then(function ($v) { return $v['mime_type']; })
587587
->end()
588-
->beforeNormalization()
589-
->ifTrue(function ($v) { return !\is_array($v); })
590-
->then(function ($v) { return [$v]; })
591-
->end()
588+
->beforeNormalization()->castToArray()->end()
592589
->prototype('scalar')->end()
593590
->end()
594591
->end()
@@ -646,10 +643,7 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode)
646643
->fixXmlConfig('loader')
647644
->children()
648645
->arrayNode('loaders')
649-
->beforeNormalization()
650-
->ifTrue(function ($v) { return !\is_array($v); })
651-
->then(function ($v) { return [$v]; })
652-
->end()
646+
->beforeNormalization()->castToArray()->end()
653647
->prototype('scalar')->end()
654648
->end()
655649
->end()
@@ -674,10 +668,7 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode)
674668
->scalarNode('base_path')->defaultValue('')->end()
675669
->arrayNode('base_urls')
676670
->requiresAtLeastOneElement()
677-
->beforeNormalization()
678-
->ifTrue(function ($v) { return !\is_array($v); })
679-
->then(function ($v) { return [$v]; })
680-
->end()
671+
->beforeNormalization()->castToArray()->end()
681672
->prototype('scalar')->end()
682673
->end()
683674
->end()
@@ -719,10 +710,7 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode)
719710
->scalarNode('base_path')->defaultValue('')->end()
720711
->arrayNode('base_urls')
721712
->requiresAtLeastOneElement()
722-
->beforeNormalization()
723-
->ifTrue(function ($v) { return !\is_array($v); })
724-
->then(function ($v) { return [$v]; })
725-
->end()
713+
->beforeNormalization()->castToArray()->end()
726714
->prototype('scalar')->end()
727715
->end()
728716
->end()
@@ -817,10 +805,7 @@ private function addValidationSection(ArrayNodeDefinition $rootNode)
817805
->defaultValue(['loadValidatorMetadata'])
818806
->prototype('scalar')->end()
819807
->treatFalseLike([])
820-
->validate()
821-
->ifTrue(function ($v) { return !\is_array($v); })
822-
->then(function ($v) { return (array) $v; })
823-
->end()
808+
->validate()->castToArray()->end()
824809
->end()
825810
->scalarNode('translation_domain')->defaultValue('validators')->end()
826811
->booleanNode('strict_email')->end()

0 commit comments

Comments
 (0)