Bug #49177 [Ver->Bgs]: include() causes strict erros when including overloading methods (PHP_5_2 only!)
| From: | stas@php.net | Date: | Thu, 12 Aug 2010 21:59:18 +0000 |
| Subject: | Bug #49177 [Ver->Bgs]: include() causes strict erros when including overloading methods (PHP_5_2 only!) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-153384@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=49177&edit=1
ID: 49177
Updated by: stas@php.net
Reported by: ss at zornig dot dk
Summary: include() causes strict erros when including
overloading methods (PHP_5_2 only!)
-Status: Verified
+Status: Bogus
Type: Bug
Package: Scripting Engine problem
Operating System: *
PHP Version: 5.*
Block user comment: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
You example restricts first parameter from ObjParent to ObjChild. making
child function accept only subset of arguments that parent function
accepts. This is a violation of LSP, of which the warning warns.
Previous Comments:
------------------------------------------------------------------------
[2010-04-20 13:40:29] ss at zornig dot dk
I have found a similar error in 5.3.2
------------------------------------------------------------------------
[2010-04-20 13:39:38] ss at zornig dot dk
Description:
------------
This works in 5.3.2 however, I have found a similar error.
Reproduce code:
---------------
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
------------------------------------------------------------------------
[2009-08-06 12:03:08] ss at zornig dot dk
Description:
------------
When overloading a method, changing a parameter to accept a default
value E_STRICT error is triggered. This however only happens if the
object declaration is loading using include, not if the declaration is
in the file called.
Reproduce code:
---------------
test.php:
<?php
error_reporting(E_ALL | E_STRICT);
abstract class ObjParent {
public function set($param1, $param2){ }
}
require_once('obj.php');
?>
obj.php:
<?php
class ObjChild extends ObjParent {
public function set($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($param1, $param2){ }
}
class ObjChild extends ObjParent {
public function set($param1, $param2=true){ }
}
?>
Actual result:
--------------
Strict Standards: Declaration of ObjChild::set() should be compatible
with that of ObjParent::set() in /home/webroot/dumpsite/obj.php on line
8
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=49177&edit=1