php-src/Zend/tests/gh12102_2.phpt
Ilija Tovilo 748adf18fc
Fix zend_separate_if_call_and_write for FUNC_ARGs
Fixes GH-12102
Closees GH-12140
2023-09-07 14:25:11 +02:00

44 lines
640 B
PHP

--TEST--
GH-12102: Incorrect "Cannot use temporary expression in write context" error for BP_VAR_FUNC_ARG
--FILE--
<?php
function test() {
global $ref;
byVal(getRef()[0]);
var_dump($ref);
byRef(getRef()[0]);
var_dump($ref);
}
/* Intentionally declared after test() to avoid compile-time checking of ref args. */
function &getRef() {
global $ref;
$ref = [];
return $ref;
}
function byVal($arg) {
$arg[] = 42;
}
function byRef(&$arg) {
$arg[] = 42;
}
test();
?>
--EXPECTF--
Warning: Undefined array key 0 in %s on line %d
array(0) {
}
array(1) {
[0]=>
array(1) {
[0]=>
int(42)
}
}