|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-03-26 12:35 UTC] nikic@php.net
-Status: Open
+Status: Duplicate
[2019-03-26 12:35 UTC] nikic@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 17:00:01 2025 UTC |
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" }