Bug #77797 [NEW]: Array assignment
From: taco at procurios dot nl
Operating system: linux
PHP version: 7.2.16
Package: Unknown/Other Function
Bug Type: Bug
Bug description:Array assignment
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 bug report at https://bugs.php.net/bug.php?id=77797&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77797&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77797&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77797&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77797&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77797&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77797&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77797&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77797&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77797&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77797&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77797&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77797&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77797&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77797&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77797&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77797&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77797&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77797&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77797&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77797&r=mysqlcfg
Thread (2 messages)
- taco at procurios dot nl