|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-08-21 16:42 UTC] hrach dot cz at gmail dot com
Description:
------------
See the testcase. Worked ok in 7.0.0-beta3
Test script:
---------------
<?php
class foo
{
private $bar;
public function __construct()
{
$this->bar = new bar();
}
public function & __get($key)
{
$bar = $this->bar;
return $bar;
}
}
class bar { public $onBaz = []; }
$foo = new foo();
$foo->bar->onBaz[] = function() {};
var_dump($foo->bar->onBaz);
Expected result:
----------------
array(1) {
[0]=>
object(Closure)#4 (0) {
}
}
Actual result:
--------------
array(0) {
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 02:00:01 2025 UTC |
No, on Windows the bahavior has changed: /d/storage $ php --version PHP 7.0.0beta3 (cli) (built: Aug 5 2015 12:17:06) Copyright (c) 1997-2015 The PHP Group Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies /d/storage $ php test.php array(1) { [0]=> object(Closure)#3 (0) { } } /d/storage $ php --version PHP 7.0.0RC1 (cli) (built: Aug 20 2015 12:42:50) Copyright (c) 1997-2015 The PHP Group Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies /d/storage $ php test.php array(0) { } On Linux probably too, since travis was ok! - ok: https://travis-ci.org/nextras/orm/jobs/72314843 - broken: https://travis-ci.org/nextras/orm/jobs/76666269 I do not meant that proposed change. Since I'm returning object by magic getter, it's has no meaning to put the reference there. The reference would be important for that magic property, not the holding object itself, wouldn't be?It turns out what matter is NTS vs. TS build. If we modify the testcase to print more info echo "PHP_VERSION: " . PHP_VERSION . "\n"; echo "PHP_ZTS: " . PHP_ZTS . "\n"; echo "\n"; we get the following results: $ php test.php PHP_VERSION: 7.0.0RC1 PHP_ZTS: 0 array(0) { } $ php test.php PHP_VERSION: 7.0.0RC1 PHP_ZTS: 1 array(0) { } $ php test.php PHP_VERSION: 7.0.0beta3 PHP_ZTS: 0 array(0) { } $ php test.php PHP_VERSION: 7.0.0beta3 PHP_ZTS: 1 array(1) { [0]=> object(Closure)#3 (0) { } }