|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-09-18 11:13 UTC] johannes@php.net
-Status: Open
+Status: Not a bug
[2014-09-18 11:13 UTC] johannes@php.net
[2014-09-18 11:34 UTC] sosingus at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 08 04:00:01 2026 UTC |
Description: ------------ If we use interfaced instance to access a method not defined in interface itself, code will work! Expected is RuntimeException of some kind. Same applies for using parent class on instance of some subclass. If anyone cares I'll serach and create similar bug report for classes. This behavior can lead to serious problems in any serious OO code. Worst of all it cannot be predicted in any way. I think this is a system issue and probably exists since the OO beginning in php. Test script: --------------- <?php interface TestInterface { public function printMe(); } class TestClass implements TestInterface { public function printMe() { print "1\n"; } public function printMeToo() { print "2\n"; } } function testInterfaceShouldFail(TestInterface $instance) { $instance->printMe(); $instance->printMeToo(); } testInterfaceShouldFail(new TestClass()); Expected result: ---------------- raised/thrown RuntimeException Actual result: -------------- 1 2