diff --git a/rules-tests/CodeQuality/Rector/FuncCall/InlineIsAInstanceOfRector/Fixture/some_class.php.inc b/rules-tests/CodeQuality/Rector/FuncCall/InlineIsAInstanceOfRector/Fixture/some_class.php.inc index 9f751874842..e2ff51bf9f2 100644 --- a/rules-tests/CodeQuality/Rector/FuncCall/InlineIsAInstanceOfRector/Fixture/some_class.php.inc +++ b/rules-tests/CodeQuality/Rector/FuncCall/InlineIsAInstanceOfRector/Fixture/some_class.php.inc @@ -24,7 +24,7 @@ class SomeClass { public function run(object $object) { - return $object instanceof \Rector\Tests\CodeQuality\Rector\FuncCall\InlineIsAInstanceOfRector\Source\SomeType; + return $object instanceof SomeType; } } diff --git a/rules/CodeQuality/Rector/FuncCall/InlineIsAInstanceOfRector.php b/rules/CodeQuality/Rector/FuncCall/InlineIsAInstanceOfRector.php index 509979bb0b0..02d7b0a3e5f 100644 --- a/rules/CodeQuality/Rector/FuncCall/InlineIsAInstanceOfRector.php +++ b/rules/CodeQuality/Rector/FuncCall/InlineIsAInstanceOfRector.php @@ -10,6 +10,7 @@ use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\Instanceof_; use PhpParser\Node\Expr\Variable; +use PhpParser\Node\Name; use PhpParser\Node\Name\FullyQualified; use PHPStan\Type\Generic\GenericClassStringType; use PHPStan\Type\ObjectType; @@ -96,6 +97,10 @@ public function refactor(Node $node): ?Node return null; } + if ($secondArgValue->class instanceof Name) { + return new Instanceof_($firstArgValue, $secondArgValue->class); + } + return new Instanceof_($firstArgValue, new FullyQualified($className)); }