Bug #73348 [Ver]: A class can override a constant inherited from an indirect parent interface.

From: Date: Fri, 21 Oct 2016 15:42:30 +0000
Subject: Bug #73348 [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-204953@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: leigh@php.net Reported by: mkh117 at gmail dot com Summary: A class can override a constant inherited from an indirect parent interface. 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: 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 implementors Previous Comments: ------------------------------------------------------------------------ [2016-10-19 15:17:45] cmb@php.net Confirmed: <https://3v4l.org/u4Y1q>. ------------------------------------------------------------------------ [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

« previous php.bugs (#204953) next »