|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-05-08 07:17 UTC] r dot van dot bezooijen at factua dot nl
Description:
------------
when overriding and interface method in another interface it's says they are incompatible with eachother while the overriding method contains a class/interface which is extended from the class/interface defined in the parent
I think its also related to bug report 43200, Although it's not exactly the same problem.
Test script:
---------------
<?php
interface IVisitee
{
public function accept( IVisitor $visitor );
}
interface IVisitor
{
public function visit( IVisitee $visitee );
}
interface IMetadata extends IVisitee
{
public function accept( IValidatorVisitor $visitor );
public function findConstraints( $group );
}
interface IValidatorVisitor extends IVisitor
{
public function validate( $group, $transverse = false, $deep = false );
public function visit( IMetadata $visitee );
}
Actual result:
--------------
PHP Fatal error: Declaration of IMetadata::accept() must be compatible with IVisitee::accept(IVisitor $visitor) in /tmp/test.php on line 30
PHP Stack trace:
PHP 1. {main}() /tmp/test.php:0
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 07 10:00:01 2026 UTC |
You are correct about LSP, but if i replace S & T with my class i get this: {quote} if S(IMetadata) is a subtype of T(IVisitee), then objects of type T(IVisitee) in a program may be replaced with objects of type S(IMetadata) without altering any of the desirable properties of that program {quote}