mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Fix GH-15731: Prevent #[AllowDynamicProperties] on enums (#15733)
This commit is contained in:
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user