mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
e52684ea8a
This fixes the oversight that an anonymous class should be able to be readonly. Other identifiers such as final and abstract do not make sense. As we still want nice errors for when users try to use these modifiers, or use multiple modifiers, we introduce a new function zend_add_anonymous_class_modifier that will perform verification for anonymous class modifiers, just like zend_add_class_modifier does for non-anonymous classes. Closes GH-10381
16 lines
397 B
PHP
16 lines
397 B
PHP
--TEST--
|
|
GH-10377 (Unable to have an anonymous readonly class) - usage variation: dynamic properties attribute
|
|
--FILE--
|
|
<?php
|
|
|
|
$readonly_anon = new #[AllowDynamicProperties] readonly class {
|
|
public int $field;
|
|
function __construct() {
|
|
$this->field = 2;
|
|
}
|
|
};
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Fatal error: Cannot apply #[AllowDynamicProperties] to readonly class class@anonymous in %s on line %d
|