From:
Operating system: GNU/Linux
PHP version: 5.3.2
Package: Scripting Engine problem
Bug Type: Bug
Bug description:Overriding method type hint with child interface raises strict
standards
Description:
------------
When using an interface for type hinting, PHP raises a strict standards
warning
if an overriding method uses an interface that implements the type hint. In
the
example below, ITwo implements IOne and method One::foo expects the first
argument to implement IOne. Two extends One and expects the first argument
to
implement ITwo, which implements IOne. This should be allowed, much like it
is
allowed if the interfaces were simply classes.
Test script:
---------------
interface IOne {}
interface ITwo extends IOne {}
class One
{
public function foo( IOne $bla ) {}
}
class Two extends One
{
public function foo( ITwo $bla ) {}
}
class Test implements ITwo {}
// yet, this does work
var_dump( new Test instanceof IOne );
Expected result:
----------------
bool(true)
Actual result:
--------------
PHP Strict Standards: Declaration of Two::foo() should be compatible with
that
of One::foo() in test.php on line 25
Strict Standards: Declaration of Two::foo() should be compatible with that
of
One::foo() in test.php on line 25
bool(true)
--
Edit bug report at http://bugs.php.net/bug.php?id=51542&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=51542&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=51542&r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=51542&r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=51542&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=51542&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=51542&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=51542&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=51542&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=51542&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=51542&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=51542&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=51542&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=51542&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=51542&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51542&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=51542&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=51542&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=51542&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=51542&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=51542&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=51542&r=mysqlcfg