|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-08-12 07:55 UTC] laruence@php.net
-Status: Open
+Status: Verified
-Assigned To:
+Assigned To: laruence
[2016-08-12 07:55 UTC] laruence@php.net
[2016-08-12 08:20 UTC] laruence@php.net
-Summary: Different behavior for PHP 5.6.* and PHP 7.* when
values are returned by ref.
+Summary: Segfault with __get returned by ref
[2016-08-12 08:41 UTC] laruence@php.net
[2016-08-12 08:41 UTC] laruence@php.net
-Status: Verified
+Status: Closed
[2016-10-17 10:10 UTC] bwoebi@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 12:00:02 2025 UTC |
Description: ------------ I use PHP 7.0.4 When I run the script represented below I get the different result for versions 5.6.* and 7.0. If it is not a bug I would want to know what changes were made in PHP that may cause that different behavior. Test script: --------------- class Test { private $props = ['a' => 'text', 'b' => 1]; public function &__get($prop) { return $this->props[$prop]; } public function __set($prop, $value) { if ($prop === 'b') $value = [$value]; $this->props[$prop] = $value; } public function getProperties() { return [$this->props]; } } $obj = new Test; $obj->b = $obj->b; print_r($obj->getProperties()); Expected result: ---------------- Array ( [0] => Array ( [a] => text [b] => Array ( [0] => 1 ) ) ) Actual result: -------------- Array ( [0] => Array ( [a] => text [b] => Array *RECURSION* ) )