#29417 [Opn->Sus]: Type hints do not allow for extended interfaces
| From: | helly@php.net | Date: | Wed, 28 Jul 2004 03:58:14 +0000 |
| Subject: | #29417 [Opn->Sus]: Type hints do not allow for extended interfaces | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-63659@lists.php.net to get a copy of this message | ||
ID: 29417
Updated by: helly@php.net
Reported By: ah08010-zend at yahoo dot com
-Status: Open
+Status: Suspended
Bug Type: Feature/Change Request
-Operating System: Windows 2000
+Operating System: *
PHP Version: 5.0.0
-Assigned To:
+Assigned To: hellz
New Comment:
Wow it seems you'd be the first person answering my OOP test question
correctly. Anyway structer is the wrong word here but you are right.
The code you have here should work. If you wanna experiment with that
you can try this patch:
http://marcus-boerger.de/php/ext/ze2/ze2-type-hint-classes-20040719.diff.txt
But though it works in CLI this is not even a proof of concept.
Previous Comments:
------------------------------------------------------------------------
[2004-07-28 03:41:39] ah08010-zend at yahoo dot com
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
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=29417&edit=1