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

Commitee94cc9

Browse files
bug#48502 [DependencyInjection] FixContainerBuilder stats env usage with enum (alamirault)
This PR was squashed before being merged into the 6.2 branch.Discussion----------[DependencyInjection] Fix `ContainerBuilder` stats env usage with enum| Q | A| ------------- | ---| Branch? | 6.2| Bug fix? | yes| New feature? | no <!-- please update src/**/CHANGELOG.md files -->| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tickets |Fix#48498 <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead -->| License | MIT| Doc PR | symfony/symfony-docs#... <!-- required for new features -->Without patch:```php[ 'enum:Symfony\Component\DependencyInjection\Tests\Fixtures\StringBackedEnum:foo' => 0, 'Bar' => 1,]```With patch:```php[ 'enum:Symfony\Component\DependencyInjection\Tests\Fixtures\StringBackedEnum:foo' => 1, 'Bar' => 1,]```Commits-------75da869 [DependencyInjection] Fix `ContainerBuilder` stats env usage with enum
2 parents7d45767 +75da869 commitee94cc9

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

‎src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function get(string $name): array|bool|string|int|float|\UnitEnum|null
4949
}
5050

5151
$uniqueName =md5($name.'_'.self::$counter++);
52-
$placeholder =sprintf('%s_%s_%s',$this->getEnvPlaceholderUniquePrefix(),strtr($env,':-.','___'),$uniqueName);
52+
$placeholder =sprintf('%s_%s_%s',$this->getEnvPlaceholderUniquePrefix(),strtr($env,':-.\\','____'),$uniqueName);
5353
$this->envPlaceholders[$env][$placeholder] =$placeholder;
5454

5555
return$placeholder;

‎src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
useSymfony\Component\DependencyInjection\Tests\Fixtures\FooWithAbstractArgument;
5252
useSymfony\Component\DependencyInjection\Tests\Fixtures\ScalarFactory;
5353
useSymfony\Component\DependencyInjection\Tests\Fixtures\SimilarArgumentsDummy;
54+
useSymfony\Component\DependencyInjection\Tests\Fixtures\StringBackedEnum;
5455
useSymfony\Component\DependencyInjection\Tests\Fixtures\WitherStaticReturnType;
5556
useSymfony\Component\DependencyInjection\TypedReference;
5657
useSymfony\Component\ExpressionLanguage\Expression;
@@ -545,6 +546,23 @@ public function testEnvExpressionFunction()
545546
$this->assertEquals('Foo value',$container->get('bar')->foo);
546547
}
547548

549+
publicfunctiontestGetEnvCountersWithEnum()
550+
{
551+
$bag =newEnvPlaceholderParameterBag();
552+
$config =newContainerBuilder($bag);
553+
$config->resolveEnvPlaceholders([
554+
$bag->get('env(enum:'.StringBackedEnum::class.':foo)'),
555+
$bag->get('env(Bar)'),
556+
]);
557+
558+
$expected = [
559+
'enum:Symfony\Component\DependencyInjection\Tests\Fixtures\StringBackedEnum:foo' =>1,
560+
'Bar' =>1,
561+
];
562+
563+
$this->assertSame($expected,$config->getEnvCounters());
564+
}
565+
548566
publicfunctiontestCreateServiceWithAbstractArgument()
549567
{
550568
$this->expectException(RuntimeException::class);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp