Req #52648 [Opn->Bgs]: interface/class

From: Date: Fri, 20 Aug 2010 05:11:03 +0000
Subject: Req #52648 [Opn->Bgs]: interface/class
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-153628@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 Updated by: aharvey@php.net Reported by: augusteiner at hotmail dot com Summary: interface/class -Status: Open +Status: Bogus Type: Feature/Change Request Package: Class/Object related Operating System: Windows PHP Version: Irrelevant Block user comment: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [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 (#153628) next »