You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SplitGroupedClassConstantsRector drops the type of every constant after the first #9928
SplitGroupedClassConstantsRector drops the declared type, and any attribute groups, from every constant after the first when it splits a typed group.
Minimal PHP Code Causing Issue
<?phpdeclare(strict_types=1);
class OpenGroup
{
publicconstintB = 2, C = 3;
}
Run with the CODING_STYLE set (the rule is in CodingStyleLevel::RULES).
Responsible rules
SplitGroupedClassConstantsRector
Expected Behavior
- public const int B = 2, C = 3;+ public const int B = 2;+ public const int C = 3;
Actual Behavior
- public const int B = 2, C = 3;+ public const int B = 2;+ public const C = 3;
The same happens in an interface and a trait. In a final class AddTypeToConstRector (TYPE_DECLARATION) then re-adds int from the value, which hides the bug there. Anywhere else the declared type is lost.
Cause
createNextClassConsts() builds each new statement as
Whether the attribute groups should be copied onto every split constant is your call. They currently apply to the whole group, so copying them preserves the meaning.
Activity
samsonasik commentedon Oct 13, 2026
I created PR:
for it.
Skip the Rector rule that drops a split constant's type