#45601 [Com]: Extending interfaces

From: Date: Wed, 23 Jul 2008 11:33:10 +0000
Subject: #45601 [Com]: Extending interfaces
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-127179@lists.php.net to get a copy of this message
 ID:               45601
 Comment by:       david at grudl dot com
 Reported By:      david at grudl dot com
 Status:           Open
 Bug Type:         Feature/Change Request
 Operating System: irrelevant
 PHP Version:      5.3CVS-2008-07-23 (snap)
 New Comment:

p.s. is really the error message formulation "(previously declared
abstract in IHuman)" correct?


Previous Comments:
------------------------------------------------------------------------

[2008-07-23 11:30:28] david at grudl dot com

Description:
------------
I think this fatal error is needless. 

Interface implementors can append optional parameter:

interface IAnimal
{
	function speak();
}

class Dog implements IAnimal
{
	function speak($optional = NULL)
	{
		echo 'Bark!';
	}
}

class Labrador extends Dog
{
	function speak($optional = NULL, $anotherOptinal = NULL)
	{
		...
	}
}


That's correct behaviour. But the same behaviour is unallowed for
interface extenders. 



Reproduce code:
---------------
interface IAnimal
{
	function speak();
}


interface IHuman extends IAnimal
{
	function speak($language = NULL);
}




Expected result:
----------------
no error

Actual result:
--------------
Fatal error: Can't inherit abstract function IAnimal::speak()
(previously declared abstract in IHuman) 


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=45601&edit=1



Thread (5 messages)

« previous php.bugs (#127179) next »