Merge pull request #2963 from rectorphp/fix-null-trait

fix get class on trait
This commit is contained in:
Tomas Votruba 2020-02-29 03:21:59 +01:00 committed by GitHub
commit a5fb185c04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,6 +12,7 @@ use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\Ternary;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt\Trait_;
use PHPStan\Analyser\Scope;
use PHPStan\Type\NullType;
use Rector\Core\Rector\AbstractRector;
@ -107,6 +108,11 @@ PHP
private function shouldSkip(FuncCall $funcCall): bool
{
$class = $funcCall->getAttribute(AttributeKey::CLASS_NODE);
if ($class instanceof Trait_) {
return true;
}
$parentNode = $funcCall->getAttribute(AttributeKey::PARENT_NODE);
if (! $parentNode instanceof Ternary) {
return false;
@ -115,7 +121,12 @@ PHP
if ($this->isIdenticalToNotNull($funcCall, $parentNode)) {
return true;
}
return $this->isNotIdenticalToNull($funcCall, $parentNode);
if ($this->isNotIdenticalToNull($funcCall, $parentNode)) {
return true;
}
return false;
}
/**