Edit report at https://bugs.php.net/bug.php?id=64731&edit=1
ID: 64731
Comment by: Danack at basereality dot com
Reported by: Danack at basereality dot com
Summary: Constructor called from trait gives warning message
Status: Open
Type: Bug
Package: Compile Failure
Operating System: Ubuntu 12.04 LTS
PHP Version: 5.5.0beta4
Block user comment: N
Private report: N
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[2013-04-28 22:42:08] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64731&edit=1