From: Danack at basereality dot com Operating system: Ubuntu 12.04 LTS PHP version: 5.5.0beta4 Package: Compile Failure Bug Type: Bug Bug description:Constructor called from trait gives warning message
Description: ------------ Calling a constructor that takes a parameter inside a trait, the parameter isn't passed to the constructor and so a warning is generated and the constructor is missing a parameter. I was only able to get this to be repeatable when the trait is defined in a file that is outside of the current directory i.e. the bug is dependent of file location, so may be hard to replicate. This was seen both against 5.5.0beta4 and the current 5.5 git head. This issue isn't present on 5.4 (afaik). Test script: --------------- Code is a bit too long to post entirely, example files are here: https://gist.github.com/Danack/5478333 with instructions of where to put the files to see the bug. The relevant parts of the code are: trait Singleton{ public static function getInstance($data = array()){ new static($data); } } class TestClass { use Singleton; public function __construct($params){ echo "params count is ".count($params)."<br/>"; } } $params = array( 'test' => 'value' ); TestClass::getInstance($params); Expected result: ---------------- Expected result: params count is 1 Ok Actual result: -------------- Actual result: Warning: Missing argument 1 for TestClass::__construct(), called in /home/intahwebz/12345/vendor/intahwebz/utils/src/Intahwebz/Utils/Singleton.php on line 15 and defined in /home/intahwebz/12345/basereality/traitTestBroken.php on line 12 params count is 0 Ok -- Edit bug report at https://bugs.php.net/bug.php?id=64731&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64731&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64731&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64731&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64731&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64731&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64731&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64731&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64731&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=64731&r=support Expected behavior: https://bugs.php.net/fix.php?id=64731&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64731&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64731&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64731&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64731&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64731&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64731&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=64731&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64731&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64731&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64731&r=mysqlcfg