|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-01-24 05:39 UTC] scott dot pascoe at gmail dot com
Description: ------------ The reproduce code is in a test format. In php 5.1.4, it outputs the expected output, it does not in 5.2.0, or does it in the 5.2.1 snapshot from today. It was reported to be fixed on 2007-01-10, but isn't yet. The symfony framework depends upon this capability. Reproduce code: --------------- --TEST-- Bug #39449 (Behavior changed from php 5.1.4 to 5.2.0) --FILE-- <?php // hacked for this test $ns = 'test'; class ParameterHolder { protected $parameters = array(); public function & get($name) { return & $this->parameters[$ns][$name]; } public function setByRef($name, & $value) { if (!isset($this->parameters[$ns])) $this->parameters[$ns] = array(); $this->parameters[$ns][$name] =& $value; } } class Bug39449 { protected $varHolder = null; public function __construct() { $this->varHolder = new ParameterHolder(); } public function getVarHolder() { return $this->varHolder; } public function __set($key, $value) { return $this->varHolder->setByRef($key, $value); } public function __get($key) { return $this->varHolder->get($key); } } $b = new Bug39449(); $b->foo = Array(); $b->foo[0] = 'bar'; foreach ($b->foo as $k => $v) { echo "$k => $v\n"; } ?> --EXPECT-- 0 => bar Expected result: ---------------- 0 => bar Actual result: -------------- [nothing] PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 10:00:01 2025 UTC |
<?php class ParameterHolder { protected $parameters = array(); public function &get($name) { return $this->parameters['test'][$name]; } public function setByRef($name, & $value) { if (!isset($this->parameters['test'])) $this->parameters['test'] = array(); $this->parameters['test'][$name] =& $value; } } class Bug39449 { protected $varHolder = null; public function __construct() { $this->varHolder = new ParameterHolder(); } public function getVarHolder() { return $this->varHolder; } public function __set($key, $value) { return $this->varHolder->setByRef($key, $value); } public function &__get($key) { /* NB */ return $this->varHolder->get($key); } } $b = new Bug39449(); $b->foo = Array(); $b->foo[0] = 'bar'; foreach ($b->foo as $k => $v) { echo "$k => $v\n"; } ?>