Bug #77951 [Opn->Fbk]: ReflectionReference bugs recounting

From: Date: Mon, 29 Apr 2019 06:48:25 +0000
Subject: Bug #77951 [Opn->Fbk]: ReflectionReference bugs recounting
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220639@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:         requinix@php.net
 Reported by:        nicolas dot grekas+php at gmail dot com
 Summary:            ReflectionReference bugs recounting
-Status:             Open
+Status:             Feedback
 Type:               Bug
 Package:            Reflection related
 PHP Version:        Next Minor Version
 Block user comment: N
 Private report:     N

 New Comment:

It's working for me, with both 7.4 and 8.0 built earlier today. What version/commit are you
testing with?


Previous Comments:
------------------------------------------------------------------------
[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


Thread (6 messages)

« previous php.bugs (#220639) next »