php-src/Zend/tests/static_variables_throwing_initializer.phpt
Ilija Tovilo 50217b35ea
Remove IS_STATIC_VAR_UNINITIALIZED (#15227)
This flag was never necessary. We know a static variable is uninitialized (i.e.
the initializer has never been called) iff the zval in the static variable array
does not contain a reference.

Prompted by a related issue in ext-uopz reported by Christoph.
2024-08-05 11:19:13 +02:00

21 lines
340 B
PHP

--TEST--
Static variable with throwing initializer
--FILE--
<?php
function foo($throw) {
static $a = $throw ? (throw new Exception('Throwing from foo()')) : 42;
return $a;
}
try {
var_dump(foo(true));
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
var_dump(foo(false));
?>
--EXPECT--
Throwing from foo()
int(42)