Req #52648 [Bgs]: interface/class

From: Date: Fri, 20 Aug 2010 15:53:45 +0000
Subject: Req #52648 [Bgs]: interface/class
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-153666@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52648&edit=1 ID: 52648 User updated by: augusteiner at hotmail dot com Reported by: augusteiner at hotmail dot com Summary: interface/class Status: Bogus Type: Feature/Change Request Package: Class/Object related Operating System: Windows PHP Version: Irrelevant Block user comment: N New Comment: But if instead of an interface it was an abstract class with Equals marked as abstract? This situation could not be compatible with my first description!? Previous Comments: ------------------------------------------------------------------------ [2010-08-20 07:11:02] aharvey@php.net This is by design. In your example, Entity::equals() is more restrictive than IEntity::equals(): it wouldn't accept another class that implemented IEntity independently of Entity, even though the interface explicitly allows that. ------------------------------------------------------------------------ [2010-08-19 23:48:35] augusteiner at hotmail dot com Description: ------------ A class that implements an interface should implement interface's methods, but a method inside that class with type hint of class that implements the interface would be accepted. Or not!? After all, both are hierarchically identical. Test script: --------------- interface IEntity { public function equals(IEntity $other); } class Entity implements IEntity { public function equals(Entity $other) { return $this === $other; } } Actual result: -------------- Fatal error: Declaration of Entity::equals() must be compatible with that of IEntity::equals() in C:\wamp\www\horusweb\models\Coded.class.php ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52648&edit=1

« previous php.bugs (#153666) next »