Bug #51867 [Opn->Bgs]: include() causes strict erros when including overloading methods
| From: | johannes@php.net | Date: | Thu, 20 May 2010 08:58:25 +0000 |
| Subject: | Bug #51867 [Opn->Bgs]: include() causes strict erros when including overloading methods | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-150647@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: johannes@php.net
Reported by: ss at zornig dot dk
Summary: include() causes strict erros when including
overloading methods
-Status: Open
+Status: Bogus
Type: Bug
Package: Scripting Engine problem
Operating System: FreeBSD 7.2
PHP Version: 5.3.2
New Comment:
.
Previous Comments:
------------------------------------------------------------------------
[2010-05-20 10:53:10] johannes@php.net
If you put all in one file the error is triggered during compilation,
before error_reporting() is executed. You have to change your error
reporting settings in php.ini.
And no it is an strict error as it is no real problem for the engine but
an hint for you to write better code.
------------------------------------------------------------------------
[2010-05-20 10:18:07] ss at zornig dot dk
It looks like it is 100% my bad, however i should change the bug
description then? But maybe it should trigger a fatal error then?
------------------------------------------------------------------------
[2010-05-20 09:33:08] mike@php.net
It should actually always case an E_STRICT, as you force a more specific
method signature which is strictly speaking incompatible.
------------------------------------------------------------------------
[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