Skip to content

[DependencyInjection] EnvPlaceholderParameterBag::get() can't return UnitEnum #47635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 26, 2022

Conversation

php-rock
Copy link

@php-rock php-rock commented Sep 20, 2022

Q A
Branch? 6.0
Bug fix? yes
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

This PR allows to get enums from container in the next situation:

parameters:
    app.someEnum.yes !php/const \App\Context\SomeEnum::YES

Currently, we'll have an error:

[critical] Uncaught Error: Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag::get(): Return value must be of type array|string|int|float|bool|null, \App\Context\SomeEnum returned

This bugfix fixes this error.

EnvPlaceholderParameterBag::get() has a signature: array|bool|string|int|float|null
ParameterBag::get() has another signature: array|bool|string|int|float|\UnitEnum|null

Why do we need this fix?
To make the results of two dependent methods consistent.

EnvPlaceholderParameterBag::get() call ParameterBag::get() here: https://github.com/symfony/symfony/blob/6.1/src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php#L61

This PR makes it consistent and adding UnitEnum to EnvPlaceholderParameterBag::get() result.

@carsonbot carsonbot added this to the 6.1 milestone Sep 20, 2022
@php-rock php-rock changed the title Bugfix: EnvPlaceholderParameterBag::get() can't return UnitEnum (Symfony 6.1) [DependencyInjection] [Bugfix] EnvPlaceholderParameterBag::get() can't return UnitEnum (Symfony 6.1) Sep 20, 2022
@nicolas-grekas nicolas-grekas changed the title [DependencyInjection] [Bugfix] EnvPlaceholderParameterBag::get() can't return UnitEnum (Symfony 6.1) [DependencyInjection] EnvPlaceholderParameterBag::get() can't return UnitEnum Sep 26, 2022
@nicolas-grekas nicolas-grekas modified the milestones: 6.1, 6.0 Sep 26, 2022
@nicolas-grekas
Copy link
Member

Thank you @php-rock.

@nicolas-grekas nicolas-grekas merged commit 540425a into symfony:6.0 Sep 26, 2022
This was referenced Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants