Bug #77951 [Opn]: ReflectionReference bugs recounting

From: Date: Mon, 29 Apr 2019 08:07:27 +0000
Subject: Bug #77951 [Opn]: ReflectionReference bugs recounting
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220642@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77951&edit=1 ID: 77951 Updated by: nikic@php.net Reported by: nicolas dot grekas+php at gmail dot com Summary: ReflectionReference bugs recounting Status: Open Type: Bug Package: Reflection related PHP Version: Next Minor Version -Assigned To: +Assigned To: nikic Block user comment: N Private report: N New Comment: Not sure whether we should return null or add a method to detect singleton references. Previous Comments: ------------------------------------------------------------------------ [2019-04-29 07:53:56] nicolas dot grekas+php at gmail dot com I'm using devilbox-php-fpm-7-4 docker image, freshly pulled php -v returns: PHP 7.4.0-dev (cli) (built: Apr 28 2019 22:36:49) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0-dev, Copyright (c) Zend Technologies ------------------------------------------------------------------------ [2019-04-29 06:48:25] requinix@php.net It's working for me, with both 7.4 and 8.0 built earlier today. What version/commit are you testing with? ------------------------------------------------------------------------ [2019-04-29 06:40:40] nicolas dot grekas+php at gmail dot com Description: ------------ ReflectionReference must have a bug with zval that have is_ref=1 but refcount=1 Test script: --------------- $a = [1, 2]; foreach ($a as &$v) { } // This should return null but instead it returns a ReflectionReference. // a few lines below, $b[0] becomes a reference to $a[0] // while this is not the case when this line is commented. $r = ReflectionReference::fromArrayElement($a, 0); $b = $a; $b[0] = 123; var_dump($a); var_dump($b); Expected result: ---------------- array(2) { [0]=> int(1) [1]=> &int(2) } array(2) { [0]=> int(123) [1]=> &int(2) } Actual result: -------------- array(2) { [0]=> &int(123) [1]=> &int(2) } array(2) { [0]=> &int(123) [1]=> &int(2) } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77951&edit=1

« previous php.bugs (#220642) next »