28#define ZEND_ENUM_DISALLOW_MAGIC_METHOD(propertyName, methodName) \
30 if (ce->propertyName) { \
31 zend_error_noreturn(E_COMPILE_ERROR, "Enum %s cannot include magic method %s", ZSTR_VAL(ce->name), methodName); \
49 if (backing_value_zv !=
NULL) {
65 if (zend_string_equals(property_info->
name,
ZSTR_KNOWN(ZEND_STR_NAME))) {
70 && zend_string_equals(property_info->
name,
ZSTR_KNOWN(ZEND_STR_VALUE))
96 static const char *
const forbidden_methods[] = {
102 uint32_t forbidden_methods_length =
sizeof(forbidden_methods) /
sizeof(forbidden_methods[0]);
103 for (uint32_t i = 0; i < forbidden_methods_length; ++i) {
104 const char *forbidden_method = forbidden_methods[i];
116 "Enum %s cannot implement the Serializable interface",
ZSTR_VAL(ce->
name));
122 zend_verify_enum_properties(ce);
123 zend_verify_enum_magic_methods(ce);
124 zend_verify_enum_interfaces(ce);
206 zend_class_set_backed_enum_table(ce, backed_enum_table);
219 zval *case_name = zend_enum_fetch_case_name(
Z_OBJ_P(c_value));
220 zval *case_value = zend_enum_fetch_case_value(
Z_OBJ_P(c_value));
223 zend_type_error(
"Enum case type %s does not match enum backing type %s",
232 if (existing_case_name) {
245 if (existing_case_name !=
NULL) {
260 zend_hash_release(backed_enum_table);
261 zend_class_set_backed_enum_table(ce,
NULL);
298 if (!backed_enum_table) {
311 if (case_name_zv ==
NULL) {
346 bool release_string =
false;
371 release_string =
true;
382 if (case_obj ==
NULL) {
387 if (release_string) {
388 zend_string_release(string_key);
393 if (release_string) {
394 zend_string_release(string_key);
399 if (release_string) {
400 zend_string_release(string_key);
441 const uint32_t fn_flags =
444 cases_function->
handler = zend_enum_cases_func;
446 cases_function->
fn_flags = fn_flags;
449 zend_enum_register_func(ce, ZEND_STR_CASES, cases_function);
453 from_function->
handler = zend_enum_from_func;
460 zend_enum_register_func(ce, ZEND_STR_FROM, from_function);
463 try_from_function->
handler = zend_enum_try_from_func;
465 try_from_function->
fn_flags = fn_flags;
470 zend_enum_register_func(ce, ZEND_STR_TRYFROM_LOWERCASE, try_from_function);
478 zval name_default_value;
484 zval value_default_value;
517 zend_class_set_backed_enum_table(ce, backed_enum_table);
610 zend_string_release(name_str);
630 zend_string_release(name_str);
foreach($dp as $el) foreach( $dp as $el) if( $pass2< 2) echo ""
php_output_handler * active
HashTable properties_info
zend_class_name * interface_names
uint32_t enum_backing_type
const zend_object_handlers * default_object_handlers
uint32_t required_num_args
zend_string * function_name
struct _zend_module_entry * module
zend_internal_arg_info * arg_info
zend_string * doc_comment
ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_noreturn(int type, const char *format,...)
ZEND_API ZEND_COLD void zend_throw_error(zend_class_entry *exception_ce, const char *format,...)
ZEND_API ZEND_COLD void zend_type_error(const char *format,...)
ZEND_API ZEND_COLD void zend_value_error(const char *format,...)
struct _zend_class_name zend_class_name
#define INTERNAL_FUNCTION_PARAMETERS
#define INTERNAL_FUNCTION_PARAM_PASSTHRU
ZEND_API zend_result zend_update_class_constants(zend_class_entry *class_type)
ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend_function_entry *functions, HashTable *function_table, int type)
ZEND_API const char * zend_get_type_by_const(int type)
ZEND_API zend_property_info * zend_declare_typed_property(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment, zend_type type)
ZEND_API zend_class_entry * zend_register_internal_class(zend_class_entry *orig_class_entry)
ZEND_API void zend_class_implements(zend_class_entry *class_entry, int num_interfaces,...)
ZEND_API zend_class_constant * zend_declare_class_constant_ex(zend_class_entry *ce, zend_string *name, zval *value, int flags, zend_string *doc_comment)
#define ZEND_NAMED_ME(zend_name, name, arg_info, flags)
#define INIT_CLASS_ENTRY_EX(class_container, class_name, class_name_len, functions)
#define ZEND_PARSE_PARAMETERS_END()
struct _zend_function_entry zend_function_entry
#define ZEND_PARSE_PARAMETERS_NONE()
#define Z_PARAM_STR(dest)
#define ZEND_PARSE_PARAMETERS_START(min_num_args, max_num_args)
#define Z_PARAM_LONG(dest)
#define RETURN_OBJ_COPY(r)
#define CE_CONSTANTS_TABLE(ce)
#define ZEND_NAMED_FUNCTION(name)
#define Z_PARAM_STR_OR_LONG(dest_str, dest_long)
#define CE_BACKED_ENUM_TABLE(ce)
#define pemalloc(size, persistent)
#define erealloc(ptr, size)
struct _zend_ast_zval zend_ast_zval
@ ZEND_AST_CONST_ENUM_INIT
zend_string * zval_make_interned_string(zval *zv)
#define ZEND_ACC_NO_DYNAMIC_PROPERTIES
#define OBJ_PROP_NUM(obj, num)
#define ZEND_COMPILE_PRELOAD
#define ZEND_INTERNAL_FUNCTION
#define ZEND_CLASS_CONST_FLAGS(c)
#define ZEND_ACC_READONLY
struct _zend_class_constant zend_class_constant
struct _zend_property_info zend_property_info
#define ZEND_ACC_PRELOADED
#define ZEND_ACC_CONSTANTS_UPDATED
struct _zend_internal_arg_info zend_internal_arg_info
#define ZEND_ACC_HAS_RETURN_TYPE
#define ZEND_ACC_RESOLVED_INTERFACES
#define ZEND_ACC_ARENA_ALLOCATED
#define ZEND_CLASS_CONST_IS_CASE
struct _zend_internal_function zend_internal_function
#define ZEND_ARG_USES_STRICT_TYPES()
ZEND_API zend_class_entry * zend_ce_unit_enum
ZEND_API zend_result zend_enum_get_case_by_value(zend_object **result, zend_class_entry *ce, zend_long long_key, zend_string *string_key, bool try_from)
ZEND_API zend_object_handlers zend_enum_object_handlers
ZEND_API zend_object * zend_enum_get_case(zend_class_entry *ce, zend_string *name)
void zend_verify_enum(const zend_class_entry *ce)
ZEND_API zend_class_entry * zend_ce_backed_enum
ZEND_API zend_class_entry * zend_register_internal_enum(const char *name, uint8_t type, const zend_function_entry *functions)
zend_result zend_enum_build_backed_enum_table(zend_class_entry *ce)
void zend_enum_register_funcs(zend_class_entry *ce)
void zend_enum_register_props(zend_class_entry *ce)
ZEND_API void zend_enum_add_case_cstr(zend_class_entry *ce, const char *name, zval *value)
ZEND_API void zend_enum_add_case(zend_class_entry *ce, zend_string *case_name, zval *value)
void zend_enum_add_interfaces(zend_class_entry *ce)
#define ZEND_ENUM_DISALLOW_MAGIC_METHOD(propertyName, methodName)
ZEND_API zend_object * zend_enum_get_case_cstr(zend_class_entry *ce, const char *name)
zend_object * zend_enum_new(zval *result, zend_class_entry *ce, zend_string *case_name, zval *backing_value_zv)
void zend_register_enum_ce(void)
ZEND_API zend_result ZEND_FASTCALL zval_update_constant_ex(zval *pp, zend_class_entry *scope)
ZEND_API size_t zend_internal_run_time_cache_reserved_size(void)
ZEND_API zval *ZEND_FASTCALL zend_hash_next_index_insert_new(HashTable *ht, zval *pData)
ZEND_API zval *ZEND_FASTCALL zend_hash_index_add_new(HashTable *ht, zend_ulong h, zval *pData)
ZEND_API zval *ZEND_FASTCALL zend_hash_add_new(HashTable *ht, zend_string *key, zval *pData)
ZEND_API zval *ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key)
ZEND_API zval *ZEND_FASTCALL zend_hash_index_find(const HashTable *ht, zend_ulong h)
#define zend_hash_init(ht, nSize, pHashFunction, pDestructor, persistent)
#define ZEND_HASH_MAP_FOREACH_PTR(ht, _ptr)
#define ZEND_HASH_FOREACH_END()
#define ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(ht, _key, _val)
ZEND_API zend_class_entry * zend_ce_serializable
struct _zend_string zend_string
#define ZEND_MAP_PTR_INIT(ptr, val)
#define ZEND_MAP_PTR_NEW_STATIC(ptr)
ZEND_API int zend_objects_not_comparable(zval *o1, zval *o2)
ZEND_API const zend_object_handlers std_object_handlers
ZEND_API zend_object *ZEND_FASTCALL zend_objects_new(zend_class_entry *ce)
#define ZEND_OBSERVER_ENABLED
ZEND_API zend_string *ZEND_FASTCALL zend_long_to_str(zend_long num)
ZEND_API bool ZEND_FASTCALL zend_class_implements_interface(const zend_class_entry *class_ce, const zend_class_entry *interface_ce)
#define ZEND_UNREACHABLE()
struct _zend_class_entry zend_class_entry
struct _zend_object zend_object
ZEND_API zend_string_init_interned_func_t zend_string_init_interned
#define ZSTR_IS_INTERNED(s)
enum _zend_known_string_id zend_known_string_id
#define ZSTR_INIT_LITERAL(s, persistent)
struct _zend_ast_ref zend_ast_ref
#define Z_TRY_ADDREF_P(pz)
#define GC_SET_REFCOUNT(p, rc)
#define Z_STRVAL_P(zval_p)
#define Z_ARRVAL_P(zval_p)
#define Z_REFCOUNTED_P(zval_p)
#define ZVAL_STR_COPY(z, s)
struct _zend_array HashTable
#define Z_LINENO_P(zval_p)
#define ZEND_TYPE_INIT_CODE(code, allow_null, extra_flags)
#define Z_TYPE_INFO(zval)
ZEND_RESULT_CODE zend_result
struct _zend_object_handlers zend_object_handlers
struct _zend_ast zend_ast
#define ZVAL_COPY_VALUE(z, v)