Updated Rector to commit 8fea0f5b27dbdb4d3e0b2d672d43c60cb0c2ea2c

8fea0f5b27 [Php54] Use token base replace on LongArrayToShortArrayRector (#6616)
This commit is contained in:
Tomas Votruba 2024-12-19 07:37:44 +00:00
parent e2a64c439d
commit fa66798989
2 changed files with 25 additions and 3 deletions

View File

@ -62,8 +62,30 @@ CODE_SAMPLE
if ($node->getAttribute(AttributeKey::KIND) === Array_::KIND_SHORT) {
return null;
}
$node->setAttribute(AttributeKey::ORIGINAL_NODE, null);
$node->setAttribute(AttributeKey::KIND, Array_::KIND_SHORT);
$tokens = $this->file->getOldTokens();
$startTokenPos = $node->getStartTokenPos();
$endTokenPos = $node->getEndTokenPos();
if (!isset($tokens[$startTokenPos], $tokens[$endTokenPos])) {
return null;
}
// replace array opening
$tokens[$startTokenPos]->text = '';
$iteration = 1;
while (isset($tokens[$startTokenPos + $iteration])) {
if (\trim($tokens[$startTokenPos + $iteration]->text) === '') {
++$iteration;
continue;
}
if (\trim($tokens[$startTokenPos + $iteration]->text) !== '(') {
break;
}
// replace ( parentheses opening
$tokens[$startTokenPos + $iteration]->text = '[';
// replace ) parentheses closing
$tokens[$endTokenPos]->text = ']';
break;
}
return $node;
}
}

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'e9e88d4d1b6e85b4a5e40f9c17dc12a951a748a8';
public const PACKAGE_VERSION = '8fea0f5b27dbdb4d3e0b2d672d43c60cb0c2ea2c';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-12-19 13:22:08';
public const RELEASE_DATE = '2024-12-19 08:35:14';
/**
* @var int
*/