php-src/Zend/tests/function_default_argument_cache.phpt
Ilija Tovilo 8731fb2d09
Fix caching of default params with side-effects
Fixes GH-9965
Closes GH-9935
2022-11-17 11:52:12 +01:00

25 lines
361 B
PHP

--TEST--
Function default argument is not cached when its evaluation had side effects
--FILE--
<?php
class Foo {
public function __toString() {
static $i = 0;
return (string) $i++;
}
}
function test(string $foo = new Foo() . '') {
var_dump($foo);
}
test();
test();
test();
?>
--EXPECT--
string(1) "0"
string(1) "1"
string(1) "2"