Skip to content

Commit c8de323

Browse files
Fix GH-15731: Prevent #[AllowDynamicProperties] on enums
1 parent eb87de1 commit c8de323

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-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 in %s on line %d

Zend/zend_attributes.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ static void validate_allow_dynamic_properties(
8484
ZSTR_VAL(scope->name)
8585
);
8686
}
87+
if (scope->ce_flags & ZEND_ACC_ENUM) {
88+
zend_error_noreturn(E_ERROR, "Cannot apply #[AllowDynamicProperties] to enum");
89+
}
8790
scope->ce_flags |= ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES;
8891
}
8992

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