Edit report at https://bugs.php.net/bug.php?id=63177&edit=1
ID: 63177 Comment by: maciej dot sz at gmail dot com Reported by: maciej dot sz at gmail dot com Summary: Implementing interface in sub-class with a trait triggers fatal error Status: Open Type: Bug Package: Scripting Engine problem Operating System: irrelevant PHP Version: 5.4Git-2012-09-28 (snap) Block user comment: N Private report: N New Comment: In case if someone has the same problem I came up with an ugly workaround, which requires yet another sub class: <?php class Sub extends Base { use T; } class SubSub extends Sub implements I {} Previous Comments: ------------------------------------------------------------------------ [2012-09-28 11:33:31] maciej dot sz at gmail dot com Description: ------------ This happens when method of a sub-class introduce new, optional parameters which are needed for an interface implementation. If a trait is source for the implementation of that method then a fatal error is triggered: Fatal error: Declaration of Base::push() must be compatible with I::push Bug #60153 might be related as it considers opposite situation. I've checked this with: 5.4.1 5.4.7 5.5-dev (snap 201209280930) Test script: --------------- <?php error_reporting(E_ALL); interface I { public function push($val, $scope = null); } trait T { public function push($val, $scope = null){} } class Base { public function push($val){} } class Sub extends Base { use T; } $SubReflection = new ReflectionClass('Sub'); // this shows correct push() method, compatible with 'I' interface: echo $SubReflection->getMethod('push'); // however adding 'implements I' triggers fatal error: class SubImplements extends Base implements I { use T; } Expected result: ---------------- No errors (interface is implemented properly) Actual result: -------------- Fatal error: Declaration of Base::push() must be compatible with I::push($val, $scope = NULL) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63177&edit=1