Skip to content

[DependencyInjection] Deprecate numeric parameter names #47683

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

HeahDude
Copy link
Contributor

@HeahDude HeahDude commented Sep 24, 2022

Q A
Branch? 6.2
Bug fix? no
New feature? no
Deprecations? yes
Tickets ~
License MIT
Doc PR TODO

While trying to use '.' !== $key[0] instead of str_starts_with($key, '.') in #47680, I noticed some tests were failing due to the usage of numeric parameter names in the fixtures.

This leads to inconsistent behavior since the following code: $parameterBag->set(10, 10), will first cast the name 10 to string because of the method signature, but will then cast back to integer when using it as an array key in https://github.com/symfony/symfony/blob/6.2/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php#L89.
Because Symfony does not use strict types, it can be really tricky.

This PR propose to deprecate using such names to be able to properly throw in 7.0.

@carsonbot carsonbot added this to the 6.2 milestone Sep 24, 2022
@HeahDude HeahDude force-pushed the deprecate/numeric-parameter-names branch 2 times, most recently from f47f3bd to 8083245 Compare September 24, 2022 18:59
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGMT, just some minor comment

@HeahDude HeahDude force-pushed the deprecate/numeric-parameter-names branch 2 times, most recently from d3af9e4 to e391711 Compare September 26, 2022 11:51
@HeahDude HeahDude force-pushed the deprecate/numeric-parameter-names branch from e391711 to 3e0050a Compare September 26, 2022 13:23
@chalasr
Copy link
Member

chalasr commented Sep 26, 2022

Thank you @HeahDude.

@chalasr chalasr merged commit 59da7ea into symfony:6.2 Sep 26, 2022
@HeahDude HeahDude deleted the deprecate/numeric-parameter-names branch September 26, 2022 14:18
@fabpot fabpot mentioned this pull request Oct 24, 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.

4 participants