Skip to content

Commit

Permalink
[TypeDeclaration] Reduce double traverse on StrictReturnNewAnalyzer R…
Browse files Browse the repository at this point in the history
…eturnTypeFromStrictNewArrayRector (#6321)
  • Loading branch information
samsonasik committed Sep 21, 2024
1 parent 92f64ff commit c5940d2
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Expr\New_;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Expr\Yield_;
use PhpParser\Node\Expr\YieldFrom;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Expression;
Expand Down Expand Up @@ -37,13 +35,6 @@ public function matchAlwaysReturnVariableNew(ClassMethod|Function_ $functionLike
return null;
}

if ($this->betterNodeFinder->hasInstancesOfInFunctionLikeScoped(
$functionLike,
[Yield_::class, YieldFrom::class]
)) {
return null;
}

$returns = $this->betterNodeFinder->findReturnsScoped($functionLike);
if (! $this->returnAnalyzer->hasOnlyReturnWithExpr($functionLike, $returns)) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Expr\Yield_;
use PhpParser\Node\Expr\YieldFrom;
use PhpParser\Node\Identifier;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\ClassMethod;
Expand Down Expand Up @@ -110,11 +108,6 @@ public function refactorWithScope(Node $node, Scope $scope): ?Node
return null;
}

// 2. skip yields
if ($this->betterNodeFinder->hasInstancesOfInFunctionLikeScoped($node, [Yield_::class, YieldFrom::class])) {
return null;
}

$returns = $this->betterNodeFinder->findReturnsScoped($node);
if (! $this->returnAnalyzer->hasOnlyReturnWithExpr($node, $returns)) {
return null;
Expand Down

0 comments on commit c5940d2

Please sign in to comment.