1
0
mirror of https://github.com/php/php-src.git synced 2026-04-26 17:38:14 +02:00
Files
archived-php-src/Zend/tests/constexpr/new_not_allowed_class_constant.phpt
T
Nikita Popov 52d3d0d8d7 Add limited support for new in initializers
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.
2021-07-13 14:03:20 +02:00

19 lines
631 B
PHP

--TEST--
New not allowed in class constant
--FILE--
<?php
// New in class constants (and static properties) brings up evaluation order questions: When
// should the (potentially side-effecting) new expression be evaluated? Evaluating it when the
// class is declared would break references to classes that are declared later in the same
// file. On the other hand, the current lazy evaluation of initializers is somewhat ill-defined
// when we start considering side-effecting expressions.
class Test {
const X = new stdClass;
}
?>
--EXPECTF--
Fatal error: New expressions are not supported in this context in %s on line %d