Skip to content

Commit dd6b1b7

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Fix GH-7757: Multi-inherited final constant causes fatal error
2 parents 443a420 + 206c521 commit dd6b1b7

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Bug GH-7757 (Multi-inherited final constant causes fatal error)
3+
--FILE--
4+
<?php
5+
interface EntityInterface {
6+
final public const TEST = 'this';
7+
}
8+
9+
interface KeyInterface extends EntityInterface {
10+
}
11+
12+
interface StringableInterface extends EntityInterface {
13+
}
14+
15+
class SomeTestClass implements KeyInterface, StringableInterface {
16+
}
17+
?>
18+
--EXPECT--

Zend/zend_inheritance.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1601,7 +1601,7 @@ static bool do_inherit_constant_check(
16011601
}
16021602

16031603
zend_class_constant *old_constant = Z_PTR_P(zv);
1604-
if ((ZEND_CLASS_CONST_FLAGS(parent_constant) & ZEND_ACC_FINAL)) {
1604+
if (parent_constant->ce != old_constant->ce && (ZEND_CLASS_CONST_FLAGS(parent_constant) & ZEND_ACC_FINAL)) {
16051605
zend_error_noreturn(E_COMPILE_ERROR, "%s::%s cannot override final constant %s::%s",
16061606
ZSTR_VAL(old_constant->ce->name), ZSTR_VAL(name),
16071607
ZSTR_VAL(parent_constant->ce->name), ZSTR_VAL(name)

0 commit comments

Comments
 (0)