Bug #73348 [Opn->Ver]: A class can override a constant inherited from an indirect parent interface.
| From: | cmb@php.net | Date: | Wed, 19 Oct 2016 15:17:45 +0000 |
| Subject: | Bug #73348 [Opn->Ver]: A class can override a constant inherited from an indirect parent interface. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-204921@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73348&edit=1
ID: 73348
Updated by: cmb@php.net
Reported by: mkh117 at gmail dot com
Summary: A class can override a constant inherited from an
indirect parent interface.
-Status: Open
+Status: Verified
Type: Bug
Package: Class/Object related
Operating System: Ubuntu 16.04.1
PHP Version: 7.0.12
Block user comment: N
Private report: N
New Comment:
Confirmed: <https://3v4l.org/u4Y1q>.
Previous Comments:
------------------------------------------------------------------------
[2016-10-19 13:08:33] mkh117 at gmail dot com
Description:
------------
When a class inherits a constant from an interface that is not a direct parent of the class, it can
override its value without any errors thrown.
Test script:
---------------
<?php
interface a {
const con = 'Original value';
}
abstract class b implements a {
}
class d extends b {
const con='Overridden value';
}
echo d::con;
Expected result:
----------------
Fatal error: Cannot inherit previously-inherited constant con from interface a ... on line 11
Actual result:
--------------
The script works and the interface constant is overridden.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73348&edit=1