Skip to content

Commit 28f5dbd

Browse files
committed
Updated Rector to commit c14f8d45175bd4c10fef503e350d677c4a73ce29
rectorphp/rector-src@c14f8d4 [Php72][TypeDeclaration] Rollback tweak infinite loop handling on DeclareStrictTypesRector (#5700)
1 parent 2e30301 commit 28f5dbd

File tree

21 files changed

+32
-12
lines changed

21 files changed

+32
-12
lines changed

rules/CodeQuality/Rector/ClassMethod/InlineArrayReturnAssignRector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ private function areAssignExclusiveToDimFetch(array $stmts) : bool
152152
{
153153
\end($stmts);
154154
$lastKey = \key($stmts);
155+
\reset($stmts);
155156
foreach ($stmts as $key => $stmt) {
156157
if ($key === $lastKey) {
157158
// skip last item

rules/CodingStyle/Rector/Stmt/NewlineAfterStatementRector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ private function processAddNewLine($node, bool $hasChanged, int $jumpToKey = 0)
8989
}
9090
\end($node->stmts);
9191
$totalKeys = \key($node->stmts);
92+
\reset($node->stmts);
9293
for ($key = $jumpToKey; $key < $totalKeys; ++$key) {
9394
if (!isset($node->stmts[$key], $node->stmts[$key + 1])) {
9495
break;

rules/DeadCode/Rector/For_/RemoveDeadContinueRector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ private function canRemoveLastStatement(array $stmts) : bool
6363
}
6464
\end($stmts);
6565
$lastKey = \key($stmts);
66+
\reset($stmts);
6667
$lastStmt = $stmts[$lastKey];
6768
return $this->isRemovable($lastStmt);
6869
}

rules/DeadCode/Rector/FunctionLike/RemoveDeadReturnRector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public function refactor(Node $node) : ?Node
6868
}
6969
\end($node->stmts);
7070
$lastStmtKey = \key($node->stmts);
71+
\reset($node->stmts);
7172
$lastStmt = $node->stmts[$lastStmtKey];
7273
if ($lastStmt instanceof If_) {
7374
if (!$this->isBareIfWithOnlyStmtEmptyReturn($lastStmt)) {

rules/EarlyReturn/Rector/If_/ChangeIfElseValueAssignToEarlyReturnRector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ public function refactor(Node $node) : ?StmtsAwareInterface
101101
}
102102
\end($if->stmts);
103103
$lastIfStmtKey = \key($if->stmts);
104+
\reset($if->stmts);
104105
/** @var Assign $assign */
105106
$assign = $this->stmtsManipulator->getUnwrappedLastStmt($if->stmts);
106107
$returnLastIf = new Return_($assign->expr);

rules/Php72/Rector/FuncCall/ParseStrWithResultArgumentRector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ private function processStrWithResult(StmtsAwareInterface $stmtsAware, bool $has
5959
}
6060
\end($stmtsAware->stmts);
6161
$totalKeys = \key($stmtsAware->stmts);
62+
\reset($stmtsAware->stmts);
6263
for ($key = $jumpToKey; $key < $totalKeys; ++$key) {
6364
if (!isset($stmtsAware->stmts[$key], $stmtsAware->stmts[$key + 1])) {
6465
break;

rules/Php73/Rector/FuncCall/ArrayKeyFirstLastRector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ private function processArrayKeyFirstLast(StmtsAwareInterface $stmtsAware, bool
104104
\end($stmtsAware->stmts);
105105
/** @var int $totalKeys */
106106
$totalKeys = \key($stmtsAware->stmts);
107+
\reset($stmtsAware->stmts);
107108
for ($key = $jumpToKey; $key < $totalKeys; ++$key) {
108109
if (!isset($stmtsAware->stmts[$key], $stmtsAware->stmts[$key + 1])) {
109110
break;

rules/TypeDeclaration/Rector/StmtsAwareInterface/DeclareStrictTypesRector.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,10 @@ public function beforeTraverse(array $nodes) : ?array
5252
if ($newStmts === []) {
5353
return null;
5454
}
55-
// use 0 index to avoid infinite loop
56-
$rootStmt = $newStmts[0] ?? null;
55+
$rootStmt = \current($newStmts);
5756
$stmt = $rootStmt;
5857
if ($rootStmt instanceof FileWithoutNamespace) {
59-
// use 0 index to avoid infinite loop
60-
$currentStmt = $rootStmt->stmts[0] ?? null;
58+
$currentStmt = \current($rootStmt->stmts);
6159
if (!$currentStmt instanceof Stmt) {
6260
return null;
6361
}

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 = '13bafcba1524782c349fe6523ce9c18d0f765452';
22+
public const PACKAGE_VERSION = 'c14f8d45175bd4c10fef503e350d677c4a73ce29';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2024-03-08 04:07:33';
27+
public const RELEASE_DATE = '2024-03-08 06:31:37';
2828
/**
2929
* @var int
3030
*/

src/BetterPhpDocParser/ValueObject/PhpDoc/DoctrineAnnotation/AbstractValuesAwareNode.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ protected function printValuesContent(array $values) : string
105105
$itemContents = '';
106106
\end($values);
107107
$lastItemKey = \key($values);
108+
\reset($values);
108109
foreach ($values as $key => $value) {
109110
if (\is_int($key)) {
110111
$itemContents .= $this->stringifyValue($value);

0 commit comments

Comments
 (0)