mirror of
https://github.com/php/php-src.git
synced 2024-11-26 19:33:55 +08:00
Fix GH-15731: Prevent #[AllowDynamicProperties]
on enums (#15733)
This commit is contained in:
parent
6435bb5ae1
commit
5a18279b5d
11
Zend/tests/allow_dynamic_properties_on_enum.phpt
Normal file
11
Zend/tests/allow_dynamic_properties_on_enum.phpt
Normal file
@ -0,0 +1,11 @@
|
||||
--TEST--
|
||||
#[AllowDynamicProperties] cannot be applied to enum (GH-15731)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
#[AllowDynamicProperties]
|
||||
enum Test {}
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Cannot apply #[AllowDynamicProperties] to enum Test in %s on line %d
|
@ -86,6 +86,11 @@ static void validate_allow_dynamic_properties(
|
||||
ZSTR_VAL(scope->name)
|
||||
);
|
||||
}
|
||||
if (scope->ce_flags & ZEND_ACC_ENUM) {
|
||||
zend_error_noreturn(E_ERROR, "Cannot apply #[AllowDynamicProperties] to enum %s",
|
||||
ZSTR_VAL(scope->name)
|
||||
);
|
||||
}
|
||||
scope->ce_flags |= ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user