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);
$lastKey = \key($stmts);
\reset($stmts);
foreach ($stmts as $key => $stmt) {
if ($key === $lastKey) {
// skip last item

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/
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()
{
}

View File

@ -180,6 +180,13 @@ CODE_SAMPLE
$firstArg->value = $array;
}
$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;
}
/**

View File

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

View File

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

View File

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

View File

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