Updated Rector to commit c14f8d45175bd4c10fef503e350d677c4a73ce29

c14f8d4517 [Php72][TypeDeclaration] Rollback tweak infinite loop handling on DeclareStrictTypesRector (#5700)
This commit is contained in:
Tomas Votruba 2024-03-08 06:34:02 +00:00
parent 2e30301381
commit 28f5dbde13
21 changed files with 32 additions and 12 deletions

View File

@ -152,6 +152,7 @@ CODE_SAMPLE
{ {
\end($stmts); \end($stmts);
$lastKey = \key($stmts); $lastKey = \key($stmts);
\reset($stmts);
foreach ($stmts as $key => $stmt) { foreach ($stmts as $key => $stmt) {
if ($key === $lastKey) { if ($key === $lastKey) {
// skip last item // skip last item

View File

@ -89,6 +89,7 @@ CODE_SAMPLE
} }
\end($node->stmts); \end($node->stmts);
$totalKeys = \key($node->stmts); $totalKeys = \key($node->stmts);
\reset($node->stmts);
for ($key = $jumpToKey; $key < $totalKeys; ++$key) { for ($key = $jumpToKey; $key < $totalKeys; ++$key) {
if (!isset($node->stmts[$key], $node->stmts[$key + 1])) { if (!isset($node->stmts[$key], $node->stmts[$key + 1])) {
break; break;

View File

@ -63,6 +63,7 @@ CODE_SAMPLE
} }
\end($stmts); \end($stmts);
$lastKey = \key($stmts); $lastKey = \key($stmts);
\reset($stmts);
$lastStmt = $stmts[$lastKey]; $lastStmt = $stmts[$lastKey];
return $this->isRemovable($lastStmt); return $this->isRemovable($lastStmt);
} }

View File

@ -68,6 +68,7 @@ CODE_SAMPLE
} }
\end($node->stmts); \end($node->stmts);
$lastStmtKey = \key($node->stmts); $lastStmtKey = \key($node->stmts);
\reset($node->stmts);
$lastStmt = $node->stmts[$lastStmtKey]; $lastStmt = $node->stmts[$lastStmtKey];
if ($lastStmt instanceof If_) { if ($lastStmt instanceof If_) {
if (!$this->isBareIfWithOnlyStmtEmptyReturn($lastStmt)) { if (!$this->isBareIfWithOnlyStmtEmptyReturn($lastStmt)) {

View File

@ -101,6 +101,7 @@ CODE_SAMPLE
} }
\end($if->stmts); \end($if->stmts);
$lastIfStmtKey = \key($if->stmts); $lastIfStmtKey = \key($if->stmts);
\reset($if->stmts);
/** @var Assign $assign */ /** @var Assign $assign */
$assign = $this->stmtsManipulator->getUnwrappedLastStmt($if->stmts); $assign = $this->stmtsManipulator->getUnwrappedLastStmt($if->stmts);
$returnLastIf = new Return_($assign->expr); $returnLastIf = new Return_($assign->expr);

View File

@ -59,6 +59,7 @@ CODE_SAMPLE
} }
\end($stmtsAware->stmts); \end($stmtsAware->stmts);
$totalKeys = \key($stmtsAware->stmts); $totalKeys = \key($stmtsAware->stmts);
\reset($stmtsAware->stmts);
for ($key = $jumpToKey; $key < $totalKeys; ++$key) { for ($key = $jumpToKey; $key < $totalKeys; ++$key) {
if (!isset($stmtsAware->stmts[$key], $stmtsAware->stmts[$key + 1])) { if (!isset($stmtsAware->stmts[$key], $stmtsAware->stmts[$key + 1])) {
break; break;

View File

@ -104,6 +104,7 @@ CODE_SAMPLE
\end($stmtsAware->stmts); \end($stmtsAware->stmts);
/** @var int $totalKeys */ /** @var int $totalKeys */
$totalKeys = \key($stmtsAware->stmts); $totalKeys = \key($stmtsAware->stmts);
\reset($stmtsAware->stmts);
for ($key = $jumpToKey; $key < $totalKeys; ++$key) { for ($key = $jumpToKey; $key < $totalKeys; ++$key) {
if (!isset($stmtsAware->stmts[$key], $stmtsAware->stmts[$key + 1])) { if (!isset($stmtsAware->stmts[$key], $stmtsAware->stmts[$key + 1])) {
break; break;

View File

@ -52,12 +52,10 @@ CODE_SAMPLE
if ($newStmts === []) { if ($newStmts === []) {
return null; return null;
} }
// use 0 index to avoid infinite loop $rootStmt = \current($newStmts);
$rootStmt = $newStmts[0] ?? null;
$stmt = $rootStmt; $stmt = $rootStmt;
if ($rootStmt instanceof FileWithoutNamespace) { if ($rootStmt instanceof FileWithoutNamespace) {
// use 0 index to avoid infinite loop $currentStmt = \current($rootStmt->stmts);
$currentStmt = $rootStmt->stmts[0] ?? null;
if (!$currentStmt instanceof Stmt) { if (!$currentStmt instanceof Stmt) {
return null; return null;
} }

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api * @api
* @var string * @var string
*/ */
public const PACKAGE_VERSION = '13bafcba1524782c349fe6523ce9c18d0f765452'; public const PACKAGE_VERSION = 'c14f8d45175bd4c10fef503e350d677c4a73ce29';
/** /**
* @api * @api
* @var string * @var string
*/ */
public const RELEASE_DATE = '2024-03-08 04:07:33'; public const RELEASE_DATE = '2024-03-08 06:31:37';
/** /**
* @var int * @var int
*/ */

View File

@ -105,6 +105,7 @@ abstract class AbstractValuesAwareNode implements PhpDocTagValueNode
$itemContents = ''; $itemContents = '';
\end($values); \end($values);
$lastItemKey = \key($values); $lastItemKey = \key($values);
\reset($values);
foreach ($values as $key => $value) { foreach ($values as $key => $value) {
if (\is_int($key)) { if (\is_int($key)) {
$itemContents .= $this->stringifyValue($value); $itemContents .= $this->stringifyValue($value);

View File

@ -35,6 +35,7 @@ final class CurlyListNode extends \Rector\BetterPhpDocParser\ValueObject\PhpDoc\
$itemContents = ''; $itemContents = '';
\end($array); \end($array);
$lastItemKey = \key($array); $lastItemKey = \key($array);
\reset($array);
foreach ($array as $key => $value) { foreach ($array as $key => $value) {
if (\is_int($key)) { if (\is_int($key)) {
$itemContents .= (string) $value; $itemContents .= (string) $value;

View File

@ -137,6 +137,7 @@ final class TerminatedNodeAnalyzer
} }
\end($stmts); \end($stmts);
$lastKey = \key($stmts); $lastKey = \key($stmts);
\reset($stmts);
$lastNode = $stmts[$lastKey]; $lastNode = $stmts[$lastKey];
if (isset($stmts[$lastKey - 1]) && $this->isTerminatedNode($stmts[$lastKey - 1], $node)) { if (isset($stmts[$lastKey - 1]) && $this->isTerminatedNode($stmts[$lastKey - 1], $node)) {
return \false; return \false;

View File

@ -41,6 +41,7 @@ final class StmtsManipulator
{ {
\end($stmts); \end($stmts);
$lastStmtKey = \key($stmts); $lastStmtKey = \key($stmts);
\reset($stmts);
$lastStmt = $stmts[$lastStmtKey]; $lastStmt = $stmts[$lastStmtKey];
if ($lastStmt instanceof Expression) { if ($lastStmt instanceof Expression) {
return $lastStmt->expr; return $lastStmt->expr;

View File

@ -1742,12 +1742,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-downgrade-php.git", "url": "https:\/\/github.com\/rectorphp\/rector-downgrade-php.git",
"reference": "68e063523222616f23572af49458eb851405e5b4" "reference": "e4776356ac976734d56072410185fe06594cc642"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/68e063523222616f23572af49458eb851405e5b4", "url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/e4776356ac976734d56072410185fe06594cc642",
"reference": "68e063523222616f23572af49458eb851405e5b4", "reference": "e4776356ac976734d56072410185fe06594cc642",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1769,7 +1769,7 @@
"tomasvotruba\/class-leak": "^0.2", "tomasvotruba\/class-leak": "^0.2",
"tracy\/tracy": "^2.10" "tracy\/tracy": "^2.10"
}, },
"time": "2024-02-24T21:31:51+00:00", "time": "2024-03-08T06:25:11+00:00",
"default-branch": true, "default-branch": true,
"type": "rector-extension", "type": "rector-extension",
"extra": { "extra": {

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/ */
final class GeneratedConfig final class GeneratedConfig
{ {
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main a1d50bb'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main 68e0635'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main e065c40'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main 5ce789d')); public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main a1d50bb'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main e477635'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main e065c40'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main 5ce789d'));
private function __construct() private function __construct()
{ {
} }

View File

@ -180,6 +180,13 @@ CODE_SAMPLE
$firstArg->value = $array; $firstArg->value = $array;
} }
$newStmts[] = $stmt; $newStmts[] = $stmt;
$resetExpression = new Expression($this->nodeFactory->createFuncCall('reset', [$array]));
if (!$stmt instanceof StmtsAwareInterface && !$stmt instanceof Return_) {
$newStmts[] = new Expression($this->nodeFactory->createFuncCall('reset', [$array]));
}
if ($stmt instanceof StmtsAwareInterface) {
$stmt->stmts = \array_merge([$resetExpression], $stmt->stmts);
}
return $newStmts; return $newStmts;
} }
/** /**

View File

@ -55,6 +55,7 @@ CODE_SAMPLE
if ($node->vars !== []) { if ($node->vars !== []) {
\end($node->vars); \end($node->vars);
$lastArgumentPosition = \key($node->vars); $lastArgumentPosition = \key($node->vars);
\reset($node->vars);
$last = $node->vars[$lastArgumentPosition]; $last = $node->vars[$lastArgumentPosition];
if (!$this->followedByCommaAnalyzer->isFollowed($this->file, $last)) { if (!$this->followedByCommaAnalyzer->isFollowed($this->file, $last)) {
return null; return null;

View File

@ -108,6 +108,7 @@ CODE_SAMPLE
{ {
\end($array); \end($array);
$lastPosition = \key($array); $lastPosition = \key($array);
\reset($array);
$last = $array[$lastPosition]; $last = $array[$lastPosition];
if (!$this->followedByCommaAnalyzer->isFollowed($this->file, $last)) { if (!$this->followedByCommaAnalyzer->isFollowed($this->file, $last)) {
return null; return null;

View File

@ -160,6 +160,7 @@ CODE_SAMPLE
$stmts = (array) $classMethod->stmts; $stmts = (array) $classMethod->stmts;
\end($stmts); \end($stmts);
$lastKey = \key($stmts); $lastKey = \key($stmts);
\reset($stmts);
$return = new Return_(new LNumber(0)); $return = new Return_(new LNumber(0));
if ($lastKey !== null && (isset($classMethod->stmts[$lastKey]) && $this->terminatedNodeAnalyzer->isAlwaysTerminated($classMethod, $classMethod->stmts[$lastKey], $return))) { if ($lastKey !== null && (isset($classMethod->stmts[$lastKey]) && $this->terminatedNodeAnalyzer->isAlwaysTerminated($classMethod, $classMethod->stmts[$lastKey], $return))) {
return; return;

View File

@ -113,6 +113,7 @@ final class CompletionInput extends ArgvInput
if (\is_array($argumentValue)) { if (\is_array($argumentValue)) {
\end($argumentValue); \end($argumentValue);
$this->completionValue = $argumentValue ? $argumentValue[\key($argumentValue)] : null; $this->completionValue = $argumentValue ? $argumentValue[\key($argumentValue)] : null;
\reset($argumentValue);
} else { } else {
$this->completionValue = $argumentValue; $this->completionValue = $argumentValue;
} }