Skip to content

[DI] Remove case insensitive parameter names #24052

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 1, 2017
Merged

[DI] Remove case insensitive parameter names #24052

merged 1 commit into from
Sep 1, 2017

Conversation

ro0NL
Copy link
Contributor

@ro0NL ro0NL commented Aug 31, 2017

Q A
Branch? master
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #...
License MIT
Doc PR symfony/symfony-docs#...

First round, lets see :)

@@ -1643,7 +1613,7 @@ private function getServiceCall($id, Reference $reference = null)
if ('service_container' === $id) {
return '$this';
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

3.4 is ok :)

@nicolas-grekas nicolas-grekas modified the milestones: 3.4, 4.0 Aug 31, 2017
@@ -68,7 +66,7 @@ public function all()
*/
public function get($name)
{
$name = $this->normalizeName($name);
$name = (string) $name;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why these string casts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously implied by strtolower. And we actually rely on that, tests fail otherwise.

https://github.com/symfony/symfony/blob/master/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php#L1558 leads to has/getParameter($paramInstance) call.

Copy link
Member

Choose a reason for hiding this comment

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

then the dumper should be updated on the lowest branch for making it cast to string beforehand IMHO

Copy link
Member

Choose a reason for hiding this comment

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

why? we don't use strict types (fortunately), so casting is just fine IMHO - and is functionally similar to adding the type hint on the signature (if we could)

Copy link
Contributor

Choose a reason for hiding this comment

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

It's a matter of contract. If @param string means, we also support objects that can be cast to string, then we need to add the string cast everywhere in symfony. So I agree with @chalasr that this is a bug of the dumper.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm just saying string and castable object instance have not been treated the same everywhere.

The thing is we used strtolower before, which happily casts. Thus making it a supported feature, probably unintended but at this point we have to consider it.

Therefor i dont think it's part of this PR, which is now merged anyway. But maybe for the sake of consistency, we could cast beforehand, where needed. And deprecate passing stringish values or just ignore the fact it was possible before, regarding end users.

Copy link
Member

Choose a reason for hiding this comment

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

In the past we usually rejected explicit type casts and let it be the user's responsibility to respect our API.

Copy link
Member

Choose a reason for hiding this comment

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

And in the past also we had to revert as bugfix because we broke things with this policy...

Copy link
Contributor Author

@ro0NL ro0NL Sep 1, 2017

Choose a reason for hiding this comment

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

But we break BC in this case :) Technically at least, passing a stringish object actually worked as expected before. Core uses it :)

So yes there's an inconsistency between $a[strtolower($k)] and $a[$k] by design. I believe @nicolas-grekas comment "This is PHP" reflects that.

Now if everywhere we'd do fn(string $k) the inconsistency is gone, while preserving the stringish behavior. Id prefer doing that instead of removing it here first.

edit: missed comment in between, as usual :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Lets just keep it. This will always be a case-by-case decision until we have type declarations.

@fabpot
Copy link
Member

fabpot commented Sep 1, 2017

Thank you @ro0NL.

@fabpot fabpot merged commit ed3df04 into symfony:master Sep 1, 2017
fabpot added a commit that referenced this pull request Sep 1, 2017
This PR was merged into the 4.0-dev branch.

Discussion
----------

[DI] Remove case insensitive parameter names

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!--highly recommended for new features-->

First round, lets see :)

Commits
-------

ed3df04 [DI] Remove case insensitive parameter names
@ro0NL ro0NL deleted the di/params-4.0 branch September 1, 2017 19:23
@TomasVotruba
Copy link
Contributor

Yes, thank you! 👏

I think this resolves my issue #23381

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.

9 participants