Bug #78263 [Opn]: \ReflectionReference::fromArrayElement() returns null while item is a reference

From: Date: Mon, 08 Jul 2019 13:33:39 +0000
Subject: Bug #78263 [Opn]: \ReflectionReference::fromArrayElement() returns null while item is a reference
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-221659@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78263&edit=1 ID: 78263 Updated by: nikic@php.net Reported by: nicolas dot grekas+php at gmail dot com Summary: \ReflectionReference::fromArrayElement() returns null while item is a reference Status: Open Type: Bug Package: Reflection related PHP Version: 7.4Git-2019-07-08 (Git) Block user comment: N Private report: N New Comment: Null is returned here because it is an rc=1 reference, as requested in bug #77951. Does that mean that we should return non-null for rc=1 references after all? Previous Comments: ------------------------------------------------------------------------ [2019-07-08 13:13:46] nicolas dot grekas+php at gmail dot com Description: ------------ See reproducer: Test script: --------------- $var = function &() { $var = []; $var[] = &$var; return $var; }; $var = [$var()]; function isref1(array $a, string $k) { return null !== \ReflectionReference::fromArrayElement($a, $k); } function isref2(array $a, string $k) { $v = $a[$k]; $b = $a; $b[$k] = $c = new \stdClass(); if ($a[$k] === $c) { $a[$k] = $v; return true; } return false; } var_dump($var); var_dump([isref1($var[0], 0), isref2($var[0], 0)]); Expected result: ---------------- array(1) { [0]=> array(1) { [0]=> *RECURSION* } } array(2) { [0]=> bool(false) [1]=> bool(true) } Actual result: -------------- array(1) { [0]=> array(1) { [0]=> *RECURSION* } } array(2) { [0]=> bool(true) [1]=> bool(true) } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78263&edit=1

« previous php.bugs (#221659) next »