-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] Cleanup array_key_exists #19689
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
Conversation
I tend to think this could theoretically be OK , BUT practically I don't see any reasons to take the risk of breaking something given that the existing |
What would we break? Only null is affected.. we shouldnt consider people actually relying on this quirk from our side. Imo. |
Not cleaning up out of fear.. or not knowing about intention of code is 👎 for me. |
That's where our opinions diverge. By experience, people do use extension points to do clever things we can't imagine beforehand. |
Understand, and i know this is difficult. My point is, this was not intended/designed to be a extension point at all. We make it really hard for ourselves also this way. This should be considered rationally, do we intend My opionion:
|
Re-read, removing my 👎 |
Rebased. Diff is the same :-) I cant edit the base branch on github i guess? |
@ro0NL you can edit it (they deployed this feature 1 week ago) |
Made my day. Thanks @stof |
👍 :) |
👍 |
Indeed, |
Thank you @ro0NL. |
This PR was squashed before being merged into the 2.7 branch (closes #19689). Discussion ---------- [DI] Cleanup array_key_exists | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | comma-separated list of tickets fixed by the PR, if any | License | MIT | Doc PR | reference to the documentation PR, if any Investigated this a bit, and to me it looks like left-over code. `null` doesnt end up in `$this->services` by design (this was done in #8582) so it seems. The test added then for regression still passes :) I cant believe we guarantee BC for users doing `$this->services['id'] = null` (due protected), allowing them to break the design of `has`, `get` and `initialized` right now. This also happens for `$this->definitions` in `ContainerBuilder`, maybe because `Container` did it alteady.. but im not sure. Then again, there's this comment: #14470 (comment) Commits ------- 3306c70 [DI] Cleanup array_key_exists
This seems to be causing some BC breaks 😢 |
See #19847 |
…" (nicolas-grekas) This PR was merged into the 2.7 branch. Discussion ---------- Revert "minor #19689 [DI] Cleanup array_key_exists (ro0NL)" | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | Tests pass? | yes | Fixed tickets | #19689 #19840 #19825 #19857 | License | MIT | Doc PR | - This reverts commit c89f80a, reversing changes made to 386e5e7. See discussion in #19847 I'll try adding test cases soon that ensure that: - [x] *when not leaving scope* synthetic services always throw and ignore the `ContainerInterface::NULL_ON_INVALID_REFERENCE` flag (on 3.x also) - [x] *when leaving scope* synthetic services always return null and ignore the `ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE` (until 2.8 since scopes are gone in 3.x) Commits ------- 8cb28bf [DI] Add anti-regression test ac742df Revert "minor #19689 [DI] Cleanup array_key_exists (ro0NL)"
* 2.7: [FrameworkBundle] Check for class existence before is_subclass_of Update GroupSequence.php Code enhancement and cleanup [DI] Add anti-regression test Revert "minor #19689 [DI] Cleanup array_key_exists (ro0NL)" [BrowserKit] Fix cookie expiration on 32 bit systems bumped Symfony version to 2.7.18 updated VERSION for 2.7.17 update CONTRIBUTORS for 2.7.17 updated CHANGELOG for 2.7.17 Update misleading comment about RFC4627
* 2.8: [FrameworkBundle] Check for class existence before is_subclass_of Update GroupSequence.php Code enhancement and cleanup [Form] Fix transformer tests after the ICU update [DI] Add anti-regression test Revert "minor #19689 [DI] Cleanup array_key_exists (ro0NL)" bumped Symfony version to 2.8.11 updated VERSION for 2.8.10 updated CHANGELOG for 2.8.10 [BrowserKit] Fix cookie expiration on 32 bit systems bumped Symfony version to 2.7.18 updated VERSION for 2.7.17 update CONTRIBUTORS for 2.7.17 updated CHANGELOG for 2.7.17 Update misleading comment about RFC4627
* 3.1: [FrameworkBundle] Check for class existence before is_subclass_of Update GroupSequence.php Code enhancement and cleanup [Form] Fix transformer tests after the ICU update [DI] Add anti-regression test Revert "minor #19689 [DI] Cleanup array_key_exists (ro0NL)" bumped Symfony version to 3.1.5 updated VERSION for 3.1.4 updated CHANGELOG for 3.1.4 bumped Symfony version to 2.8.11 updated VERSION for 2.8.10 updated CHANGELOG for 2.8.10 [BrowserKit] Fix cookie expiration on 32 bit systems bumped Symfony version to 2.7.18 updated VERSION for 2.7.17 update CONTRIBUTORS for 2.7.17 updated CHANGELOG for 2.7.17 Update misleading comment about RFC4627
Reverted on 2.7 & 2.8, kept on 3.* |
@nicolas-grekas @fabpot sorry for this :-) |
* 2.7: [FrameworkBundle] Check for class existence before is_subclass_of Update GroupSequence.php Code enhancement and cleanup [DI] Add anti-regression test Revert "minor symfony#19689 [DI] Cleanup array_key_exists (ro0NL)" [BrowserKit] Fix cookie expiration on 32 bit systems bumped Symfony version to 2.7.18 updated VERSION for 2.7.17 update CONTRIBUTORS for 2.7.17 updated CHANGELOG for 2.7.17 Update misleading comment about RFC4627
* 2.8: [FrameworkBundle] Check for class existence before is_subclass_of Update GroupSequence.php Code enhancement and cleanup [Form] Fix transformer tests after the ICU update [DI] Add anti-regression test Revert "minor symfony#19689 [DI] Cleanup array_key_exists (ro0NL)" bumped Symfony version to 2.8.11 updated VERSION for 2.8.10 updated CHANGELOG for 2.8.10 [BrowserKit] Fix cookie expiration on 32 bit systems bumped Symfony version to 2.7.18 updated VERSION for 2.7.17 update CONTRIBUTORS for 2.7.17 updated CHANGELOG for 2.7.17 Update misleading comment about RFC4627
* 3.1: [FrameworkBundle] Check for class existence before is_subclass_of Update GroupSequence.php Code enhancement and cleanup [Form] Fix transformer tests after the ICU update [DI] Add anti-regression test Revert "minor symfony#19689 [DI] Cleanup array_key_exists (ro0NL)" bumped Symfony version to 3.1.5 updated VERSION for 3.1.4 updated CHANGELOG for 3.1.4 bumped Symfony version to 2.8.11 updated VERSION for 2.8.10 updated CHANGELOG for 2.8.10 [BrowserKit] Fix cookie expiration on 32 bit systems bumped Symfony version to 2.7.18 updated VERSION for 2.7.17 update CONTRIBUTORS for 2.7.17 updated CHANGELOG for 2.7.17 Update misleading comment about RFC4627
Investigated this a bit, and to me it looks like left-over code.
null
doesnt end up in$this->services
by design (this was done in #8582) so it seems. The test added then for regression still passes :)I cant believe we guarantee BC for users doing
$this->services['id'] = null
(due protected), allowing them to break the design ofhas
,get
andinitialized
right now.This also happens for
$this->definitions
inContainerBuilder
, maybe becauseContainer
did it alteady.. but im not sure.Then again, there's this comment: #14470 (comment)