php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27623 implementation of interfaces not correct handled
Submitted: 2004-03-17 05:46 UTC Modified: 2004-03-17 13:13 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: fd@php.net Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5CVS-2004-03-17 (dev) OS: debian linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: fd@php.net
New email:
PHP Version: OS:

 

 [2004-03-17 05:46 UTC] fd@php.net
Description:
------------
A implementation of a class whith a method which is not declared as in the interface should throw an error, which it does in php5b4 but not in the current HEAD.

Reproduce code:
---------------
<?php

    interface Person {
        function doSth($sWhat,$sWhere);
    }
     
    class Member implements Person {
        function doSth($sWhat) {
            echo "Person does ".$sWhat."\n";
        }
    }
    
    $Member = new Member;
    $Member->doSth('nothing');

?> 

Expected result:
----------------
Fatal error: Declaration of Member::doSth() must be the same as Person::doSth()

Actual result:
--------------
Person does nothing

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-17 05:53 UTC] derick@php.net
This is correct behavior now, turn on E_STRICT and E_ALL and you'll see it.
 [2004-03-17 06:04 UTC] fd@php.net
Actually I do not get the point why that does not throw a fatal error, in my opinion the script should terminate on such an error, shouldn't it?
 [2004-03-17 06:27 UTC] derick@php.net
No, we had a discussion on this on the internals@ list. This only throws an E_STRICT type error.
 [2004-03-17 07:56 UTC] fd@php.net
That does not make sence in my eys. As an example, if you have a interface "car" which declares "four wheels" and an implementation of "car" just declares "three wheels" the car shouldn't even start driving. But now it does, I think that is stupid.
 [2004-03-17 13:13 UTC] helly@php.net
Maybe it is but PHP is still a weak typed language and other people make good use of that fact. They have E_STRICT off because turning it on makes PHP a bit more type strict.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 07:01:33 2025 UTC