Skip to content

Commit

Permalink
Updated Rector to commit f6fa83409bd80bf25f0677988100709c2ad7ab38
Browse files Browse the repository at this point in the history
rectorphp/rector-src@f6fa834 [Php81] Skip reassign on array destruct on ReadOnlyPropertyRector (#6596)
  • Loading branch information
TomasVotruba committed Dec 16, 2024
1 parent 3e53616 commit fc37f9a
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 30 deletions.
1 change: 1 addition & 0 deletions vendor/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -1440,6 +1440,7 @@
'Rector\\DowngradePhp73\\Rector\\Unset_\\DowngradeTrailingCommasInUnsetRector' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp73/Rector/Unset_/DowngradeTrailingCommasInUnsetRector.php',
'Rector\\DowngradePhp73\\Tokenizer\\FollowedByCommaAnalyzer' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp73/Tokenizer/FollowedByCommaAnalyzer.php',
'Rector\\DowngradePhp73\\Tokenizer\\FollowedByNewlineOnlyMaybeWithSemicolonAnalyzer' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp73/Tokenizer/FollowedByNewlineOnlyMaybeWithSemicolonAnalyzer.php',
'Rector\\DowngradePhp73\\Tokenizer\\TrailingCommaRemover' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp73/Tokenizer/TrailingCommaRemover.php',
'Rector\\DowngradePhp74\\Rector\\Array_\\DowngradeArraySpreadRector' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp74/Rector/Array_/DowngradeArraySpreadRector.php',
'Rector\\DowngradePhp74\\Rector\\ArrowFunction\\ArrowFunctionToAnonymousFunctionRector' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp74/Rector/ArrowFunction/ArrowFunctionToAnonymousFunctionRector.php',
'Rector\\DowngradePhp74\\Rector\\ClassMethod\\DowngradeContravariantArgumentTypeRector' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp74/Rector/ClassMethod/DowngradeContravariantArgumentTypeRector.php',
Expand Down
1 change: 1 addition & 0 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -1659,6 +1659,7 @@ class ComposerStaticInit4280c40f0ee92945093567ebf9648fda
'Rector\\DowngradePhp73\\Rector\\Unset_\\DowngradeTrailingCommasInUnsetRector' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp73/Rector/Unset_/DowngradeTrailingCommasInUnsetRector.php',
'Rector\\DowngradePhp73\\Tokenizer\\FollowedByCommaAnalyzer' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp73/Tokenizer/FollowedByCommaAnalyzer.php',
'Rector\\DowngradePhp73\\Tokenizer\\FollowedByNewlineOnlyMaybeWithSemicolonAnalyzer' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp73/Tokenizer/FollowedByNewlineOnlyMaybeWithSemicolonAnalyzer.php',
'Rector\\DowngradePhp73\\Tokenizer\\TrailingCommaRemover' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp73/Tokenizer/TrailingCommaRemover.php',
'Rector\\DowngradePhp74\\Rector\\Array_\\DowngradeArraySpreadRector' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp74/Rector/Array_/DowngradeArraySpreadRector.php',
'Rector\\DowngradePhp74\\Rector\\ArrowFunction\\ArrowFunctionToAnonymousFunctionRector' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp74/Rector/ArrowFunction/ArrowFunctionToAnonymousFunctionRector.php',
'Rector\\DowngradePhp74\\Rector\\ClassMethod\\DowngradeContravariantArgumentTypeRector' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp74/Rector/ClassMethod/DowngradeContravariantArgumentTypeRector.php',
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -1752,12 +1752,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-downgrade-php.git",
"reference": "4a4281592cdb00c38c7034d5de4bb80bec76e3c9"
"reference": "7b990bd35788fc6b62645d3dd8335871e4ba4e77"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/4a4281592cdb00c38c7034d5de4bb80bec76e3c9",
"reference": "4a4281592cdb00c38c7034d5de4bb80bec76e3c9",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/7b990bd35788fc6b62645d3dd8335871e4ba4e77",
"reference": "7b990bd35788fc6b62645d3dd8335871e4ba4e77",
"shasum": ""
},
"require": {
Expand All @@ -1775,7 +1775,7 @@
"tomasvotruba\/class-leak": "^1.0",
"tracy\/tracy": "^2.10"
},
"time": "2024-12-12T15:18:45+00:00",
"time": "2024-12-16T14:58:05+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {
Expand Down
2 changes: 1 addition & 1 deletion vendor/composer/installed.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion vendor/rector/extension-installer/src/GeneratedConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
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 00ef1cd'), '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 4a42815'), '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 510a99d'), '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 29a1abf'));
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 00ef1cd'), '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 7b990bd'), '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 510a99d'), '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 29a1abf'));
private function __construct()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use PhpParser\Node\Expr\New_;
use PhpParser\Node\Expr\StaticCall;
use Rector\DowngradePhp73\Tokenizer\FollowedByCommaAnalyzer;
use Rector\DowngradePhp73\Tokenizer\TrailingCommaRemover;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
Expand All @@ -21,9 +22,14 @@ final class DowngradeTrailingCommasInFunctionCallsRector extends AbstractRector
* @readonly
*/
private FollowedByCommaAnalyzer $followedByCommaAnalyzer;
public function __construct(FollowedByCommaAnalyzer $followedByCommaAnalyzer)
/**
* @readonly
*/
private TrailingCommaRemover $trailingCommaRemover;
public function __construct(FollowedByCommaAnalyzer $followedByCommaAnalyzer, TrailingCommaRemover $trailingCommaRemover)
{
$this->followedByCommaAnalyzer = $followedByCommaAnalyzer;
$this->trailingCommaRemover = $trailingCommaRemover;
}
public function getRuleDefinition() : RuleDefinition
{
Expand Down Expand Up @@ -77,19 +83,7 @@ public function refactor(Node $node) : ?Node
if (!$this->followedByCommaAnalyzer->isFollowed($this->file, $lastArg)) {
return null;
}
$tokens = $this->file->getOldTokens();
$iteration = 1;
while (isset($tokens[$args[$lastArgKey]->getEndTokenPos() + $iteration])) {
if (\trim($tokens[$args[$lastArgKey]->getEndTokenPos() + $iteration]->text) === '') {
++$iteration;
continue;
}
if (\trim($tokens[$args[$lastArgKey]->getEndTokenPos() + $iteration]->text) !== ',') {
break;
}
$tokens[$args[$lastArgKey]->getEndTokenPos() + $iteration]->text = '';
break;
}
$this->trailingCommaRemover->remove($this->file, $lastArg);
return $node;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use PhpParser\Node;
use PhpParser\Node\Stmt\Unset_;
use Rector\DowngradePhp73\Tokenizer\FollowedByCommaAnalyzer;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\DowngradePhp73\Tokenizer\TrailingCommaRemover;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
Expand All @@ -19,9 +19,14 @@ final class DowngradeTrailingCommasInUnsetRector extends AbstractRector
* @readonly
*/
private FollowedByCommaAnalyzer $followedByCommaAnalyzer;
public function __construct(FollowedByCommaAnalyzer $followedByCommaAnalyzer)
/**
* @readonly
*/
private TrailingCommaRemover $trailingCommaRemover;
public function __construct(FollowedByCommaAnalyzer $followedByCommaAnalyzer, TrailingCommaRemover $trailingCommaRemover)
{
$this->followedByCommaAnalyzer = $followedByCommaAnalyzer;
$this->trailingCommaRemover = $trailingCommaRemover;
}
public function getRuleDefinition() : RuleDefinition
{
Expand Down Expand Up @@ -57,8 +62,7 @@ public function refactor(Node $node) : ?Node
if (!$this->followedByCommaAnalyzer->isFollowed($this->file, $last)) {
return null;
}
// remove comma
$node->setAttribute(AttributeKey::ORIGINAL_NODE, null);
$this->trailingCommaRemover->remove($this->file, $last);
return $node;
}
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare (strict_types=1);
namespace Rector\DowngradePhp73\Tokenizer;

use PhpParser\Node;
use Rector\ValueObject\Application\File;
final class TrailingCommaRemover
{
public function remove(File $file, Node $node) : void
{
$tokens = $file->getOldTokens();
$iteration = 1;
while (isset($tokens[$node->getEndTokenPos() + $iteration])) {
if (\trim($tokens[$node->getEndTokenPos() + $iteration]->text) === '') {
++$iteration;
continue;
}
if (\trim($tokens[$node->getEndTokenPos() + $iteration]->text) !== ',') {
break;
}
$tokens[$node->getEndTokenPos() + $iteration]->text = '';
break;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Function_;
use Rector\DowngradePhp73\Tokenizer\FollowedByCommaAnalyzer;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\DowngradePhp73\Tokenizer\TrailingCommaRemover;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
Expand All @@ -23,9 +23,14 @@ final class DowngradeTrailingCommasInParamUseRector extends AbstractRector
* @readonly
*/
private FollowedByCommaAnalyzer $followedByCommaAnalyzer;
public function __construct(FollowedByCommaAnalyzer $followedByCommaAnalyzer)
/**
* @readonly
*/
private TrailingCommaRemover $trailingCommaRemover;
public function __construct(FollowedByCommaAnalyzer $followedByCommaAnalyzer, TrailingCommaRemover $trailingCommaRemover)
{
$this->followedByCommaAnalyzer = $followedByCommaAnalyzer;
$this->trailingCommaRemover = $trailingCommaRemover;
}
public function getRuleDefinition() : RuleDefinition
{
Expand Down Expand Up @@ -110,7 +115,7 @@ private function cleanTrailingComma($node, array $array) : ?Node
if (!$this->followedByCommaAnalyzer->isFollowed($this->file, $last)) {
return null;
}
$node->setAttribute(AttributeKey::ORIGINAL_NODE, null);
$this->trailingCommaRemover->remove($this->file, $last);
return $node;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\New_;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
Expand Down Expand Up @@ -43,10 +42,16 @@ public function refactor(Node $node) : ?Node
return null;
}
$oldTokens = $this->file->getOldTokens();
if (isset($oldTokens[$node->getStartTokenPos()]) && (string) $oldTokens[$node->getStartTokenPos()] === '(') {
$startTokenPos = $node->getStartTokenPos();
$endTokenPos = $node->getEndTokenPos();
if (!isset($oldTokens[$startTokenPos], $oldTokens[$endTokenPos])) {
return null;
}
$node->var->setAttribute(AttributeKey::ORIGINAL_NODE, null);
if ((string) $oldTokens[$node->getStartTokenPos()] === '(') {
return null;
}
$oldTokens[$node->var->getStartTokenPos()]->text = '(' . $oldTokens[$node->var->getStartTokenPos()];
$oldTokens[$node->var->getEndTokenPos()]->text .= ')';
return $node;
}
}

0 comments on commit fc37f9a

Please sign in to comment.