Req #45601 [Com]: Extending interfaces

From: Date: Tue, 22 Mar 2011 23:11:36 +0000
Subject: Req #45601 [Com]: Extending interfaces
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-159713@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=45601&edit=1

 ID:                 45601
 Comment by:         clicky at erebot dot net
 Reported by:        david at grudl dot com
 Summary:            Extending interfaces
 Status:             Open
 Type:               Feature/Change Request
 Package:            Feature/Change Request
 Operating System:   irrelevant
 PHP Version:        5.3CVS-2008-07-23 (snap)
 Block user comment: N
 Private report:     N

 New Comment:

See also bug #46705 for other suggestions on how to improve the way
interfaces currently work in PHP.


Previous Comments:
------------------------------------------------------------------------
[2008-07-23 11:33:10] david at grudl dot com

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

------------------------------------------------------------------------
[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/bug.php?id=45601&edit=1


Thread (5 messages)

« previous php.bugs (#159713) next »