Skip to content

Commit

Permalink
fix internal properties on interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
orklah committed Jan 23, 2022
1 parent 67c4a7e commit 3a8ed81
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
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
12 changes: 12 additions & 0 deletions tests/EnumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,18 @@ enum Foo {
false,
'8.1',
],
'InterfacesWithProperties' => [
'<?php
static fn (\UnitEnum $tag): string => $tag->name;
static fn (\BackedEnum $tag): string|int => $tag->value;
',
'error_message' => '',
'ignored_issues' => [],
false,
'php_version' => '8.1',
],
];
}
}

0 comments on commit 3a8ed81

Please sign in to comment.