fix get class on trait

This commit is contained in:
TomasVotruba 2020-02-29 02:10:30 +01:00
parent d3bf2c0364
commit 935b08e4ad

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;
}
/**