#30080 [Ver->Csd]: Passing array or non array of objects

From: Date: Fri, 03 Jun 2005 15:03:25 +0000
Subject: #30080 [Ver->Csd]: Passing array or non array of objects
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-79856@lists.php.net to get a copy of this message
ID: 30080 Updated by: dmitry@php.net Reported By: portfolio at gmx dot co dot uk -Status: Verified +Status: Closed Bug Type: Zend Engine 2 problem Operating System: * PHP Version: 5CVS-2005-03-09 New Comment: Fixed in CVS HEAD and PHP_5_0. Previous Comments: ------------------------------------------------------------------------ [2005-03-09 21:53:46] sniper@php.net # sapi/cli/php /home/jani/t.php UNKNOWN:0 /usr/src/php/php5/Zend/zend_vm_execute.h(370) : Freeing 0x092FE03C (16 bytes), script=/home/jani/t.php === Total 1 memory leaks detected === ------------------------------------------------------------------------ [2005-01-13 19:00:06] tony2001@php.net No crash here, but I still got "UNKNOWN:0" as var_dump's output. ------------------------------------------------------------------------ [2004-11-28 16:35:55] tony2001@php.net Reproducible only with HEAD & 5.0.x. <?php class A { function A($arrayobj) { var_dump($arrayobj); } } class B { } new A( new B() ); ?> ------------------------------------------------------------------------ [2004-09-14 17:55:33] php30080 at pointbeing dot net Behaviour is reproducible using 5.00 on Fedora Linux (core 2). There's an ongoing discussion of the behaviour on the Sitepoint forums here: http://www.sitepoint.com/forums/showthread.php?t=195284 By way of a summary, it appears that the problems occur when constructing a number of new objects without assigning them anywhere, so: new A( array( new B(), new C())); // fails $a = new A( array( new B(), new C())); // fine some_function( array( new B(), new C())); //fine ------------------------------------------------------------------------ [2004-09-14 05:44:10] portfolio at gmx dot co dot uk Description: ------------ When I pass an array of objects without first initializing them with a variable, I get either a crash or error (Depends on whether if its array). Reproduce code: --------------- class A { function A($arrayobj) { while(list($key, $value) = each($arrayobj)) { echo $value->spit(); } } } class B { function spit() { return 'This is class B' . "\n"; } } class C { function spit() { return 'This is class C' . "\n"; } } new A( array( new B(), new C())); Expected result: ---------------- I got this error: This is class B Fatal error: Call to a member function spit() on a non-object in If I do: $b = new B; $c = new C; new A( array($b, $c)); It works but very long winded. Another bug here causes Apache to crash: class A { function A($value) { echo $value->spit(); } } class B { function spit() { return 'This is class B' . "\n"; } } new A( new B()); ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=30080&edit=1

« previous php.bugs (#79856) next »