Skip to content

Commit 000e6d3

Browse files
committed
Updated Rector to commit c671491e7141870aba0f138e3197876cee5eac7b
rectorphp/rector-src@c671491 [CodeQuality] Properly handle Goto_ on ExplicitReturnNullRector (#7018)
1 parent d513dea commit 000e6d3

3 files changed

Lines changed: 4 additions & 15 deletions

File tree

rules/CodeQuality/Rector/ClassMethod/ExplicitReturnNullRector.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@
1111
use PhpParser\Node\Stmt\Class_;
1212
use PhpParser\Node\Stmt\ClassMethod;
1313
use PhpParser\Node\Stmt\Function_;
14-
use PhpParser\Node\Stmt\Goto_;
1514
use PhpParser\Node\Stmt\Return_;
1615
use PhpParser\NodeVisitor;
1716
use PHPStan\Type\NullType;
1817
use PHPStan\Type\UnionType;
1918
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
2019
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger;
2120
use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory;
22-
use Rector\PhpParser\Node\BetterNodeFinder;
2321
use Rector\Rector\AbstractRector;
2422
use Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer;
2523
use Rector\TypeDeclaration\TypeInferer\SilentVoidResolver;
@@ -51,18 +49,13 @@ final class ExplicitReturnNullRector extends AbstractRector
5149
* @readonly
5250
*/
5351
private ReturnTypeInferer $returnTypeInferer;
54-
/**
55-
* @readonly
56-
*/
57-
private BetterNodeFinder $betterNodeFinder;
58-
public function __construct(SilentVoidResolver $silentVoidResolver, PhpDocInfoFactory $phpDocInfoFactory, TypeFactory $typeFactory, PhpDocTypeChanger $phpDocTypeChanger, ReturnTypeInferer $returnTypeInferer, BetterNodeFinder $betterNodeFinder)
52+
public function __construct(SilentVoidResolver $silentVoidResolver, PhpDocInfoFactory $phpDocInfoFactory, TypeFactory $typeFactory, PhpDocTypeChanger $phpDocTypeChanger, ReturnTypeInferer $returnTypeInferer)
5953
{
6054
$this->silentVoidResolver = $silentVoidResolver;
6155
$this->phpDocInfoFactory = $phpDocInfoFactory;
6256
$this->typeFactory = $typeFactory;
6357
$this->phpDocTypeChanger = $phpDocTypeChanger;
6458
$this->returnTypeInferer = $returnTypeInferer;
65-
$this->betterNodeFinder = $betterNodeFinder;
6659
}
6760
public function getRuleDefinition() : RuleDefinition
6861
{
@@ -121,10 +114,6 @@ public function refactor(Node $node) : ?Node
121114
if (!$returnType instanceof UnionType) {
122115
return null;
123116
}
124-
$hasGoto = (bool) $this->betterNodeFinder->findFirstInFunctionLikeScoped($node, fn(Node $node): bool => $node instanceof Goto_);
125-
if ($hasGoto) {
126-
return null;
127-
}
128117
$hasChanged = \false;
129118
$this->traverseNodesWithCallable((array) $node->stmts, static function (Node $node) use(&$hasChanged) {
130119
if ($node instanceof Class_ || $node instanceof Function_ || $node instanceof Closure) {

rules/TypeDeclaration/TypeInferer/SilentVoidResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ private function isStopped(Stmt $stmt) : bool
175175
if ($stmt instanceof Expression) {
176176
$stmt = $stmt->expr;
177177
}
178-
return $stmt instanceof Throw_ || $stmt instanceof Exit_ || $stmt instanceof Return_ && $stmt->expr instanceof Expr || $stmt instanceof Yield_ || $stmt instanceof YieldFrom;
178+
return $stmt instanceof Throw_ || $stmt instanceof Exit_ || $stmt instanceof Return_ && $stmt->expr instanceof Expr || $stmt instanceof Yield_ || $stmt instanceof YieldFrom || $stmt instanceof Goto_;
179179
}
180180
private function isSwitchWithAlwaysReturnOrExit(Switch_ $switch) : bool
181181
{

src/Application/VersionResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ final class VersionResolver
1919
* @api
2020
* @var string
2121
*/
22-
public const PACKAGE_VERSION = '2.1.0';
22+
public const PACKAGE_VERSION = 'c671491e7141870aba0f138e3197876cee5eac7b';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2025-06-24 22:23:49';
27+
public const RELEASE_DATE = '2025-06-25 11:01:09';
2828
/**
2929
* @var int
3030
*/

0 commit comments

Comments
 (0)