Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6eb836b

Browse files
committed
[OptionsResolver] Fix force prepend normalizer
1 parentecb5f7c commit6eb836b

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

‎src/Symfony/Component/OptionsResolver/OptionsResolver.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ public function addNormalizer(string $option, \Closure $normalizer, bool $forceP
532532
}
533533

534534
if ($forcePrepend) {
535+
$this->normalizers[$option] =$this->normalizers[$option] ?? [];
535536
array_unshift($this->normalizers[$option],$normalizer);
536537
}else {
537538
$this->normalizers[$option][] =$normalizer;

‎src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,17 @@ public function testForcePrependNormalizerClosure()
15061506
$this->assertEquals(['foo' =>'2nd-normalized-1st-normalized-bar'],$this->resolver->resolve());
15071507
}
15081508

1509+
publicfunctiontestForcePrependNormalizerForResolverWithoutPreviousNormalizers()
1510+
{
1511+
// defined by superclass
1512+
$this->resolver->setDefault('foo','bar');
1513+
$this->resolver->addNormalizer('foo',function (Options$options,$value) {
1514+
return'1st-normalized-'.$value;
1515+
},true);
1516+
1517+
$this->assertEquals(['foo' =>'1st-normalized-bar'],$this->resolver->resolve());
1518+
}
1519+
15091520
publicfunctiontestAddNormalizerFailsIfUnknownOption()
15101521
{
15111522
$this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp