Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion rules/php-72/src/Rector/FuncCall/GetClassOnNullRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
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;
Expand Down Expand Up @@ -107,6 +108,11 @@ public function refactor(Node $node): ?Node

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;
Expand All @@ -115,7 +121,12 @@ private function shouldSkip(FuncCall $funcCall): bool
if ($this->isIdenticalToNotNull($funcCall, $parentNode)) {
return true;
}
return $this->isNotIdenticalToNull($funcCall, $parentNode);

if ($this->isNotIdenticalToNull($funcCall, $parentNode)) {
return true;
}

return false;
}

/**
Expand Down