Skip to content

Commit

Permalink
[CodeQuality] Skip not autoloaded parent class on CompleteDynamicProp…
Browse files Browse the repository at this point in the history
…ertiesRector (#5636)
  • Loading branch information
samsonasik committed Feb 18, 2024
1 parent 287deb2 commit 914349c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
@@ -0,0 +1,11 @@
<?php

namespace Rector\Tests\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector\Fixture;

class SkipUndefinedParentClass extends NotAutoloaded
{
public function set()
{
$this->value = 5;
}
}
Expand Up @@ -5,6 +5,7 @@
namespace Rector\CodeQuality\Rector\Class_;

use PhpParser\Node;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Stmt\Class_;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\ReflectionProvider;
Expand Down Expand Up @@ -149,7 +150,11 @@ private function shouldSkipClass(Class_ $class): bool
return true;
}

return $classReflection->hasMethod('__get');
if ($classReflection->hasMethod('__get')) {
return true;
}

return $class->extends instanceof FullyQualified && ! $this->reflectionProvider->hasClass($class->extends->toString());
}

/**
Expand Down

0 comments on commit 914349c

Please sign in to comment.