|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-04-28 22:42 UTC] Danack at basereality dot com
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 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 08 14:00:02 2025 UTC |
Forgot to post my configure settings. configure \ --disable-debug \ --disable-rpath \ --enable-fpm \ --enable-inline-optimization \ --enable-json \ --enable-mbregex \ --enable-mbstring \ --enable-pcntl \ --enable-sockets \ --enable-sysvsem \ --enable-sysvshm \ --enable-zip \ --with-bz2 \ --with-config-file-path=/etc \ --with-curl \ --with-freetype-dir=/usr/lib \ --with-gd \ --with-jpeg-dir=/usr/lib \ --with-mcrypt \ --with-pecl=/usr/lib \ --with-pic \ --with-png-dir=/usr/lib \ --with-zlib \ --with-mhash \ --with-mysql \ --with-mysqli \ --with-pcre-regex \ --without-pdo-sqlite