Edit report at https://bugs.php.net/bug.php?id=60153&edit=1
ID: 60153 Updated by: g...@php.net Reported by: tsteiner at nerdclub dot net Summary: Interface method prototypes not enforced when implementd via traits. -Status: Open +Status: Closed Type: Bug Package: Class/Object related PHP Version: 5.4.0beta2 -Assigned To: +Assigned To: gron Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2011-11-01 15:25:19] g...@php.net Automatic comment from SVN on behalf of gron Revision: http://svn.php.net/viewvc/?view=revision&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-10-27 20:02:06] 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-10-27 19:58:30] 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. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=60153&edit=1