Bug #77797 [Opn->Dup]: Array assignment

From: Date: Tue, 26 Mar 2019 12:35:07 +0000
Subject: Bug #77797 [Opn->Dup]: Array assignment
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220187@lists.php.net to get a copy of this message
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)

« previous php.bugs (#220187) next »