php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49162 Interfaces not Inherited in Method Signatures
Submitted: 2009-08-05 02:41 UTC Modified: 2009-08-05 07:54 UTC
From: wjaspers4 at gmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.2.10 OS: Windows XP SP3 (32-bit)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: wjaspers4 at gmail dot com
New email:
PHP Version: OS:

 

 [2009-08-05 02:41 UTC] wjaspers4 at gmail dot com
Description:
------------
In proper OOP, i should be able to define an interface, and have a class 
or abstract class implement it.

If I create a class (or abstract class) which calls upon the interface 
in a method signature, everything is ok.

However; if I extend the aforementioned class (or extend unto an 
abstract class), and I call upon the class which implements the 
interface, my compilation fails.

Even if I provide a method in my interface and implement it in the class 
which uses the interface, it still fails.

I have been able to reproduce this in both php 5.2.10 and 5.2.6 
(personal and work servers, respectively)

Reproduce code:
---------------
interface Validatable {};

class Form implements Validatable
{
}

abstract class Validator
{
 abstract public function Validate( Validatable $v );
}

abstract class Form_Validator
extends Validator
{
 public function Validate( Form $f )
 { // do something in here...
 }
}

Expected result:
----------------
I should see nothing.
OR -- if i look in memory, I should see that my Form_Validator has a 
Validate method in it.

Actual result:
--------------
Fatal error: Declaration of Form_Validator::Validate() must be 
compatible with that of Validator::Validate() in ....

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-05 07:54 UTC] jani@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 21:01:29 2024 UTC