mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-16 16:12:22 +00:00
[EarlyReturn][Php80] Fix used along tweak between Php8ResourceReturnToObjectRector+ChangeOrIfReturnToEarlyReturnRector (#1984)
This commit is contained in:
parent
12f027c8a1
commit
3596755157
|
@ -8,7 +8,6 @@ use PhpParser\Node;
|
|||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
use PhpParser\Node\Expr\BinaryOp\BooleanOr;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
use PhpParser\Node\Expr\Instanceof_;
|
||||
use PhpParser\Node\Stmt\If_;
|
||||
use PhpParser\Node\Stmt\Return_;
|
||||
|
@ -93,11 +92,6 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
|
||||
// maybe used along with Php8ResourceReturnToObjectRector rule
|
||||
if ($this->isMaybeUsedAlongWithResourceToObjectRector($node->cond)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @var Return_ $return */
|
||||
$return = $node->stmts[0];
|
||||
|
||||
|
@ -118,27 +112,6 @@ CODE_SAMPLE
|
|||
return $ifs;
|
||||
}
|
||||
|
||||
private function isMaybeUsedAlongWithResourceToObjectRector(BooleanOr $booleanOr): bool
|
||||
{
|
||||
if ($booleanOr->left instanceof FuncCall) {
|
||||
if (! $this->nodeNameResolver->isName($booleanOr->left, 'is_resource')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $booleanOr->right instanceof Instanceof_;
|
||||
}
|
||||
|
||||
if ($booleanOr->right instanceof FuncCall) {
|
||||
if (! $this->nodeNameResolver->isName($booleanOr->right, 'is_resource')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $booleanOr->left instanceof Instanceof_;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param If_[] $ifs
|
||||
* @return If_[]
|
||||
|
@ -189,6 +162,6 @@ CODE_SAMPLE
|
|||
return $this->isInstanceofCondOnly($booleanOr->right);
|
||||
}
|
||||
|
||||
return $booleanOr->right instanceof Instanceof_;
|
||||
return $booleanOr->left instanceof Instanceof_ || $booleanOr->right instanceof Instanceof_;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user