Skip to content

Commit 25f719e

Browse files
committed
minor symfony#14173 Use specialized config methods instead of the generic ifTrue() method (javiereguiluz)
This PR was merged into the 2.3 branch. Discussion ---------- Use specialized config methods instead of the generic ifTrue() method | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Commits ------- dbd02b0 Use specialized config methods instead of the generic ifTrue() method
2 parents feb48c2 + dbd02b0 commit 25f719e

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,7 @@ public function getConfigTreeBuilder()
6969
->booleanNode('test')->end()
7070
->scalarNode('default_locale')->defaultValue('en')->end()
7171
->arrayNode('trusted_hosts')
72-
->beforeNormalization()
73-
->ifTrue(function ($v) { return is_string($v); })
74-
->then(function ($v) { return array($v); })
75-
->end()
72+
->beforeNormalization()->ifString()->then(function ($v) { return array($v); })->end()
7673
->prototype('scalar')->end()
7774
->end()
7875
->end()
@@ -263,7 +260,7 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode)
263260
->addDefaultChildrenIfNoneSet()
264261
->prototype('scalar')->defaultValue('FrameworkBundle:Form')->end()
265262
->validate()
266-
->ifTrue(function ($v) {return !in_array('FrameworkBundle:Form', $v); })
263+
->ifNotInArray(array('FrameworkBundle:Form'))
267264
->then(function ($v) {
268265
return array_merge(array('FrameworkBundle:Form'), $v);
269266
})

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private function addFormSection(ArrayNodeDefinition $rootNode)
5858
->prototype('scalar')->defaultValue('form_div_layout.html.twig')->end()
5959
->example(array('MyBundle::form.html.twig'))
6060
->validate()
61-
->ifTrue(function ($v) { return !in_array('form_div_layout.html.twig', $v); })
61+
->ifNotInArray(array('form_div_layout.html.twig'))
6262
->then(function ($v) {
6363
return array_merge(array('form_div_layout.html.twig'), $v);
6464
})

0 commit comments

Comments
 (0)