diff --git a/rules-tests/Php83/Rector/FuncCall/RemoveGetClassGetParentClassNoArgsRector/Fixture/fixture_get_parent_class.php.inc b/rules-tests/Php83/Rector/FuncCall/RemoveGetClassGetParentClassNoArgsRector/Fixture/fixture_get_parent_class.php.inc index daf6b9e8d83..0b1eef9f40a 100644 --- a/rules-tests/Php83/Rector/FuncCall/RemoveGetClassGetParentClassNoArgsRector/Fixture/fixture_get_parent_class.php.inc +++ b/rules-tests/Php83/Rector/FuncCall/RemoveGetClassGetParentClassNoArgsRector/Fixture/fixture_get_parent_class.php.inc @@ -2,7 +2,9 @@ namespace Rector\Tests\Php83\Rector\FuncCall\RemoveGetClassGetParentClassNoArgsRector\Fixture; -class Fixture +use Rector\Tests\Php83\Rector\FuncCall\RemoveGetClassGetParentClassNoArgsRector\Source\SomeParentClass; + +class Fixture extends SomeParentClass { public function test() { @@ -16,7 +18,9 @@ class Fixture namespace Rector\Tests\Php83\Rector\FuncCall\RemoveGetClassGetParentClassNoArgsRector\Fixture; -class Fixture +use Rector\Tests\Php83\Rector\FuncCall\RemoveGetClassGetParentClassNoArgsRector\Source\SomeParentClass; + +class Fixture extends SomeParentClass { public function test() { diff --git a/rules-tests/Php83/Rector/FuncCall/RemoveGetClassGetParentClassNoArgsRector/Fixture/skip_get_parent_class_without_parent.php.inc b/rules-tests/Php83/Rector/FuncCall/RemoveGetClassGetParentClassNoArgsRector/Fixture/skip_get_parent_class_without_parent.php.inc new file mode 100644 index 00000000000..5c6fce3e09e --- /dev/null +++ b/rules-tests/Php83/Rector/FuncCall/RemoveGetClassGetParentClassNoArgsRector/Fixture/skip_get_parent_class_without_parent.php.inc @@ -0,0 +1,11 @@ +reflectionResolver->resolveClassReflection($node); + if (! $classReflection instanceof ClassReflection) { + return null; + } + + // parent::class is a fatal error in a class without parent + if ($target === 'parent' && ! $classReflection->getParentClass() instanceof ClassReflection) { + return null; } - return null; + return new ClassConstFetch(new Name([$target]), new VarLikeIdentifier('class')); } public function provideMinPhpVersion(): int