|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-04-13 16:52 UTC] degeberg@php.net
-Status: Open
+Status: Bogus
[2010-04-13 16:52 UTC] degeberg@php.net
[2010-04-13 19:47 UTC] mike at mikegerwitz dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 14 11:00:02 2025 UTC |
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)