php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60153 Interface method prototypes not enforced when implementd via traits.
Submitted: 2011-10-27 19:58 UTC Modified: 2011-11-01 15:26 UTC
From: tsteiner at nerdclub dot net Assigned: gron (profile)
Status: Closed Package: Class/Object related
PHP Version: 5.4.0beta2 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
32 - 26 = ?
Subscribe to this entry?

 
 [2011-10-27 19:58 UTC] tsteiner at nerdclub dot net
Description:
------------
When an class implements an interface and then uses a method defined in a trait for the implementation, the prototype of the method is not enforced.

Test script:
---------------
<?php

interface I {
    public function oneArgument($a);
}

trait T {
    public function oneArgument() {}
}

class C implements I {
    use T;
}


Expected result:
----------------
PHP Fatal error:  Declaration of C::oneArgument() must be compatible with C::oneArgument($a) in test.php on line 11

Actual result:
--------------
Script compiles and runs without error.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-10-27 20:02 UTC] tsteiner at nerdclub dot net
Sorry, the expected result should be

PHP Fatal error:  Declaration of C::oneArgument() must be compatible with I::oneArgument($a) in test.php on line 11
 [2011-11-01 15:25 UTC] gron@php.net
Automatic comment from SVN on behalf of gron
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=318650
Log: Fixed Bug #60153 (Interface method prototypes not enforced when implementd via traits.)
# Moved the freeing of overriden functions to a point after the check.
# The new check comes after the normal inheritance check to give the first check
# the opportunity to abort with a more detailed error.
# Also fixed a small type in an unrelated test.
 [2011-11-01 15:26 UTC] gron@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

Fixed with SVN rev 318650.
 [2011-11-01 15:26 UTC] gron@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: gron
 [2012-04-18 09:48 UTC] laruence@php.net
Automatic comment on behalf of gron
Revision: http://git.php.net/?p=php-src.git;a=commit;h=7cd55955d1be231d304b36151170f673629145f2
Log: Fixed Bug #60153 (Interface method prototypes not enforced when implementd via traits.) # Moved the freeing of overriden functions to a point after the check. # The new check comes after the normal inheritance check to give the first check # the opportunity to abort with a more detailed error. # Also fixed a small type in an unrelated test.
 [2012-07-24 23:39 UTC] rasmus@php.net
Automatic comment on behalf of gron
Revision: http://git.php.net/?p=php-src.git;a=commit;h=7cd55955d1be231d304b36151170f673629145f2
Log: Fixed Bug #60153 (Interface method prototypes not enforced when implementd via traits.) # Moved the freeing of overriden functions to a point after the check. # The new check comes after the normal inheritance check to give the first check # the opportunity to abort with a more detailed error. # Also fixed a small type in an unrelated test.
 [2013-11-17 09:35 UTC] laruence@php.net
Automatic comment on behalf of gron
Revision: http://git.php.net/?p=php-src.git;a=commit;h=7cd55955d1be231d304b36151170f673629145f2
Log: Fixed Bug #60153 (Interface method prototypes not enforced when implementd via traits.) # Moved the freeing of overriden functions to a point after the check. # The new check comes after the normal inheritance check to give the first check # the opportunity to abort with a more detailed error. # Also fixed a small type in an unrelated test.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 14:01:29 2024 UTC