|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-07-28 05:58 UTC] helly@php.net
[2006-01-13 02:02 UTC] matt at builtfromsource dot com
[2006-01-13 09:27 UTC] helly@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 08:00:01 2025 UTC |
Description: ------------ Type hints in a derived class that specify a function parameter implements an interface derived from the interface specified in the (other) interface implemented by the base class (whew!) are flagged as an error despite being type-compatible: Fatal error: Declaration of TranslatedPlural::compose() must be compatible with that of Translatable::compose() in ...\TranslatedMessage.php on line 83 Reproduce code: --------------- // Parameter type hint (BASE) interface TranslationMap { public function fetch($the_key); } // Parameter type hint (DERIVED) interface TranslationLexicon extends TranslationMap { public function plural($the_noun, $the_count); } // Implementation Interface interface Translatable { function set_args(); function compose(TranslationMap $map); } // Base class class TranslatedMessage implements Translatable { public function set_args() { } public function compose(TranslationMap $lex) { } } // Derived class class TranslatedPlural extends TranslatedMessage { public function compose(TranslationLexicon $lex) { } } Expected result: ---------------- I expect that the derived class, TranslatedPlural, will be checked for a stricter (but type-compatible) interface than the base class. Actual result: -------------- Fatal error: Declaration of TranslatedPlural::compose() must be compatible with that of Translatable::compose() in ...\TranslatedMessage.php on line 83