Skip to content

Commit 5a18279

Browse files
Fix GH-15731: Prevent #[AllowDynamicProperties] on enums (#15733)
1 parent 6435bb5 commit 5a18279

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
#[AllowDynamicProperties] cannot be applied to enum (GH-15731)
3+
--FILE--
4+
<?php
5+
6+
#[AllowDynamicProperties]
7+
enum Test {}
8+
9+
?>
10+
--EXPECTF--
11+
Fatal error: Cannot apply #[AllowDynamicProperties] to enum Test in %s on line %d

Zend/zend_attributes.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ static void validate_allow_dynamic_properties(
8686
ZSTR_VAL(scope->name)
8787
);
8888
}
89+
if (scope->ce_flags & ZEND_ACC_ENUM) {
90+
zend_error_noreturn(E_ERROR, "Cannot apply #[AllowDynamicProperties] to enum %s",
91+
ZSTR_VAL(scope->name)
92+
);
93+
}
8994
scope->ce_flags |= ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES;
9095
}
9196

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy