Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ parameters:
message: '#Function "var_dump\(\)" cannot be used/left in the code#'
path: src/functions/node_helper.php

-
message: '#Function "class_exists\(\)" cannot be used/left in the code#'
path: src/Configuration/OnlyRuleResolver.php

# lack of generic array in nikic/php-parser
- '#Method (.*?) should return array<PhpParser\\Node\\(.*?)\> but returns array<PhpParser\\Node\>#'

Expand Down
10 changes: 4 additions & 6 deletions src/Configuration/OnlyRuleResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Rector\Configuration;

use PHPStan\Reflection\ReflectionProvider;
use Rector\Contract\Rector\RectorInterface;
use Rector\Exception\Configuration\RectorRuleNameAmbiguousException;
use Rector\Exception\Configuration\RectorRuleNotFoundException;
Expand All @@ -19,7 +18,6 @@
*/
public function __construct(
private array $rectors,
private ReflectionProvider $reflectionProvider
) {
}

Expand Down Expand Up @@ -104,16 +102,16 @@ public function resolve(string $rule): string
*/
private function isRectorRuleClass(string $className): bool
{
if (! $this->reflectionProvider->hasClass($className)) {
if (! class_exists($className)) {
return false;
}

$classReflection = $this->reflectionProvider->getClass($className);
if ($classReflection->isAbstract()) {
$reflectionClass = new \ReflectionClass($className);
if ($reflectionClass->isAbstract()) {
return false;
}

return $classReflection->implementsInterface(RectorInterface::class);
return $reflectionClass->implementsInterface(RectorInterface::class);
}

private function createUnregisteredMessage(string $ruleClass): string
Expand Down
1 change: 0 additions & 1 deletion tests/Configuration/OnlyRuleResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ protected function setUp(): void

$this->onlyRuleResolver = new OnlyRuleResolver(
iterator_to_array($rectorConfig->tagged(RectorInterface::class)),
$this->make(ReflectionProvider::class)
);
}

Expand Down
Loading