File tree Expand file tree Collapse file tree 7 files changed +109
-6
lines changed
Expand file tree Collapse file tree 7 files changed +109
-6
lines changed Original file line number Diff line number Diff line change 88 ],
99 "files" : [
1010 " preload.php" ,
11- " vendor/composer/installed.php"
11+ " vendor/composer/installed.php" ,
12+ " vendor/attributes.php"
1213 ],
1314 "directories" : [
1415 " conf" ,
Original file line number Diff line number Diff line change 2323 "nette/schema" : " ^1.2.2" ,
2424 "nette/utils" : " ^3.2.5" ,
2525 "nikic/php-parser" : " ^5.4.0" ,
26+ "olvlvl/composer-attribute-collector" : " ^2.0" ,
2627 "ondram/ci-detector" : " ^3.4.0" ,
2728 "ondrejmirtes/better-reflection" : " 6.57.0.0" ,
2829 "phpstan/php-8-stubs" : " 0.4.12" ,
7273 "platform-check" : false ,
7374 "sort-packages" : true ,
7475 "allow-plugins" : {
75- "cweagans/composer-patches" : true
76+ "cweagans/composer-patches" : true ,
77+ "olvlvl/composer-attribute-collector" : true ,
78+ "vaimo/composer-patches" : true
7679 }
7780 },
7881 "extra" : {
82+ "composer-attribute-collector" : {
83+ "include" : [
84+ " src"
85+ ]
86+ },
7987 "composer-exit-on-patch-failure" : true ,
8088 "patches" : {
8189 "composer/ca-bundle" : [
Original file line number Diff line number Diff line change @@ -210,6 +210,7 @@ parameters:
210210extensions :
211211 rules : PHPStan\DependencyInjection\RulesExtension
212212 expandRelativePaths : PHPStan\DependencyInjection\ExpandRelativePathExtension
213+ autowiredAttributeServices : PHPStan\DependencyInjection\AutowiredAttributeServicesExtension
213214 conditionalTags : PHPStan\DependencyInjection\ConditionalTagsExtension
214215 parametersSchema : PHPStan\DependencyInjection\ParametersSchemaExtension
215216 validateIgnoredErrors : PHPStan\DependencyInjection\ValidateIgnoredErrorsExtension
@@ -575,9 +576,6 @@ services:
575576 editorUrl : %editorUrl%
576577 usedLevel : %usedLevel%
577578
578- -
579- class : PHPStan\Dependency\DependencyResolver
580-
581579 -
582580 class : PHPStan\Dependency\ExportedNodeFetcher
583581 arguments :
Original file line number Diff line number Diff line change 1111use PHPStan \Analyser \Scope ;
1212use PHPStan \Broker \ClassNotFoundException ;
1313use PHPStan \Broker \FunctionNotFoundException ;
14+ use PHPStan \DependencyInjection \AutowiredService ;
1415use PHPStan \File \FileHelper ;
1516use PHPStan \Node \ClassPropertyNode ;
1617use PHPStan \Node \InClassMethodNode ;
2829use function array_merge ;
2930use function count ;
3031
32+ #[AutowiredService]
3133final class DependencyResolver
3234{
3335
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 );
2+
3+ namespace PHPStan \DependencyInjection ;
4+
5+ use Nette \DI \CompilerExtension ;
6+ use olvlvl \ComposerAttributeCollector \Attributes ;
7+
8+ final class AutowiredAttributeServicesExtension extends CompilerExtension
9+ {
10+
11+ public function loadConfiguration (): void
12+ {
13+ require_once __DIR__ . '/../../vendor/attributes.php ' ;
14+ $ autowiredServiceClasses = Attributes::findTargetClasses (AutowiredService::class);
15+ $ builder = $ this ->getContainerBuilder ();
16+
17+ foreach ($ autowiredServiceClasses as $ class ) {
18+ $ builder ->addDefinition (null )
19+ ->setType ($ class ->name )
20+ ->setAutowired ();
21+ }
22+ }
23+
24+ }
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 );
2+
3+ namespace PHPStan \DependencyInjection ;
4+
5+ use Attribute ;
6+
7+ #[Attribute(flags: Attribute::TARGET_CLASS )]
8+ final class AutowiredService
9+ {
10+
11+ }
You can’t perform that action at this time.
0 commit comments