Skip to content

Commit

Permalink
Merge pull request #8665 from danog/fix_8664
Browse files Browse the repository at this point in the history
Fix #8664
  • Loading branch information
orklah committed Nov 5, 2022
2 parents d0be59e + da21229 commit 2ae819e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
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

0 comments on commit 2ae819e

Please sign in to comment.