Updated Rector to commit 526a61b034c626be8c1c86ec5e08c8b64afcde20

526a61b034 [Php83] Skip multiple consts on AddTypeToConstRector when types are different (#5974)
This commit is contained in:
Tomas Votruba 2024-06-17 03:49:48 +00:00
parent 2058e5fc17
commit b53e3c0d6a
2 changed files with 16 additions and 5 deletions

View File

@ -85,7 +85,7 @@ CODE_SAMPLE
$parentClassReflections = $this->getParentReflections($className);
$hasChanged = \false;
foreach ($classConsts as $classConst) {
$valueType = null;
$valueTypes = [];
// If a type is set, skip
if ($classConst->type !== null) {
continue;
@ -97,9 +97,20 @@ CODE_SAMPLE
if ($this->canBeInherited($classConst, $node)) {
continue;
}
$valueType = $this->findValueType($constNode->value);
$valueTypes[] = $this->findValueType($constNode->value);
}
if (!($valueType ?? null) instanceof Identifier) {
if ($valueTypes === []) {
continue;
}
if (\count($valueTypes) > 1) {
$valueTypes = \array_unique($valueTypes, \SORT_REGULAR);
}
// once more verify after uniquate
if (\count($valueTypes) > 1) {
continue;
}
$valueType = \current($valueTypes);
if (!$valueType instanceof Identifier) {
continue;
}
$classConst->type = $valueType;

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '9a0d03a293b3a6aef9fb2c134c27586e2f046043';
public const PACKAGE_VERSION = '526a61b034c626be8c1c86ec5e08c8b64afcde20';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-06-16 07:09:11';
public const RELEASE_DATE = '2024-06-17 10:46:28';
/**
* @var int
*/