Edit report at https://bugs.php.net/bug.php?id=63816&edit=1
ID: 63816 Comment by: kotlyar dot maksim at gmail dot com Reported by: kotlyar dot maksim at gmail dot com Summary: implementation child interface and after parent cause fatal error. Status: Feedback Type: Bug Package: Scripting Engine problem Operating System: linux PHP Version: 5.4.7 Assigned To: dmitry Block user comment: N Private report: N New Comment: I think that described order of interfaces is absolutely correct. So there should not be a warning\fatal. About BC break. I dont feel like expert in this question. Personally I dont think that this BC break would be a problem because: 1) There are few developers how can implement interfaces in this order. 2) They will be affected only while downgrade of php version. 3) The fatal error message gives some usefull info about what could be a problem. 4) The change log of php 5.5 would contain description of this change. Previous Comments: ------------------------------------------------------------------------ [2013-01-10 06:20:47] dmi...@php.net It may be a warning, but actually it's not a big deal to fix a script once you see this FATAL error. Finally, if we change it to warning, some script will work on 5.5 but fail on 5.3. Do we really need to introduce another incompatibility because of this small issue? ------------------------------------------------------------------------ [2013-01-10 04:40:07] larue...@php.net Hey, I think it not deserved a FATAL. maybe a warning ? ------------------------------------------------------------------------ [2013-01-09 10:49:51] kotlyar dot maksim at gmail dot com @dmitry I see you reason. I am completely agree with you that be silent and allow two same interface is not a good solution. But from the other side. I believed that I could implement interface in any order I want. Ordering of interfaces(maybe should be?) is not documented anywhere. Also the described situation could be resolved without a fatal error so it at least not developer friendly. ------------------------------------------------------------------------ [2013-01-09 09:41:18] dmi...@php.net I'm not sure if this is a bug. At least the error message is absolutely correct. When class "C" implements interface "FirstChildInterface" it also implements its parent interface - "RootInterface", and when it tries to implement "RootInterface" it sees that it was already implemented before. The Laruence's patch removes the error message completely, so the following buggy code becomes legal. <?php interface foo {} class bar implements foo, foo {} ?> I would prefer not to do it. ------------------------------------------------------------------------ [2013-01-05 05:37:24] larue...@php.net not sure why such error is threw in zend_compile.c line 2926 we can simply be silence(or warning), then ignore it. diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index e395795..9063023 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -2920,11 +2920,7 @@ ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry memmove(ce->interfaces + i, ce->interfaces + i + 1, sizeof(zend_class_entry*) * (--ce->num_interfaces - i)); i--; } else if (ce->interfaces[i] == iface) { - if (i < parent_iface_num) { - ignore = 1; - } else { - zend_error(E_COMPILE_ERROR, "Class %s cannot implement previously implemented interface %s", ce->name, iface->name); - } + ignore = 1; } } if (ignore) { ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=63816 -- Edit this bug report at https://bugs.php.net/bug.php?id=63816&edit=1