|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-10-19 13:08 UTC] 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.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 03:00:01 2025 UTC |
Related: 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 implementorsActually that might not be a bug, possibly designed to prevent: class B implements A, A {}