-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] fix reporting bindings on overriden services as unused #29597
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
nicolas-grekas
commented
Dec 13, 2018
Q | A |
---|---|
Branch? | 3.4 |
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #28326 |
License | MIT |
Doc PR | - |
I'm afraid this won't work in most cases: we deep copy bindings in the loaders (see https://github.com/symfony/symfony/blob/master/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php#L523). So instead we need to store bindings id and check against this list in the pass. |
5405676
to
e07ad2b
Compare
@GuilhemN thanks for the review! Updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice improvement 👍 thank you!
…d (nicolas-grekas) This PR was merged into the 3.4 branch. Discussion ---------- [DI] fix reporting bindings on overriden services as unused | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #28326 | License | MIT | Doc PR | - Commits ------- e07ad2b [DI] fix reporting bindings on overriden services as unused
If I am not mistaken, this fix has created a new problem in ResolveBindingsPass. The newly added puts all bindings that are set within a file into the usedBindings array. Before that, usedBindings array was empty as set in the property's declaration. symfony/src/Symfony/Component/DependencyInjection/Compiler/ResolveBindingsPass.php Line 37 in 1d3ce9b
This means that aftewards, when processValue is called, the unusedBindings array remains empty, because the following condition is not met. symfony/src/Symfony/Component/DependencyInjection/Compiler/ResolveBindingsPass.php Lines 84 to 86 in 1d3ce9b
As a result, InvalidArgumentException (informing about an unused binding) is not thrown, even if a binding is actually not used. I have come upon this, because I was just about to make a PR solving #27828, but after I fetched the symfony code to make sure it is up to date my fix stopped working. I believe I can find a new solution, solving both problems. |
The current code prefers a false negative to the previous false positive. |
…rvices as unused" This reverts commit e07ad2b
…n services as unused" (mmarynich) This PR was merged into the 3.4 branch. Discussion ---------- Revert "bug #29597 [DI] fix reporting bindings on overriden services as unused" This reverts commit 44e9a91, reversing changes made to 91b28ff. | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #29836 | License | MIT | Doc PR | 4.2.2 release changed the way tagged service are injected As asked by @nicolas-grekas #29836 (comment) Commits ------- b3e17d2 Revert "bug #29597 [DI] fix reporting bindings on overriden services as unused (nicolas-grekas)"
* 3.4: fix compatibility with Twig >= 2.6.1 [Form] SA fix fix compatibility with PHPUnit 4.8 remove return type hint for PHP 5 compatibility Component CssSelector tests [DebugClassLoader] Readd findFile() method [Console] Fix composer.json suggest/provide Revert "bug #29597 [DI] fix reporting bindings on overriden services as unused (nicolas-grekas)" Fixed exception wording Fix SwiftMailerHandler to support Monolog's latest reset functionality
* 4.1: bump required Twig version fix compatibility with Twig >= 2.6.1 [Form] SA fix fix compatibility with PHPUnit 4.8 remove return type hint for PHP 5 compatibility SCA: minor code tweaks Component CssSelector tests [DebugClassLoader] Readd findFile() method [Console] Fix composer.json suggest/provide Revert "bug #29597 [DI] fix reporting bindings on overriden services as unused (nicolas-grekas)" Fixed exception wording Fix SwiftMailerHandler to support Monolog's latest reset functionality
* 4.2: bump required Twig version fix compatibility with Twig >= 2.6.1 [Form] SA fix fix compatibility with PHPUnit 4.8 remove return type hint for PHP 5 compatibility SCA: minor code tweaks Component CssSelector tests [DebugClassLoader] Readd findFile() method [Console] Fix composer.json suggest/provide Revert "bug #29597 [DI] fix reporting bindings on overriden services as unused (nicolas-grekas)" Fixed exception wording Fix SwiftMailerHandler to support Monolog's latest reset functionality
In symfony#29853 the bugfix made in symfony#29597 was reverted as it did not work as expected. This fixture file has been modified after the 3.4 branch was merged up to account for the changes made in symfony#2957 and must now be reverted to the former state too.
…abbuh) This PR was merged into the 4.2 branch. Discussion ---------- [DependencyInjection] fix test after revert of bugfix | Q | A | ------------- | --- | Branch? | 4.2 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | In #29853 the bugfix made in #29597 was reverted as it did not work as expected. This fixture file has been modified after the 3.4 branch was merged up to account for the changes made in #2957 and must now be reverted to the former state too. Commits ------- 81f63b1 fix test after revert of bugfix