Skip to content

Commit

Permalink
Updated Rector to commit 526a61b034c626be8c1c86ec5e08c8b64afcde20
Browse files Browse the repository at this point in the history
rectorphp/rector-src@526a61b [Php83] Skip multiple consts on AddTypeToConstRector when types are different (#5974)
  • Loading branch information
TomasVotruba committed Jun 17, 2024
1 parent 2058e5f commit b53e3c0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
17 changes: 14 additions & 3 deletions rules/Php83/Rector/ClassConst/AddTypeToConstRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function refactor(Node $node) : ?Class_
$parentClassReflections = $this->getParentReflections($className);
$hasChanged = \false;
foreach ($classConsts as $classConst) {
$valueType = null;
$valueTypes = [];
// If a type is set, skip
if ($classConst->type !== null) {
continue;
Expand All @@ -97,9 +97,20 @@ public function refactor(Node $node) : ?Class_
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;
Expand Down
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit b53e3c0

Please sign in to comment.