mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00

Add support for new expressions inside parameter default values, static variable initializers, global constant initializers and attribute arguments. RFC: https://wiki.php.net/rfc/new_in_initializers Closes GH-7153.
27 lines
503 B
PHP
27 lines
503 B
PHP
--TEST--
|
|
Handling of new in constant expressions in reflection
|
|
--FILE--
|
|
<?php
|
|
|
|
function test1() {
|
|
static $x = new stdClass;
|
|
return $x;
|
|
}
|
|
|
|
$rf = new ReflectionFunction('test1');
|
|
$s = $rf->getStaticVariables();
|
|
var_dump($s['x'] === test1());
|
|
|
|
function test2($x = new stdClass) {
|
|
return $x;
|
|
}
|
|
|
|
$rf = new ReflectionFunction('test2');
|
|
$rp = $rf->getParameters()[0];
|
|
// Parameter default should *not* be the same.
|
|
var_dump($rp->getDefaultValue() !== test2());
|
|
|
|
?>
|
|
--EXPECT--
|
|
bool(true)
|
|
bool(true)
|