@@ -23,11 +23,12 @@ public function __construct(
2323 ) {
2424 }
2525
26- public function reportDeprecatedRules (): void
26+ public function reportDeprecatedRules (): int
2727 {
2828 /** @var string[] $registeredRectorRules */
2929 $ registeredRectorRules = SimpleParameterProvider ::provideArrayParameter (Option::REGISTERED_RECTOR_RULES );
3030
31+ $ reportedCount = 0 ;
3132 foreach ($ registeredRectorRules as $ registeredRectorRule ) {
3233 if (! is_a ($ registeredRectorRule , DeprecatedInterface::class, true )) {
3334 continue ;
@@ -39,88 +40,112 @@ public function reportDeprecatedRules(): void
3940 $ registeredRectorRule
4041 )
4142 );
43+ ++$ reportedCount ;
4244 }
45+
46+ return $ reportedCount ;
4347 }
4448
45- public function reportDeprecatedSkippedRules (): void
49+ public function reportDeprecatedSkippedRules (): int
4650 {
4751 /** @var string[] $skippedRectorRules */
4852 $ skippedRectorRules = SimpleParameterProvider ::provideArrayParameter (Option::SKIPPED_RECTOR_RULES );
4953
54+ $ reportedCount = 0 ;
5055 foreach ($ skippedRectorRules as $ skippedRectorRule ) {
5156 if (! is_a ($ skippedRectorRule , DeprecatedInterface::class, true )) {
5257 continue ;
5358 }
5459
5560 $ this ->symfonyStyle ->warning (sprintf ('Skipped rule "%s" is deprecated ' , $ skippedRectorRule ));
61+ ++$ reportedCount ;
5662 }
63+
64+ return $ reportedCount ;
5765 }
5866
59- public function reportDeprecatedCacheMetaExtensions (): void
67+ public function reportDeprecatedCacheMetaExtensions (): int
6068 {
6169 /** @var string[] $cacheMetaExtensions */
6270 $ cacheMetaExtensions = SimpleParameterProvider ::provideArrayParameter (Option::CACHE_META_EXTENSIONS );
6371
72+ $ reportedCount = 0 ;
6473 foreach ($ cacheMetaExtensions as $ cacheMetumExtension ) {
6574 $ this ->symfonyStyle ->warning (sprintf (
6675 'Cache meta extension "%s" is deprecated and no longer applied. It is a niche mechanism, let Rector handle cache on its own. If custom invalidation is needed, handle it in CI in a more generic way, e.g. by clearing the cache directory. ' ,
6776 $ cacheMetumExtension
6877 ));
78+ ++$ reportedCount ;
6979 }
80+
81+ return $ reportedCount ;
7082 }
7183
72- public function reportDeprecatedPhpSetsMethods (): void
84+ public function reportDeprecatedPhpSetsMethods (): int
7385 {
7486 /** @var string[] $deprecatedPhpSetsMethods */
7587 $ deprecatedPhpSetsMethods = SimpleParameterProvider ::provideArrayParameter (
7688 Option::DEPRECATED_PHP_SETS_METHODS
7789 );
7890
91+ $ reportedCount = 0 ;
7992 foreach (array_unique ($ deprecatedPhpSetsMethods ) as $ deprecatedPhpSetsMethod ) {
8093 $ this ->symfonyStyle ->warning (sprintf (
8194 'The "->%s()" method is deprecated and no longer applied. Use "->withPhpLevel()" instead, to raise PHP level one rule at a time. ' ,
8295 $ deprecatedPhpSetsMethod
8396 ));
97+ ++$ reportedCount ;
8498 }
99+
100+ return $ reportedCount ;
85101 }
86102
87- public function reportDeprecatedAttributesSetsArgs (): void
103+ public function reportDeprecatedAttributesSetsArgs (): int
88104 {
89105 /** @var string[] $deprecatedAttributesSetsArgs */
90106 $ deprecatedAttributesSetsArgs = SimpleParameterProvider ::provideArrayParameter (
91107 Option::DEPRECATED_ATTRIBUTES_SETS_ARGS
92108 );
93109
110+ $ reportedCount = 0 ;
94111 foreach (array_unique ($ deprecatedAttributesSetsArgs ) as $ deprecatedAttributesSetsArg ) {
95112 $ this ->symfonyStyle ->warning (sprintf (
96113 'The "->withAttributesSets(%s: true)" argument is deprecated and no longer applied. It is already included in the "symfony: true" argument, use it instead. ' ,
97114 $ deprecatedAttributesSetsArg
98115 ));
116+ ++$ reportedCount ;
99117 }
118+
119+ return $ reportedCount ;
100120 }
101121
102- public function reportDeprecatedComposerBasedArgs (): void
122+ public function reportDeprecatedComposerBasedArgs (): int
103123 {
104124 /** @var string[] $deprecatedComposerBasedArgs */
105125 $ deprecatedComposerBasedArgs = SimpleParameterProvider ::provideArrayParameter (
106126 Option::DEPRECATED_COMPOSER_BASED_ARGS
107127 );
108128
129+ $ reportedCount = 0 ;
109130 foreach (array_unique ($ deprecatedComposerBasedArgs ) as $ deprecatedComposerBasedArg ) {
110131 $ this ->symfonyStyle ->warning (sprintf (
111132 'The "->withComposerBased(%s: true)" argument is deprecated and no longer applied. It only added named args to 2 methods of a single package, register the rule directly if needed. ' ,
112133 $ deprecatedComposerBasedArg
113134 ));
135+ ++$ reportedCount ;
114136 }
137+
138+ return $ reportedCount ;
115139 }
116140
117- public function reportDeprecatedRectorUnsupportedMethods (): void
141+ public function reportDeprecatedRectorUnsupportedMethods (): int
118142 {
119143 // to be added in related PR
120144 if (! class_exists (FileNode::class)) {
121- return ;
145+ return 0 ;
122146 }
123147
148+ $ reportedCount = 0 ;
124149 foreach ($ this ->rectors as $ rector ) {
125150 $ beforeTraverseMethodReflection = new ReflectionMethod ($ rector , 'beforeTraverse ' );
126151 if ($ beforeTraverseMethodReflection ->getDeclaringClass ()->getName () === $ rector ::class) {
@@ -129,7 +154,10 @@ public function reportDeprecatedRectorUnsupportedMethods(): void
129154 $ rector ::class,
130155 FileNode::class
131156 ));
157+ ++$ reportedCount ;
132158 }
133159 }
160+
161+ return $ reportedCount ;
134162 }
135163}
0 commit comments