From:             ah08010-zend at yahoo dot com
Operating system: Windows 2000
PHP version:      5.0.0
PHP Bug Type:     Feature/Change Request
Bug description:  Type hints do not allow for extended interfaces

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 bug report at http://bugs.php.net/?id=29417&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=29417&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=29417&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=29417&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=29417&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=29417&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=29417&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=29417&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=29417&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=29417&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=29417&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=29417&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=29417&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29417&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=29417&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=29417&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=29417&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29417&r=float

Reply via email to