[DI] Remove deprecated case insensitive service ids#22811
Conversation
| 4.0.0 | ||
| ----- | ||
|
|
||
| * [BC BREAK] removed support for case insensitive service identifiers |
There was a problem hiding this comment.
BC BREAK prefix not needed
|
I think we need a proper behavior + test when two services are defined (ie pre-compile, using ContainerBuilder) and they have an id that differs only by the case: either it works properly (does it already?) or fail early (might be more DX friendly?) |
|
method map seems prepared :) $this->methodMap = array(
- 'bar' => 'getBarService',
+ 'BAR' => 'getBARService',
+ 'BAR2' => 'getBAR2Service',
+ 'bar' => 'getBar3Service',
+ 'bar2' => 'getBar22Service',will add one more test for PhpDumper :) but i think it works properly 👍 |
| node_closure_proxy [label="closure_proxy\nBarClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; | ||
| node_bar [label="BAR\nstdClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; | ||
| node_bar2 [label="bar2\nstdClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; | ||
| node_bar2 [label="BAR2\nstdClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; |
There was a problem hiding this comment.
not sure this is actually needs to be lowercased, perhaps qualifies a bugfix (2.7).
edit: or master / this PR; as it's an issue as of now. Let me know.
There was a problem hiding this comment.
IMO this needs to be fixed as part of this PR
There was a problem hiding this comment.
Graphviz nodes seem to be case-sensitive. so removing the lowercase should fix this.
|
@nicolas-grekas geen! new tests are proper imo. and allows for future edge cases to be added. I think we should at least try out this behavior on master =/ Changes to fabbot.io failure seems unrelated :) Ready for review. |
|
rebase needed |
| $this->assertSame($childDefA, $container->registerForAutoconfiguration('AInterface')); | ||
| } | ||
|
|
||
| public function testCaseInsensitivity() |
There was a problem hiding this comment.
should be testCaseSensitivity
| * @expectedDeprecation Service identifiers will be made case sensitive in Symfony 4.0. Using "Foo" instead of "foo" is deprecated since version 3.3. | ||
| */ | ||
| public function testGetInsensitivity() | ||
| public function testCaseInsensitivity() |
| if (isset($this->aliases[$name])) { | ||
| $name = $this->aliases[$name]; | ||
| } | ||
| $method = !isset($this->methodMap[$name]) ? 'get'.strtr($name, $this->underscoreMap).'Service' : $this->methodMap[$name]; |
There was a problem hiding this comment.
@stof not sure here.. it seems forgotten? This is the only use-case of Container::$underscoreMap left.
There was a problem hiding this comment.
methodMap will always be filled in 4.0 (we removed support for dumping a container with a custom dumper not dumping the method map)
|
should i remove the (deprecated) cc @GuilhemN |
#18167 indeed added support for sensitivity while fixing the PhpDumper for non alphanumeric ids.
I think it would be easier to review if it was done in another PR. Nothing would prevent you from merging this PR here though. |
|
Reverted compiler passes, they need to have a look though :) as well as the Other then that, i think this is ready :) |
| if (isset($this->aliases[$name])) { | ||
| $name = $this->aliases[$name]; | ||
| } | ||
| $method = !isset($this->methodMap[$name]) ? 'get'.strtr($name, $this->underscoreMap).'Service' : $this->methodMap[$name]; |
There was a problem hiding this comment.
methodMap will always be filled in 4.0 (we removed support for dumping a container with a custom dumper not dumping the method map)
| } | ||
| $manager->setProxyInitializer(\Closure::bind( | ||
| function (&$wrappedInstance, LazyLoadingInterface $manager) use ($name) { | ||
| if (isset($this->aliases[$name = strtolower($name)])) { |
There was a problem hiding this comment.
this requires a bugfix in 3.3 first instead: we need to use the normalizedIds property here instead of lowercasing (internal storage does not use lowercase anymore)
|
@ro0NL What's the status of this PR? |
|
@fabpot i should rebase at least :) let me have a look tomorrow evening / saturday. Status: needs work |
| * Parameter and service keys are case insensitive. | ||
| * | ||
| * A service id can contain lowercased letters, digits, underscores, and dots. | ||
| * A service id can contain letters, digits, underscores, and dots. |
There was a problem hiding this comment.
This doesn't seem correct anymore. Service ids are not actually validated are they? They can also contain namespace backslashes for example.
There was a problem hiding this comment.
Imo this comment should be removed, a service id can indeed contain any character.
There was a problem hiding this comment.
My guess is this was written from a file loader pov, As in fact any character is allowed as of 2.7.
| @@ -28,7 +28,7 @@ | |||
| * | |||
| * Parameter and service keys are case insensitive. | |||
There was a problem hiding this comment.
this is not up-to-date as well
| * | ||
| * A service id can contain lowercased letters, digits, underscores, and dots. | ||
| * A service id can contain letters, digits, underscores, and dots. | ||
| * Underscores are used to separate words, and dots to group services |
There was a problem hiding this comment.
this should also mention that this is only relevant when you have several services of the same class. otherwise you can use service id == class name.
There was a problem hiding this comment.
I removed the whole block =/ This is just some service id convention, not really related to the container at all; as it allows any character as mentioned.
The part about creating a method is outdated, as it only checks the method map now.
|
Thank you @ro0NL. |
This PR was merged into the 2.7 branch. Discussion ---------- [DI] Remove irrelevant comment from container | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes-ish | 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--> Spotted in #22811 Commits ------- 595a225 [DI] Remove irrelevant comment from container
See #21223