Skip to content

Commit

Permalink
Merge pull request #7467 from orklah/fix-enum-properties
Browse files Browse the repository at this point in the history
fix internal properties on interfaces
  • Loading branch information
orklah committed Jan 23, 2022
2 parents 67c4a7e + 82d84b0 commit 64206d9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Expand Up @@ -1007,7 +1007,10 @@ private static function handleNonExistentClass(
}
}

if (!$class_exists) {
if (!$class_exists &&
//interfaces can't have properties. Except when they do... In PHP Core, they can
!in_array($fq_class_name, ['UnitEnum', 'BackedEnum'], true)
) {
if (IssueBuffer::accepts(
new NoInterfaceProperties(
'Interfaces cannot have properties',
Expand Down
11 changes: 11 additions & 0 deletions tests/EnumTest.php
Expand Up @@ -371,6 +371,17 @@ enum Status: int {
[],
'8.1',
],
'InterfacesWithProperties' => [
'<?php
static fn (\UnitEnum $tag): string => $tag->name;
static fn (\BackedEnum $tag): string|int => $tag->value;
',
'assertions' => [],
[],
'8.1',
],
];
}

Expand Down

0 comments on commit 64206d9

Please sign in to comment.