Bug #77797 [Opn->Dup]: Array assignment
Edit report at https://bugs.php.net/bug.php?id=77797&edit=1
ID: 77797
Updated by: nikic@php.net
Reported by: taco at procurios dot nl
Summary: Array assignment
-Status: Open
+Status: Duplicate
Type: Bug
Package: Unknown/Other Function
Operating System: linux
PHP Version: 7.2.16
Block user comment: N
Private report: N
New Comment:
Duplicate of bug #77691, which has been fixed in 7.2.17.
Previous Comments:
------------------------------------------------------------------------
[2019-03-26 12:27:36] taco at procurios dot nl
Description:
------------
When passing an array append assignment directly to a public or protected method with opcache
enabled, the array itself is passed to the method instead of the assigned value. Calling private
methods or functions will not trigger this behaviour.
This behaviour only occurs with opcache enabled (tested both in cli and as apache module), so
you'll need to run it at least twice to see the faulty behaviour.
Test script:
---------------
<?php
class Foo
{
public function baz($arg)
{
return $arg;
}
public function bar()
{
$a = [];
return $this->baz($a[] = 'foo');
}
}
$foo = new Foo();
var_dump($foo->bar());
Expected result:
----------------
string(3) "foo"
Actual result:
--------------
array(1) {
[0] =>
string(3) "foo"
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77797&edit=1
Thread (2 messages)