Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #8664 #8665

Merged
merged 1 commit into from Nov 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -780,7 +780,7 @@ public static function analyze(
}

// Check overridden final
if ($parent_const_storage->final) {
if ($parent_const_storage->final && $parent_const_storage !== $const_storage) {
IssueBuffer::maybeAdd(
new OverriddenFinalConstant(
"{$const_name} cannot be overridden because it is marked as final in "
Expand Down
38 changes: 38 additions & 0 deletions tests/ConstantTest.php
Expand Up @@ -1482,6 +1482,44 @@ class Foo {
}
',
],
'finalConst' => [
'code' => '<?php
class Foo
{
final public const BAR="baz";
}

class Baz extends Foo
{
}

$a = Baz::BAR;
',
'assertions' => [
'$a===' => "'baz'"
],
'ignored_issues' => [],
'php_version' => '8.1'
],
'finalConstInterface' => [
'code' => '<?php
interface Foo
{
final public const BAR="baz";
}

class Baz implements Foo
{
}

$a = Baz::BAR;
',
'assertions' => [
'$a===' => "'baz'"
],
'ignored_issues' => [],
'php_version' => '8.1'
],
];
}

Expand Down