8000 Revert "minor #19689 [DI] Cleanup array_key_exists (ro0NL)" by nicolas-grekas · Pull Request #19848 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Revert "minor #19689 [DI] Cleanup array_key_exists (ro0NL)" #19848

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 2 commits into from
Sep 6, 2016

Conversation

nicolas-grekas
Copy link
Member
@nicolas-grekas nicolas-grekas commented Sep 4, 2016
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:

  • when not leaving scope synthetic services always throw and ignore the ContainerInterface::NULL_ON_INVALID_REFERENCE flag (on 3.x also)
  • 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)

This reverts commit c89f80a, reversing
changes made to 386e5e7.
@nicolas-grekas
Copy link
Member Author

Tests added, PR ready

@@ -223,6 +223,7 @@ public function has($id)
if ('service_container' === $id
|| isset($this->aliases[$id])
|| isset($this->services[$id])
Copy link
Member
@dunglas dunglas Sep 5, 2016

Choose a reason for hiding this comment

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

IIUC, $this->services always exist and is always an array, so this line can be removed (the array_key_exists call in the next will do the check).

Copy link
Member Author
@nicolas-grekas nicolas-grekas Sep 5, 2016

Choose a reason for hiding this comment

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

yes but: isset is faster, and isset is what we'll keep on 3.x - and this is a revert, let's stop "optimizing" things that worked fine and had already been reviewed hundred of times.

Copy link
Member
@dunglas dunglas Sep 5, 2016

Choose a reason for hiding this comment

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

Ok to ease the merge between branches.
Regarding the perf, does it really worth to make the code more complex for such micro-optimizations?

Copy link
Member Author
@nicolas-grekas nicolas-grekas Sep 5, 2016

Choose a reason for hiding this comment

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

container->has/get() is full of micro-optimizations because it can be called thousands of time.
Which immediately unqualifies this as a "micro"-optimization and makes it a "macro" one.

@dunglas
Copy link
Member
dunglas commented Sep 5, 2016

👍

@nicolas-grekas nicolas-grekas merged commit 8cb28bf into symfony:2.7 Sep 6, 2016
nicolas-grekas added a commit that referenced this pull request Sep 6, 2016
…" (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)"
@nicolas-grekas nicolas-grekas deleted the revert-di-break branch September 6, 2016 11:08
This was referenced Sep 7, 2016
@fabpot fabpot mentioned this pull request Oct 3, 2016
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
0