Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #22306 [DI] Restrict autowired registration to "same-vendor" …
…namespaces (nicolas-grekas) This PR was merged into the 3.3-dev branch. Discussion ---------- [DI] Restrict autowired registration to "same-vendor" namespaces | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Following #22295, it came to me that I've already been bitten hard by the auto-registration we decided to keep working: when one type-hints some class in the Symfony namespace (eg `Request`), then autoregistration creates a corresponding service. You see the issue. Hard time debugging that. By restricting autoregistration to same-vendor (=same-root-namespace), we can keep all benefits of autoregistration, while closing this DX trap. The patch is bigger than strictly required to implement this, but contains a few related fixes and cleanups. Commits ------- 9c53b3d [DI] Restrict autowired registration to "same-vendor" namespaces
- Loading branch information
Showing
13 changed files
with
130 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/Symfony/Component/DependencyInjection/Tests/Fixtures/TestServiceSubscriber.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\DependencyInjection\Tests\Fixtures; | ||
|
||
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface; | ||
|
||
class TestServiceSubscriber implements ServiceSubscriberInterface | ||
{ | ||
public function __construct($container) | ||
{ | ||
} | ||
|
||
public static function getSubscribedServices() | ||
{ | ||
return array( | ||
__CLASS__, | ||
'?'.CustomDefinition::class, | ||
'bar' => CustomDefinition::class, | ||
'baz' => '?'.CustomDefinition::class, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.