File tree 8 files changed +108
-5
lines changed
8 files changed +108
-5
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ use Symfony\Component\Console\Helper\ProgressBar;
19
19
$ analysisStartTime = microtime (true );
20
20
21
21
$ devOrPharLoader = require_once __DIR__ . '/../vendor/autoload.php ' ;
22
+ require_once __DIR__ . '/../vendor/attributes.php ' ;
22
23
require_once __DIR__ . '/../preload.php ' ;
23
24
$ composer = ComposerHelper::getComposerConfig (getcwd ());
24
25
Original file line number Diff line number Diff line change 23
23
"nette/schema" : " ^1.2.2" ,
24
24
"nette/utils" : " ^3.2.5" ,
25
25
"nikic/php-parser" : " ^5.4.0" ,
26
+ "olvlvl/composer-attribute-collector" : " ^2.0" ,
26
27
"ondram/ci-detector" : " ^3.4.0" ,
27
28
"ondrejmirtes/better-reflection" : " 6.57.0.0" ,
28
29
"phpstan/php-8-stubs" : " 0.4.12" ,
72
73
"platform-check" : false ,
73
74
"sort-packages" : true ,
74
75
"allow-plugins" : {
75
- "cweagans/composer-patches" : true
76
+ "cweagans/composer-patches" : true ,
77
+ "olvlvl/composer-attribute-collector" : true ,
78
+ "vaimo/composer-patches" : true
76
79
}
77
80
},
78
81
"extra" : {
82
+ "composer-attribute-collector" : {
83
+ "include" : [
84
+ " src"
85
+ ]
86
+ },
79
87
"composer-exit-on-patch-failure" : true ,
80
88
"patches" : {
81
89
"composer/ca-bundle" : [
Original file line number Diff line number Diff line change @@ -210,6 +210,7 @@ parameters:
210
210
extensions :
211
211
rules : PHPStan\DependencyInjection\RulesExtension
212
212
expandRelativePaths : PHPStan\DependencyInjection\ExpandRelativePathExtension
213
+ autowiredAttributeServices : PHPStan\DependencyInjection\AutowiredAttributeServicesExtension
213
214
conditionalTags : PHPStan\DependencyInjection\ConditionalTagsExtension
214
215
parametersSchema : PHPStan\DependencyInjection\ParametersSchemaExtension
215
216
validateIgnoredErrors : PHPStan\DependencyInjection\ValidateIgnoredErrorsExtension
@@ -575,9 +576,6 @@ services:
575
576
editorUrl : %editorUrl%
576
577
usedLevel : %usedLevel%
577
578
578
- -
579
- class : PHPStan\Dependency\DependencyResolver
580
-
581
579
-
582
580
class : PHPStan\Dependency\ExportedNodeFetcher
583
581
arguments :
Original file line number Diff line number Diff line change 11
11
use PHPStan \Analyser \Scope ;
12
12
use PHPStan \Broker \ClassNotFoundException ;
13
13
use PHPStan \Broker \FunctionNotFoundException ;
14
+ use PHPStan \DependencyInjection \AutowiredService ;
14
15
use PHPStan \File \FileHelper ;
15
16
use PHPStan \Node \ClassPropertyNode ;
16
17
use PHPStan \Node \InClassMethodNode ;
28
29
use function array_merge ;
29
30
use function count ;
30
31
32
+ #[AutowiredService]
31
33
final class DependencyResolver
32
34
{
33
35
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
+ $ autowiredServiceClasses = Attributes::findTargetClasses (AutowiredService::class);
14
+ $ builder = $ this ->getContainerBuilder ();
15
+
16
+ foreach ($ autowiredServiceClasses as $ class ) {
17
+ $ builder ->addDefinition (null )
18
+ ->setType ($ class ->name )
19
+ ->setAutowired ();
20
+ }
21
+ }
22
+
23
+ }
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
+ }
Original file line number Diff line number Diff line change 5
5
error_reporting (E_ALL );
6
6
7
7
require_once __DIR__ . '/../vendor/autoload.php ' ;
8
+ require_once __DIR__ . '/../vendor/attributes.php ' ;
8
9
require_once __DIR__ . '/PHPStan/Rules/AlwaysFailRule.php ' ;
9
10
require_once __DIR__ . '/PHPStan/Rules/DummyRule.php ' ;
10
11
require_once __DIR__ . '/phpstan-bootstrap.php ' ;
You can’t perform that action at this time.
0 commit comments