mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-16 13:00:23 +01:00
Updated Rector to commit 8fea0f5b27dbdb4d3e0b2d672d43c60cb0c2ea2c
8fea0f5b27
[Php54] Use token base replace on LongArrayToShortArrayRector (#6616)
This commit is contained in:
parent
e2a64c439d
commit
fa66798989
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user