Bug #63025 [Com]: Method in trait not called when called as __constructor() argument

From: Date: Sat, 08 Sep 2012 15:38:03 +0000
Subject: Bug #63025 [Com]: Method in trait not called when called as __constructor() argument
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-8830@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63025&edit=1 ID: 63025 Comment by: reeze dot xia at gmail dot com Reported by: hinikato at mail dot ru Summary: Method in trait not called when called as __constructor() argument Status: Open Type: Bug Package: Documentation problem Operating System: Windows 7 x64 PHP Version: 5.4.6 Block user comment: N Private report: N New Comment: I found a same bug reported before: https://bugs.php.net/bug.php?id=54162 we could mark one of them as duplicated Previous Comments: ------------------------------------------------------------------------ [2012-09-07 08:42:29] laruence@php.net s #if there is construct,#if there is no constructor,# ------------------------------------------------------------------------ [2012-09-07 08:41:41] laruence@php.net construct is a fcall after ZEND_NEW opcode, if there is construct, then no fcall at all(thus no argument substituation). <?php class Foo { } function a() { die("DIE ME!"); } $b = new Foo(a()); ?> I'd like to mark this as a DOC bug, since agrumets eval is useless in most of the times. ------------------------------------------------------------------------ [2012-09-07 07:14:19] reeze dot xia at gmail dot com hi hinikato, Yes, as previous email, if constructor was defined it will get called so your func_get_args() test script works :) . if not it will not get called, so the params expression will not executed. new operator is not the same as normal function call. so it behavior differently, ------------------------------------------------------------------------ [2012-09-07 07:04:36] hinikato at mail dot ru @reeze.xia, yes, this weird behavior, because we can do somethink like this: function __construct() { $args = func_get_args(); // do something with $args } It seems like a bug. ------------------------------------------------------------------------ [2012-09-07 05:50:03] reeze dot xia at gmail dot com There is nothing to do with trait. look http://3v4l.org/eOVRJ class A { /* no constructor public function __construct() {} */ } class B { public function __construct() { die("DIE ME!"); } } $a = new A(new B()); // output nothing. it didn't die with "DIE ME!" since class A didn't have any constructor, so the construct params will not executed the same as: if (false && $it->iWillNotBeExecuted()) { // } I thought this is a document problem :) ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=63025 -- Edit this bug report at https://bugs.php.net/bug.php?id=63025&edit=1

« previous php.doc.bugs (#8830) next »