php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
zend_enum.c
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Zend Engine |
4 +----------------------------------------------------------------------+
5 | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 2.00 of the Zend license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.zend.com/license/2_00.txt. |
11 | If you did not receive a copy of the Zend license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@zend.com so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
15 | Authors: Ilija Tovilo <ilutov@php.net> |
16 +----------------------------------------------------------------------+
17*/
18
19#include "zend.h"
20#include "zend_API.h"
21#include "zend_compile.h"
22#include "zend_enum_arginfo.h"
23#include "zend_interfaces.h"
24#include "zend_enum.h"
25#include "zend_extensions.h"
26#include "zend_observer.h"
27
28#define ZEND_ENUM_DISALLOW_MAGIC_METHOD(propertyName, methodName) \
29 do { \
30 if (ce->propertyName) { \
31 zend_error_noreturn(E_COMPILE_ERROR, "Enum %s cannot include magic method %s", ZSTR_VAL(ce->name), methodName); \
32 } \
33 } while (0);
34
38
40{
43
44 zval *zname = OBJ_PROP_NUM(zobj, 0);
45 ZVAL_STR_COPY(zname, case_name);
46 /* ZVAL_COPY does not set Z_PROP_FLAG, this needs to be cleared to avoid leaving IS_PROP_REINITABLE set */
47 Z_PROP_FLAG_P(zname) = 0;
48
49 if (backing_value_zv != NULL) {
50 zval *prop = OBJ_PROP_NUM(zobj, 1);
51
52 ZVAL_COPY(prop, backing_value_zv);
53 /* ZVAL_COPY does not set Z_PROP_FLAG, this needs to be cleared to avoid leaving IS_PROP_REINITABLE set */
54 Z_PROP_FLAG_P(prop) = 0;
55 }
56
57 return zobj;
58}
59
60static void zend_verify_enum_properties(const zend_class_entry *ce)
61{
62 const zend_property_info *property_info;
63
64 ZEND_HASH_MAP_FOREACH_PTR(&ce->properties_info, property_info) {
65 if (zend_string_equals(property_info->name, ZSTR_KNOWN(ZEND_STR_NAME))) {
66 continue;
67 }
68 if (
70 && zend_string_equals(property_info->name, ZSTR_KNOWN(ZEND_STR_VALUE))
71 ) {
72 continue;
73 }
74 // FIXME: File/line number for traits?
75 zend_error_noreturn(E_COMPILE_ERROR, "Enum %s cannot include properties",
76 ZSTR_VAL(ce->name));
78}
79
80static void zend_verify_enum_magic_methods(const zend_class_entry *ce)
81{
82 // Only __get, __call and __invoke are allowed
83
84 ZEND_ENUM_DISALLOW_MAGIC_METHOD(constructor, "__construct");
85 ZEND_ENUM_DISALLOW_MAGIC_METHOD(destructor, "__destruct");
86 ZEND_ENUM_DISALLOW_MAGIC_METHOD(clone, "__clone");
87 ZEND_ENUM_DISALLOW_MAGIC_METHOD(__get, "__get");
88 ZEND_ENUM_DISALLOW_MAGIC_METHOD(__set, "__set");
89 ZEND_ENUM_DISALLOW_MAGIC_METHOD(__unset, "__unset");
90 ZEND_ENUM_DISALLOW_MAGIC_METHOD(__isset, "__isset");
91 ZEND_ENUM_DISALLOW_MAGIC_METHOD(__tostring, "__toString");
92 ZEND_ENUM_DISALLOW_MAGIC_METHOD(__debugInfo, "__debugInfo");
93 ZEND_ENUM_DISALLOW_MAGIC_METHOD(__serialize, "__serialize");
94 ZEND_ENUM_DISALLOW_MAGIC_METHOD(__unserialize, "__unserialize");
95
96 static const char *const forbidden_methods[] = {
97 "__sleep",
98 "__wakeup",
99 "__set_state",
100 };
101
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];
105
106 if (zend_hash_str_exists(&ce->function_table, forbidden_method, strlen(forbidden_method))) {
107 zend_error_noreturn(E_COMPILE_ERROR, "Enum %s cannot include magic method %s", ZSTR_VAL(ce->name), forbidden_method);
108 }
109 }
110}
111
112static void zend_verify_enum_interfaces(const zend_class_entry *ce)
113{
116 "Enum %s cannot implement the Serializable interface", ZSTR_VAL(ce->name));
117 }
118}
119
121{
122 zend_verify_enum_properties(ce);
123 zend_verify_enum_magic_methods(ce);
124 zend_verify_enum_interfaces(ce);
125}
126
127static int zend_implement_unit_enum(zend_class_entry *interface, zend_class_entry *class_type)
128{
129 if (class_type->ce_flags & ZEND_ACC_ENUM) {
130 return SUCCESS;
131 }
132
133 zend_error_noreturn(E_ERROR, "Non-enum class %s cannot implement interface %s",
134 ZSTR_VAL(class_type->name),
135 ZSTR_VAL(interface->name));
136
137 return FAILURE;
138}
139
140static int zend_implement_backed_enum(zend_class_entry *interface, zend_class_entry *class_type)
141{
142 if (!(class_type->ce_flags & ZEND_ACC_ENUM)) {
143 zend_error_noreturn(E_ERROR, "Non-enum class %s cannot implement interface %s",
144 ZSTR_VAL(class_type->name),
145 ZSTR_VAL(interface->name));
146 return FAILURE;
147 }
148
149 if (class_type->enum_backing_type == IS_UNDEF) {
150 zend_error_noreturn(E_ERROR, "Non-backed enum %s cannot implement interface %s",
151 ZSTR_VAL(class_type->name),
152 ZSTR_VAL(interface->name));
153 return FAILURE;
154 }
155
156 return SUCCESS;
157}
158
160{
161 zend_ce_unit_enum = register_class_UnitEnum();
162 zend_ce_unit_enum->interface_gets_implemented = zend_implement_unit_enum;
163
164 zend_ce_backed_enum = register_class_BackedEnum(zend_ce_unit_enum);
165 zend_ce_backed_enum->interface_gets_implemented = zend_implement_backed_enum;
166
170}
171
173{
174 uint32_t num_interfaces_before = ce->num_interfaces;
175
176 ce->num_interfaces++;
177 if (ce->enum_backing_type != IS_UNDEF) {
178 ce->num_interfaces++;
179 }
180
182
184
185 ce->interface_names[num_interfaces_before].name = zend_string_copy(zend_ce_unit_enum->name);
186 ce->interface_names[num_interfaces_before].lc_name = ZSTR_INIT_LITERAL("unitenum", 0);
187
188 if (ce->enum_backing_type != IS_UNDEF) {
189 ce->interface_names[num_interfaces_before + 1].name = zend_string_copy(zend_ce_backed_enum->name);
190 ce->interface_names[num_interfaces_before + 1].lc_name = ZSTR_INIT_LITERAL("backedenum", 0);
191 }
192
194}
195
197{
200
201 uint32_t backing_type = ce->enum_backing_type;
202 ZEND_ASSERT(backing_type != IS_UNDEF);
203
204 HashTable *backed_enum_table = emalloc(sizeof(HashTable));
205 zend_hash_init(backed_enum_table, 0, NULL, ZVAL_PTR_DTOR, 0);
206 zend_class_set_backed_enum_table(ce, backed_enum_table);
207
208 const zend_string *enum_class_name = ce->name;
209
211 zval *val;
215 continue;
216 }
217
218 zval *c_value = &c->value;
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));
221
222 if (ce->enum_backing_type != Z_TYPE_P(case_value)) {
223 zend_type_error("Enum case type %s does not match enum backing type %s",
224 zend_get_type_by_const(Z_TYPE_P(case_value)),
226 goto failure;
227 }
228
229 if (ce->enum_backing_type == IS_LONG) {
230 zend_long long_key = Z_LVAL_P(case_value);
231 const zval *existing_case_name = zend_hash_index_find(backed_enum_table, long_key);
232 if (existing_case_name) {
233 zend_throw_error(NULL, "Duplicate value in enum %s for cases %s and %s",
234 ZSTR_VAL(enum_class_name),
235 Z_STRVAL_P(existing_case_name),
236 ZSTR_VAL(name));
237 goto failure;
238 }
239 Z_TRY_ADDREF_P(case_name);
240 zend_hash_index_add_new(backed_enum_table, long_key, case_name);
241 } else {
243 zend_string *string_key = Z_STR_P(case_value);
244 const zval *existing_case_name = zend_hash_find(backed_enum_table, string_key);
245 if (existing_case_name != NULL) {
246 zend_throw_error(NULL, "Duplicate value in enum %s for cases %s and %s",
247 ZSTR_VAL(enum_class_name),
248 Z_STRVAL_P(existing_case_name),
249 ZSTR_VAL(name));
250 goto failure;
251 }
252 Z_TRY_ADDREF_P(case_name);
253 zend_hash_add_new(backed_enum_table, string_key, case_name);
254 }
256
257 return SUCCESS;
258
259failure:
260 zend_hash_release(backed_enum_table);
261 zend_class_set_backed_enum_table(ce, NULL);
262 return FAILURE;
263}
264
265static ZEND_NAMED_FUNCTION(zend_enum_cases_func)
266{
267 zend_class_entry *ce = execute_data->func->common.scope;
269
271
273
276 continue;
277 }
278 zval *zv = &c->value;
279 if (Z_TYPE_P(zv) == IS_CONSTANT_AST) {
280 if (zval_update_constant_ex(zv, c->ce) == FAILURE) {
282 }
283 }
284 Z_ADDREF_P(zv);
287}
288
290{
293 return FAILURE;
294 }
295 }
296
297 const HashTable *backed_enum_table = CE_BACKED_ENUM_TABLE(ce);
298 if (!backed_enum_table) {
299 goto not_found;
300 }
301
302 zval *case_name_zv;
303 if (ce->enum_backing_type == IS_LONG) {
304 case_name_zv = zend_hash_index_find(backed_enum_table, long_key);
305 } else {
307 ZEND_ASSERT(string_key != NULL);
308 case_name_zv = zend_hash_find(backed_enum_table, string_key);
309 }
310
311 if (case_name_zv == NULL) {
312not_found:
313 if (try_from) {
314 *result = NULL;
315 return SUCCESS;
316 }
317
318 if (ce->enum_backing_type == IS_LONG) {
319 zend_value_error(ZEND_LONG_FMT " is not a valid backing value for enum %s", long_key, ZSTR_VAL(ce->name));
320 } else {
322 zend_value_error("\"%s\" is not a valid backing value for enum %s", ZSTR_VAL(string_key), ZSTR_VAL(ce->name));
323 }
324 return FAILURE;
325 }
326
327 // TODO: We might want to store pointers to constants in backed_enum_table instead of names,
328 // to make this lookup more efficient.
329 ZEND_ASSERT(Z_TYPE_P(case_name_zv) == IS_STRING);
330 zend_class_constant *c = zend_hash_find_ptr(CE_CONSTANTS_TABLE(ce), Z_STR_P(case_name_zv));
331 ZEND_ASSERT(c != NULL);
332 zval *case_zv = &c->value;
333 if (Z_TYPE_P(case_zv) == IS_CONSTANT_AST) {
334 if (zval_update_constant_ex(case_zv, c->ce) == FAILURE) {
335 return FAILURE;
336 }
337 }
338
339 *result = Z_OBJ_P(case_zv);
340 return SUCCESS;
341}
342
343static void zend_enum_from_base(INTERNAL_FUNCTION_PARAMETERS, bool try_from)
344{
345 zend_class_entry *ce = execute_data->func->common.scope;
346 bool release_string = false;
347 zend_string *string_key = NULL;
348 zend_long long_key = 0;
349
350 if (ce->enum_backing_type == IS_LONG) {
352 Z_PARAM_LONG(long_key)
354 } else {
356
359 Z_PARAM_STR(string_key)
361 } else {
362 // We allow long keys so that coercion to string doesn't happen implicitly. The JIT
363 // skips deallocation of params that don't require it. In the case of from/tryFrom
364 // passing int to from(int|string) looks like no coercion will happen, so the JIT
365 // won't emit a dtor call. Thus we allocate/free the string manually.
367 Z_PARAM_STR_OR_LONG(string_key, long_key)
369
370 if (string_key == NULL) {
371 release_string = true;
372 string_key = zend_long_to_str(long_key);
373 }
374 }
375 }
376
377 zend_object *case_obj;
378 if (zend_enum_get_case_by_value(&case_obj, ce, long_key, string_key, try_from) == FAILURE) {
379 goto throw;
380 }
381
382 if (case_obj == NULL) {
383 ZEND_ASSERT(try_from);
384 goto return_null;
385 }
386
387 if (release_string) {
388 zend_string_release(string_key);
389 }
390 RETURN_OBJ_COPY(case_obj);
391
392throw:
393 if (release_string) {
394 zend_string_release(string_key);
395 }
397
398return_null:
399 if (release_string) {
400 zend_string_release(string_key);
401 }
402 RETURN_NULL();
403}
404
405static ZEND_NAMED_FUNCTION(zend_enum_from_func)
406{
407 zend_enum_from_base(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
408}
409
410static ZEND_NAMED_FUNCTION(zend_enum_try_from_func)
411{
412 zend_enum_from_base(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
413}
414
415static void zend_enum_register_func(zend_class_entry *ce, zend_known_string_id name_id, zend_internal_function *zif) {
416 zend_string *name = ZSTR_KNOWN(name_id);
418 zif->module = EG(current_module);
419 zif->scope = ce;
421 if (EG(active)) { // at run-time
422 if (CG(compiler_options) & ZEND_COMPILE_PRELOAD) {
424 }
425 ZEND_MAP_PTR_INIT(zif->run_time_cache, zend_arena_calloc(&CG(arena), 1, zend_internal_run_time_cache_reserved_size()));
426 } else {
427#ifdef ZTS
428 ZEND_MAP_PTR_NEW_STATIC(zif->run_time_cache);
429#else
430 ZEND_MAP_PTR_INIT(zif->run_time_cache, NULL);
431#endif
432 }
433
434 if (!zend_hash_add_ptr(&ce->function_table, name, zif)) {
435 zend_error_noreturn(E_COMPILE_ERROR, "Cannot redeclare %s::%s()", ZSTR_VAL(ce->name), ZSTR_VAL(name));
436 }
437}
438
440{
441 const uint32_t fn_flags =
443 zend_internal_function *cases_function = zend_arena_calloc(&CG(arena), sizeof(zend_internal_function), 1);
444 cases_function->handler = zend_enum_cases_func;
445 cases_function->function_name = ZSTR_KNOWN(ZEND_STR_CASES);
446 cases_function->fn_flags = fn_flags;
447 cases_function->doc_comment = NULL;
448 cases_function->arg_info = (zend_internal_arg_info *) (arginfo_class_UnitEnum_cases + 1);
449 zend_enum_register_func(ce, ZEND_STR_CASES, cases_function);
450
451 if (ce->enum_backing_type != IS_UNDEF) {
452 zend_internal_function *from_function = zend_arena_calloc(&CG(arena), sizeof(zend_internal_function), 1);
453 from_function->handler = zend_enum_from_func;
454 from_function->function_name = ZSTR_KNOWN(ZEND_STR_FROM);
455 from_function->fn_flags = fn_flags;
456 from_function->doc_comment = NULL;
457 from_function->num_args = 1;
458 from_function->required_num_args = 1;
459 from_function->arg_info = (zend_internal_arg_info *) (arginfo_class_BackedEnum_from + 1);
460 zend_enum_register_func(ce, ZEND_STR_FROM, from_function);
461
462 zend_internal_function *try_from_function = zend_arena_calloc(&CG(arena), sizeof(zend_internal_function), 1);
463 try_from_function->handler = zend_enum_try_from_func;
464 try_from_function->function_name = ZSTR_KNOWN(ZEND_STR_TRYFROM);
465 try_from_function->fn_flags = fn_flags;
466 try_from_function->doc_comment = NULL;
467 try_from_function->num_args = 1;
468 try_from_function->required_num_args = 1;
469 try_from_function->arg_info = (zend_internal_arg_info *) (arginfo_class_BackedEnum_tryFrom + 1);
470 zend_enum_register_func(ce, ZEND_STR_TRYFROM_LOWERCASE, try_from_function);
471 }
472}
473
475{
477
478 zval name_default_value;
479 ZVAL_UNDEF(&name_default_value);
480 zend_type name_type = ZEND_TYPE_INIT_CODE(IS_STRING, 0, 0);
481 zend_declare_typed_property(ce, ZSTR_KNOWN(ZEND_STR_NAME), &name_default_value, ZEND_ACC_PUBLIC | ZEND_ACC_READONLY, NULL, name_type);
482
483 if (ce->enum_backing_type != IS_UNDEF) {
484 zval value_default_value;
485 ZVAL_UNDEF(&value_default_value);
486 zend_type value_type = ZEND_TYPE_INIT_CODE(ce->enum_backing_type, 0, 0);
487 zend_declare_typed_property(ce, ZSTR_KNOWN(ZEND_STR_VALUE), &value_default_value, ZEND_ACC_PUBLIC | ZEND_ACC_READONLY, NULL, value_type);
488 }
489}
490
491static const zend_function_entry unit_enum_methods[] = {
492 ZEND_NAMED_ME(cases, zend_enum_cases_func, arginfo_class_UnitEnum_cases, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
494};
495
496static const zend_function_entry backed_enum_methods[] = {
497 ZEND_NAMED_ME(cases, zend_enum_cases_func, arginfo_class_UnitEnum_cases, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
498 ZEND_NAMED_ME(from, zend_enum_from_func, arginfo_class_BackedEnum_from, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
499 ZEND_NAMED_ME(tryFrom, zend_enum_try_from_func, arginfo_class_BackedEnum_tryFrom, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
501};
502
504 const char *name, uint8_t type, const zend_function_entry *functions)
505{
507
508 zend_class_entry tmp_ce;
510
512 ce->ce_flags |= ZEND_ACC_ENUM;
514 if (type != IS_UNDEF) {
515 HashTable *backed_enum_table = pemalloc(sizeof(HashTable), 1);
516 zend_hash_init(backed_enum_table, 0, NULL, ZVAL_PTR_DTOR, 1);
517 zend_class_set_backed_enum_table(ce, backed_enum_table);
518 }
519
521 if (type == IS_UNDEF) {
523 ce, unit_enum_methods, &ce->function_table, EG(current_module)->type);
525 } else {
527 ce, backed_enum_methods, &ce->function_table, EG(current_module)->type);
529 }
530
531 return ce;
532}
533
534static zend_ast_ref *create_enum_case_ast(
535 zend_string *class_name, zend_string *case_name, zval *value) {
536 // TODO: Use custom node type for enum cases?
537 size_t size = sizeof(zend_ast_ref) + zend_ast_size(3)
538 + (value ? 3 : 2) * sizeof(zend_ast_zval);
539 char *p = pemalloc(size, 1);
540 zend_ast_ref *ref = (zend_ast_ref *) p; p += sizeof(zend_ast_ref);
541 GC_SET_REFCOUNT(ref, 1);
543
544 zend_ast *ast = (zend_ast *) p; p += zend_ast_size(3);
546 ast->attr = 0;
547 ast->lineno = 0;
548
549 ast->child[0] = (zend_ast *) p; p += sizeof(zend_ast_zval);
550 ast->child[0]->kind = ZEND_AST_ZVAL;
551 ast->child[0]->attr = 0;
552 ZEND_ASSERT(ZSTR_IS_INTERNED(class_name));
553 ZVAL_STR(zend_ast_get_zval(ast->child[0]), class_name);
554 Z_LINENO_P(zend_ast_get_zval(ast->child[0])) = 0;
555
556 ast->child[1] = (zend_ast *) p; p += sizeof(zend_ast_zval);
557 ast->child[1]->kind = ZEND_AST_ZVAL;
558 ast->child[1]->attr = 0;
559 ZEND_ASSERT(ZSTR_IS_INTERNED(case_name));
560 ZVAL_STR(zend_ast_get_zval(ast->child[1]), case_name);
561 Z_LINENO_P(zend_ast_get_zval(ast->child[1])) = 0;
562
563 if (value) {
564 ast->child[2] = (zend_ast *) p; p += sizeof(zend_ast_zval);
565 ast->child[2]->kind = ZEND_AST_ZVAL;
566 ast->child[2]->attr = 0;
568 ZVAL_COPY_VALUE(zend_ast_get_zval(ast->child[2]), value);
569 Z_LINENO_P(zend_ast_get_zval(ast->child[2])) = 0;
570 } else {
571 ast->child[2] = NULL;
572 }
573
574 return ref;
575}
576
578{
579 if (value) {
583 }
584
585 HashTable *backed_enum_table = CE_BACKED_ENUM_TABLE(ce);
586
587 zval case_name_zv;
588 ZVAL_STR(&case_name_zv, case_name);
589 if (Z_TYPE_P(value) == IS_LONG) {
590 zend_hash_index_add_new(backed_enum_table, Z_LVAL_P(value), &case_name_zv);
591 } else {
592 zend_hash_add_new(backed_enum_table, Z_STR_P(value), &case_name_zv);
593 }
594 } else {
596 }
597
598 zval ast_zv;
600 Z_AST(ast_zv) = create_enum_case_ast(ce->name, case_name, value);
602 ce, case_name, &ast_zv, ZEND_ACC_PUBLIC, NULL);
604}
605
607{
609 zend_enum_add_case(ce, name_str, value);
610 zend_string_release(name_str);
611}
612
614 zend_class_constant *c = zend_hash_find_ptr(CE_CONSTANTS_TABLE(ce), name);
615 ZEND_ASSERT(c && "Must be a valid enum case");
617
618 if (Z_TYPE(c->value) == IS_CONSTANT_AST) {
619 if (zval_update_constant_ex(&c->value, c->ce) == FAILURE) {
621 }
622 }
624 return Z_OBJ(c->value);
625}
626
628 zend_string *name_str = zend_string_init(name, strlen(name), 0);
629 zend_object *result = zend_enum_get_case(ce, name_str);
630 zend_string_release(name_str);
631 return result;
632}
zend_ffi_type * type
Definition ffi.c:3812
zval * zv
Definition ffi.c:3975
new_type size
Definition ffi.c:4365
memcpy(ptr1, ptr2, size)
zval * val
Definition ffi.c:4262
#define NULL
Definition gdcache.h:45
#define SUCCESS
Definition hash_sha3.c:261
foreach($dp as $el) foreach( $dp as $el) if( $pass2< 2) echo ""
char * arena
Definition php_bcmath.h:37
php_output_handler * active
Definition php_output.h:140
HashTable functions
p
Definition session.c:1105
zend_ast_attr attr
Definition zend_ast.h:188
zend_ast_kind kind
Definition zend_ast.h:187
zend_ast * child[1]
Definition zend_ast.h:190
uint32_t lineno
Definition zend_ast.h:189
zend_class_entry * ce
HashTable properties_info
Definition zend.h:164
zend_class_name * interface_names
Definition zend.h:213
zend_string * name
Definition zend.h:149
uint32_t num_interfaces
Definition zend.h:205
uint32_t ce_flags
Definition zend.h:156
char type
Definition zend.h:148
uint32_t enum_backing_type
Definition zend.h:221
HashTable function_table
Definition zend.h:163
const zend_object_handlers * default_object_handlers
Definition zend.h:186
zend_string * lc_name
Definition zend.h:87
zend_string * name
Definition zend.h:86
zend_class_entry * scope
zend_string * function_name
struct _zend_module_entry * module
zend_internal_arg_info * arg_info
zend_string * doc_comment
zend_string * name
ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_noreturn(int type, const char *format,...)
Definition zend.c:1703
ZEND_API ZEND_COLD void zend_throw_error(zend_class_entry *exception_ce, const char *format,...)
Definition zend.c:1772
ZEND_API ZEND_COLD void zend_type_error(const char *format,...)
Definition zend.c:1824
ZEND_API ZEND_COLD void zend_value_error(const char *format,...)
Definition zend.c:1849
struct _zend_class_name zend_class_name
#define INTERNAL_FUNCTION_PARAMETERS
Definition zend.h:49
#define INTERNAL_FUNCTION_PARAM_PASSTHRU
Definition zend.h:50
ZEND_API zend_result zend_update_class_constants(zend_class_entry *class_type)
Definition zend_API.c:1518
ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend_function_entry *functions, HashTable *function_table, int type)
Definition zend_API.c:2927
ZEND_API const char * zend_get_type_by_const(int type)
Definition zend_API.c:112
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)
Definition zend_API.c:4505
ZEND_API zend_class_entry * zend_register_internal_class(zend_class_entry *orig_class_entry)
Definition zend_API.c:3551
ZEND_API void zend_class_implements(zend_class_entry *class_entry, int num_interfaces,...)
Definition zend_API.c:3527
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)
Definition zend_API.c:4909
#define ZEND_NAMED_ME(zend_name, name, arg_info, flags)
Definition zend_API.h:90
#define INIT_CLASS_ENTRY_EX(class_container, class_name, class_name_len, functions)
Definition zend_API.h:282
#define ZEND_FE_END
Definition zend_API.h:124
#define ZEND_PARSE_PARAMETERS_END()
Definition zend_API.h:1641
struct _zend_function_entry zend_function_entry
#define ZEND_PARSE_PARAMETERS_NONE()
Definition zend_API.h:1623
#define RETURN_NULL()
Definition zend_API.h:1036
#define Z_PARAM_STR(dest)
Definition zend_API.h:2086
#define ZEND_PARSE_PARAMETERS_START(min_num_args, max_num_args)
Definition zend_API.h:1620
#define Z_PARAM_LONG(dest)
Definition zend_API.h:1896
#define RETURN_OBJ_COPY(r)
Definition zend_API.h:1053
#define RETURN_THROWS()
Definition zend_API.h:1060
#define CE_CONSTANTS_TABLE(ce)
Definition zend_API.h:331
#define ZEND_NAMED_FUNCTION(name)
Definition zend_API.h:74
#define Z_PARAM_STR_OR_LONG(dest_str, dest_long)
Definition zend_API.h:2165
#define CE_BACKED_ENUM_TABLE(ce)
Definition zend_API.h:337
#define array_init(arg)
Definition zend_API.h:537
#define pemalloc(size, persistent)
Definition zend_alloc.h:189
#define erealloc(ptr, size)
Definition zend_alloc.h:159
#define emalloc(size)
Definition zend_alloc.h:151
struct _zend_ast_zval zend_ast_zval
@ ZEND_AST_CONST_ENUM_INIT
Definition zend_ast.h:169
@ ZEND_AST_ZVAL
Definition zend_ast.h:36
struct _zval_struct zval
strlen(string $string)
zend_string * zval_make_interned_string(zval *zv)
#define ZEND_ACC_NO_DYNAMIC_PROPERTIES
#define ZEND_ACC_ENUM
#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_STATIC
#define ZEND_ACC_PUBLIC
#define ZEND_ACC_HAS_RETURN_TYPE
#define ZEND_ACC_RESOLVED_INTERFACES
#define ZEND_ACC_ARENA_ALLOCATED
#define ZEND_USER_CLASS
#define ZEND_CLASS_CONST_IS_CASE
struct _zend_internal_function zend_internal_function
#define ZEND_ARG_USES_STRICT_TYPES()
#define ZEND_API
ZEND_API zend_class_entry * zend_ce_unit_enum
Definition zend_enum.c:35
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)
Definition zend_enum.c:289
ZEND_API zend_object_handlers zend_enum_object_handlers
Definition zend_enum.c:37
ZEND_API zend_object * zend_enum_get_case(zend_class_entry *ce, zend_string *name)
Definition zend_enum.c:613
void zend_verify_enum(const zend_class_entry *ce)
Definition zend_enum.c:120
ZEND_API zend_class_entry * zend_ce_backed_enum
Definition zend_enum.c:36
ZEND_API zend_class_entry * zend_register_internal_enum(const char *name, uint8_t type, const zend_function_entry *functions)
Definition zend_enum.c:503
zend_result zend_enum_build_backed_enum_table(zend_class_entry *ce)
Definition zend_enum.c:196
void zend_enum_register_funcs(zend_class_entry *ce)
Definition zend_enum.c:439
void zend_enum_register_props(zend_class_entry *ce)
Definition zend_enum.c:474
ZEND_API void zend_enum_add_case_cstr(zend_class_entry *ce, const char *name, zval *value)
Definition zend_enum.c:606
ZEND_API void zend_enum_add_case(zend_class_entry *ce, zend_string *case_name, zval *value)
Definition zend_enum.c:577
void zend_enum_add_interfaces(zend_class_entry *ce)
Definition zend_enum.c:172
#define ZEND_ENUM_DISALLOW_MAGIC_METHOD(propertyName, methodName)
Definition zend_enum.c:28
ZEND_API zend_object * zend_enum_get_case_cstr(zend_class_entry *ce, const char *name)
Definition zend_enum.c:627
zend_object * zend_enum_new(zval *result, zend_class_entry *ce, zend_string *case_name, zval *backing_value_zv)
Definition zend_enum.c:39
void zend_register_enum_ce(void)
Definition zend_enum.c:159
#define E_COMPILE_ERROR
Definition zend_errors.h:29
#define E_ERROR
Definition zend_errors.h:23
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)
#define CG(v)
#define EG(v)
ZEND_API zval *ZEND_FASTCALL zend_hash_next_index_insert_new(HashTable *ht, zval *pData)
Definition zend_hash.c:1229
ZEND_API zval *ZEND_FASTCALL zend_hash_index_add_new(HashTable *ht, zend_ulong h, zval *pData)
Definition zend_hash.c:1214
ZEND_API zval *ZEND_FASTCALL zend_hash_add_new(HashTable *ht, zend_string *key, zval *pData)
Definition zend_hash.c:1007
ZEND_API zval *ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key)
Definition zend_hash.c:2668
ZEND_API zval *ZEND_FASTCALL zend_hash_index_find(const HashTable *ht, zend_ulong h)
Definition zend_hash.c:2701
#define zend_hash_init(ht, nSize, pHashFunction, pDestructor, persistent)
Definition zend_hash.h:108
#define ZEND_HASH_MAP_FOREACH_PTR(ht, _ptr)
Definition zend_hash.h:1326
#define ZEND_HASH_FOREACH_END()
Definition zend_hash.h:1086
#define ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(ht, _key, _val)
Definition zend_hash.h:1374
else
Definition zend_ini.c:906
ZEND_API zend_class_entry * zend_ce_serializable
int32_t zend_long
Definition zend_long.h:42
#define ZEND_LONG_FMT
Definition zend_long.h:87
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_ASSERT(c)
#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
Definition zend_string.c:31
#define ZSTR_IS_INTERNED(s)
Definition zend_string.h:84
enum _zend_known_string_id zend_known_string_id
#define ZSTR_VAL(zstr)
Definition zend_string.h:68
#define ZSTR_INIT_LITERAL(s, persistent)
#define ZSTR_KNOWN(idx)
#define Z_TYPE_P(zval_p)
Definition zend_types.h:660
#define ZVAL_STR(z, s)
struct _zend_ast_ref zend_ast_ref
Definition zend_types.h:101
#define Z_TRY_ADDREF_P(pz)
#define ZVAL_UNDEF(z)
#define GC_SET_REFCOUNT(p, rc)
Definition zend_types.h:708
#define Z_STRVAL_P(zval_p)
Definition zend_types.h:975
#define IS_UNDEF
Definition zend_types.h:600
#define Z_ARRVAL_P(zval_p)
Definition zend_types.h:987
#define IS_STRING
Definition zend_types.h:606
#define Z_REFCOUNTED_P(zval_p)
Definition zend_types.h:921
#define ZVAL_STR_COPY(z, s)
struct _zend_array HashTable
Definition zend_types.h:386
#define Z_OBJ_P(zval_p)
Definition zend_types.h:990
#define Z_STR_P(zval_p)
Definition zend_types.h:972
#define Z_PTR_P(zval_p)
#define Z_ADDREF_P(pz)
#define Z_LINENO_P(zval_p)
Definition zend_types.h:678
#define GC_CONSTANT_AST
Definition zend_types.h:790
#define ZVAL_OBJ(z, o)
@ FAILURE
Definition zend_types.h:61
#define IS_OBJECT
Definition zend_types.h:608
#define IS_LONG
Definition zend_types.h:604
#define ZEND_TYPE_INIT_CODE(code, allow_null, extra_flags)
Definition zend_types.h:286
#define Z_AST(zval)
#define ZVAL_COPY(z, v)
#define Z_TYPE_INFO(zval)
Definition zend_types.h:668
ZEND_RESULT_CODE zend_result
Definition zend_types.h:64
#define IS_CONSTANT_AST
Definition zend_types.h:611
struct _zend_object_handlers zend_object_handlers
Definition zend_types.h:88
#define GC_PERSISTENT
Definition zend_types.h:781
#define Z_PROP_FLAG_P(z)
#define Z_TYPE(zval)
Definition zend_types.h:659
struct _zend_ast zend_ast
Definition zend_types.h:102
#define Z_LVAL_P(zval_p)
Definition zend_types.h:966
#define ZVAL_COPY_VALUE(z, v)
#define GC_IMMUTABLE
Definition zend_types.h:780
#define GC_TYPE_INFO(p)
Definition zend_types.h:754
#define Z_OBJ(zval)
Definition zend_types.h:989
#define ZVAL_PTR_DTOR
zval * return_value
zend_string * name
bool result
execute_data
value
zend_object * zobj