Bug #51867 [Opn]: include() causes strict erros when including overloading methods

From: Date: Thu, 20 May 2010 07:33:09 +0000
Subject: Bug #51867 [Opn]: include() causes strict erros when including overloading methods
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-150640@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=51867&edit=1 ID: 51867 Updated by: mike@php.net Reported by: ss at zornig dot dk Summary: include() causes strict erros when including overloading methods Status: Open Type: Bug Package: Scripting Engine problem Operating System: FreeBSD 7.2 PHP Version: 5.3.2 New Comment: It should actually always case an E_STRICT, as you force a more specific method signature which is strictly speaking incompatible. Previous Comments: ------------------------------------------------------------------------ [2010-05-20 09:26:11] ss at zornig dot dk Description: ------------ When overloading a method, changing a object type hint to accept a child class instead a E_STRICT error is triggered. This however only happens if the object declaration is loaded using include, not if the declaration is in the file called. Test script: --------------- test.php: <?php error_reporting(E_ALL | E_STRICT); abstract class ObjParent { public function set(ObjParent $param1, $param2){ } } require_once('obj.php'); ?> obj.php: <?php class ObjChild extends ObjParent { public function set(ObjChild $param1, $param2=true){ } } ?> Expected result: ---------------- This should be without any errors as i would if the test.php looks like this: <?php error_reporting(E_ALL | E_STRICT); abstract class ObjParent { public function set(ObjParent $param1, $param2){ } } class ObjChild extends ObjParent { public function set(ObjChild $param1, $param2){ } } ?> Actual result: -------------- Strict Standards: Declaration of ObjChild::set() should be compatible with that of ObjParent::set() in /usr/home/webroot/dumpsite/bug/obj.php on line 4 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=51867&edit=1

« previous php.bugs (#150640) next »