Skip to content

Commit 5cc44d8

Browse files
committed
Updated Rector to commit 3dacd700b6cf461af650cd2714a460f08cc3d6fb
rectorphp/rector-src@3dacd70 [CodeQuality] Properly handle Goto_ on ExplicitReturnNullRector take 3 (#7020)
1 parent 637519b commit 5cc44d8

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

rules/TypeDeclaration/TypeInferer/SilentVoidResolver.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,25 @@ public function hasSilentVoid(FunctionLike $functionLike) : bool
9696
*/
9797
private function hasStmtsAlwaysReturnOrExit(array $stmts) : bool
9898
{
99-
// early label check
99+
// early label check position key stmt
100100
// as label can be defined later after goto
101+
$hasAlwaysReturnOrExitAfterLabelPosition = null;
101102
foreach ($stmts as $key => $stmt) {
102-
if ($stmt instanceof Label && isset($stmts[$key + 1])) {
103-
return $this->hasStmtsAlwaysReturnOrExit(\array_slice($stmts, $key + 1));
103+
if ($stmt instanceof Label && isset($stmts[$key + 1]) && $this->hasStmtsAlwaysReturnOrExit(\array_slice($stmts, $key + 1))) {
104+
$hasAlwaysReturnOrExitAfterLabelPosition = $key;
105+
break;
104106
}
105107
}
106-
foreach ($stmts as $stmt) {
108+
foreach ($stmts as $key => $stmt) {
107109
if ($this->neverFuncCallAnalyzer->isWithNeverTypeExpr($stmt)) {
108110
return \true;
109111
}
110112
if ($this->isStopped($stmt)) {
111113
return \true;
112114
}
115+
if ($stmt instanceof Goto_ && $hasAlwaysReturnOrExitAfterLabelPosition < $key) {
116+
return \true;
117+
}
113118
// has switch with always return
114119
if ($stmt instanceof Switch_ && $this->isSwitchWithAlwaysReturnOrExit($stmt)) {
115120
return \true;
@@ -183,7 +188,7 @@ private function isStopped(Stmt $stmt) : bool
183188
if ($stmt instanceof Expression) {
184189
$stmt = $stmt->expr;
185190
}
186-
return $stmt instanceof Throw_ || $stmt instanceof Exit_ || $stmt instanceof Return_ && $stmt->expr instanceof Expr || $stmt instanceof Yield_ || $stmt instanceof YieldFrom || $stmt instanceof Goto_;
191+
return $stmt instanceof Throw_ || $stmt instanceof Exit_ || $stmt instanceof Return_ && $stmt->expr instanceof Expr || $stmt instanceof Yield_ || $stmt instanceof YieldFrom;
187192
}
188193
private function isSwitchWithAlwaysReturnOrExit(Switch_ $switch) : bool
189194
{

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 = '09661240c16bb4b308129584c392ece51ad9a06c';
22+
public const PACKAGE_VERSION = '3dacd700b6cf461af650cd2714a460f08cc3d6fb';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2025-06-25 11:41:10';
27+
public const RELEASE_DATE = '2025-06-25 16:45:58';
2828
/**
2929
* @var int
3030
*/

0 commit comments

Comments
 (0)