From:             maciej dot sz at gmail dot com
Operating system: irrelevant
PHP version:      5.4Git-2012-09-28 (snap)
Package:          Scripting Engine problem
Bug Type:         Bug
Bug description:Implementing interface in sub-class with a trait triggers fatal 
error

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 bug report at https://bugs.php.net/bug.php?id=63177&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=63177&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=63177&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=63177&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=63177&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=63177&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=63177&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=63177&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=63177&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=63177&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=63177&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=63177&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=63177&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=63177&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63177&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=63177&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=63177&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=63177&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63177&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=63177&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=63177&r=mysqlcfg

Reply via email to