|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73348 A class can override a constant inherited from an indirect parent interface.
Submitted: 2016-10-19 13:08 UTC Modified: 2016-10-21 15:57 UTC
Avg. Score:3.8 ± 1.0
Reproduced:4 of 4 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (25.0%)
From: mkh117 at gmail dot com Assigned:
Status: Verified Package: Class/Object related
PHP Version: 7.0.12 OS: Ubuntu 16.04.1
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-10-19 13:08 UTC] mkh117 at gmail dot com
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:
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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-10-19 15:17 UTC]
-Status: Open +Status: Verified
 [2016-10-19 15:17 UTC]
Confirmed: <>.
 [2016-10-21 15:42 UTC]

interface A {}
abstract class B implements A {}
class C extends B implements A {}

I would expect this to generate: "Class %s cannot implement previously implemented interface %s"

Both this and the constant override issue are handled by zend_do_implement_interface which is not called for for grandchildren implementors
 [2016-10-21 15:57 UTC]
Actually that might not be a bug, possibly designed to prevent:

class B implements A, A {}
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Jul 26 21:01:24 2021 UTC