mirror of
https://github.com/php/php-src.git
synced 2026-04-19 05:51:02 +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.
40 lines
641 B
PHP
40 lines
641 B
PHP
--TEST--
|
|
new self / new parent in constant expression
|
|
--FILE--
|
|
<?php
|
|
|
|
class A {
|
|
public static function invalid($x = new parent) {
|
|
}
|
|
}
|
|
class B extends A {
|
|
public static function method($x = new self, $y = new parent) {
|
|
var_dump($x, $y);
|
|
}
|
|
}
|
|
|
|
function invalid($x = new self) {}
|
|
|
|
B::method();
|
|
|
|
try {
|
|
invalid();
|
|
} catch (Error $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
try {
|
|
B::invalid();
|
|
} catch (Error $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
object(B)#1 (0) {
|
|
}
|
|
object(A)#2 (0) {
|
|
}
|
|
Cannot access "self" when no class scope is active
|
|
Cannot access "parent" when current class scope has no parent
|