Fix dump rectors (#4059)

* fix missing Whatever rector

* [rector] fix missing Whatever rector

* [cs] fix missing Whatever rector

Co-authored-by: rector-bot <tomas@getrector.org>
This commit is contained in:
Tomas Votruba 2020-08-29 16:43:32 +02:00 committed by GitHub
parent 351e59fa3b
commit 07708488a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,21 +50,11 @@ final class RectorsFinder
$rectors = [];
foreach ($foundClasses as $class) {
// not relevant for documentation
if (is_a($class, PostRectorInterface::class, true)) {
continue;
}
// special case, because robot loader is case insensitive
if ($class === ExceptionCorrector::class) {
if ($this->shouldSkipClass($class)) {
continue;
}
$reflectionClass = new ReflectionClass($class);
if ($reflectionClass->isAbstract()) {
continue;
}
$rector = $reflectionClass->newInstanceWithoutConstructor();
if (! $rector instanceof RectorInterface) {
// lowercase letter bug in RobotLoader
@ -110,6 +100,27 @@ final class RectorsFinder
return $classNames;
}
private function shouldSkipClass(string $class): bool
{
// not relevant for documentation
if (is_a($class, PostRectorInterface::class, true)) {
return true;
}
// special case, because robot loader is case insensitive
if ($class === ExceptionCorrector::class) {
return true;
}
// test fixture class
if ($class === 'Rector\ModeratePackage\Rector\MethodCall\WhateverRector') {
return true;
}
$reflectionClass = new ReflectionClass($class);
return $reflectionClass->isAbstract();
}
/**
* @param RectorInterface[] $objects
* @return RectorInterface[]