Req #45601 [Opn->Csd]: Extending interfaces

From: Date: Tue, 07 Apr 2015 16:59:15 +0000
Subject: Req #45601 [Opn->Csd]: Extending interfaces
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-191879@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=45601&edit=1

 ID:                 45601
 Updated by:         nikic@php.net
 Reported by:        david at grudl dot com
 Summary:            Extending interfaces
-Status:             Open
+Status:             Closed
 Type:               Feature/Change Request
-Package:            Feature/Change Request
+Package:            *General Issues
 Operating System:   irrelevant
 PHP Version:        5.3CVS-2008-07-23 (snap)
-Assigned To:        
+Assigned To:        nikic
 Block user comment: N
 Private report:     N

 New Comment:

As clicky mentioned, this is fixed since PHP 5.3.9.


Previous Comments:
------------------------------------------------------------------------
[2011-12-04 09:40:20] clicky at erebot dot net

This issue and a few others dealing with interfaces have been solved in PHP 5.4RC2 & 5.3.9RC2.

------------------------------------------------------------------------
[2011-03-23 00:11:36] clicky at erebot dot net

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

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


Thread (5 messages)

« previous php.bugs (#191879) next »