|
18 | 18 | use Rector\Configuration\Levels\LevelRulesResolver; |
19 | 19 | use Rector\Configuration\Parameter\SimpleParameterProvider; |
20 | 20 | use Rector\Console\Notifier; |
| 21 | +use Rector\Contract\PhpParser\DecoratingNodeVisitorInterface; |
21 | 22 | use Rector\Contract\Rector\ConfigurableRectorInterface; |
22 | 23 | use Rector\Contract\Rector\RectorInterface; |
23 | 24 | use Rector\Doctrine\Set\DoctrineSetList; |
24 | 25 | use Rector\Enum\Config\Defaults; |
25 | 26 | use Rector\Exception\Configuration\InvalidConfigurationException; |
| 27 | +use Rector\NodeTypeResolver\PHPStan\Scope\Contract\NodeVisitor\ScopeResolverNodeVisitorInterface; |
26 | 28 | use Rector\Php\PhpVersionResolver\ComposerJsonPhpVersionResolver; |
27 | 29 | use Rector\Php80\Rector\Class_\AnnotationToAttributeRector; |
28 | 30 | use Rector\Php80\ValueObject\AnnotationToAttribute; |
@@ -1217,11 +1219,31 @@ public function withTreatClassesAsFinal(bool $isTreatClassesAsFinal = true): sel |
1217 | 1219 |
|
1218 | 1220 | public function registerService(string $className, ?string $alias = null, ?string $tag = null): self |
1219 | 1221 | { |
| 1222 | + // BC layer since 2.2.9 |
| 1223 | + if ($tag === ScopeResolverNodeVisitorInterface::class) { |
| 1224 | + $tag = DecoratingNodeVisitorInterface::class; |
| 1225 | + } |
| 1226 | + |
1220 | 1227 | $this->registerServices[] = new RegisteredService($className, $alias, $tag); |
1221 | 1228 |
|
1222 | 1229 | return $this; |
1223 | 1230 | } |
1224 | 1231 |
|
| 1232 | + /** |
| 1233 | + * DX helper |
| 1234 | + * @see https://getrector.com/documentation/creating-a-node-visitor |
| 1235 | + */ |
| 1236 | + public function registerDecoratingNodeVisitor(string $decoratingNodeVisitorClass): self |
| 1237 | + { |
| 1238 | + Assert::isAOf($decoratingNodeVisitorClass, DecoratingNodeVisitorInterface::class); |
| 1239 | + $this->registerServices[] = new RegisteredService( |
| 1240 | + $decoratingNodeVisitorClass, |
| 1241 | + null, |
| 1242 | + DecoratingNodeVisitorInterface::class |
| 1243 | + ); |
| 1244 | + return $this; |
| 1245 | + } |
| 1246 | + |
1225 | 1247 | public function withDowngradeSets( |
1226 | 1248 | bool $php84 = false, |
1227 | 1249 | bool $php83 = false, |
|
0 commit comments