Skip to content

Commit

Permalink
[DX] Use directly instanceof (#3021)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Oct 28, 2022
1 parent 81d79a8 commit af4cf28
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Rector\CodeQuality\Rector\If_;

use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\If_;
use PhpParser\Node\Stmt\Return_;
Expand Down Expand Up @@ -62,7 +63,7 @@ public function getNodeTypes(): array
public function refactor(Node $node): ?Stmt
{
$expr = $this->ifManipulator->matchIfNotNullReturnValue($node);
if ($expr !== null) {
if ($expr instanceof Expr) {
$insideIfNode = $node->stmts[0];

$nextNode = $node->getAttribute(AttributeKey::NEXT_NODE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\Transform\NodeAnalyzer;

use PhpParser\Node\Expr;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\Variable;
Expand Down Expand Up @@ -42,7 +43,7 @@ public function matchTypeProvidingExpr(
$objectType
);

if ($expr !== null) {
if ($expr instanceof Expr) {
if ($expr instanceof Variable) {
$this->addClassMethodParamForVariable($expr, $objectType, $classMethod);
}
Expand Down

0 comments on commit af4cf28

Please sign in to comment.