php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
zend_API.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: Andi Gutmans <andi@php.net> |
16 | Zeev Suraski <zeev@php.net> |
17 | Andrei Zmievski <andrei@php.net> |
18 | Dmitry Stogov <dmitry@php.net> |
19 +----------------------------------------------------------------------+
20*/
21
22#include "zend.h"
23#include "zend_execute.h"
24#include "zend_API.h"
25#include "zend_hash.h"
26#include "zend_modules.h"
27#include "zend_extensions.h"
28#include "zend_constants.h"
29#include "zend_interfaces.h"
30#include "zend_exceptions.h"
31#include "zend_closures.h"
32#include "zend_inheritance.h"
33#include "zend_ini.h"
34#include "zend_enum.h"
36#include "zend_observer.h"
37
38#include <stdarg.h>
39
40/* these variables are true statics/globals, and have to be mutex'ed on every access */
42
43static zend_module_entry **module_request_startup_handlers;
44static zend_module_entry **module_request_shutdown_handlers;
45static zend_module_entry **module_post_deactivate_handlers;
46static zend_module_entry **modules_dl_loaded;
47
48static zend_class_entry **class_cleanup_handlers;
49
50ZEND_API zend_result zend_get_parameters_array_ex(uint32_t param_count, zval *argument_array) /* {{{ */
51{
52 zval *param_ptr;
53 uint32_t arg_count;
54
55 param_ptr = ZEND_CALL_ARG(EG(current_execute_data), 1);
56 arg_count = ZEND_CALL_NUM_ARGS(EG(current_execute_data));
57
58 if (param_count>arg_count) {
59 return FAILURE;
60 }
61
62 while (param_count-->0) {
63 ZVAL_COPY_VALUE(argument_array, param_ptr);
64 argument_array++;
65 param_ptr++;
66 }
67
68 return SUCCESS;
69}
70/* }}} */
71
72ZEND_API zend_result zend_copy_parameters_array(uint32_t param_count, zval *argument_array) /* {{{ */
73{
74 zval *param_ptr;
75 uint32_t arg_count;
76
77 param_ptr = ZEND_CALL_ARG(EG(current_execute_data), 1);
78 arg_count = ZEND_CALL_NUM_ARGS(EG(current_execute_data));
79
80 if (param_count>arg_count) {
81 return FAILURE;
82 }
83
84 while (param_count-->0) {
85 Z_TRY_ADDREF_P(param_ptr);
86 zend_hash_next_index_insert_new(Z_ARRVAL_P(argument_array), param_ptr);
87 param_ptr++;
88 }
89
90 return SUCCESS;
91}
92/* }}} */
93
95{
96 const char *space;
97 const char *class_name = get_active_class_name(&space);
98
99 zend_argument_count_error("Wrong parameter count for %s%s%s()", class_name, space, get_active_function_name());
100}
101/* }}} */
102
104{
105 zend_string *tmp_property_name;
106 zend_string *property_name = zval_get_tmp_string(property, &tmp_property_name);
107 zend_error(E_WARNING, "Attempt to read property \"%s\" on %s", ZSTR_VAL(property_name), zend_zval_value_name(object));
108 zend_tmp_string_release(tmp_property_name);
109}
110
111/* Argument parsing API -- andrei */
112ZEND_API const char *zend_get_type_by_const(int type) /* {{{ */
113{
114 switch(type) {
115 case IS_FALSE:
116 case IS_TRUE:
117 case _IS_BOOL:
118 return "bool";
119 case IS_LONG:
120 return "int";
121 case IS_DOUBLE:
122 return "float";
123 case IS_STRING:
124 return "string";
125 case IS_OBJECT:
126 return "object";
127 case IS_RESOURCE:
128 return "resource";
129 case IS_NULL:
130 return "null";
131 case IS_CALLABLE:
132 return "callable";
133 case IS_ITERABLE:
134 return "iterable";
135 case IS_ARRAY:
136 return "array";
137 case IS_VOID:
138 return "void";
139 case IS_MIXED:
140 return "mixed";
141 case _IS_NUMBER:
142 return "int|float";
144 }
145}
146/* }}} */
147
149{
151
152 if (Z_ISUNDEF_P(arg)) {
153 return "null";
154 }
155
156 if (Z_TYPE_P(arg) == IS_OBJECT) {
157 return ZSTR_VAL(Z_OBJCE_P(arg)->name);
158 } else if (Z_TYPE_P(arg) == IS_FALSE) {
159 return "false";
160 } else if (Z_TYPE_P(arg) == IS_TRUE) {
161 return "true";
162 }
163
165}
166
168{
170
171 if (Z_ISUNDEF_P(arg)) {
172 return "null";
173 }
174
175 if (Z_TYPE_P(arg) == IS_OBJECT) {
176 return ZSTR_VAL(Z_OBJCE_P(arg)->name);
177 }
178
180}
181
182/* This API exists *only* for use in gettype().
183 * For anything else, you likely want zend_zval_type_name(). */
185{
186 switch (Z_TYPE_P(arg)) {
187 case IS_NULL:
188 return ZSTR_KNOWN(ZEND_STR_NULL);
189 case IS_FALSE:
190 case IS_TRUE:
191 return ZSTR_KNOWN(ZEND_STR_BOOLEAN);
192 case IS_LONG:
193 return ZSTR_KNOWN(ZEND_STR_INTEGER);
194 case IS_DOUBLE:
195 return ZSTR_KNOWN(ZEND_STR_DOUBLE);
196 case IS_STRING:
197 return ZSTR_KNOWN(ZEND_STR_STRING);
198 case IS_ARRAY:
199 return ZSTR_KNOWN(ZEND_STR_ARRAY);
200 case IS_OBJECT:
201 return ZSTR_KNOWN(ZEND_STR_OBJECT);
202 case IS_RESOURCE:
204 return ZSTR_KNOWN(ZEND_STR_RESOURCE);
205 } else {
206 return ZSTR_KNOWN(ZEND_STR_CLOSED_RESOURCE);
207 }
208 default:
209 return NULL;
210 }
211}
212/* }}} */
213
215{
216 int num_args = ZEND_CALL_NUM_ARGS(EG(current_execute_data));
218
219 zend_argument_count_error("%s() expects exactly 0 arguments, %d given", ZSTR_VAL(func_name), num_args);
220
221 zend_string_release(func_name);
222}
223/* }}} */
224
225ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_error(uint32_t min_num_args, uint32_t max_num_args) /* {{{ */
226{
227 uint32_t num_args = ZEND_CALL_NUM_ARGS(EG(current_execute_data));
229
231 "%s() expects %s %d argument%s, %d given",
233 min_num_args == max_num_args ? "exactly" : num_args < min_num_args ? "at least" : "at most",
234 num_args < min_num_args ? min_num_args : max_num_args,
235 (num_args < min_num_args ? min_num_args : max_num_args) == 1 ? "" : "s",
237 );
238
239 zend_string_release(func_name);
240}
241/* }}} */
242
282/* }}} */
283
285{
286 static const char * const expected_error[] = {
288 NULL
289 };
290
291 if (EG(exception)) {
292 return;
293 }
294
295 if ((expected_type == Z_EXPECTED_PATH || expected_type == Z_EXPECTED_PATH_OR_NULL)
296 && Z_TYPE_P(arg) == IS_STRING) {
297 zend_argument_value_error(num, "must not contain any null bytes");
298 return;
299 }
300
301 zend_argument_type_error(num, "must be %s, %s given", expected_error[expected_type], zend_zval_value_name(arg));
302}
303/* }}} */
304
306{
307 if (EG(exception)) {
308 return;
309 }
310
311 zend_argument_type_error(num, "must be of type %s, %s given", name, zend_zval_value_name(arg));
312}
313/* }}} */
314
316{
317 if (EG(exception)) {
318 return;
319 }
320
321 zend_argument_type_error(num, "must be of type ?%s, %s given", name, zend_zval_value_name(arg));
322}
323/* }}} */
324
326{
327 if (EG(exception)) {
328 return;
329 }
330
331 zend_argument_type_error(num, "must be of type %s|int, %s given", name, zend_zval_value_name(arg));
332}
333/* }}} */
334
336{
337 if (EG(exception)) {
338 return;
339 }
340
341 zend_argument_type_error(num, "must be of type %s|int|null, %s given", name, zend_zval_value_name(arg));
342}
343/* }}} */
344
346{
347 if (EG(exception)) {
348 return;
349 }
350
351 zend_argument_type_error(num, "must be of type %s|string, %s given", name, zend_zval_value_name(arg));
352}
353/* }}} */
354
356{
357 if (EG(exception)) {
358 return;
359 }
360
361 zend_argument_type_error(num, "must be of type %s|string|null, %s given", name, zend_zval_value_name(arg));
362}
363/* }}} */
364
366{
367 if (!EG(exception)) {
368 zend_argument_type_error(num, "must be a valid callback, %s", error);
369 }
370 efree(error);
371}
372/* }}} */
373
375{
376 if (!EG(exception)) {
377 zend_argument_type_error(num, "must be a valid callback or null, %s", error);
378 }
379 efree(error);
380}
381/* }}} */
382
384{
385 const char *space;
386 const char *class_name = get_active_class_name(&space);
387 zend_argument_count_error("%s%s%s() does not accept unknown named parameters",
388 class_name, space, get_active_function_name());
389}
390
391ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_error_variadic(zend_class_entry *error_ce, uint32_t arg_num, const char *format, va_list va) /* {{{ */
392{
394 const char *arg_name;
395 char *message = NULL;
396 if (EG(exception)) {
397 return;
398 }
399
402
403 zend_vspprintf(&message, 0, format, va);
404 zend_throw_error(error_ce, "%s(): Argument #%d%s%s%s %s",
406 arg_name ? " ($" : "", arg_name ? arg_name : "", arg_name ? ")" : "", message
407 );
408 efree(message);
409 zend_string_release(func_name);
410}
411/* }}} */
412
413ZEND_API ZEND_COLD void zend_argument_error(zend_class_entry *error_ce, uint32_t arg_num, const char *format, ...) /* {{{ */
414{
415 va_list va;
416
417 va_start(va, format);
418 zend_argument_error_variadic(error_ce, arg_num, format, va);
419 va_end(va);
420}
421/* }}} */
422
423ZEND_API ZEND_COLD void zend_argument_type_error(uint32_t arg_num, const char *format, ...) /* {{{ */
424{
425 va_list va;
426
427 va_start(va, format);
429 va_end(va);
430}
431/* }}} */
432
433ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *format, ...) /* {{{ */
434{
435 va_list va;
436
437 va_start(va, format);
439 va_end(va);
440}
441/* }}} */
442
447
449{
450 if (old_ce->type == ZEND_INTERNAL_CLASS) {
451 zend_error(type, "Cannot redeclare %s %s",
452 zend_get_object_type(old_ce),
453 ZSTR_VAL(new_name));
454 } else {
455 zend_error(type, "Cannot redeclare %s %s (previously declared in %s:%d)",
456 zend_get_object_type(old_ce),
457 ZSTR_VAL(new_name),
458 ZSTR_VAL(old_ce->info.user.filename),
459 old_ce->info.user.line_start);
460 }
461}
462
467
468ZEND_API bool ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **pce, uint32_t num, bool check_null) /* {{{ */
469{
470 zend_class_entry *ce_base = *pce;
471
472 if (check_null && Z_TYPE_P(arg) == IS_NULL) {
473 *pce = NULL;
474 return 1;
475 }
476 if (!try_convert_to_string(arg)) {
477 *pce = NULL;
478 return 0;
479 }
480
482 if (ce_base) {
483 if ((!*pce || !instanceof_function(*pce, ce_base))) {
484 zend_argument_type_error(num, "must be a class name derived from %s, %s given", ZSTR_VAL(ce_base->name), Z_STRVAL_P(arg));
485 *pce = NULL;
486 return 0;
487 }
488 }
489 if (!*pce) {
490 zend_argument_type_error(num, "must be a valid class name, %s given", Z_STRVAL_P(arg));
491 return 0;
492 }
493 return 1;
494}
495/* }}} */
496
497static ZEND_COLD bool zend_null_arg_deprecated(const char *fallback_type, uint32_t arg_num) {
498 zend_function *func = zend_active_function();
499 ZEND_ASSERT(arg_num > 0);
500 uint32_t arg_offset = arg_num - 1;
501 if (arg_offset >= func->common.num_args) {
502 ZEND_ASSERT(func->common.fn_flags & ZEND_ACC_VARIADIC);
503 arg_offset = func->common.num_args;
504 }
505
506 zend_arg_info *arg_info = &func->common.arg_info[arg_offset];
508 const char *arg_name = get_active_function_arg_name(arg_num);
509
510 /* If no type is specified in arginfo, use the specified fallback_type determined through
511 * zend_parse_parameters instead. */
512 zend_string *type_str = zend_type_to_string(arg_info->type);
513 const char *type = type_str ? ZSTR_VAL(type_str) : fallback_type;
515 "%s(): Passing null to parameter #%" PRIu32 "%s%s%s of type %s is deprecated",
517 arg_name ? " ($" : "", arg_name ? arg_name : "", arg_name ? ")" : "",
518 type);
519 zend_string_release(func_name);
520 if (type_str) {
521 zend_string_release(type_str);
522 }
523 return !EG(exception);
524}
525
526ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_weak(const zval *arg, bool *dest, uint32_t arg_num) /* {{{ */
527{
528 if (EXPECTED(Z_TYPE_P(arg) <= IS_STRING)) {
529 if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("bool", arg_num)) {
530 return 0;
531 }
532 *dest = zend_is_true(arg);
533 } else {
534 return 0;
535 }
536 return 1;
537}
538/* }}} */
539
540ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_slow(const zval *arg, bool *dest, uint32_t arg_num) /* {{{ */
541{
543 return 0;
544 }
545 return zend_parse_arg_bool_weak(arg, dest, arg_num);
546}
547/* }}} */
548
550{
552 return 0;
553 }
554 return zend_parse_arg_bool_weak(arg, dest, arg_num);
555}
556
558{
559 if (EXPECTED(Z_TYPE_P(arg) == IS_DOUBLE)) {
561 return 0;
562 }
564 return 0;
565 } else {
566 zend_long lval = zend_dval_to_lval(Z_DVAL_P(arg));
567 if (UNEXPECTED(!zend_is_long_compatible(Z_DVAL_P(arg), lval))) {
568 /* Check arg_num is not (uint32_t)-1, as otherwise its called by
569 * zend_verify_weak_scalar_type_hint_no_sideeffect() */
570 if (arg_num != (uint32_t)-1) {
572 }
573 if (UNEXPECTED(EG(exception))) {
574 return 0;
575 }
576 }
577 *dest = lval;
578 }
579 } else if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) {
580 double d;
581 uint8_t type;
582
583 if (UNEXPECTED((type = is_numeric_str_function(Z_STR_P(arg), dest, &d)) != IS_LONG)) {
584 if (EXPECTED(type != 0)) {
585 zend_long lval;
586 if (UNEXPECTED(zend_isnan(d))) {
587 return 0;
588 }
590 return 0;
591 }
592
593 lval = zend_dval_to_lval(d);
594 /* This only checks for a fractional part as if doesn't fit it already throws a TypeError */
595 if (UNEXPECTED(!zend_is_long_compatible(d, lval))) {
596 /* Check arg_num is not (uint32_t)-1, as otherwise its called by
597 * zend_verify_weak_scalar_type_hint_no_sideeffect() */
598 if (arg_num != (uint32_t)-1) {
600 }
601 if (UNEXPECTED(EG(exception))) {
602 return 0;
603 }
604 }
605 *dest = lval;
606 } else {
607 return 0;
608 }
609 }
610 if (UNEXPECTED(EG(exception))) {
611 return 0;
612 }
613 } else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) {
614 if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("int", arg_num)) {
615 return 0;
616 }
617 *dest = 0;
618 } else if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) {
619 *dest = 1;
620 } else {
621 return 0;
622 }
623 return 1;
624}
625/* }}} */
626
628{
630 return 0;
631 }
632 return zend_parse_arg_long_weak(arg, dest, arg_num);
633}
634/* }}} */
635
637{
639 return 0;
640 }
641 return zend_parse_arg_long_weak(arg, dest, arg_num);
642}
643
644ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_weak(const zval *arg, double *dest, uint32_t arg_num) /* {{{ */
645{
646 if (EXPECTED(Z_TYPE_P(arg) == IS_LONG)) {
647 *dest = (double)Z_LVAL_P(arg);
648 } else if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) {
649 zend_long l;
650 uint8_t type;
651
653 if (EXPECTED(type != 0)) {
654 *dest = (double)(l);
655 } else {
656 return 0;
657 }
658 }
659 if (UNEXPECTED(EG(exception))) {
660 return 0;
661 }
662 } else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) {
663 if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("float", arg_num)) {
664 return 0;
665 }
666 *dest = 0.0;
667 } else if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) {
668 *dest = 1.0;
669 } else {
670 return 0;
671 }
672 return 1;
673}
674/* }}} */
675
676ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_slow(const zval *arg, double *dest, uint32_t arg_num) /* {{{ */
677{
678 if (EXPECTED(Z_TYPE_P(arg) == IS_LONG)) {
679 /* SSTH Exception: IS_LONG may be accepted instead as IS_DOUBLE */
680 *dest = (double)Z_LVAL_P(arg);
682 return 0;
683 }
685}
686/* }}} */
687
689{
691 return 0;
692 }
693 if (Z_TYPE_P(arg) == IS_STRING) {
694 zend_string *str = Z_STR_P(arg);
695 zend_long lval;
696 double dval;
697 uint8_t type = is_numeric_str_function(str, &lval, &dval);
698 if (type == IS_LONG) {
699 ZVAL_LONG(arg, lval);
700 } else if (type == IS_DOUBLE) {
702 } else {
703 return 0;
704 }
705 zend_string_release(str);
706 } else if (Z_TYPE_P(arg) < IS_TRUE) {
707 if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("int|float", arg_num)) {
708 return 0;
709 }
710 ZVAL_LONG(arg, 0);
711 } else if (Z_TYPE_P(arg) == IS_TRUE) {
712 ZVAL_LONG(arg, 1);
713 } else {
714 return 0;
715 }
716 *dest = arg;
717 return 1;
718}
719/* }}} */
720
721
723{
725 return false;
726 }
727 if (Z_TYPE_P(arg) < IS_TRUE) {
728 if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("string|int|float", arg_num)) {
729 return false;
730 }
731 ZVAL_LONG(arg, 0);
732 } else if (Z_TYPE_P(arg) == IS_TRUE) {
733 ZVAL_LONG(arg, 1);
734 } else if (UNEXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) {
736 zval obj;
737 if (zobj->handlers->cast_object(zobj, &obj, IS_STRING) == SUCCESS) {
739 ZVAL_COPY_VALUE(arg, &obj);
740 *dest = arg;
741 return true;
742 }
743 return false;
744 } else {
745 return false;
746 }
747 *dest = arg;
748 return true;
749}
750
752{
753 if (EXPECTED(Z_TYPE_P(arg) < IS_STRING)) {
754 if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("string", arg_num)) {
755 return 0;
756 }
758 *dest = Z_STR_P(arg);
759 } else if (UNEXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) {
761 zval obj;
762 if (zobj->handlers->cast_object(zobj, &obj, IS_STRING) == SUCCESS) {
764 ZVAL_COPY_VALUE(arg, &obj);
765 *dest = Z_STR_P(arg);
766 return 1;
767 }
768 return 0;
769 } else {
770 return 0;
771 }
772 return 1;
773}
774/* }}} */
775
777{
779 return 0;
780 }
781 return zend_parse_arg_str_weak(arg, dest, arg_num);
782}
783/* }}} */
784
786{
788 return 0;
789 }
790 return zend_parse_arg_str_weak(arg, dest, arg_num);
791}
792
794{
796 return 0;
797 }
798 if (zend_parse_arg_long_weak(arg, dest_long, arg_num)) {
799 *dest_str = NULL;
800 return 1;
801 } else if (zend_parse_arg_str_weak(arg, dest_str, arg_num)) {
802 *dest_long = 0;
803 return 1;
804 } else {
805 return 0;
806 }
807}
808/* }}} */
809
810static const char *zend_parse_arg_impl(zval *arg, va_list *va, const char **spec, char **error, uint32_t arg_num) /* {{{ */
811{
812 const char *spec_walk = *spec;
813 char c = *spec_walk++;
814 bool check_null = 0;
815 bool separate = 0;
816 zval *real_arg = arg;
817
818 /* scan through modifiers */
820 while (1) {
821 if (*spec_walk == '/') {
823 real_arg = arg;
824 separate = 1;
825 } else if (*spec_walk == '!') {
826 check_null = 1;
827 } else {
828 break;
829 }
830 spec_walk++;
831 }
832
833 switch (c) {
834 case 'l':
835 {
836 zend_long *p = va_arg(*va, zend_long *);
837 bool *is_null = NULL;
838
839 if (check_null) {
840 is_null = va_arg(*va, bool *);
841 }
842
843 if (!zend_parse_arg_long(arg, p, is_null, check_null, arg_num)) {
844 return check_null ? "?int" : "int";
845 }
846 }
847 break;
848
849 case 'd':
850 {
851 double *p = va_arg(*va, double *);
852 bool *is_null = NULL;
853
854 if (check_null) {
855 is_null = va_arg(*va, bool *);
856 }
857
858 if (!zend_parse_arg_double(arg, p, is_null, check_null, arg_num)) {
859 return check_null ? "?float" : "float";
860 }
861 }
862 break;
863
864 case 'n':
865 {
866 zval **p = va_arg(*va, zval **);
867
868 if (!zend_parse_arg_number(arg, p, check_null, arg_num)) {
869 return check_null ? "int|float|null" : "int|float";
870 }
871 }
872 break;
873
874 case 's':
875 {
876 char **p = va_arg(*va, char **);
877 size_t *pl = va_arg(*va, size_t *);
878 if (!zend_parse_arg_string(arg, p, pl, check_null, arg_num)) {
879 return check_null ? "?string" : "string";
880 }
881 }
882 break;
883
884 case 'p':
885 {
886 char **p = va_arg(*va, char **);
887 size_t *pl = va_arg(*va, size_t *);
888 if (!zend_parse_arg_path(arg, p, pl, check_null, arg_num)) {
889 if (Z_TYPE_P(arg) == IS_STRING) {
890 zend_spprintf(error, 0, "must not contain any null bytes");
891 return "";
892 } else {
893 return check_null ? "?string" : "string";
894 }
895 }
896 }
897 break;
898
899 case 'P':
900 {
901 zend_string **str = va_arg(*va, zend_string **);
902 if (!zend_parse_arg_path_str(arg, str, check_null, arg_num)) {
903 if (Z_TYPE_P(arg) == IS_STRING) {
904 zend_spprintf(error, 0, "must not contain any null bytes");
905 return "";
906 } else {
907 return check_null ? "?string" : "string";
908 }
909 }
910 }
911 break;
912
913 case 'S':
914 {
915 zend_string **str = va_arg(*va, zend_string **);
916 if (!zend_parse_arg_str(arg, str, check_null, arg_num)) {
917 return check_null ? "?string" : "string";
918 }
919 }
920 break;
921
922 case 'b':
923 {
924 bool *p = va_arg(*va, bool *);
925 bool *is_null = NULL;
926
927 if (check_null) {
928 is_null = va_arg(*va, bool *);
929 }
930
931 if (!zend_parse_arg_bool(arg, p, is_null, check_null, arg_num)) {
932 return check_null ? "?bool" : "bool";
933 }
934 }
935 break;
936
937 case 'r':
938 {
939 zval **p = va_arg(*va, zval **);
940
941 if (!zend_parse_arg_resource(arg, p, check_null)) {
942 return check_null ? "resource or null" : "resource";
943 }
944 }
945 break;
946
947 case 'A':
948 case 'a':
949 {
950 zval **p = va_arg(*va, zval **);
951
952 if (!zend_parse_arg_array(arg, p, check_null, c == 'A')) {
953 return check_null ? "?array" : "array";
954 }
955 }
956 break;
957
958 case 'H':
959 case 'h':
960 {
961 HashTable **p = va_arg(*va, HashTable **);
962
963 if (!zend_parse_arg_array_ht(arg, p, check_null, c == 'H', separate)) {
964 return check_null ? "?array" : "array";
965 }
966 }
967 break;
968
969 case 'o':
970 {
971 zval **p = va_arg(*va, zval **);
972
973 if (!zend_parse_arg_object(arg, p, NULL, check_null)) {
974 return check_null ? "?object" : "object";
975 }
976 }
977 break;
978
979 case 'O':
980 {
981 zval **p = va_arg(*va, zval **);
982 zend_class_entry *ce = va_arg(*va, zend_class_entry *);
983
984 if (!zend_parse_arg_object(arg, p, ce, check_null)) {
985 if (ce) {
986 if (check_null) {
987 zend_spprintf(error, 0, "must be of type ?%s, %s given", ZSTR_VAL(ce->name), zend_zval_value_name(arg));
988 return "";
989 } else {
990 return ZSTR_VAL(ce->name);
991 }
992 } else {
993 return check_null ? "?object" : "object";
994 }
995 }
996 }
997 break;
998
999 case 'C':
1000 {
1001 zend_class_entry *lookup, **pce = va_arg(*va, zend_class_entry **);
1002 zend_class_entry *ce_base = *pce;
1003
1004 if (check_null && Z_TYPE_P(arg) == IS_NULL) {
1005 *pce = NULL;
1006 break;
1007 }
1008 if (!try_convert_to_string(arg)) {
1009 *pce = NULL;
1010 return ""; /* try_convert_to_string() throws an exception */
1011 }
1012
1013 if ((lookup = zend_lookup_class(Z_STR_P(arg))) == NULL) {
1014 *pce = NULL;
1015 } else {
1016 *pce = lookup;
1017 }
1018 if (ce_base) {
1019 if ((!*pce || !instanceof_function(*pce, ce_base))) {
1020 zend_spprintf(error, 0, "must be a class name derived from %s%s, %s given",
1021 ZSTR_VAL(ce_base->name), check_null ? " or null" : "", Z_STRVAL_P(arg));
1022 *pce = NULL;
1023 return "";
1024 }
1025 }
1026 if (!*pce) {
1027 zend_spprintf(error, 0, "must be a valid class name%s, %s given",
1028 check_null ? " or null" : "", Z_STRVAL_P(arg));
1029 return "";
1030 }
1031 break;
1032
1033 }
1034 break;
1035
1036 case 'F':
1037 case 'f':
1038 {
1039 zend_fcall_info *fci = va_arg(*va, zend_fcall_info *);
1040 zend_fcall_info_cache *fcc = va_arg(*va, zend_fcall_info_cache *);
1041 char *is_callable_error = NULL;
1042
1043 if (check_null && Z_TYPE_P(arg) == IS_NULL) {
1044 fci->size = 0;
1045 fcc->function_handler = 0;
1046 break;
1047 }
1048
1049 if (zend_fcall_info_init(arg, 0, fci, fcc, NULL, &is_callable_error) == SUCCESS) {
1050 ZEND_ASSERT(!is_callable_error);
1051 if (c == 'f') {
1052 /* Release call trampolines: The function may not get called, in which case
1053 * the trampoline will leak. Force it to be refetched during
1054 * zend_call_function instead. */
1056 }
1057 break;
1058 }
1059
1060 if (is_callable_error) {
1061 zend_spprintf(error, 0, "must be a valid callback%s, %s", check_null ? " or null" : "", is_callable_error);
1062 efree(is_callable_error);
1063 return "";
1064 } else {
1065 return check_null ? "a valid callback or null" : "a valid callback";
1066 }
1067 }
1068
1069 case 'z':
1070 {
1071 zval **p = va_arg(*va, zval **);
1072
1073 zend_parse_arg_zval_deref(real_arg, p, check_null);
1074 }
1075 break;
1076
1077 case 'Z': /* replace with 'z' */
1078 case 'L': /* replace with 'l' */
1079 ZEND_ASSERT(0 && "ZPP modifier no longer supported");
1081 default:
1082 return "unknown";
1083 }
1084
1085 *spec = spec_walk;
1086
1087 return NULL;
1088}
1089/* }}} */
1090
1091static zend_result zend_parse_arg(uint32_t arg_num, zval *arg, va_list *va, const char **spec, int flags) /* {{{ */
1092{
1093 const char *expected_type = NULL;
1094 char *error = NULL;
1095
1096 expected_type = zend_parse_arg_impl(arg, va, spec, &error, arg_num);
1097 if (expected_type) {
1098 if (EG(exception)) {
1099 return FAILURE;
1100 }
1101 if (!(flags & ZEND_PARSE_PARAMS_QUIET) && (*expected_type || error)) {
1102 if (error) {
1103 if (strcmp(error, "must not contain any null bytes") == 0) {
1105 } else {
1107 }
1108 efree(error);
1109 } else {
1110 zend_argument_type_error(arg_num, "must be of type %s, %s given", expected_type, zend_zval_value_name(arg));
1111 }
1112 } else if (error) {
1113 efree(error);
1114 }
1115
1116 return FAILURE;
1117 }
1118
1119 return SUCCESS;
1120}
1121/* }}} */
1122
1123ZEND_API zend_result zend_parse_parameter(int flags, uint32_t arg_num, zval *arg, const char *spec, ...)
1124{
1125 va_list va;
1127
1128 va_start(va, spec);
1129 ret = zend_parse_arg(arg_num, arg, &va, &spec, flags);
1130 va_end(va);
1131
1132 return ret;
1133}
1134
1135static ZEND_COLD void zend_parse_parameters_debug_error(const char *msg) {
1136 zend_function *active_function = EG(current_execute_data)->func;
1137 const char *class_name = active_function->common.scope
1138 ? ZSTR_VAL(active_function->common.scope->name) : "";
1139 zend_error_noreturn(E_CORE_ERROR, "%s%s%s(): %s",
1140 class_name, class_name[0] ? "::" : "",
1141 ZSTR_VAL(active_function->common.function_name), msg);
1142}
1143
1144static zend_result zend_parse_va_args(uint32_t num_args, const char *type_spec, va_list *va, int flags) /* {{{ */
1145{
1146 const char *spec_walk;
1147 char c;
1148 uint32_t i;
1149 uint32_t min_num_args = 0;
1150 uint32_t max_num_args = 0;
1151 uint32_t post_varargs = 0;
1152 zval *arg;
1153 bool have_varargs = 0;
1154 bool have_optional_args = 0;
1155 zval **varargs = NULL;
1156 uint32_t *n_varargs = NULL;
1157
1158 for (spec_walk = type_spec; *spec_walk; spec_walk++) {
1159 c = *spec_walk;
1160 switch (c) {
1161 case 'l': case 'd':
1162 case 's': case 'b':
1163 case 'r': case 'a':
1164 case 'o': case 'O':
1165 case 'z': case 'Z':
1166 case 'C': case 'h':
1167 case 'f': case 'F': case 'A':
1168 case 'H': case 'p':
1169 case 'S': case 'P':
1170 case 'L': case 'n':
1171 max_num_args++;
1172 break;
1173
1174 case '|':
1175 min_num_args = max_num_args;
1176 have_optional_args = 1;
1177 break;
1178
1179 case '/':
1180 case '!':
1181 /* Pass */
1182 break;
1183
1184 case '*':
1185 case '+':
1186 if (have_varargs) {
1187 zend_parse_parameters_debug_error(
1188 "only one varargs specifier (* or +) is permitted");
1189 return FAILURE;
1190 }
1191 have_varargs = 1;
1192 /* we expect at least one parameter in varargs */
1193 if (c == '+') {
1194 max_num_args++;
1195 }
1196 /* mark the beginning of varargs */
1197 post_varargs = max_num_args;
1198
1199 if (ZEND_CALL_INFO(EG(current_execute_data)) & ZEND_CALL_HAS_EXTRA_NAMED_PARAMS) {
1201 return FAILURE;
1202 }
1203 break;
1204
1205 default:
1206 zend_parse_parameters_debug_error("bad type specifier while parsing parameters");
1207 return FAILURE;
1208 }
1209 }
1210
1211 /* with no optional arguments the minimum number of arguments must be the same as the maximum */
1212 if (!have_optional_args) {
1213 min_num_args = max_num_args;
1214 }
1215
1216 if (have_varargs) {
1217 /* calculate how many required args are at the end of the specifier list */
1218 post_varargs = max_num_args - post_varargs;
1219 max_num_args = UINT32_MAX;
1220 }
1221
1222 if (num_args < min_num_args || num_args > max_num_args) {
1223 if (!(flags & ZEND_PARSE_PARAMS_QUIET)) {
1225
1226 zend_argument_count_error("%s() expects %s %d argument%s, %d given",
1228 min_num_args == max_num_args ? "exactly" : num_args < min_num_args ? "at least" : "at most",
1229 num_args < min_num_args ? min_num_args : max_num_args,
1230 (num_args < min_num_args ? min_num_args : max_num_args) == 1 ? "" : "s",
1231 num_args
1232 );
1233
1234 zend_string_release(func_name);
1235 }
1236 return FAILURE;
1237 }
1238
1239 if (num_args > ZEND_CALL_NUM_ARGS(EG(current_execute_data))) {
1240 zend_parse_parameters_debug_error("could not obtain parameters for parsing");
1241 return FAILURE;
1242 }
1243
1244 i = 0;
1245 while (num_args-- > 0) {
1246 if (*type_spec == '|') {
1247 type_spec++;
1248 }
1249
1250 if (*type_spec == '*' || *type_spec == '+') {
1251 uint32_t num_varargs = num_args + 1 - post_varargs;
1252
1253 /* eat up the passed in storage even if it won't be filled in with varargs */
1254 varargs = va_arg(*va, zval **);
1255 n_varargs = va_arg(*va, uint32_t *);
1256 type_spec++;
1257
1258 if (num_varargs > 0) {
1259 *n_varargs = num_varargs;
1260 *varargs = ZEND_CALL_ARG(EG(current_execute_data), i + 1);
1261 /* adjust how many args we have left and restart loop */
1262 num_args += 1 - num_varargs;
1263 i += num_varargs;
1264 continue;
1265 } else {
1266 *varargs = NULL;
1267 *n_varargs = 0;
1268 }
1269 }
1270
1271 arg = ZEND_CALL_ARG(EG(current_execute_data), i + 1);
1272
1273 if (zend_parse_arg(i+1, arg, va, &type_spec, flags) == FAILURE) {
1274 /* clean up varargs array if it was used */
1275 if (varargs && *varargs) {
1276 *varargs = NULL;
1277 }
1278 return FAILURE;
1279 }
1280 i++;
1281 }
1282
1283 return SUCCESS;
1284}
1285/* }}} */
1286
1287ZEND_API zend_result zend_parse_parameters_ex(int flags, uint32_t num_args, const char *type_spec, ...) /* {{{ */
1288{
1289 va_list va;
1291
1292 va_start(va, type_spec);
1293 retval = zend_parse_va_args(num_args, type_spec, &va, flags);
1294 va_end(va);
1295
1296 return retval;
1297}
1298/* }}} */
1299
1300ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec, ...) /* {{{ */
1301{
1302 va_list va;
1304 int flags = 0;
1305
1306 va_start(va, type_spec);
1307 retval = zend_parse_va_args(num_args, type_spec, &va, flags);
1308 va_end(va);
1309
1310 return retval;
1311}
1312/* }}} */
1313
1314ZEND_API zend_result zend_parse_method_parameters(uint32_t num_args, zval *this_ptr, const char *type_spec, ...) /* {{{ */
1315{
1316 va_list va;
1318 int flags = 0;
1319 const char *p = type_spec;
1320 zval **object;
1321 zend_class_entry *ce;
1322
1323 /* Just checking this_ptr is not enough, because fcall_common_helper does not set
1324 * Z_OBJ(EG(This)) to NULL when calling an internal function with common.scope == NULL.
1325 * In that case EG(This) would still be the $this from the calling code and we'd take the
1326 * wrong branch here. */
1327 bool is_method = EG(current_execute_data)->func->common.scope != NULL;
1328
1329 if (!is_method || !this_ptr || Z_TYPE_P(this_ptr) != IS_OBJECT) {
1330 va_start(va, type_spec);
1331 retval = zend_parse_va_args(num_args, type_spec, &va, flags);
1332 va_end(va);
1333 } else {
1334 p++;
1335
1336 va_start(va, type_spec);
1337
1338 object = va_arg(va, zval **);
1339 ce = va_arg(va, zend_class_entry *);
1340 *object = this_ptr;
1341
1342 if (ce && !instanceof_function(Z_OBJCE_P(this_ptr), ce)) {
1343 zend_error_noreturn(E_CORE_ERROR, "%s::%s() must be derived from %s::%s()",
1345 }
1346
1347 retval = zend_parse_va_args(num_args, p, &va, flags);
1348 va_end(va);
1349 }
1350 return retval;
1351}
1352/* }}} */
1353
1354ZEND_API zend_result zend_parse_method_parameters_ex(int flags, uint32_t num_args, zval *this_ptr, const char *type_spec, ...) /* {{{ */
1355{
1356 va_list va;
1358 const char *p = type_spec;
1359 zval **object;
1360 zend_class_entry *ce;
1361
1362 if (!this_ptr) {
1363 va_start(va, type_spec);
1364 retval = zend_parse_va_args(num_args, type_spec, &va, flags);
1365 va_end(va);
1366 } else {
1367 p++;
1368 va_start(va, type_spec);
1369
1370 object = va_arg(va, zval **);
1371 ce = va_arg(va, zend_class_entry *);
1372 *object = this_ptr;
1373
1374 if (ce && !instanceof_function(Z_OBJCE_P(this_ptr), ce)) {
1375 if (!(flags & ZEND_PARSE_PARAMS_QUIET)) {
1376 zend_error_noreturn(E_CORE_ERROR, "%s::%s() must be derived from %s::%s()",
1378 }
1379 va_end(va);
1380 return FAILURE;
1381 }
1382
1383 retval = zend_parse_va_args(num_args, p, &va, flags);
1384 va_end(va);
1385 }
1386 return retval;
1387}
1388/* }}} */
1389
1390/* This function should be called after the constructor has been called
1391 * because it may call __set from the uninitialized object otherwise. */
1392ZEND_API void zend_merge_properties(zval *obj, HashTable *properties) /* {{{ */
1393{
1394 zend_object *zobj = Z_OBJ_P(obj);
1395 zend_object_write_property_t write_property = zobj->handlers->write_property;
1396 zend_class_entry *old_scope = EG(fake_scope);
1398 zval *value;
1399
1400 if (HT_IS_PACKED(properties)) {
1401 return;
1402 }
1403 EG(fake_scope) = Z_OBJCE_P(obj);
1405 if (key) {
1407 }
1409 EG(fake_scope) = old_scope;
1410}
1411/* }}} */
1412
1413static zend_class_mutable_data *zend_allocate_mutable_data(zend_class_entry *class_type) /* {{{ */
1414{
1415 zend_class_mutable_data *mutable_data;
1416
1417 ZEND_ASSERT(ZEND_MAP_PTR(class_type->mutable_data) != NULL);
1418 ZEND_ASSERT(ZEND_MAP_PTR_GET_IMM(class_type->mutable_data) == NULL);
1419
1420 mutable_data = zend_arena_alloc(&CG(arena), sizeof(zend_class_mutable_data));
1421 memset(mutable_data, 0, sizeof(zend_class_mutable_data));
1422 mutable_data->ce_flags = class_type->ce_flags;
1423 ZEND_MAP_PTR_SET_IMM(class_type->mutable_data, mutable_data);
1424
1425 return mutable_data;
1426}
1427/* }}} */
1428
1430{
1431 zend_class_mutable_data *mutable_data;
1432 HashTable *constants_table;
1434 zend_class_constant *new_c, *c;
1435
1436 constants_table = zend_arena_alloc(&CG(arena), sizeof(HashTable));
1437 zend_hash_init(constants_table, zend_hash_num_elements(&class_type->constants_table), NULL, NULL, 0);
1438 zend_hash_extend(constants_table, zend_hash_num_elements(&class_type->constants_table), 0);
1439
1441 if (c->ce == class_type) {
1442 if (Z_TYPE(c->value) == IS_CONSTANT_AST) {
1443 new_c = zend_arena_alloc(&CG(arena), sizeof(zend_class_constant));
1444 memcpy(new_c, c, sizeof(zend_class_constant));
1445 c = new_c;
1446 }
1447 Z_TRY_ADDREF(c->value);
1448 } else {
1449 if (Z_TYPE(c->value) == IS_CONSTANT_AST) {
1450 c = zend_hash_find_ptr(CE_CONSTANTS_TABLE(c->ce), key);
1451 ZEND_ASSERT(c);
1452 }
1453 }
1454 _zend_hash_append_ptr(constants_table, key, c);
1456
1457 ZEND_ASSERT(ZEND_MAP_PTR(class_type->mutable_data) != NULL);
1458
1459 mutable_data = ZEND_MAP_PTR_GET_IMM(class_type->mutable_data);
1460 if (!mutable_data) {
1461 mutable_data = zend_allocate_mutable_data(class_type);
1462 }
1463
1464 mutable_data->constants_table = constants_table;
1465
1466 return constants_table;
1467}
1468
1469static zend_result update_property(zval *val, zend_property_info *prop_info) {
1470 if (ZEND_TYPE_IS_SET(prop_info->type)) {
1471 zval tmp;
1472
1473 ZVAL_COPY(&tmp, val);
1475 zval_ptr_dtor(&tmp);
1476 return FAILURE;
1477 }
1478 /* property initializers must always be evaluated with strict types */;
1479 if (UNEXPECTED(!zend_verify_property_type(prop_info, &tmp, /* strict */ 1))) {
1480 zval_ptr_dtor(&tmp);
1481 return FAILURE;
1482 }
1484 ZVAL_COPY_VALUE(val, &tmp);
1485 return SUCCESS;
1486 }
1488}
1489
1491{
1493
1495 return zval_update_constant_ex(&c->value, scope);
1496 }
1497
1498 zval tmp;
1499
1500 ZVAL_COPY(&tmp, &c->value);
1502 if (result == FAILURE) {
1503 zval_ptr_dtor(&tmp);
1504 return FAILURE;
1505 }
1506
1508 zval_ptr_dtor(&tmp);
1509 return FAILURE;
1510 }
1511
1512 zval_ptr_dtor(&c->value);
1513 ZVAL_COPY_VALUE(&c->value, &tmp);
1514
1515 return SUCCESS;
1516}
1517
1519{
1520 zend_class_mutable_data *mutable_data = NULL;
1521 zval *default_properties_table = NULL;
1522 zval *static_members_table = NULL;
1524 zval *val;
1525 uint32_t ce_flags;
1526
1527 ce_flags = class_type->ce_flags;
1528
1529 if (ce_flags & ZEND_ACC_CONSTANTS_UPDATED) {
1530 return SUCCESS;
1531 }
1532
1533 bool uses_mutable_data = ZEND_MAP_PTR(class_type->mutable_data) != NULL;
1534 if (uses_mutable_data) {
1535 mutable_data = ZEND_MAP_PTR_GET_IMM(class_type->mutable_data);
1536 if (mutable_data) {
1537 ce_flags = mutable_data->ce_flags;
1538 if (ce_flags & ZEND_ACC_CONSTANTS_UPDATED) {
1539 return SUCCESS;
1540 }
1541 } else {
1542 mutable_data = zend_allocate_mutable_data(class_type);
1543 }
1544 }
1545
1546 if (class_type->parent) {
1548 return FAILURE;
1549 }
1550 }
1551
1552 if (ce_flags & ZEND_ACC_HAS_AST_CONSTANTS) {
1553 HashTable *constants_table;
1554
1555 if (uses_mutable_data) {
1556 constants_table = mutable_data->constants_table;
1557 if (!constants_table) {
1558 constants_table = zend_separate_class_constants_table(class_type);
1559 }
1560 } else {
1561 constants_table = &class_type->constants_table;
1562 }
1563
1565 ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(constants_table, name, val) {
1566 c = Z_PTR_P(val);
1567 if (Z_TYPE(c->value) == IS_CONSTANT_AST) {
1568 if (c->ce != class_type) {
1569 Z_PTR_P(val) = c = zend_hash_find_ptr(CE_CONSTANTS_TABLE(c->ce), name);
1570 if (Z_TYPE(c->value) != IS_CONSTANT_AST) {
1571 continue;
1572 }
1573 }
1574
1575 val = &c->value;
1577 return FAILURE;
1578 }
1579 }
1581 }
1582
1583 if (class_type->default_static_members_count) {
1584 static_members_table = CE_STATIC_MEMBERS(class_type);
1585 if (!static_members_table) {
1586 zend_class_init_statics(class_type);
1587 static_members_table = CE_STATIC_MEMBERS(class_type);
1588 }
1589 }
1590
1591 default_properties_table = class_type->default_properties_table;
1592 if (uses_mutable_data && (ce_flags & ZEND_ACC_HAS_AST_PROPERTIES)) {
1593 zval *src, *dst, *end;
1594
1595 default_properties_table = mutable_data->default_properties_table;
1596 if (!default_properties_table) {
1597 default_properties_table = zend_arena_alloc(&CG(arena), sizeof(zval) * class_type->default_properties_count);
1598 src = class_type->default_properties_table;
1599 dst = default_properties_table;
1600 end = dst + class_type->default_properties_count;
1601 do {
1602 ZVAL_COPY_PROP(dst, src);
1603 src++;
1604 dst++;
1605 } while (dst != end);
1606 mutable_data->default_properties_table = default_properties_table;
1607 }
1608 }
1609
1612
1613 /* Use the default properties table to also update initializers of private properties
1614 * that have been shadowed in a child class. */
1615 for (uint32_t i = 0; i < class_type->default_properties_count; i++) {
1616 prop_info = class_type->properties_info_table[i];
1617 if (!prop_info) {
1618 continue;
1619 }
1620
1621 val = &default_properties_table[OBJ_PROP_TO_NUM(prop_info->offset)];
1623 && UNEXPECTED(update_property(val, prop_info) != SUCCESS)) {
1624 return FAILURE;
1625 }
1626 }
1627
1628 if (class_type->default_static_members_count) {
1630 if (prop_info->flags & ZEND_ACC_STATIC) {
1631 val = static_members_table + prop_info->offset;
1633 && UNEXPECTED(update_property(val, prop_info) != SUCCESS)) {
1634 return FAILURE;
1635 }
1636 }
1638 }
1639 }
1640
1641 if (class_type->type == ZEND_USER_CLASS && class_type->ce_flags & ZEND_ACC_ENUM && class_type->enum_backing_type != IS_UNDEF) {
1642 if (zend_enum_build_backed_enum_table(class_type) == FAILURE) {
1643 return FAILURE;
1644 }
1645 }
1646
1647 ce_flags |= ZEND_ACC_CONSTANTS_UPDATED;
1648 ce_flags &= ~ZEND_ACC_HAS_AST_CONSTANTS;
1649 ce_flags &= ~ZEND_ACC_HAS_AST_PROPERTIES;
1650 ce_flags &= ~ZEND_ACC_HAS_AST_STATICS;
1651 if (uses_mutable_data) {
1652 mutable_data->ce_flags = ce_flags;
1653 } else {
1654 class_type->ce_flags = ce_flags;
1655 }
1656
1657 return SUCCESS;
1658}
1659/* }}} */
1660
1661static zend_always_inline void _object_properties_init(zend_object *object, zend_class_entry *class_type) /* {{{ */
1662{
1663 if (class_type->default_properties_count) {
1664 zval *src = CE_DEFAULT_PROPERTIES_TABLE(class_type);
1665 zval *dst = object->properties_table;
1666 zval *end = src + class_type->default_properties_count;
1667
1668 if (UNEXPECTED(class_type->type == ZEND_INTERNAL_CLASS)) {
1669 /* We don't have to account for refcounting because
1670 * zend_declare_typed_property() disallows refcounted defaults for internal classes. */
1671 do {
1673 ZVAL_COPY_VALUE_PROP(dst, src);
1674 src++;
1675 dst++;
1676 } while (src != end);
1677 } else {
1678 do {
1679 ZVAL_COPY_PROP(dst, src);
1680 src++;
1681 dst++;
1682 } while (src != end);
1683 }
1684 }
1685}
1686/* }}} */
1687
1689{
1690 object->properties = NULL;
1691 _object_properties_init(object, class_type);
1692}
1693/* }}} */
1694
1695ZEND_API void object_properties_init_ex(zend_object *object, HashTable *properties) /* {{{ */
1696{
1697 object->properties = properties;
1698 if (object->ce->default_properties_count) {
1699 zval *prop;
1701 zend_property_info *property_info;
1702
1703 ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(properties, key, prop) {
1704 property_info = zend_get_property_info(object->ce, key, 1);
1705 if (property_info != ZEND_WRONG_PROPERTY_INFO &&
1706 property_info &&
1707 (property_info->flags & ZEND_ACC_STATIC) == 0) {
1708 zval *slot = OBJ_PROP(object, property_info->offset);
1709
1710 if (ZEND_TYPE_IS_SET(property_info->type)) {
1711 zval tmp;
1712
1713 ZVAL_COPY_VALUE(&tmp, prop);
1714 if (UNEXPECTED(!zend_verify_property_type(property_info, &tmp, 0))) {
1715 continue;
1716 }
1717 ZVAL_COPY_VALUE(slot, &tmp);
1718 } else {
1719 ZVAL_COPY_VALUE(slot, prop);
1720 }
1721 ZVAL_INDIRECT(prop, slot);
1722 }
1724 }
1725}
1726/* }}} */
1727
1728ZEND_API void object_properties_load(zend_object *object, HashTable *properties) /* {{{ */
1729{
1730 zval *prop, tmp;
1732 zend_long h;
1733 zend_property_info *property_info;
1734
1735 ZEND_HASH_FOREACH_KEY_VAL(properties, h, key, prop) {
1736 if (key) {
1737 if (ZSTR_VAL(key)[0] == '\0') {
1738 const char *class_name, *prop_name;
1739 size_t prop_name_len;
1740 if (zend_unmangle_property_name_ex(key, &class_name, &prop_name, &prop_name_len) == SUCCESS) {
1741 zend_string *pname = zend_string_init(prop_name, prop_name_len, 0);
1742 zend_class_entry *prev_scope = EG(fake_scope);
1743 if (class_name && class_name[0] != '*') {
1744 zend_string *cname = zend_string_init(class_name, strlen(class_name), 0);
1745 EG(fake_scope) = zend_lookup_class(cname);
1746 zend_string_release_ex(cname, 0);
1747 }
1748 property_info = zend_get_property_info(object->ce, pname, 1);
1749 zend_string_release_ex(pname, 0);
1750 EG(fake_scope) = prev_scope;
1751 } else {
1752 property_info = ZEND_WRONG_PROPERTY_INFO;
1753 }
1754 } else {
1755 property_info = zend_get_property_info(object->ce, key, 1);
1756 }
1757 if (property_info != ZEND_WRONG_PROPERTY_INFO &&
1758 property_info &&
1759 (property_info->flags & ZEND_ACC_STATIC) == 0) {
1760 zval *slot = OBJ_PROP(object, property_info->offset);
1761 zval_ptr_dtor(slot);
1762 ZVAL_COPY_VALUE(slot, prop);
1763 zval_add_ref(slot);
1764 if (object->properties) {
1765 ZVAL_INDIRECT(&tmp, slot);
1766 zend_hash_update(object->properties, key, &tmp);
1767 }
1768 } else {
1769 if (UNEXPECTED(object->ce->ce_flags & ZEND_ACC_NO_DYNAMIC_PROPERTIES)) {
1770 zend_throw_error(NULL, "Cannot create dynamic property %s::$%s",
1771 ZSTR_VAL(object->ce->name), property_info != ZEND_WRONG_PROPERTY_INFO ? zend_get_unmangled_property_name(key): "");
1772 return;
1773 } else if (!(object->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) {
1774 zend_error(E_DEPRECATED, "Creation of dynamic property %s::$%s is deprecated",
1775 ZSTR_VAL(object->ce->name), property_info != ZEND_WRONG_PROPERTY_INFO ? zend_get_unmangled_property_name(key): "");
1776 }
1777
1778 prop = zend_hash_update(zend_std_get_properties_ex(object), key, prop);
1779 zval_add_ref(prop);
1780 }
1781 } else {
1782 if (UNEXPECTED(object->ce->ce_flags & ZEND_ACC_NO_DYNAMIC_PROPERTIES)) {
1783 zend_throw_error(NULL, "Cannot create dynamic property %s::$" ZEND_LONG_FMT, ZSTR_VAL(object->ce->name), h);
1784 return;
1785 } else if (!(object->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) {
1786 zend_error(E_DEPRECATED, "Creation of dynamic property %s::$" ZEND_LONG_FMT " is deprecated",
1787 ZSTR_VAL(object->ce->name), h);
1788 }
1789
1790 prop = zend_hash_index_update(zend_std_get_properties_ex(object), h, prop);
1791 zval_add_ref(prop);
1792 }
1794}
1795/* }}} */
1796
1797/* This function requires 'properties' to contain all props declared in the
1798 * class and all props being public. If only a subset is given or the class
1799 * has protected members then you need to merge the properties separately by
1800 * calling zend_merge_properties(). */
1801static zend_always_inline zend_result _object_and_properties_init(zval *arg, zend_class_entry *class_type, HashTable *properties) /* {{{ */
1802{
1803 if (UNEXPECTED(class_type->ce_flags & ZEND_ACC_UNINSTANTIABLE)) {
1804 if (class_type->ce_flags & ZEND_ACC_INTERFACE) {
1805 zend_throw_error(NULL, "Cannot instantiate interface %s", ZSTR_VAL(class_type->name));
1806 } else if (class_type->ce_flags & ZEND_ACC_TRAIT) {
1807 zend_throw_error(NULL, "Cannot instantiate trait %s", ZSTR_VAL(class_type->name));
1808 } else if (class_type->ce_flags & ZEND_ACC_ENUM) {
1809 zend_throw_error(NULL, "Cannot instantiate enum %s", ZSTR_VAL(class_type->name));
1810 } else {
1812 zend_throw_error(NULL, "Cannot instantiate abstract class %s", ZSTR_VAL(class_type->name));
1813 }
1814 ZVAL_NULL(arg);
1815 Z_OBJ_P(arg) = NULL;
1816 return FAILURE;
1817 }
1818
1819 if (UNEXPECTED(!(class_type->ce_flags & ZEND_ACC_CONSTANTS_UPDATED))) {
1820 if (UNEXPECTED(zend_update_class_constants(class_type) != SUCCESS)) {
1821 ZVAL_NULL(arg);
1822 Z_OBJ_P(arg) = NULL;
1823 return FAILURE;
1824 }
1825 }
1826
1827 if (class_type->create_object == NULL) {
1828 zend_object *obj = zend_objects_new(class_type);
1829
1830 ZVAL_OBJ(arg, obj);
1831 if (properties) {
1832 object_properties_init_ex(obj, properties);
1833 } else {
1834 _object_properties_init(obj, class_type);
1835 }
1836 } else {
1837 ZVAL_OBJ(arg, class_type->create_object(class_type));
1838 }
1839 return SUCCESS;
1840}
1841/* }}} */
1842
1844{
1845 return _object_and_properties_init(arg, class_type, properties);
1846}
1847/* }}} */
1848
1850{
1851 return _object_and_properties_init(arg, class_type, NULL);
1852}
1853/* }}} */
1854
1855ZEND_API zend_result object_init_with_constructor(zval *arg, zend_class_entry *class_type, uint32_t param_count, zval *params, HashTable *named_params) /* {{{ */
1856{
1857 zend_result status = _object_and_properties_init(arg, class_type, NULL);
1858 if (UNEXPECTED(status == FAILURE)) {
1859 ZVAL_UNDEF(arg);
1860 return FAILURE;
1861 }
1862 zend_object *obj = Z_OBJ_P(arg);
1863 zend_function *constructor = obj->handlers->get_constructor(obj);
1864 if (constructor == NULL) {
1865 /* The constructor can be NULL for 2 different reasons:
1866 * - It is not defined
1867 * - We are not allowed to call the constructor (e.g. private, or internal opaque class)
1868 * and an exception has been thrown
1869 * in the former case, we are (mostly) done and the object is initialized,
1870 * in the latter we need to destroy the object as initialization failed
1871 */
1872 if (UNEXPECTED(EG(exception))) {
1874 ZVAL_UNDEF(arg);
1875 return FAILURE;
1876 }
1877
1878 /* Surprisingly, this is the only case where internal classes will allow to pass extra arguments
1879 * However, if there are named arguments (and it is not empty),
1880 * an Error must be thrown to be consistent with new ClassName() */
1881 if (UNEXPECTED(named_params != NULL && zend_hash_num_elements(named_params) != 0)) {
1882 /* Throw standard Error */
1883 zend_string *arg_name = NULL;
1884 zend_hash_get_current_key(named_params, &arg_name, /* num_index */ NULL);
1885 ZEND_ASSERT(arg_name != NULL);
1886 zend_throw_error(NULL, "Unknown named parameter $%s", ZSTR_VAL(arg_name));
1887 /* Do not call destructor, free object, and set arg to IS_UNDEF */
1888 zend_object_store_ctor_failed(obj);
1890 ZVAL_UNDEF(arg);
1891 return FAILURE;
1892 } else {
1893 return SUCCESS;
1894 }
1895 }
1896 /* A constructor should not return a value, however if an exception is thrown
1897 * zend_call_known_function() will set the retval to IS_UNDEF */
1898 zval retval;
1900 constructor,
1901 obj,
1902 class_type,
1903 &retval,
1904 param_count,
1905 params,
1906 named_params
1907 );
1908 if (Z_TYPE(retval) == IS_UNDEF) {
1909 /* Do not call destructor, free object, and set arg to IS_UNDEF */
1910 zend_object_store_ctor_failed(obj);
1912 ZVAL_UNDEF(arg);
1913 return FAILURE;
1914 } else {
1915 /* Unlikely, but user constructors may return any value they want */
1917 return SUCCESS;
1918 }
1919}
1920/* }}} */
1921
1926/* }}} */
1927
1928ZEND_API void add_assoc_long_ex(zval *arg, const char *key, size_t key_len, zend_long n) /* {{{ */
1929{
1930 zval tmp;
1931
1932 ZVAL_LONG(&tmp, n);
1933 zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp);
1934}
1935/* }}} */
1936
1937ZEND_API void add_assoc_null_ex(zval *arg, const char *key, size_t key_len) /* {{{ */
1938{
1939 zval tmp;
1940
1941 ZVAL_NULL(&tmp);
1942 zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp);
1943}
1944/* }}} */
1945
1946ZEND_API void add_assoc_bool_ex(zval *arg, const char *key, size_t key_len, bool b) /* {{{ */
1947{
1948 zval tmp;
1949
1950 ZVAL_BOOL(&tmp, b);
1951 zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp);
1952}
1953/* }}} */
1954
1955ZEND_API void add_assoc_resource_ex(zval *arg, const char *key, size_t key_len, zend_resource *r) /* {{{ */
1956{
1957 zval tmp;
1958
1959 ZVAL_RES(&tmp, r);
1960 zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp);
1961}
1962/* }}} */
1963
1964ZEND_API void add_assoc_double_ex(zval *arg, const char *key, size_t key_len, double d) /* {{{ */
1965{
1966 zval tmp;
1967
1968 ZVAL_DOUBLE(&tmp, d);
1969 zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp);
1970}
1971/* }}} */
1972
1973ZEND_API void add_assoc_str_ex(zval *arg, const char *key, size_t key_len, zend_string *str) /* {{{ */
1974{
1975 zval tmp;
1976
1977 ZVAL_STR(&tmp, str);
1978 zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp);
1979}
1980/* }}} */
1981
1982ZEND_API void add_assoc_string_ex(zval *arg, const char *key, size_t key_len, const char *str) /* {{{ */
1983{
1984 zval tmp;
1985
1986 ZVAL_STRING(&tmp, str);
1987 zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp);
1988}
1989/* }}} */
1990
1991ZEND_API void add_assoc_stringl_ex(zval *arg, const char *key, size_t key_len, const char *str, size_t length) /* {{{ */
1992{
1993 zval tmp;
1994
1995 ZVAL_STRINGL(&tmp, str, length);
1996 zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp);
1997}
1998/* }}} */
1999
2000ZEND_API void add_assoc_array_ex(zval *arg, const char *key, size_t key_len, zend_array *arr) /* {{{ */
2001{
2002 zval tmp;
2003
2004 ZVAL_ARR(&tmp, arr);
2005 zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp);
2006}
2007/* }}} */
2008
2009ZEND_API void add_assoc_object_ex(zval *arg, const char *key, size_t key_len, zend_object *obj) /* {{{ */
2010{
2011 zval tmp;
2012
2013 ZVAL_OBJ(&tmp, obj);
2014 zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp);
2015}
2016/* }}} */
2017
2018ZEND_API void add_assoc_reference_ex(zval *arg, const char *key, size_t key_len, zend_reference *ref) /* {{{ */
2019{
2020 zval tmp;
2021
2022 ZVAL_REF(&tmp, ref);
2023 zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp);
2024}
2025/* }}} */
2026
2027ZEND_API void add_assoc_zval_ex(zval *arg, const char *key, size_t key_len, zval *value) /* {{{ */
2028{
2029 zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, value);
2030}
2031/* }}} */
2032
2034{
2035 zval tmp;
2036
2037 ZVAL_LONG(&tmp, n);
2038 zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp);
2039}
2040/* }}} */
2041
2043{
2044 zval tmp;
2045
2046 ZVAL_NULL(&tmp);
2047 zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp);
2048}
2049/* }}} */
2050
2051ZEND_API void add_index_bool(zval *arg, zend_ulong index, bool b) /* {{{ */
2052{
2053 zval tmp;
2054
2055 ZVAL_BOOL(&tmp, b);
2056 zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp);
2057}
2058/* }}} */
2059
2061{
2062 zval tmp;
2063
2064 ZVAL_RES(&tmp, r);
2065 zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp);
2066}
2067/* }}} */
2068
2069ZEND_API void add_index_double(zval *arg, zend_ulong index, double d) /* {{{ */
2070{
2071 zval tmp;
2072
2073 ZVAL_DOUBLE(&tmp, d);
2074 zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp);
2075}
2076/* }}} */
2077
2079{
2080 zval tmp;
2081
2082 ZVAL_STR(&tmp, str);
2083 zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp);
2084}
2085/* }}} */
2086
2087ZEND_API void add_index_string(zval *arg, zend_ulong index, const char *str) /* {{{ */
2088{
2089 zval tmp;
2090
2091 ZVAL_STRING(&tmp, str);
2092 zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp);
2093}
2094/* }}} */
2095
2096ZEND_API void add_index_stringl(zval *arg, zend_ulong index, const char *str, size_t length) /* {{{ */
2097{
2098 zval tmp;
2099
2100 ZVAL_STRINGL(&tmp, str, length);
2101 zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp);
2102}
2103/* }}} */
2104
2106{
2107 zval tmp;
2108
2109 ZVAL_ARR(&tmp, arr);
2110 zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp);
2111}
2112/* }}} */
2113
2115{
2116 zval tmp;
2117
2118 ZVAL_OBJ(&tmp, obj);
2119 zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp);
2120}
2121/* }}} */
2122
2124{
2125 zval tmp;
2126
2127 ZVAL_REF(&tmp, ref);
2128 zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp);
2129}
2130/* }}} */
2131
2133{
2134 zval tmp;
2135
2136 ZVAL_LONG(&tmp, n);
2138}
2139/* }}} */
2140
2142{
2143 zval tmp;
2144
2145 ZVAL_NULL(&tmp);
2147}
2148/* }}} */
2149
2151{
2152 zval tmp;
2153
2154 ZVAL_BOOL(&tmp, b);
2156}
2157/* }}} */
2158
2160{
2161 zval tmp;
2162
2163 ZVAL_RES(&tmp, r);
2165}
2166/* }}} */
2167
2169{
2170 zval tmp;
2171
2172 ZVAL_DOUBLE(&tmp, d);
2174}
2175/* }}} */
2176
2178{
2179 zval tmp;
2180
2181 ZVAL_STR(&tmp, str);
2183}
2184/* }}} */
2185
2187{
2188 zval tmp;
2189
2190 ZVAL_STRING(&tmp, str);
2192}
2193/* }}} */
2194
2195ZEND_API zend_result add_next_index_stringl(zval *arg, const char *str, size_t length) /* {{{ */
2196{
2197 zval tmp;
2198
2199 ZVAL_STRINGL(&tmp, str, length);
2201}
2202/* }}} */
2203
2205{
2206 zval tmp;
2207
2208 ZVAL_ARR(&tmp, arr);
2210}
2211/* }}} */
2212
2214{
2215 zval tmp;
2216
2217 ZVAL_OBJ(&tmp, obj);
2219}
2220/* }}} */
2221
2223{
2224 zval tmp;
2225
2226 ZVAL_REF(&tmp, ref);
2228}
2229/* }}} */
2230
2232{
2233 zval *result;
2234
2235 switch (Z_TYPE_P(key)) {
2236 case IS_STRING:
2237 result = zend_symtable_update(ht, Z_STR_P(key), value);
2238 break;
2239 case IS_NULL:
2241 break;
2242 case IS_RESOURCE:
2245 break;
2246 case IS_FALSE:
2248 break;
2249 case IS_TRUE:
2251 break;
2252 case IS_LONG:
2254 break;
2255 case IS_DOUBLE:
2256 result = zend_hash_index_update(ht, zend_dval_to_lval_safe(Z_DVAL_P(key)), value);
2257 break;
2258 default:
2260 result = NULL;
2261 }
2262
2263 if (result) {
2265 return SUCCESS;
2266 } else {
2267 return FAILURE;
2268 }
2269}
2270/* }}} */
2271
2272ZEND_API void add_property_long_ex(zval *arg, const char *key, size_t key_len, zend_long n) /* {{{ */
2273{
2274 zval tmp;
2275
2276 ZVAL_LONG(&tmp, n);
2277 add_property_zval_ex(arg, key, key_len, &tmp);
2278}
2279/* }}} */
2280
2281ZEND_API void add_property_bool_ex(zval *arg, const char *key, size_t key_len, zend_long b) /* {{{ */
2282{
2283 zval tmp;
2284
2285 ZVAL_BOOL(&tmp, b);
2286 add_property_zval_ex(arg, key, key_len, &tmp);
2287}
2288/* }}} */
2289
2290ZEND_API void add_property_null_ex(zval *arg, const char *key, size_t key_len) /* {{{ */
2291{
2292 zval tmp;
2293
2294 ZVAL_NULL(&tmp);
2295 add_property_zval_ex(arg, key, key_len, &tmp);
2296}
2297/* }}} */
2298
2299ZEND_API void add_property_resource_ex(zval *arg, const char *key, size_t key_len, zend_resource *r) /* {{{ */
2300{
2301 zval tmp;
2302
2303 ZVAL_RES(&tmp, r);
2304 add_property_zval_ex(arg, key, key_len, &tmp);
2305 zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
2306}
2307/* }}} */
2308
2309ZEND_API void add_property_double_ex(zval *arg, const char *key, size_t key_len, double d) /* {{{ */
2310{
2311 zval tmp;
2312
2313 ZVAL_DOUBLE(&tmp, d);
2314 add_property_zval_ex(arg, key, key_len, &tmp);
2315}
2316/* }}} */
2317
2318ZEND_API void add_property_str_ex(zval *arg, const char *key, size_t key_len, zend_string *str) /* {{{ */
2319{
2320 zval tmp;
2321
2322 ZVAL_STR(&tmp, str);
2323 add_property_zval_ex(arg, key, key_len, &tmp);
2324 zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
2325}
2326/* }}} */
2327
2328ZEND_API void add_property_string_ex(zval *arg, const char *key, size_t key_len, const char *str) /* {{{ */
2329{
2330 zval tmp;
2331
2332 ZVAL_STRING(&tmp, str);
2333 add_property_zval_ex(arg, key, key_len, &tmp);
2334 zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
2335}
2336/* }}} */
2337
2338ZEND_API void add_property_stringl_ex(zval *arg, const char *key, size_t key_len, const char *str, size_t length) /* {{{ */
2339{
2340 zval tmp;
2341
2342 ZVAL_STRINGL(&tmp, str, length);
2343 add_property_zval_ex(arg, key, key_len, &tmp);
2344 zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
2345}
2346/* }}} */
2347
2348ZEND_API void add_property_array_ex(zval *arg, const char *key, size_t key_len, zend_array *arr) /* {{{ */
2349{
2350 zval tmp;
2351
2352 ZVAL_ARR(&tmp, arr);
2353 add_property_zval_ex(arg, key, key_len, &tmp);
2354 zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
2355}
2356/* }}} */
2357
2358ZEND_API void add_property_object_ex(zval *arg, const char *key, size_t key_len, zend_object *obj) /* {{{ */
2359{
2360 zval tmp;
2361
2362 ZVAL_OBJ(&tmp, obj);
2363 add_property_zval_ex(arg, key, key_len, &tmp);
2364 zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
2365}
2366/* }}} */
2367
2368ZEND_API void add_property_reference_ex(zval *arg, const char *key, size_t key_len, zend_reference *ref) /* {{{ */
2369{
2370 zval tmp;
2371
2372 ZVAL_REF(&tmp, ref);
2373 add_property_zval_ex(arg, key, key_len, &tmp);
2374 zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
2375}
2376/* }}} */
2377
2378ZEND_API void add_property_zval_ex(zval *arg, const char *key, size_t key_len, zval *value) /* {{{ */
2379{
2380 zend_string *str;
2381
2382 str = zend_string_init(key, key_len, 0);
2384 zend_string_release_ex(str, 0);
2385}
2386/* }}} */
2387
2389{
2390 size_t name_len;
2392
2393 if (module->module_started) {
2394 return SUCCESS;
2395 }
2396 module->module_started = 1;
2397
2398 /* Check module dependencies */
2399 if (module->deps) {
2400 const zend_module_dep *dep = module->deps;
2401
2402 while (dep->name) {
2403 if (dep->type == MODULE_DEP_REQUIRED) {
2404 zend_module_entry *req_mod;
2405
2406 name_len = strlen(dep->name);
2407 lcname = zend_string_alloc(name_len, 0);
2408 zend_str_tolower_copy(ZSTR_VAL(lcname), dep->name, name_len);
2409
2410 if ((req_mod = zend_hash_find_ptr(&module_registry, lcname)) == NULL || !req_mod->module_started) {
2411 zend_string_efree(lcname);
2412 /* TODO: Check version relationship */
2413 zend_error(E_CORE_WARNING, "Cannot load module \"%s\" because required module \"%s\" is not loaded", module->name, dep->name);
2414 module->module_started = 0;
2415 return FAILURE;
2416 }
2417 zend_string_efree(lcname);
2418 }
2419 ++dep;
2420 }
2421 }
2422
2423 /* Initialize module globals */
2424 if (module->globals_size) {
2425#ifdef ZTS
2426 ts_allocate_id(module->globals_id_ptr, module->globals_size, (ts_allocate_ctor) module->globals_ctor, (ts_allocate_dtor) module->globals_dtor);
2427#else
2428 if (module->globals_ctor) {
2429 module->globals_ctor(module->globals_ptr);
2430 }
2431#endif
2432 }
2433 if (module->module_startup_func) {
2434 EG(current_module) = module;
2435 if (module->module_startup_func(module->type, module->module_number)==FAILURE) {
2436 zend_error_noreturn(E_CORE_ERROR,"Unable to start %s module", module->name);
2437 EG(current_module) = NULL;
2438 return FAILURE;
2439 }
2440 EG(current_module) = NULL;
2441 }
2442 return SUCCESS;
2443}
2444/* }}} */
2445
2446static int zend_startup_module_zval(zval *zv) /* {{{ */
2447{
2448 zend_module_entry *module = Z_PTR_P(zv);
2449
2451}
2452/* }}} */
2453
2454static void zend_sort_modules(void *base, size_t count, size_t siz, compare_func_t compare, swap_func_t swp) /* {{{ */
2455{
2456 Bucket *b1 = base;
2457 Bucket *b2;
2458 Bucket *end = b1 + count;
2459 Bucket tmp;
2460 zend_module_entry *m, *r;
2461
2462 while (b1 < end) {
2463try_again:
2464 m = (zend_module_entry*)Z_PTR(b1->val);
2465 if (!m->module_started && m->deps) {
2466 const zend_module_dep *dep = m->deps;
2467 while (dep->name) {
2468 if (dep->type == MODULE_DEP_REQUIRED || dep->type == MODULE_DEP_OPTIONAL) {
2469 b2 = b1 + 1;
2470 while (b2 < end) {
2471 r = (zend_module_entry*)Z_PTR(b2->val);
2472 if (strcasecmp(dep->name, r->name) == 0) {
2473 tmp = *b1;
2474 *b1 = *b2;
2475 *b2 = tmp;
2476 goto try_again;
2477 }
2478 b2++;
2479 }
2480 }
2481 dep++;
2482 }
2483 }
2484 b1++;
2485 }
2486}
2487/* }}} */
2488
2490{
2491 zend_module_entry *module;
2492 int startup_count = 0;
2493 int shutdown_count = 0;
2494 int post_deactivate_count = 0;
2495 int dl_loaded_count = 0;
2496 zend_class_entry *ce;
2497 int class_count = 0;
2498
2499 /* Collect extensions with request startup/shutdown handlers */
2501 if (module->request_startup_func) {
2502 startup_count++;
2503 }
2504 if (module->request_shutdown_func) {
2505 shutdown_count++;
2506 }
2507 if (module->post_deactivate_func) {
2508 post_deactivate_count++;
2509 }
2510 if (module->handle) {
2511 dl_loaded_count++;
2512 }
2514 module_request_startup_handlers = (zend_module_entry**)realloc(
2515 module_request_startup_handlers,
2516 sizeof(zend_module_entry*) *
2517 (startup_count + 1 +
2518 shutdown_count + 1 +
2519 post_deactivate_count + 1));
2520 module_request_startup_handlers[startup_count] = NULL;
2521 module_request_shutdown_handlers = module_request_startup_handlers + startup_count + 1;
2522 module_request_shutdown_handlers[shutdown_count] = NULL;
2523 module_post_deactivate_handlers = module_request_shutdown_handlers + shutdown_count + 1;
2524 module_post_deactivate_handlers[post_deactivate_count] = NULL;
2525 /* Cannot reuse module_request_startup_handlers because it is freed in zend_destroy_modules, which happens before zend_unload_modules. */
2526 modules_dl_loaded = realloc(modules_dl_loaded, sizeof(zend_module_entry*) * (dl_loaded_count + 1));
2527 modules_dl_loaded[dl_loaded_count] = NULL;
2528 startup_count = 0;
2529
2531 if (module->request_startup_func) {
2532 module_request_startup_handlers[startup_count++] = module;
2533 }
2534 if (module->request_shutdown_func) {
2535 module_request_shutdown_handlers[--shutdown_count] = module;
2536 }
2537 if (module->post_deactivate_func) {
2538 module_post_deactivate_handlers[--post_deactivate_count] = module;
2539 }
2540 if (module->handle) {
2541 modules_dl_loaded[--dl_loaded_count] = module;
2542 }
2544
2545 /* Collect internal classes with static members */
2546 ZEND_HASH_MAP_FOREACH_PTR(CG(class_table), ce) {
2547 if (ce->type == ZEND_INTERNAL_CLASS &&
2549 class_count++;
2550 }
2552
2553 class_cleanup_handlers = (zend_class_entry**)realloc(
2554 class_cleanup_handlers,
2555 sizeof(zend_class_entry*) *
2556 (class_count + 1));
2557 class_cleanup_handlers[class_count] = NULL;
2558
2559 if (class_count) {
2560 ZEND_HASH_MAP_FOREACH_PTR(CG(class_table), ce) {
2561 if (ce->type == ZEND_INTERNAL_CLASS &&
2563 class_cleanup_handlers[--class_count] = ce;
2564 }
2566 }
2567}
2568/* }}} */
2569
2570ZEND_API void zend_startup_modules(void) /* {{{ */
2571{
2572 zend_hash_sort_ex(&module_registry, zend_sort_modules, NULL, 0);
2573 zend_hash_apply(&module_registry, zend_startup_module_zval);
2574}
2575/* }}} */
2576
2577ZEND_API void zend_destroy_modules(void) /* {{{ */
2578{
2579 free(class_cleanup_handlers);
2580 class_cleanup_handlers = NULL;
2581 free(module_request_startup_handlers);
2582 module_request_startup_handlers = NULL;
2584}
2585/* }}} */
2586
2588{
2589 size_t name_len;
2591 zend_module_entry *module_ptr;
2592
2593 if (!module) {
2594 return NULL;
2595 }
2596
2597#if 0
2598 zend_printf("%s: Registering module %d\n", module->name, module->module_number);
2599#endif
2600
2601 /* Check module dependencies */
2602 if (module->deps) {
2603 const zend_module_dep *dep = module->deps;
2604
2605 while (dep->name) {
2606 if (dep->type == MODULE_DEP_CONFLICTS) {
2607 name_len = strlen(dep->name);
2608 lcname = zend_string_alloc(name_len, 0);
2609 zend_str_tolower_copy(ZSTR_VAL(lcname), dep->name, name_len);
2610
2611 if (zend_hash_exists(&module_registry, lcname) || zend_get_extension(dep->name)) {
2612 zend_string_efree(lcname);
2613 /* TODO: Check version relationship */
2614 zend_error(E_CORE_WARNING, "Cannot load module \"%s\" because conflicting module \"%s\" is already loaded", module->name, dep->name);
2615 return NULL;
2616 }
2617 zend_string_efree(lcname);
2618 }
2619 ++dep;
2620 }
2621 }
2622
2623 name_len = strlen(module->name);
2624 lcname = zend_string_alloc(name_len, module_type == MODULE_PERSISTENT);
2625 zend_str_tolower_copy(ZSTR_VAL(lcname), module->name, name_len);
2626
2627 int module_number = zend_next_free_module();
2628
2630 if ((module_ptr = zend_hash_add_ptr(&module_registry, lcname, module)) == NULL) {
2631 zend_error(E_CORE_WARNING, "Module \"%s\" is already loaded", module->name);
2632 zend_string_release(lcname);
2633 return NULL;
2634 }
2635 module = module_ptr;
2636 EG(current_module) = module;
2637
2638 module->module_number = module_number;
2639 module->type = module_type;
2640
2641 if (module->functions && zend_register_functions(NULL, module->functions, NULL, module_type)==FAILURE) {
2643 zend_string_release(lcname);
2644 EG(current_module) = NULL;
2645 zend_error(E_CORE_WARNING,"%s: Unable to register functions, unable to load", module->name);
2646 return NULL;
2647 }
2648
2649 EG(current_module) = NULL;
2650 zend_string_release(lcname);
2651 return module;
2652}
2653/* }}} */
2654
2659/* }}} */
2660
2661static void zend_check_magic_method_args(
2662 uint32_t num_args, const zend_class_entry *ce, const zend_function *fptr, int error_type)
2663{
2664 if (fptr->common.num_args != num_args) {
2665 if (num_args == 0) {
2666 zend_error(error_type, "Method %s::%s() cannot take arguments",
2668 } else if (num_args == 1) {
2669 zend_error(error_type, "Method %s::%s() must take exactly 1 argument",
2671 } else {
2672 zend_error(error_type, "Method %s::%s() must take exactly %" PRIu32 " arguments",
2674 }
2675 return;
2676 }
2677 for (uint32_t i = 0; i < num_args; i++) {
2678 if (QUICK_ARG_SHOULD_BE_SENT_BY_REF(fptr, i + 1)) {
2679 zend_error(error_type, "Method %s::%s() cannot take arguments by reference",
2681 return;
2682 }
2683 }
2684}
2685
2686static void zend_check_magic_method_arg_type(uint32_t arg_num, const zend_class_entry *ce, const zend_function *fptr, int error_type, int arg_type)
2687{
2688 if (
2690 && !(ZEND_TYPE_FULL_MASK(fptr->common.arg_info[arg_num].type) & arg_type)
2691 ) {
2692 zend_error(error_type, "%s::%s(): Parameter #%d ($%s) must be of type %s when declared",
2696 }
2697}
2698
2699static void zend_check_magic_method_return_type(const zend_class_entry *ce, const zend_function *fptr, int error_type, int return_type)
2700{
2701 if (!(fptr->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE)) {
2702 /* For backwards compatibility reasons, do not enforce the return type if it is not set. */
2703 return;
2704 }
2705
2707 /* It is always legal to specify the never type. */
2708 return;
2709 }
2710
2711 bool is_complex_type = ZEND_TYPE_IS_COMPLEX(fptr->common.arg_info[-1].type);
2712 uint32_t extra_types = ZEND_TYPE_PURE_MASK(fptr->common.arg_info[-1].type) & ~return_type;
2713 if (extra_types & MAY_BE_STATIC) {
2714 extra_types &= ~MAY_BE_STATIC;
2715 is_complex_type = true;
2716 }
2717
2718 if (extra_types || (is_complex_type && return_type != MAY_BE_OBJECT)) {
2719 zend_error(error_type, "%s::%s(): Return type must be %s when declared",
2722 }
2723}
2724
2725static void zend_check_magic_method_non_static(
2726 const zend_class_entry *ce, const zend_function *fptr, int error_type)
2727{
2728 if (fptr->common.fn_flags & ZEND_ACC_STATIC) {
2729 zend_error(error_type, "Method %s::%s() cannot be static",
2731 }
2732}
2733
2734static void zend_check_magic_method_static(
2735 const zend_class_entry *ce, const zend_function *fptr, int error_type)
2736{
2737 if (!(fptr->common.fn_flags & ZEND_ACC_STATIC)) {
2738 zend_error(error_type, "Method %s::%s() must be static",
2740 }
2741}
2742
2743static void zend_check_magic_method_public(
2744 const zend_class_entry *ce, const zend_function *fptr, int error_type)
2745{
2746 // TODO: Remove this warning after adding proper visibility handling.
2747 if (!(fptr->common.fn_flags & ZEND_ACC_PUBLIC)) {
2748 zend_error(E_WARNING, "The magic method %s::%s() must have public visibility",
2750 }
2751}
2752
2753static void zend_check_magic_method_no_return_type(
2754 const zend_class_entry *ce, const zend_function *fptr, int error_type)
2755{
2757 zend_error_noreturn(error_type, "Method %s::%s() cannot declare a return type",
2759 }
2760}
2761
2763{
2764 if (ZSTR_VAL(lcname)[0] != '_'
2765 || ZSTR_VAL(lcname)[1] != '_') {
2766 return;
2767 }
2768
2770 zend_check_magic_method_non_static(ce, fptr, error_type);
2771 zend_check_magic_method_no_return_type(ce, fptr, error_type);
2773 zend_check_magic_method_args(0, ce, fptr, error_type);
2774 zend_check_magic_method_non_static(ce, fptr, error_type);
2775 zend_check_magic_method_no_return_type(ce, fptr, error_type);
2777 zend_check_magic_method_args(0, ce, fptr, error_type);
2778 zend_check_magic_method_non_static(ce, fptr, error_type);
2779 zend_check_magic_method_return_type(ce, fptr, error_type, MAY_BE_VOID);
2781 zend_check_magic_method_args(1, ce, fptr, error_type);
2782 zend_check_magic_method_non_static(ce, fptr, error_type);
2783 zend_check_magic_method_public(ce, fptr, error_type);
2784 zend_check_magic_method_arg_type(0, ce, fptr, error_type, MAY_BE_STRING);
2786 zend_check_magic_method_args(2, ce, fptr, error_type);
2787 zend_check_magic_method_non_static(ce, fptr, error_type);
2788 zend_check_magic_method_public(ce, fptr, error_type);
2789 zend_check_magic_method_arg_type(0, ce, fptr, error_type, MAY_BE_STRING);
2790 zend_check_magic_method_return_type(ce, fptr, error_type, MAY_BE_VOID);
2792 zend_check_magic_method_args(1, ce, fptr, error_type);
2793 zend_check_magic_method_non_static(ce, fptr, error_type);
2794 zend_check_magic_method_public(ce, fptr, error_type);
2795 zend_check_magic_method_arg_type(0, ce, fptr, error_type, MAY_BE_STRING);
2796 zend_check_magic_method_return_type(ce, fptr, error_type, MAY_BE_VOID);
2798 zend_check_magic_method_args(1, ce, fptr, error_type);
2799 zend_check_magic_method_non_static(ce, fptr, error_type);
2800 zend_check_magic_method_public(ce, fptr, error_type);
2801 zend_check_magic_method_arg_type(0, ce, fptr, error_type, MAY_BE_STRING);
2802 zend_check_magic_method_return_type(ce, fptr, error_type, MAY_BE_BOOL);
2804 zend_check_magic_method_args(2, ce, fptr, error_type);
2805 zend_check_magic_method_non_static(ce, fptr, error_type);
2806 zend_check_magic_method_public(ce, fptr, error_type);
2807 zend_check_magic_method_arg_type(0, ce, fptr, error_type, MAY_BE_STRING);
2808 zend_check_magic_method_arg_type(1, ce, fptr, error_type, MAY_BE_ARRAY);
2810 zend_check_magic_method_args(2, ce, fptr, error_type);
2811 zend_check_magic_method_static(ce, fptr, error_type);
2812 zend_check_magic_method_public(ce, fptr, error_type);
2813 zend_check_magic_method_arg_type(0, ce, fptr, error_type, MAY_BE_STRING);
2814 zend_check_magic_method_arg_type(1, ce, fptr, error_type, MAY_BE_ARRAY);
2816 zend_check_magic_method_args(0, ce, fptr, error_type);
2817 zend_check_magic_method_non_static(ce, fptr, error_type);
2818 zend_check_magic_method_public(ce, fptr, error_type);
2819 zend_check_magic_method_return_type(ce, fptr, error_type, MAY_BE_STRING);
2821 zend_check_magic_method_args(0, ce, fptr, error_type);
2822 zend_check_magic_method_non_static(ce, fptr, error_type);
2823 zend_check_magic_method_public(ce, fptr, error_type);
2824 zend_check_magic_method_return_type(ce, fptr, error_type, (MAY_BE_ARRAY | MAY_BE_NULL));
2825 } else if (zend_string_equals_literal(lcname, "__serialize")) {
2826 zend_check_magic_method_args(0, ce, fptr, error_type);
2827 zend_check_magic_method_non_static(ce, fptr, error_type);
2828 zend_check_magic_method_public(ce, fptr, error_type);
2829 zend_check_magic_method_return_type(ce, fptr, error_type, MAY_BE_ARRAY);
2830 } else if (zend_string_equals_literal(lcname, "__unserialize")) {
2831 zend_check_magic_method_args(1, ce, fptr, error_type);
2832 zend_check_magic_method_non_static(ce, fptr, error_type);
2833 zend_check_magic_method_public(ce, fptr, error_type);
2834 zend_check_magic_method_arg_type(0, ce, fptr, error_type, MAY_BE_ARRAY);
2835 zend_check_magic_method_return_type(ce, fptr, error_type, MAY_BE_VOID);
2836 } else if (zend_string_equals_literal(lcname, "__set_state")) {
2837 zend_check_magic_method_args(1, ce, fptr, error_type);
2838 zend_check_magic_method_static(ce, fptr, error_type);
2839 zend_check_magic_method_public(ce, fptr, error_type);
2840 zend_check_magic_method_arg_type(0, ce, fptr, error_type, MAY_BE_ARRAY);
2841 zend_check_magic_method_return_type(ce, fptr, error_type, MAY_BE_OBJECT);
2842 } else if (zend_string_equals(lcname, ZSTR_KNOWN(ZEND_STR_MAGIC_INVOKE))) {
2843 zend_check_magic_method_non_static(ce, fptr, error_type);
2844 zend_check_magic_method_public(ce, fptr, error_type);
2845 } else if (zend_string_equals(lcname, ZSTR_KNOWN(ZEND_STR_SLEEP))) {
2846 zend_check_magic_method_args(0, ce, fptr, error_type);
2847 zend_check_magic_method_non_static(ce, fptr, error_type);
2848 zend_check_magic_method_public(ce, fptr, error_type);
2849 zend_check_magic_method_return_type(ce, fptr, error_type, MAY_BE_ARRAY);
2850 } else if (zend_string_equals(lcname, ZSTR_KNOWN(ZEND_STR_WAKEUP))) {
2851 zend_check_magic_method_args(0, ce, fptr, error_type);
2852 zend_check_magic_method_non_static(ce, fptr, error_type);
2853 zend_check_magic_method_public(ce, fptr, error_type);
2854 zend_check_magic_method_return_type(ce, fptr, error_type, MAY_BE_VOID);
2855 }
2856}
2857/* }}} */
2858
2860{
2861 if (ZSTR_VAL(lcname)[0] != '_' || ZSTR_VAL(lcname)[1] != '_') {
2862 /* pass */
2864 ce->clone = fptr;
2866 ce->constructor = fptr;
2869 ce->destructor = fptr;
2871 ce->__get = fptr;
2874 ce->__set = fptr;
2877 ce->__call = fptr;
2879 ce->__unset = fptr;
2882 ce->__isset = fptr;
2885 ce->__callstatic = fptr;
2887 ce->__tostring = fptr;
2889 ce->__debugInfo = fptr;
2891 } else if (zend_string_equals_literal(lcname, "__serialize")) {
2892 ce->__serialize = fptr;
2893 } else if (zend_string_equals_literal(lcname, "__unserialize")) {
2894 ce->__unserialize = fptr;
2895 }
2896}
2897
2898ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arg_info_toString, 0, 0, IS_STRING, 0)
2900
2901static zend_always_inline void zend_normalize_internal_type(zend_type *type) {
2904 ZEND_ASSERT(!ZEND_TYPE_CONTAINS_CODE(*type, IS_RESOURCE) && "resource is not allowed in a zend_type");
2905 }
2912 } else if (ZEND_TYPE_HAS_LIST(*current)) {
2913 zend_type *inner;
2914 ZEND_TYPE_FOREACH(*current, inner) {
2916 if (ZEND_TYPE_HAS_NAME(*inner)) {
2919 ZEND_TYPE_SET_PTR(*inner, name);
2920 }
2922 }
2924}
2925
2926/* registers all functions in *library_functions in the function hash */
2928{
2931 zend_internal_function *reg_function, *internal_function = (zend_internal_function *)&function;
2932 int count=0, unload=0;
2933 HashTable *target_function_table = function_table;
2934 int error_type;
2935 zend_string *lowercase_name;
2936 size_t fname_len;
2937
2938 if (type==MODULE_PERSISTENT) {
2939 error_type = E_CORE_WARNING;
2940 } else {
2941 error_type = E_WARNING;
2942 }
2943
2944 if (!target_function_table) {
2945 target_function_table = CG(function_table);
2946 }
2947 internal_function->type = ZEND_INTERNAL_FUNCTION;
2948 internal_function->module = EG(current_module);
2950 /* Add an observer temporary to store previous observed frames. This is
2951 * normally handled by zend_observer_post_startup(), except for
2952 * functions registered at runtime (EG(active)). */
2953 internal_function->T = 1;
2954 } else {
2955 internal_function->T = 0;
2956 }
2957 memset(internal_function->reserved, 0, ZEND_MAX_RESERVED_RESOURCES * sizeof(void*));
2958
2959 while (ptr->fname) {
2960 fname_len = strlen(ptr->fname);
2961 internal_function->handler = ptr->handler;
2962 internal_function->doc_comment = ptr->doc_comment ? zend_string_init_interned(ptr->doc_comment, strlen(ptr->doc_comment), 1) : NULL;
2963 internal_function->function_name = zend_string_init_interned(ptr->fname, fname_len, 1);
2964 internal_function->scope = scope;
2965 internal_function->prototype = NULL;
2966 internal_function->prop_info = NULL;
2967 internal_function->attributes = NULL;
2968 internal_function->frameless_function_infos = ptr->frameless_function_infos;
2969 if (EG(active)) { // at run-time: this ought to only happen if registered with dl() or somehow temporarily at runtime
2970 ZEND_MAP_PTR_INIT(internal_function->run_time_cache, zend_arena_calloc(&CG(arena), 1, zend_internal_run_time_cache_reserved_size()));
2971 } else {
2972#ifdef ZTS
2973 ZEND_MAP_PTR_NEW_STATIC(internal_function->run_time_cache);
2974#else
2975 ZEND_MAP_PTR_INIT(internal_function->run_time_cache, NULL);
2976#endif
2977 }
2978 if (ptr->flags) {
2979 if (!(ptr->flags & ZEND_ACC_PPP_MASK)) {
2980 if (ptr->flags != ZEND_ACC_DEPRECATED && scope) {
2981 zend_error(error_type, "Invalid access level for %s::%s() - access must be exactly one of public, protected or private", ZSTR_VAL(scope->name), ptr->fname);
2982 }
2983 internal_function->fn_flags = ZEND_ACC_PUBLIC | ptr->flags;
2984 } else {
2985 internal_function->fn_flags = ptr->flags;
2986 }
2987 } else {
2988 internal_function->fn_flags = ZEND_ACC_PUBLIC;
2989 }
2990
2991 if (ptr->arg_info) {
2993 internal_function->arg_info = (zend_internal_arg_info*)ptr->arg_info+1;
2994 internal_function->num_args = ptr->num_args;
2995 /* Currently you cannot denote that the function can accept less arguments than num_args */
2996 if (info->required_num_args == (uintptr_t)-1) {
2997 internal_function->required_num_args = ptr->num_args;
2998 } else {
2999 internal_function->required_num_args = info->required_num_args;
3000 }
3001 if (ZEND_ARG_SEND_MODE(info)) {
3002 internal_function->fn_flags |= ZEND_ACC_RETURN_REFERENCE;
3003 }
3004 if (ZEND_ARG_IS_VARIADIC(&ptr->arg_info[ptr->num_args])) {
3005 internal_function->fn_flags |= ZEND_ACC_VARIADIC;
3006 /* Don't count the variadic argument */
3007 internal_function->num_args--;
3008 }
3009 if (ZEND_TYPE_IS_SET(info->type)) {
3010 if (ZEND_TYPE_HAS_NAME(info->type)) {
3011 const char *type_name = ZEND_TYPE_LITERAL_NAME(info->type);
3012 if (!scope && (!strcasecmp(type_name, "self") || !strcasecmp(type_name, "parent"))) {
3013 zend_error_noreturn(E_CORE_ERROR, "Cannot declare a return type of %s outside of a class scope", type_name);
3014 }
3015 }
3016
3017 internal_function->fn_flags |= ZEND_ACC_HAS_RETURN_TYPE;
3018 }
3019 } else {
3020 zend_error(E_CORE_WARNING, "Missing arginfo for %s%s%s()",
3021 scope ? ZSTR_VAL(scope->name) : "", scope ? "::" : "", ptr->fname);
3022
3023 internal_function->arg_info = NULL;
3024 internal_function->num_args = 0;
3025 internal_function->required_num_args = 0;
3026 }
3027
3028 /* If not specified, add __toString() return type for compatibility with Stringable
3029 * interface. */
3030 if (scope && zend_string_equals_literal_ci(internal_function->function_name, "__tostring") &&
3031 !(internal_function->fn_flags & ZEND_ACC_HAS_RETURN_TYPE)) {
3032 zend_error(E_CORE_WARNING, "%s::__toString() implemented without string return type",
3033 ZSTR_VAL(scope->name));
3034 internal_function->arg_info = (zend_internal_arg_info *) arg_info_toString + 1;
3035 internal_function->fn_flags |= ZEND_ACC_HAS_RETURN_TYPE;
3036 internal_function->num_args = internal_function->required_num_args = 0;
3037 }
3038
3039
3040 zend_set_function_arg_flags((zend_function*)internal_function);
3041 if (ptr->flags & ZEND_ACC_ABSTRACT) {
3042 if (scope) {
3043 /* This is a class that must be abstract itself. Here we set the check info. */
3045 if (!(scope->ce_flags & ZEND_ACC_INTERFACE)) {
3046 /* Since the class is not an interface it needs to be declared as a abstract class. */
3047 /* Since here we are handling internal functions only we can add the keyword flag. */
3048 /* This time we set the flag for the keyword 'abstract'. */
3050 }
3051 }
3052 if ((ptr->flags & ZEND_ACC_STATIC) && (!scope || !(scope->ce_flags & ZEND_ACC_INTERFACE))) {
3053 zend_error(error_type, "Static function %s%s%s() cannot be abstract", scope ? ZSTR_VAL(scope->name) : "", scope ? "::" : "", ptr->fname);
3054 }
3055 } else {
3056 if (scope && (scope->ce_flags & ZEND_ACC_INTERFACE)) {
3057 zend_error(error_type, "Interface %s cannot contain non abstract method %s()", ZSTR_VAL(scope->name), ptr->fname);
3058 return FAILURE;
3059 }
3060 if (!internal_function->handler) {
3061 zend_error(error_type, "Method %s%s%s() cannot be a NULL function", scope ? ZSTR_VAL(scope->name) : "", scope ? "::" : "", ptr->fname);
3062 zend_unregister_functions(functions, count, target_function_table);
3063 return FAILURE;
3064 }
3065 }
3066 lowercase_name = zend_string_tolower_ex(internal_function->function_name, type == MODULE_PERSISTENT);
3067 lowercase_name = zend_new_interned_string(lowercase_name);
3068 reg_function = malloc(sizeof(zend_internal_function));
3069 memcpy(reg_function, &function, sizeof(zend_internal_function));
3070 if (zend_hash_add_ptr(target_function_table, lowercase_name, reg_function) == NULL) {
3071 unload=1;
3072 free(reg_function);
3073 zend_string_release(lowercase_name);
3074 break;
3075 }
3076 if (reg_function->frameless_function_infos) {
3077 const zend_frameless_function_info *flf_info = reg_function->frameless_function_infos;
3078 while (flf_info->handler) {
3080 if (!zend_flf_capacity) {
3082 } else {
3083 zend_flf_capacity *= 2;
3084 }
3085 /* +1 for NULL terminator */
3086 zend_flf_handlers = realloc(zend_flf_handlers, (zend_flf_capacity + 1) * sizeof(void *));
3088 }
3092 flf_info++;
3093 }
3096 }
3097
3098 /* Get parameter count including variadic parameter. */
3099 uint32_t num_args = reg_function->num_args;
3100 if (reg_function->fn_flags & ZEND_ACC_VARIADIC) {
3101 num_args++;
3102 }
3103
3104 /* If types of arguments have to be checked */
3105 if (reg_function->arg_info && num_args) {
3106 uint32_t i;
3107 for (i = 0; i < num_args; i++) {
3108 zend_internal_arg_info *arg_info = &reg_function->arg_info[i];
3109 ZEND_ASSERT(arg_info->name && "Parameter must have a name");
3110 if (ZEND_TYPE_IS_SET(arg_info->type)) {
3111 reg_function->fn_flags |= ZEND_ACC_HAS_TYPE_HINTS;
3112 }
3113#if ZEND_DEBUG
3114 for (uint32_t j = 0; j < i; j++) {
3115 if (!strcmp(arg_info->name, reg_function->arg_info[j].name)) {
3117 "Duplicate parameter name $%s for function %s%s%s()", arg_info->name,
3118 scope ? ZSTR_VAL(scope->name) : "", scope ? "::" : "", ptr->fname);
3119 }
3120 }
3121#endif
3122 }
3123 }
3124
3125 /* Rebuild arginfos if parameter/property types and/or a return type are used */
3126 if (reg_function->arg_info &&
3128 /* convert "const char*" class type names into "zend_string*" */
3129 uint32_t i;
3130 zend_internal_arg_info *arg_info = reg_function->arg_info - 1;
3131 zend_internal_arg_info *new_arg_info;
3132
3133 /* Treat return type as an extra argument */
3134 num_args++;
3135 new_arg_info = malloc(sizeof(zend_internal_arg_info) * num_args);
3136 memcpy(new_arg_info, arg_info, sizeof(zend_internal_arg_info) * num_args);
3137 reg_function->arg_info = new_arg_info + 1;
3138 for (i = 0; i < num_args; i++) {
3139 if (ZEND_TYPE_HAS_LITERAL_NAME(new_arg_info[i].type)) {
3140 // gen_stubs.php does not support codegen for DNF types in arg infos.
3141 // As a temporary workaround, we split the type name on `|` characters,
3142 // converting it to an union type if necessary.
3143 const char *class_name = ZEND_TYPE_LITERAL_NAME(new_arg_info[i].type);
3144 new_arg_info[i].type.type_mask &= ~_ZEND_TYPE_LITERAL_NAME_BIT;
3145
3146 size_t num_types = 1;
3147 const char *p = class_name;
3148 while ((p = strchr(p, '|'))) {
3149 num_types++;
3150 p++;
3151 }
3152
3153 if (num_types == 1) {
3154 /* Simple class type */
3155 zend_string *str = zend_string_init_interned(class_name, strlen(class_name), 1);
3157 ZEND_TYPE_SET_PTR(new_arg_info[i].type, str);
3158 new_arg_info[i].type.type_mask |= _ZEND_TYPE_NAME_BIT;
3159 } else {
3160 /* Union type */
3161 zend_type_list *list = malloc(ZEND_TYPE_LIST_SIZE(num_types));
3162 list->num_types = num_types;
3163 ZEND_TYPE_SET_LIST(new_arg_info[i].type, list);
3164 ZEND_TYPE_FULL_MASK(new_arg_info[i].type) |= _ZEND_TYPE_UNION_BIT;
3165
3166 const char *start = class_name;
3167 uint32_t j = 0;
3168 while (true) {
3169 const char *end = strchr(start, '|');
3172 list->types[j] = (zend_type) ZEND_TYPE_INIT_CLASS(str, 0, 0);
3173 if (!end) {
3174 break;
3175 }
3176 start = end + 1;
3177 j++;
3178 }
3179 }
3180 }
3181 if (ZEND_TYPE_IS_ITERABLE_FALLBACK(new_arg_info[i].type)) {
3182 /* Warning generated an extension load warning which is emitted for every test
3183 zend_error(E_CORE_WARNING, "iterable type is now a compile time alias for array|Traversable,"
3184 " regenerate the argument info via the php-src gen_stub build script");
3185 */
3186 zend_type legacy_iterable = ZEND_TYPE_INIT_CLASS_MASK(
3187 ZSTR_KNOWN(ZEND_STR_TRAVERSABLE),
3188 (new_arg_info[i].type.type_mask | MAY_BE_ARRAY)
3189 );
3190 new_arg_info[i].type = legacy_iterable;
3191 }
3192
3193 zend_normalize_internal_type(&new_arg_info[i].type);
3194 }
3195 }
3196
3197 if (scope) {
3199 scope, (zend_function *)reg_function, lowercase_name, E_CORE_ERROR);
3200 zend_add_magic_method(scope, (zend_function *)reg_function, lowercase_name);
3201 }
3202 ptr++;
3203 count++;
3204 zend_string_release(lowercase_name);
3205 }
3206 if (unload) { /* before unloading, display all remaining bad function in the module */
3207 while (ptr->fname) {
3208 fname_len = strlen(ptr->fname);
3209 lowercase_name = zend_string_alloc(fname_len, 0);
3210 zend_str_tolower_copy(ZSTR_VAL(lowercase_name), ptr->fname, fname_len);
3211 if (zend_hash_exists(target_function_table, lowercase_name)) {
3212 zend_error(error_type, "Function registration failed - duplicate name - %s%s%s", scope ? ZSTR_VAL(scope->name) : "", scope ? "::" : "", ptr->fname);
3213 }
3214 zend_string_efree(lowercase_name);
3215 ptr++;
3216 }
3217 zend_unregister_functions(functions, count, target_function_table);
3218 return FAILURE;
3219 }
3220 return SUCCESS;
3221}
3222/* }}} */
3223
3224/* count=-1 means erase all functions, otherwise,
3225 * erase the first count functions
3226 */
3228{
3230 int i=0;
3231 HashTable *target_function_table = function_table;
3232 zend_string *lowercase_name;
3233 size_t fname_len;
3234
3235 if (!target_function_table) {
3236 target_function_table = CG(function_table);
3237 }
3238 while (ptr->fname) {
3239 if (count!=-1 && i>=count) {
3240 break;
3241 }
3242 fname_len = strlen(ptr->fname);
3243 lowercase_name = zend_string_alloc(fname_len, 0);
3244 zend_str_tolower_copy(ZSTR_VAL(lowercase_name), ptr->fname, fname_len);
3245 zend_hash_del(target_function_table, lowercase_name);
3246 zend_string_efree(lowercase_name);
3247 ptr++;
3248 i++;
3249 }
3250}
3251/* }}} */
3252
3254{
3255 if ((module = zend_register_internal_module(module)) != NULL && zend_startup_module_ex(module) == SUCCESS) {
3256 return SUCCESS;
3257 }
3258 return FAILURE;
3259}
3260/* }}} */
3261
3262ZEND_API zend_result zend_get_module_started(const char *module_name) /* {{{ */
3263{
3264 zend_module_entry *module;
3265
3266 module = zend_hash_str_find_ptr(&module_registry, module_name, strlen(module_name));
3267 return (module && module->module_started) ? SUCCESS : FAILURE;
3268}
3269/* }}} */
3270
3271static void clean_module_classes(int module_number) /* {{{ */
3272{
3273 /* Child classes may reuse structures from parent classes, so destroy in reverse order. */
3274 Bucket *bucket;
3275 ZEND_HASH_REVERSE_FOREACH_BUCKET(EG(class_table), bucket) {
3276 zend_class_entry *ce = Z_CE(bucket->val);
3277 if (ce->type == ZEND_INTERNAL_CLASS && ce->info.internal.module->module_number == module_number) {
3278 zend_hash_del_bucket(EG(class_table), bucket);
3279 }
3281
3282}
3283/* }}} */
3284
3285static int clean_module_function(zval *el, void *arg) /* {{{ */
3286{
3287 zend_function *fe = (zend_function *) Z_PTR_P(el);
3289 if (fe->common.type == ZEND_INTERNAL_FUNCTION && fe->internal_function.module == module) {
3291 } else {
3292 return ZEND_HASH_APPLY_KEEP;
3293 }
3294}
3295/* }}} */
3296
3297static void clean_module_functions(zend_module_entry *module) /* {{{ */
3298{
3299 zend_hash_apply_with_argument(CG(function_table), clean_module_function, module);
3300}
3301/* }}} */
3302
3304{
3305#if ZEND_RC_DEBUG
3306 bool orig_rc_debug = zend_rc_debug;
3307#endif
3308
3309 if (module->type == MODULE_TEMPORARY) {
3310#if ZEND_RC_DEBUG
3311 /* FIXME: Loading extensions during the request breaks some invariants.
3312 * In particular, it will create persistent interned strings, which is
3313 * not allowed at this stage. */
3314 zend_rc_debug = false;
3315#endif
3316 zend_clean_module_rsrc_dtors(module->module_number);
3317 clean_module_constants(module->module_number);
3318 clean_module_classes(module->module_number);
3319 }
3320
3321 if (module->module_started && module->module_shutdown_func) {
3322#if 0
3323 zend_printf("%s: Module shutdown\n", module->name);
3324#endif
3325 module->module_shutdown_func(module->type, module->module_number);
3326 }
3327
3328 if (module->module_started
3329 && !module->module_shutdown_func
3330 && module->type == MODULE_TEMPORARY) {
3331 zend_unregister_ini_entries_ex(module->module_number, module->type);
3332 }
3333
3334 /* Deinitialize module globals */
3335 if (module->globals_size) {
3336#ifdef ZTS
3337 if (*module->globals_id_ptr) {
3338 ts_free_id(*module->globals_id_ptr);
3339 }
3340#else
3341 if (module->globals_dtor) {
3342 module->globals_dtor(module->globals_ptr);
3343 }
3344#endif
3345 }
3346
3347 module->module_started=0;
3348 if (module->type == MODULE_TEMPORARY && module->functions) {
3349 zend_unregister_functions(module->functions, -1, NULL);
3350 /* Clean functions registered separately from module->functions */
3351 clean_module_functions(module);
3352 }
3353
3354#if ZEND_RC_DEBUG
3355 zend_rc_debug = orig_rc_debug;
3356#endif
3357}
3358/* }}} */
3359
3361{
3362#ifdef HAVE_LIBDL
3363 if (!getenv("ZEND_DONT_UNLOAD_MODULES")) {
3364 DL_UNLOAD(module->handle);
3365 }
3366#else
3367 ZEND_IGNORE_VALUE(module);
3368#endif
3369}
3370
3372{
3373 zend_module_entry **p = module_request_startup_handlers;
3374
3375 while (*p) {
3376 zend_module_entry *module = *p;
3377
3378 if (module->request_startup_func(module->type, module->module_number)==FAILURE) {
3379 zend_error(E_WARNING, "request_startup() for %s module failed", module->name);
3380 exit(1);
3381 }
3382 p++;
3383 }
3384}
3385/* }}} */
3386
3388{
3389 EG(current_execute_data) = NULL; /* we're no longer executing anything */
3390
3391 if (EG(full_tables_cleanup)) {
3392 zend_module_entry *module;
3393
3395 if (module->request_shutdown_func) {
3396 zend_try {
3397 module->request_shutdown_func(module->type, module->module_number);
3398 } zend_end_try();
3399 }
3401 } else {
3402 zend_module_entry **p = module_request_shutdown_handlers;
3403
3404 while (*p) {
3405 zend_module_entry *module = *p;
3406 zend_try {
3407 module->request_shutdown_func(module->type, module->module_number);
3408 } zend_end_try();
3409 p++;
3410 }
3411 }
3412}
3413/* }}} */
3414
3415void zend_unload_modules(void) /* {{{ */
3416{
3417 zend_module_entry **modules = modules_dl_loaded;
3418 while (*modules) {
3419 module_registry_unload(*modules);
3420 modules++;
3421 }
3422 free(modules_dl_loaded);
3423 modules_dl_loaded = NULL;
3424}
3425/* }}} */
3426
3428{
3429 if (EG(full_tables_cleanup)) {
3430 zend_module_entry *module;
3431 zval *zv;
3433
3435 if (module->post_deactivate_func) {
3436 module->post_deactivate_func();
3437 }
3440 module = Z_PTR_P(zv);
3441 if (module->type != MODULE_TEMPORARY) {
3442 break;
3443 }
3444 module_destructor(module);
3445 if (module->handle) {
3446 module_registry_unload(module);
3447 }
3450 } else {
3451 zend_module_entry **p = module_post_deactivate_handlers;
3452
3453 while (*p) {
3454 zend_module_entry *module = *p;
3455
3456 module->post_deactivate_func();
3457 p++;
3458 }
3459 }
3460}
3461/* }}} */
3462
3463/* return the next free module number */
3465{
3466 return zend_hash_num_elements(&module_registry);
3467}
3468/* }}} */
3469
3470static zend_class_entry *do_register_internal_class(zend_class_entry *orig_class_entry, uint32_t ce_flags) /* {{{ */
3471{
3472 zend_class_entry *class_entry = malloc(sizeof(zend_class_entry));
3473 zend_string *lowercase_name;
3474 *class_entry = *orig_class_entry;
3475
3476 class_entry->type = ZEND_INTERNAL_CLASS;
3477 zend_initialize_class_data(class_entry, 0);
3478 zend_alloc_ce_cache(class_entry->name);
3480 class_entry->info.internal.module = EG(current_module);
3481
3482 if (class_entry->info.internal.builtin_functions) {
3483 zend_register_functions(class_entry, class_entry->info.internal.builtin_functions, &class_entry->function_table, EG(current_module)->type);
3484 }
3485
3486 lowercase_name = zend_string_tolower_ex(orig_class_entry->name, EG(current_module)->type == MODULE_PERSISTENT);
3487 lowercase_name = zend_new_interned_string(lowercase_name);
3488 zend_hash_update_ptr(CG(class_table), lowercase_name, class_entry);
3489 zend_string_release_ex(lowercase_name, 1);
3490
3491 if (class_entry->__tostring && !zend_string_equals_literal(class_entry->name, "Stringable")
3492 && !(class_entry->ce_flags & ZEND_ACC_TRAIT)) {
3494 && "Should be registered before first class using __toString()");
3496 }
3497 return class_entry;
3498}
3499/* }}} */
3500
3501/* If parent_ce is not NULL then it inherits from parent_ce
3502 * If parent_ce is NULL and parent_name isn't then it looks for the parent and inherits from it
3503 * If both parent_ce and parent_name are NULL it does a regular class registration
3504 * If parent_name is specified but not found NULL is returned
3505 */
3507{
3508 return zend_register_internal_class_with_flags(class_entry, parent_ce, 0);
3509}
3510/* }}} */
3511
3513 zend_class_entry *class_entry,
3514 zend_class_entry *parent_ce,
3515 uint32_t ce_flags
3516) {
3517 zend_class_entry *register_class = do_register_internal_class(class_entry, ce_flags);
3518
3519 if (parent_ce) {
3520 zend_do_inheritance(register_class, parent_ce);
3521 zend_build_properties_info_table(register_class);
3522 }
3523
3524 return register_class;
3525}
3526
3527ZEND_API void zend_class_implements(zend_class_entry *class_entry, int num_interfaces, ...) /* {{{ */
3528{
3529 zend_class_entry *interface_entry;
3530 va_list interface_list;
3531 va_start(interface_list, num_interfaces);
3532
3533 while (num_interfaces--) {
3534 interface_entry = va_arg(interface_list, zend_class_entry *);
3535 if (interface_entry == zend_ce_stringable
3537 /* Stringable is implemented automatically,
3538 * silently ignore an explicit implementation. */
3539 continue;
3540 }
3541
3542 zend_do_implement_interface(class_entry, interface_entry);
3543 }
3544
3545 va_end(interface_list);
3546}
3547/* }}} */
3548
3549/* A class that contains at least one abstract method automatically becomes an abstract class.
3550 */
3552{
3553 return do_register_internal_class(orig_class_entry, 0);
3554}
3555/* }}} */
3556
3558{
3559 return do_register_internal_class(orig_class_entry, ZEND_ACC_INTERFACE);
3560}
3561/* }}} */
3562
3563ZEND_API zend_result zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce, bool persistent) /* {{{ */
3564{
3566 zval zv, *ret;
3567
3568 /* TODO: Move this out of here in 7.4. */
3569 if (persistent && EG(current_module) && EG(current_module)->type == MODULE_TEMPORARY) {
3570 persistent = 0;
3571 }
3572
3573 if (name[0] == '\\') {
3574 lcname = zend_string_alloc(name_len-1, persistent);
3575 zend_str_tolower_copy(ZSTR_VAL(lcname), name+1, name_len-1);
3576 } else {
3577 lcname = zend_string_alloc(name_len, persistent);
3579 }
3580
3581 zend_assert_valid_class_name(lcname, "a class alias");
3582
3584
3585 /* We cannot increase the refcount of an internal class during request time.
3586 * Instead of having to deal with differentiating between class types and lifetimes,
3587 * we simply don't increase the refcount of a class entry for aliases.
3588 */
3589 ZVAL_ALIAS_PTR(&zv, ce);
3590
3591 ret = zend_hash_add(CG(class_table), lcname, &zv);
3593 if (ret) {
3594 // avoid notifying at MINIT time
3595 if (ce->type == ZEND_USER_CLASS) {
3596 zend_observer_class_linked_notify(ce, lcname);
3597 }
3598 return SUCCESS;
3599 }
3600 return FAILURE;
3601}
3602/* }}} */
3603
3604// TODO num_symbol_tables as unsigned int?
3605ZEND_API zend_result zend_set_hash_symbol(zval *symbol, const char *name, size_t name_length, bool is_ref, int num_symbol_tables, ...) /* {{{ */
3606{
3607 HashTable *symbol_table;
3608 va_list symbol_table_list;
3609
3610 if (num_symbol_tables <= 0) return FAILURE;
3611
3612 if (is_ref) {
3613 ZVAL_MAKE_REF(symbol);
3614 }
3615
3616 va_start(symbol_table_list, num_symbol_tables);
3617 while (num_symbol_tables-- > 0) {
3618 symbol_table = va_arg(symbol_table_list, HashTable *);
3619 zend_hash_str_update(symbol_table, name, name_length, symbol);
3620 Z_TRY_ADDREF_P(symbol);
3621 }
3622 va_end(symbol_table_list);
3623 return SUCCESS;
3624}
3625/* }}} */
3626
3627/* Disabled functions support */
3628
3629static void zend_disable_function(const char *function_name, size_t function_name_length)
3630{
3631 if (UNEXPECTED(
3632 (function_name_length == strlen("exit") && !memcmp(function_name, "exit", strlen("exit")))
3633 || (function_name_length == strlen("die") && !memcmp(function_name, "die", strlen("die")))
3634 )) {
3635 zend_error(E_WARNING, "Cannot disable function %s()", function_name);
3636 return;
3637 }
3638 zend_hash_str_del(CG(function_table), function_name, function_name_length);
3639}
3640
3641ZEND_API void zend_disable_functions(const char *function_list) /* {{{ */
3642{
3643 if (!function_list || !*function_list) {
3644 return;
3645 }
3646
3647 const char *s = NULL, *e = function_list;
3648 while (*e) {
3649 switch (*e) {
3650 case ' ':
3651 case ',':
3652 if (s) {
3653 zend_disable_function(s, e - s);
3654 s = NULL;
3655 }
3656 break;
3657 default:
3658 if (!s) {
3659 s = e;
3660 }
3661 break;
3662 }
3663 e++;
3664 }
3665 if (s) {
3666 zend_disable_function(s, e - s);
3667 }
3668
3669 /* Rehash the function table after deleting functions. This ensures that all internal
3670 * functions are contiguous, which means we don't need to perform full table cleanup
3671 * on shutdown. */
3672 zend_hash_rehash(CG(function_table));
3673}
3674/* }}} */
3675
3676#ifdef ZEND_WIN32
3677#pragma optimize("", off)
3678#endif
3679static ZEND_COLD zend_object *display_disabled_class(zend_class_entry *class_type) /* {{{ */
3680{
3681 zend_object *intern;
3682
3683 intern = zend_objects_new(class_type);
3684
3685 /* Initialize default properties */
3686 if (EXPECTED(class_type->default_properties_count != 0)) {
3687 zval *p = intern->properties_table;
3688 zval *end = p + class_type->default_properties_count;
3689 do {
3690 ZVAL_UNDEF(p);
3691 p++;
3692 } while (p != end);
3693 }
3694
3695 zend_error(E_WARNING, "%s() has been disabled for security reasons", ZSTR_VAL(class_type->name));
3696 return intern;
3697}
3698#ifdef ZEND_WIN32
3699#pragma optimize("", on)
3700#endif
3701/* }}} */
3702
3703static const zend_function_entry disabled_class_new[] = {
3705};
3706
3707ZEND_API zend_result zend_disable_class(const char *class_name, size_t class_name_length) /* {{{ */
3708{
3709 zend_class_entry *disabled_class;
3711 zend_function *fn;
3712 zend_property_info *prop;
3713
3714 key = zend_string_alloc(class_name_length, 0);
3715 zend_str_tolower_copy(ZSTR_VAL(key), class_name, class_name_length);
3716 disabled_class = zend_hash_find_ptr(CG(class_table), key);
3718 if (!disabled_class) {
3719 return FAILURE;
3720 }
3721
3722 /* Will be reset by INIT_CLASS_ENTRY. */
3723 free(disabled_class->interfaces);
3724
3725 INIT_CLASS_ENTRY_INIT_METHODS((*disabled_class), disabled_class_new);
3726 disabled_class->create_object = display_disabled_class;
3727
3728 ZEND_HASH_MAP_FOREACH_PTR(&disabled_class->function_table, fn) {
3730 fn->common.scope == disabled_class) {
3732 }
3734 zend_hash_clean(&disabled_class->function_table);
3735 ZEND_HASH_MAP_FOREACH_PTR(&disabled_class->properties_info, prop) {
3736 if (prop->ce == disabled_class) {
3737 zend_string_release(prop->name);
3738 zend_type_release(prop->type, /* persistent */ 1);
3739 free(prop);
3740 }
3742 zend_hash_clean(&disabled_class->properties_info);
3743 return SUCCESS;
3744}
3745/* }}} */
3746
3748{
3749 return frame && frame->func ? frame->func->common.scope : NULL;
3750}
3751
3752static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *scope, zend_execute_data *frame, zend_fcall_info_cache *fcc, bool *strict_class, char **error, bool suppress_deprecation) /* {{{ */
3753{
3754 bool ret = 0;
3755 zend_class_entry *ce;
3756 size_t name_len = ZSTR_LEN(name);
3758 ALLOCA_FLAG(use_heap);
3759
3760 ZSTR_ALLOCA_ALLOC(lcname, name_len, use_heap);
3762
3763 *strict_class = 0;
3764 if (zend_string_equals_literal(lcname, "self")) {
3765 if (!scope) {
3766 if (error) *error = estrdup("cannot access \"self\" when no class scope is active");
3767 } else {
3768 if (!suppress_deprecation) {
3769 zend_error(E_DEPRECATED, "Use of \"self\" in callables is deprecated");
3770 }
3772 if (!fcc->called_scope || !instanceof_function(fcc->called_scope, scope)) {
3773 fcc->called_scope = scope;
3774 }
3775 fcc->calling_scope = scope;
3776 if (!fcc->object) {
3778 }
3779 ret = 1;
3780 }
3781 } else if (zend_string_equals_literal(lcname, "parent")) {
3782 if (!scope) {
3783 if (error) *error = estrdup("cannot access \"parent\" when no class scope is active");
3784 } else if (!scope->parent) {
3785 if (error) *error = estrdup("cannot access \"parent\" when current class scope has no parent");
3786 } else {
3787 if (!suppress_deprecation) {
3788 zend_error(E_DEPRECATED, "Use of \"parent\" in callables is deprecated");
3789 }
3791 if (!fcc->called_scope || !instanceof_function(fcc->called_scope, scope->parent)) {
3792 fcc->called_scope = scope->parent;
3793 }
3794 fcc->calling_scope = scope->parent;
3795 if (!fcc->object) {
3797 }
3798 *strict_class = 1;
3799 ret = 1;
3800 }
3801 } else if (zend_string_equals(lcname, ZSTR_KNOWN(ZEND_STR_STATIC))) {
3803
3804 if (!called_scope) {
3805 if (error) *error = estrdup("cannot access \"static\" when no class scope is active");
3806 } else {
3807 if (!suppress_deprecation) {
3808 zend_error(E_DEPRECATED, "Use of \"static\" in callables is deprecated");
3809 }
3810 fcc->called_scope = called_scope;
3811 fcc->calling_scope = called_scope;
3812 if (!fcc->object) {
3814 }
3815 *strict_class = 1;
3816 ret = 1;
3817 }
3818 } else if ((ce = zend_lookup_class(name)) != NULL) {
3819 zend_class_entry *scope = get_scope(frame);
3820 fcc->calling_scope = ce;
3821 if (scope && !fcc->object) {
3823
3824 if (object &&
3825 instanceof_function(object->ce, scope) &&
3826 instanceof_function(scope, ce)) {
3827 fcc->object = object;
3828 fcc->called_scope = object->ce;
3829 } else {
3830 fcc->called_scope = ce;
3831 }
3832 } else {
3833 fcc->called_scope = fcc->object ? fcc->object->ce : ce;
3834 }
3835 *strict_class = 1;
3836 ret = 1;
3837 } else {
3838 if (error) zend_spprintf(error, 0, "class \"%.*s\" not found", (int)name_len, ZSTR_VAL(name));
3839 }
3840 ZSTR_ALLOCA_FREE(lcname, use_heap);
3841 return ret;
3842}
3843/* }}} */
3844
3855
3856static zend_always_inline bool zend_is_callable_check_func(zval *callable, zend_execute_data *frame, zend_fcall_info_cache *fcc, bool strict_class, char **error, bool suppress_deprecation) /* {{{ */
3857{
3858 zend_class_entry *ce_org = fcc->calling_scope;
3859 bool retval = 0;
3860 zend_string *mname, *cname;
3861 zend_string *lmname;
3862 const char *colon;
3863 size_t clen;
3864 HashTable *ftable;
3865 int call_via_handler = 0;
3867 zval *zv;
3868 ALLOCA_FLAG(use_heap)
3869
3870 fcc->calling_scope = NULL;
3871
3872 if (!ce_org) {
3874 zend_string *lmname;
3875
3876 /* Check if function with given name exists.
3877 * This may be a compound name that includes namespace name */
3878 if (UNEXPECTED(Z_STRVAL_P(callable)[0] == '\\')) {
3879 /* Skip leading \ */
3880 ZSTR_ALLOCA_ALLOC(lmname, Z_STRLEN_P(callable) - 1, use_heap);
3881 zend_str_tolower_copy(ZSTR_VAL(lmname), Z_STRVAL_P(callable) + 1, Z_STRLEN_P(callable) - 1);
3882 func = zend_fetch_function(lmname);
3883 ZSTR_ALLOCA_FREE(lmname, use_heap);
3884 } else {
3885 lmname = Z_STR_P(callable);
3886 func = zend_fetch_function(lmname);
3887 if (!func) {
3888 ZSTR_ALLOCA_ALLOC(lmname, Z_STRLEN_P(callable), use_heap);
3889 zend_str_tolower_copy(ZSTR_VAL(lmname), Z_STRVAL_P(callable), Z_STRLEN_P(callable));
3890 func = zend_fetch_function(lmname);
3891 ZSTR_ALLOCA_FREE(lmname, use_heap);
3892 }
3893 }
3894 if (EXPECTED(func != NULL)) {
3895 fcc->function_handler = func;
3896 return 1;
3897 }
3898 }
3899
3900 /* Split name into class/namespace and method/function names */
3901 if ((colon = zend_memrchr(Z_STRVAL_P(callable), ':', Z_STRLEN_P(callable))) != NULL &&
3902 colon > Z_STRVAL_P(callable) &&
3903 *(colon-1) == ':'
3904 ) {
3905 size_t mlen;
3906
3907 colon--;
3908 clen = colon - Z_STRVAL_P(callable);
3909 mlen = Z_STRLEN_P(callable) - clen - 2;
3910
3911 if (colon == Z_STRVAL_P(callable)) {
3912 if (error) *error = estrdup("invalid function name");
3913 return 0;
3914 }
3915
3916 /* This is a compound name.
3917 * Try to fetch class and then find static method. */
3918 if (ce_org) {
3919 scope = ce_org;
3920 } else {
3921 scope = get_scope(frame);
3922 }
3923
3924 cname = zend_string_init_interned(Z_STRVAL_P(callable), clen, 0);
3925 if (ZSTR_HAS_CE_CACHE(cname) && ZSTR_GET_CE_CACHE(cname)) {
3926 fcc->calling_scope = ZSTR_GET_CE_CACHE(cname);
3927 if (scope && !fcc->object) {
3929
3930 if (object &&
3931 instanceof_function(object->ce, scope) &&
3932 instanceof_function(scope, fcc->calling_scope)) {
3933 fcc->object = object;
3934 fcc->called_scope = object->ce;
3935 } else {
3936 fcc->called_scope = fcc->calling_scope;
3937 }
3938 } else {
3939 fcc->called_scope = fcc->object ? fcc->object->ce : fcc->calling_scope;
3940 }
3941 strict_class = 1;
3942 } else if (!zend_is_callable_check_class(cname, scope, frame, fcc, &strict_class, error, suppress_deprecation || ce_org != NULL)) {
3943 zend_string_release_ex(cname, 0);
3944 return 0;
3945 }
3946 zend_string_release_ex(cname, 0);
3947
3948 ftable = &fcc->calling_scope->function_table;
3949 if (ce_org && !instanceof_function(ce_org, fcc->calling_scope)) {
3950 if (error) zend_spprintf(error, 0, "class %s is not a subclass of %s", ZSTR_VAL(ce_org->name), ZSTR_VAL(fcc->calling_scope->name));
3951 return 0;
3952 }
3953 if (ce_org && !suppress_deprecation) {
3955 "Callables of the form [\"%s\", \"%s\"] are deprecated",
3956 ZSTR_VAL(ce_org->name), Z_STRVAL_P(callable));
3957 }
3958 mname = zend_string_init(Z_STRVAL_P(callable) + clen + 2, mlen, 0);
3959 } else if (ce_org) {
3960 /* Try to fetch find static method of given class. */
3961 mname = Z_STR_P(callable);
3962 zend_string_addref(mname);
3963 ftable = &ce_org->function_table;
3964 fcc->calling_scope = ce_org;
3965 } else {
3966 /* We already checked for plain function before. */
3967 if (error) {
3968 zend_spprintf(error, 0, "function \"%s\" not found or invalid function name", Z_STRVAL_P(callable));
3969 }
3970 return 0;
3971 }
3972
3973 lmname = zend_string_tolower(mname);
3974 if (strict_class &&
3975 fcc->calling_scope &&
3978 if (fcc->function_handler) {
3979 retval = 1;
3980 }
3981 } else if ((zv = zend_hash_find(ftable, lmname)) != NULL) {
3982 fcc->function_handler = Z_PTR_P(zv);
3983 retval = 1;
3985 !strict_class) {
3986 scope = get_scope(frame);
3987 if (scope &&
3988 instanceof_function(fcc->function_handler->common.scope, scope)) {
3989
3990 zv = zend_hash_find(&scope->function_table, lmname);
3991 if (zv != NULL) {
3992 zend_function *priv_fbc = Z_PTR_P(zv);
3993
3994 if ((priv_fbc->common.fn_flags & ZEND_ACC_PRIVATE)
3995 && priv_fbc->common.scope == scope) {
3996 fcc->function_handler = priv_fbc;
3997 }
3998 }
3999 }
4000 }
4002 (fcc->calling_scope &&
4003 ((fcc->object && fcc->calling_scope->__call) ||
4004 (!fcc->object && fcc->calling_scope->__callstatic)))) {
4005 scope = get_scope(frame);
4006 if (fcc->function_handler->common.scope != scope) {
4009 retval = 0;
4010 fcc->function_handler = NULL;
4011 goto get_function_via_handler;
4012 }
4013 }
4014 }
4015 } else {
4016get_function_via_handler:
4017 if (fcc->object && fcc->calling_scope == ce_org) {
4018 if (strict_class && ce_org->__call) {
4019 fcc->function_handler = zend_get_call_trampoline_func(ce_org, mname, 0);
4020 call_via_handler = 1;
4021 retval = 1;
4022 } else {
4023 fcc->function_handler = fcc->object->handlers->get_method(&fcc->object, mname, NULL);
4024 if (fcc->function_handler) {
4025 if (strict_class &&
4026 (!fcc->function_handler->common.scope ||
4027 !instanceof_function(ce_org, fcc->function_handler->common.scope))) {
4029 } else {
4030 retval = 1;
4031 call_via_handler = (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) != 0;
4032 }
4033 }
4034 }
4035 } else if (fcc->calling_scope) {
4036 if (fcc->calling_scope->get_static_method) {
4038 } else {
4040 }
4041 if (fcc->function_handler) {
4042 retval = 1;
4043 call_via_handler = (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) != 0;
4044 if (call_via_handler && !fcc->object) {
4046 if (object &&
4047 instanceof_function(object->ce, fcc->calling_scope)) {
4048 fcc->object = object;
4049 }
4050 }
4051 }
4052 }
4053 }
4054
4055 if (retval) {
4056 if (fcc->calling_scope && !call_via_handler) {
4058 retval = 0;
4059 if (error) {
4060 zend_spprintf(error, 0, "cannot call abstract method %s::%s()", ZSTR_VAL(fcc->calling_scope->name), ZSTR_VAL(fcc->function_handler->common.function_name));
4061 }
4062 } else if (!fcc->object && !(fcc->function_handler->common.fn_flags & ZEND_ACC_STATIC)) {
4063 retval = 0;
4064 if (error) {
4065 zend_spprintf(error, 0, "non-static method %s::%s() cannot be called statically", ZSTR_VAL(fcc->calling_scope->name), ZSTR_VAL(fcc->function_handler->common.function_name));
4066 }
4067 }
4068 if (retval
4070 scope = get_scope(frame);
4071 if (fcc->function_handler->common.scope != scope) {
4074 if (error) {
4075 if (*error) {
4076 efree(*error);
4077 }
4079 }
4080 retval = 0;
4081 }
4082 }
4083 }
4084 }
4085 } else if (error) {
4086 if (fcc->calling_scope) {
4087 zend_spprintf(error, 0, "class %s does not have a method \"%s\"", ZSTR_VAL(fcc->calling_scope->name), ZSTR_VAL(mname));
4088 } else {
4089 zend_spprintf(error, 0, "function %s() does not exist", ZSTR_VAL(mname));
4090 }
4091 }
4092 zend_string_release_ex(lmname, 0);
4093 zend_string_release_ex(mname, 0);
4094
4095 if (fcc->object) {
4096 fcc->called_scope = fcc->object->ce;
4097 if (fcc->function_handler
4099 fcc->object = NULL;
4100 }
4101 }
4102 return retval;
4103}
4104/* }}} */
4105
4107{
4108try_again:
4109 switch (Z_TYPE_P(callable)) {
4110 case IS_STRING:
4111 if (object) {
4112 return zend_create_member_string(object->ce->name, Z_STR_P(callable));
4113 }
4114 return zend_string_copy(Z_STR_P(callable));
4115
4116 case IS_ARRAY:
4117 {
4118 zval *method = NULL;
4119 zval *obj = NULL;
4120
4121 if (zend_hash_num_elements(Z_ARRVAL_P(callable)) == 2) {
4122 obj = zend_hash_index_find_deref(Z_ARRVAL_P(callable), 0);
4123 method = zend_hash_index_find_deref(Z_ARRVAL_P(callable), 1);
4124 }
4125
4126 if (obj == NULL || method == NULL || Z_TYPE_P(method) != IS_STRING) {
4127 return ZSTR_KNOWN(ZEND_STR_ARRAY_CAPITALIZED);
4128 }
4129
4130 if (Z_TYPE_P(obj) == IS_STRING) {
4131 return zend_create_member_string(Z_STR_P(obj), Z_STR_P(method));
4132 } else if (Z_TYPE_P(obj) == IS_OBJECT) {
4133 return zend_create_member_string(Z_OBJCE_P(obj)->name, Z_STR_P(method));
4134 } else {
4135 return ZSTR_KNOWN(ZEND_STR_ARRAY_CAPITALIZED);
4136 }
4137 }
4138 case IS_OBJECT:
4139 {
4140 zend_class_entry *ce = Z_OBJCE_P(callable);
4141 return zend_string_concat2(
4142 ZSTR_VAL(ce->name), ZSTR_LEN(ce->name),
4143 "::__invoke", sizeof("::__invoke") - 1);
4144 }
4145 case IS_REFERENCE:
4146 callable = Z_REFVAL_P(callable);
4147 goto try_again;
4148 default:
4149 return zval_get_string_func(callable);
4150 }
4151}
4152/* }}} */
4153
4155{
4156 return zend_get_callable_name_ex(callable, NULL);
4157}
4158/* }}} */
4159
4161 zval *callable, zend_object *object, zend_execute_data *frame,
4162 uint32_t check_flags, zend_fcall_info_cache *fcc, char **error) /* {{{ */
4163{
4164 bool ret;
4165 zend_fcall_info_cache fcc_local;
4166 bool strict_class = 0;
4167
4168 if (fcc == NULL) {
4169 fcc = &fcc_local;
4170 }
4171 if (error) {
4172 *error = NULL;
4173 }
4174
4175 fcc->calling_scope = NULL;
4176 fcc->called_scope = NULL;
4177 fcc->function_handler = NULL;
4178 fcc->object = NULL;
4179 fcc->closure = NULL;
4180
4181again:
4182 switch (Z_TYPE_P(callable)) {
4183 case IS_STRING:
4184 if (object) {
4185 fcc->object = object;
4186 fcc->calling_scope = object->ce;
4187 }
4188
4189 if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) {
4190 fcc->called_scope = fcc->calling_scope;
4191 return 1;
4192 }
4193
4194check_func:
4195 ret = zend_is_callable_check_func(callable, frame, fcc, strict_class, error, check_flags & IS_CALLABLE_SUPPRESS_DEPRECATIONS);
4196 if (fcc == &fcc_local) {
4198 }
4199 return ret;
4200
4201 case IS_ARRAY:
4202 {
4203 if (zend_hash_num_elements(Z_ARRVAL_P(callable)) != 2) {
4204 if (error) *error = estrdup("array callback must have exactly two members");
4205 return 0;
4206 }
4207
4208 zval *obj = zend_hash_index_find(Z_ARRVAL_P(callable), 0);
4209 zval *method = zend_hash_index_find(Z_ARRVAL_P(callable), 1);
4210 if (!obj || !method) {
4211 if (error) *error = estrdup("array callback has to contain indices 0 and 1");
4212 return 0;
4213 }
4214
4215 ZVAL_DEREF(obj);
4216 if (Z_TYPE_P(obj) != IS_STRING && Z_TYPE_P(obj) != IS_OBJECT) {
4217 if (error) *error = estrdup("first array member is not a valid class name or object");
4218 return 0;
4219 }
4220
4221 ZVAL_DEREF(method);
4222 if (Z_TYPE_P(method) != IS_STRING) {
4223 if (error) *error = estrdup("second array member is not a valid method");
4224 return 0;
4225 }
4226
4227 if (Z_TYPE_P(obj) == IS_STRING) {
4228 if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) {
4229 return 1;
4230 }
4231
4232 if (!zend_is_callable_check_class(Z_STR_P(obj), get_scope(frame), frame, fcc, &strict_class, error, check_flags & IS_CALLABLE_SUPPRESS_DEPRECATIONS)) {
4233 return 0;
4234 }
4235 } else {
4237 fcc->calling_scope = Z_OBJCE_P(obj); /* TBFixed: what if it's overloaded? */
4238 fcc->object = Z_OBJ_P(obj);
4239
4240 if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) {
4241 fcc->called_scope = fcc->calling_scope;
4242 return 1;
4243 }
4244 }
4245
4246 callable = method;
4247 goto check_func;
4248 }
4249 return 0;
4250 case IS_OBJECT:
4251 if (Z_OBJ_HANDLER_P(callable, get_closure) && Z_OBJ_HANDLER_P(callable, get_closure)(Z_OBJ_P(callable), &fcc->calling_scope, &fcc->function_handler, &fcc->object, 1) == SUCCESS) {
4252 fcc->called_scope = fcc->calling_scope;
4253 fcc->closure = Z_OBJ_P(callable);
4254 if (fcc == &fcc_local) {
4256 }
4257 return 1;
4258 }
4259 if (error) *error = estrdup("no array or string given");
4260 return 0;
4261 case IS_REFERENCE:
4262 callable = Z_REFVAL_P(callable);
4263 goto again;
4264 default:
4265 if (error) *error = estrdup("no array or string given");
4266 return 0;
4267 }
4268}
4269/* }}} */
4270
4271ZEND_API bool zend_is_callable_ex(zval *callable, zend_object *object, uint32_t check_flags, zend_string **callable_name, zend_fcall_info_cache *fcc, char **error) /* {{{ */
4272{
4273 /* Determine callability at the first parent user frame. */
4274 zend_execute_data *frame = EG(current_execute_data);
4275 while (frame && (!frame->func || !ZEND_USER_CODE(frame->func->type))) {
4276 frame = frame->prev_execute_data;
4277 }
4278
4279 bool ret = zend_is_callable_at_frame(callable, object, frame, check_flags, fcc, error);
4280 if (callable_name) {
4281 *callable_name = zend_get_callable_name_ex(callable, object);
4282 }
4283 return ret;
4284}
4285
4286ZEND_API bool zend_is_callable(zval *callable, uint32_t check_flags, zend_string **callable_name) /* {{{ */
4287{
4288 return zend_is_callable_ex(callable, NULL, check_flags, callable_name, NULL, NULL);
4289}
4290/* }}} */
4291
4292ZEND_API bool zend_make_callable(zval *callable, zend_string **callable_name) /* {{{ */
4293{
4295
4296 if (zend_is_callable_ex(callable, NULL, IS_CALLABLE_SUPPRESS_DEPRECATIONS, callable_name, &fcc, NULL)) {
4297 if (Z_TYPE_P(callable) == IS_STRING && fcc.calling_scope) {
4298 zval_ptr_dtor_str(callable);
4299 array_init(callable);
4300 add_next_index_str(callable, zend_string_copy(fcc.calling_scope->name));
4301 add_next_index_str(callable, zend_string_copy(fcc.function_handler->common.function_name));
4302 }
4304 return 1;
4305 }
4306 return 0;
4307}
4308/* }}} */
4309
4310ZEND_API zend_result zend_fcall_info_init(zval *callable, uint32_t check_flags, zend_fcall_info *fci, zend_fcall_info_cache *fcc, zend_string **callable_name, char **error) /* {{{ */
4311{
4312 if (!zend_is_callable_ex(callable, NULL, check_flags, callable_name, fcc, error)) {
4313 return FAILURE;
4314 }
4315
4316 fci->size = sizeof(*fci);
4317 fci->object = fcc->object;
4318 ZVAL_COPY_VALUE(&fci->function_name, callable);
4319 fci->retval = NULL;
4320 fci->param_count = 0;
4321 fci->params = NULL;
4322 fci->named_params = NULL;
4323
4324 return SUCCESS;
4325}
4326/* }}} */
4327
4328ZEND_API void zend_fcall_info_args_clear(zend_fcall_info *fci, bool free_mem) /* {{{ */
4329{
4330 if (fci->params) {
4331 zval *p = fci->params;
4332 zval *end = p + fci->param_count;
4333
4334 while (p != end) {
4335 i_zval_ptr_dtor(p);
4336 p++;
4337 }
4338 if (free_mem) {
4339 efree(fci->params);
4340 fci->params = NULL;
4341 }
4342 }
4343 fci->param_count = 0;
4344}
4345/* }}} */
4346
4347ZEND_API void zend_fcall_info_args_save(zend_fcall_info *fci, uint32_t *param_count, zval **params) /* {{{ */
4348{
4349 *param_count = fci->param_count;
4350 *params = fci->params;
4351 fci->param_count = 0;
4352 fci->params = NULL;
4353}
4354/* }}} */
4355
4356ZEND_API void zend_fcall_info_args_restore(zend_fcall_info *fci, uint32_t param_count, zval *params) /* {{{ */
4357{
4359 fci->param_count = param_count;
4360 fci->params = params;
4361}
4362/* }}} */
4363
4365{
4366 zval *arg, *params;
4367 uint32_t n = 1;
4368
4370
4371 if (!args) {
4372 return SUCCESS;
4373 }
4374
4375 if (Z_TYPE_P(args) != IS_ARRAY) {
4376 return FAILURE;
4377 }
4378
4379 fci->param_count = zend_hash_num_elements(Z_ARRVAL_P(args));
4380 fci->params = params = (zval *) erealloc(fci->params, fci->param_count * sizeof(zval));
4381
4384 ZVAL_NEW_REF(params, arg);
4386 } else {
4387 ZVAL_COPY(params, arg);
4388 }
4389 params++;
4390 n++;
4392
4393 return SUCCESS;
4394}
4395/* }}} */
4396
4401/* }}} */
4402
4403ZEND_API void zend_fcall_info_argp(zend_fcall_info *fci, uint32_t argc, zval *argv) /* {{{ */
4404{
4405 zend_fcall_info_args_clear(fci, !argc);
4406
4407 if (argc) {
4408 fci->param_count = argc;
4409 fci->params = (zval *) erealloc(fci->params, fci->param_count * sizeof(zval));
4410
4411 for (uint32_t i = 0; i < argc; ++i) {
4412 ZVAL_COPY(&fci->params[i], &argv[i]);
4413 }
4414 }
4415}
4416/* }}} */
4417
4418ZEND_API void zend_fcall_info_argv(zend_fcall_info *fci, uint32_t argc, va_list *argv) /* {{{ */
4419{
4420 zend_fcall_info_args_clear(fci, !argc);
4421
4422 if (argc) {
4423 zval *arg;
4424 fci->param_count = argc;
4425 fci->params = (zval *) erealloc(fci->params, fci->param_count * sizeof(zval));
4426
4427 for (uint32_t i = 0; i < argc; ++i) {
4428 arg = va_arg(*argv, zval *);
4429 ZVAL_COPY(&fci->params[i], arg);
4430 }
4431 }
4432}
4433/* }}} */
4434
4435ZEND_API void zend_fcall_info_argn(zend_fcall_info *fci, uint32_t argc, ...) /* {{{ */
4436{
4437 va_list argv;
4438
4439 va_start(argv, argc);
4440 zend_fcall_info_argv(fci, argc, &argv);
4441 va_end(argv);
4442}
4443/* }}} */
4444
4446{
4447 zval retval, *org_params = NULL;
4448 uint32_t org_count = 0;
4450
4451 fci->retval = retval_ptr ? retval_ptr : &retval;
4452 if (args) {
4453 zend_fcall_info_args_save(fci, &org_count, &org_params);
4455 }
4456 result = zend_call_function(fci, fcc);
4457
4458 if (!retval_ptr && Z_TYPE(retval) != IS_UNDEF) {
4460 }
4461 if (args) {
4462 zend_fcall_info_args_restore(fci, org_count, org_params);
4463 }
4464 return result;
4465}
4466/* }}} */
4467
4469{
4470 if (fcc->closure) {
4471 ZVAL_OBJ_COPY(callable, fcc->closure);
4472 } else if (fcc->function_handler->common.scope) {
4473 array_init(callable);
4474 if (fcc->object) {
4475 GC_ADDREF(fcc->object);
4476 add_next_index_object(callable, fcc->object);
4477 } else {
4478 add_next_index_str(callable, zend_string_copy(fcc->calling_scope->name));
4479 }
4480 add_next_index_str(callable, zend_string_copy(fcc->function_handler->common.function_name));
4481 } else {
4483 }
4484}
4485
4486ZEND_API const char *zend_get_module_version(const char *module_name) /* {{{ */
4487{
4488 zend_string *lname;
4489 size_t name_len = strlen(module_name);
4490 zend_module_entry *module;
4491
4492 lname = zend_string_alloc(name_len, 0);
4493 zend_str_tolower_copy(ZSTR_VAL(lname), module_name, name_len);
4494 module = zend_hash_find_ptr(&module_registry, lname);
4495 zend_string_efree(lname);
4496 return module ? module->version : NULL;
4497}
4498/* }}} */
4499
4500static zend_always_inline bool is_persistent_class(zend_class_entry *ce) {
4501 return (ce->type & ZEND_INTERNAL_CLASS)
4503}
4504
4506{
4507 zend_property_info *property_info, *property_info_ptr;
4508
4509 if (ZEND_TYPE_IS_SET(type)) {
4511
4512 if (access_type & ZEND_ACC_READONLY) {
4514 }
4515 }
4516
4517 if (ce->type == ZEND_INTERNAL_CLASS) {
4518 property_info = pemalloc(sizeof(zend_property_info), 1);
4519 } else {
4520 property_info = zend_arena_alloc(&CG(arena), sizeof(zend_property_info));
4523 if (access_type & ZEND_ACC_STATIC) {
4525 } else {
4527 }
4528 }
4529 }
4530
4533 }
4534
4535 if (!(access_type & ZEND_ACC_PPP_MASK)) {
4536 access_type |= ZEND_ACC_PUBLIC;
4537 }
4538 /* Add the protected(set) bit for public readonly properties with no set visibility. */
4540 access_type |= ZEND_ACC_PROTECTED_SET;
4541 } else if (UNEXPECTED(access_type & ZEND_ACC_PPP_SET_MASK)) {
4542 if (!ZEND_TYPE_IS_SET(type)) {
4544 "Property with asymmetric visibility %s::$%s must have type",
4545 ZSTR_VAL(ce->name), ZSTR_VAL(name));
4546 }
4547 uint32_t get_visibility = zend_visibility_to_set_visibility(access_type & ZEND_ACC_PPP_MASK);
4548 uint32_t set_visibility = access_type & ZEND_ACC_PPP_SET_MASK;
4549 if (get_visibility > set_visibility) {
4551 "Visibility of property %s::$%s must not be weaker than set visibility",
4552 ZSTR_VAL(ce->name), ZSTR_VAL(name));
4553 }
4554 /* Remove equivalent set visibility. */
4558 access_type &= ~ZEND_ACC_PPP_SET_MASK;
4559 }
4560 /* private(set) properties are implicitly final. */
4561 if (access_type & ZEND_ACC_PRIVATE_SET) {
4562 access_type |= ZEND_ACC_FINAL;
4563 }
4564 }
4565
4566 /* Virtual properties have no backing storage, the offset should never be used. However, the
4567 * virtual flag cannot be definitively determined at compile time. Allow using default values
4568 * anyway, and assert after inheritance that the property is not actually virtual. */
4569 if (access_type & ZEND_ACC_VIRTUAL) {
4570 if (Z_TYPE_P(property) == IS_UNDEF) {
4571 property_info->offset = (uint32_t)-1;
4572 goto skip_property_storage;
4573 }
4574 }
4575 if (access_type & ZEND_ACC_STATIC) {
4576 if ((property_info_ptr = zend_hash_find_ptr(&ce->properties_info, name)) != NULL) {
4577 ZEND_ASSERT(property_info_ptr->flags & ZEND_ACC_STATIC);
4578 property_info->offset = property_info_ptr->offset;
4580 if (property_info_ptr->doc_comment && property_info_ptr->ce == ce) {
4581 zend_string_release(property_info_ptr->doc_comment);
4582 }
4584 } else {
4585 property_info->offset = ce->default_static_members_count++;
4587 }
4589 if (!ZEND_MAP_PTR(ce->static_members_table)) {
4590 if (ce->type == ZEND_INTERNAL_CLASS &&
4592 ZEND_MAP_PTR_NEW(ce->static_members_table);
4593 }
4594 }
4595 } else {
4596 zval *property_default_ptr;
4597 if ((property_info_ptr = zend_hash_find_ptr(&ce->properties_info, name)) != NULL) {
4598 ZEND_ASSERT(!(property_info_ptr->flags & ZEND_ACC_STATIC));
4599 property_info->offset = property_info_ptr->offset;
4601 if (property_info_ptr->doc_comment && property_info_ptr->ce == ce) {
4602 zend_string_release_ex(property_info_ptr->doc_comment, 1);
4603 }
4605
4608 ce->properties_info_table[OBJ_PROP_TO_NUM(property_info->offset)] = property_info;
4609 } else {
4613
4614 /* For user classes this is handled during linking */
4615 if (ce->type == ZEND_INTERNAL_CLASS) {
4617 ce->properties_info_table[ce->default_properties_count - 1] = property_info;
4618 }
4619 }
4620 property_default_ptr = &ce->default_properties_table[OBJ_PROP_TO_NUM(property_info->offset)];
4621 ZVAL_COPY_VALUE(property_default_ptr, property);
4622 Z_PROP_FLAG_P(property_default_ptr) = Z_ISUNDEF_P(property) ? IS_PROP_UNINIT : 0;
4623 }
4624skip_property_storage:
4625 if (ce->type & ZEND_INTERNAL_CLASS) {
4626 /* Must be interned to avoid ZTS data races */
4627 if (is_persistent_class(ce)) {
4628 name = zend_new_interned_string(zend_string_copy(name));
4629 }
4630
4631 if (Z_REFCOUNTED_P(property)) {
4632 zend_error_noreturn(E_CORE_ERROR, "Internal zvals cannot be refcounted");
4633 }
4634 }
4635
4636 if (access_type & ZEND_ACC_PUBLIC) {
4637 property_info->name = zend_string_copy(name);
4638 } else if (access_type & ZEND_ACC_PRIVATE) {
4639 property_info->name = zend_mangle_property_name(ZSTR_VAL(ce->name), ZSTR_LEN(ce->name), ZSTR_VAL(name), ZSTR_LEN(name), is_persistent_class(ce));
4640 } else {
4641 ZEND_ASSERT(access_type & ZEND_ACC_PROTECTED);
4642 property_info->name = zend_mangle_property_name("*", 1, ZSTR_VAL(name), ZSTR_LEN(name), is_persistent_class(ce));
4643 }
4644
4645 property_info->name = zend_new_interned_string(property_info->name);
4646 property_info->flags = access_type;
4647 property_info->doc_comment = doc_comment;
4648 property_info->attributes = NULL;
4649 property_info->prototype = property_info;
4650 property_info->hooks = NULL;
4651 property_info->ce = ce;
4652 property_info->type = type;
4653
4654 if (is_persistent_class(ce)) {
4655 zend_normalize_internal_type(&property_info->type);
4656 }
4657
4658 zend_hash_update_ptr(&ce->properties_info, name, property_info);
4659
4660 return property_info;
4661}
4662/* }}} */
4663
4665{
4666 if (UNEXPECTED(!zend_verify_ref_assignable_zval(ref, val, strict))) {
4668 return FAILURE;
4669 } else {
4670 zval_ptr_dtor(&ref->val);
4671 ZVAL_COPY_VALUE(&ref->val, val);
4672 return SUCCESS;
4673 }
4674}
4675/* }}} */
4676
4681/* }}} */
4682
4684{
4685 zval tmp;
4686
4687 ZVAL_NULL(&tmp);
4688 return zend_try_assign_typed_ref(ref, &tmp);
4689}
4690/* }}} */
4691
4693{
4694 zval tmp;
4695
4696 ZVAL_BOOL(&tmp, val);
4697 return zend_try_assign_typed_ref(ref, &tmp);
4698}
4699/* }}} */
4700
4702{
4703 zval tmp;
4704
4705 ZVAL_LONG(&tmp, lval);
4706 return zend_try_assign_typed_ref(ref, &tmp);
4707}
4708/* }}} */
4709
4711{
4712 zval tmp;
4713
4714 ZVAL_DOUBLE(&tmp, dval);
4715 return zend_try_assign_typed_ref(ref, &tmp);
4716}
4717/* }}} */
4718
4720{
4721 zval tmp;
4722
4723 ZVAL_EMPTY_STRING(&tmp);
4724 return zend_try_assign_typed_ref(ref, &tmp);
4725}
4726/* }}} */
4727
4729{
4730 zval tmp;
4731
4732 ZVAL_STR(&tmp, str);
4733 return zend_try_assign_typed_ref(ref, &tmp);
4734}
4735/* }}} */
4736
4738{
4739 zval tmp;
4740
4741 ZVAL_STRING(&tmp, string);
4742 return zend_try_assign_typed_ref(ref, &tmp);
4743}
4744/* }}} */
4745
4747{
4748 zval tmp;
4749
4750 ZVAL_STRINGL(&tmp, string, len);
4751 return zend_try_assign_typed_ref(ref, &tmp);
4752}
4753/* }}} */
4754
4756{
4757 zval tmp;
4758
4759 ZVAL_ARR(&tmp, arr);
4760 return zend_try_assign_typed_ref(ref, &tmp);
4761}
4762/* }}} */
4763
4765{
4766 zval tmp;
4767
4768 ZVAL_RES(&tmp, res);
4769 return zend_try_assign_typed_ref(ref, &tmp);
4770}
4771/* }}} */
4772
4774{
4775 zval tmp;
4776
4777 ZVAL_COPY_VALUE(&tmp, zv);
4778 return zend_try_assign_typed_ref(ref, &tmp);
4779}
4780/* }}} */
4781
4783{
4784 zval tmp;
4785
4786 ZVAL_COPY_VALUE(&tmp, zv);
4787 return zend_try_assign_typed_ref_ex(ref, &tmp, strict);
4788}
4789/* }}} */
4790
4791ZEND_API void zend_declare_property_ex(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment) /* {{{ */
4792{
4793 zend_declare_typed_property(ce, name, property, access_type, doc_comment, (zend_type) ZEND_TYPE_INIT_NONE(0));
4794}
4795/* }}} */
4796
4797ZEND_API void zend_declare_property(zend_class_entry *ce, const char *name, size_t name_length, zval *property, int access_type) /* {{{ */
4798{
4799 zend_string *key = zend_string_init(name, name_length, is_persistent_class(ce));
4800 zend_declare_property_ex(ce, key, property, access_type, NULL);
4801 zend_string_release(key);
4802}
4803/* }}} */
4804
4805ZEND_API void zend_declare_property_null(zend_class_entry *ce, const char *name, size_t name_length, int access_type) /* {{{ */
4806{
4807 zval property;
4808
4810 zend_declare_property(ce, name, name_length, &property, access_type);
4811}
4812/* }}} */
4813
4814ZEND_API void zend_declare_property_bool(zend_class_entry *ce, const char *name, size_t name_length, zend_long value, int access_type) /* {{{ */
4815{
4816 zval property;
4817
4819 zend_declare_property(ce, name, name_length, &property, access_type);
4820}
4821/* }}} */
4822
4823ZEND_API void zend_declare_property_long(zend_class_entry *ce, const char *name, size_t name_length, zend_long value, int access_type) /* {{{ */
4824{
4825 zval property;
4826
4828 zend_declare_property(ce, name, name_length, &property, access_type);
4829}
4830/* }}} */
4831
4832ZEND_API void zend_declare_property_double(zend_class_entry *ce, const char *name, size_t name_length, double value, int access_type) /* {{{ */
4833{
4834 zval property;
4835
4837 zend_declare_property(ce, name, name_length, &property, access_type);
4838}
4839/* }}} */
4840
4841ZEND_API void zend_declare_property_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value, int access_type) /* {{{ */
4842{
4843 zval property;
4844
4845 ZVAL_NEW_STR(&property, zend_string_init(value, strlen(value), ce->type & ZEND_INTERNAL_CLASS));
4846 zend_declare_property(ce, name, name_length, &property, access_type);
4847}
4848/* }}} */
4849
4850ZEND_API void zend_declare_property_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_len, int access_type) /* {{{ */
4851{
4852 zval property;
4853
4854 ZVAL_NEW_STR(&property, zend_string_init(value, value_len, ce->type & ZEND_INTERNAL_CLASS));
4855 zend_declare_property(ce, name, name_length, &property, access_type);
4856}
4857/* }}} */
4858
4860{
4862
4863 if (ce->ce_flags & ZEND_ACC_INTERFACE) {
4864 if (!(flags & ZEND_ACC_PUBLIC)) {
4865 zend_error_noreturn(E_COMPILE_ERROR, "Access type for interface constant %s::%s must be public", ZSTR_VAL(ce->name), ZSTR_VAL(name));
4866 }
4867 }
4868
4869 if (zend_string_equals_ci(name, ZSTR_KNOWN(ZEND_STR_CLASS))) {
4871 "A class constant must not be called 'class'; it is reserved for class name fetching");
4872 }
4873
4876 }
4877
4878 if (ce->type == ZEND_INTERNAL_CLASS) {
4879 c = pemalloc(sizeof(zend_class_constant), 1);
4881 ZEND_ASSERT(!ZEND_TYPE_CONTAINS_CODE(type, IS_RESOURCE) && "resource is not allowed in a zend_type");
4882 }
4883 } else {
4884 c = zend_arena_alloc(&CG(arena), sizeof(zend_class_constant));
4885 }
4888 c->doc_comment = doc_comment;
4889 c->attributes = NULL;
4890 c->ce = ce;
4891 c->type = type;
4892
4893 if (Z_TYPE_P(value) == IS_CONSTANT_AST) {
4896 if (ce->type == ZEND_INTERNAL_CLASS && !ZEND_MAP_PTR(ce->mutable_data)) {
4897 ZEND_MAP_PTR_NEW(ce->mutable_data);
4898 }
4899 }
4900
4901 if (!zend_hash_add_ptr(&ce->constants_table, name, c)) {
4903 "Cannot redefine class constant %s::%s", ZSTR_VAL(ce->name), ZSTR_VAL(name));
4904 }
4905
4906 return c;
4907}
4908
4913
4914ZEND_API void zend_declare_class_constant(zend_class_entry *ce, const char *name, size_t name_length, zval *value) /* {{{ */
4915{
4917
4918 if (ce->type == ZEND_INTERNAL_CLASS) {
4919 key = zend_string_init_interned(name, name_length, 1);
4920 } else {
4921 key = zend_string_init(name, name_length, 0);
4922 }
4924 zend_string_release(key);
4925}
4926/* }}} */
4927
4928ZEND_API void zend_declare_class_constant_null(zend_class_entry *ce, const char *name, size_t name_length) /* {{{ */
4929{
4930 zval constant;
4931
4933 zend_declare_class_constant(ce, name, name_length, &constant);
4934}
4935/* }}} */
4936
4937ZEND_API void zend_declare_class_constant_long(zend_class_entry *ce, const char *name, size_t name_length, zend_long value) /* {{{ */
4938{
4939 zval constant;
4940
4942 zend_declare_class_constant(ce, name, name_length, &constant);
4943}
4944/* }}} */
4945
4946ZEND_API void zend_declare_class_constant_bool(zend_class_entry *ce, const char *name, size_t name_length, bool value) /* {{{ */
4947{
4948 zval constant;
4949
4951 zend_declare_class_constant(ce, name, name_length, &constant);
4952}
4953/* }}} */
4954
4955ZEND_API void zend_declare_class_constant_double(zend_class_entry *ce, const char *name, size_t name_length, double value) /* {{{ */
4956{
4957 zval constant;
4958
4960 zend_declare_class_constant(ce, name, name_length, &constant);
4961}
4962/* }}} */
4963
4964ZEND_API void zend_declare_class_constant_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_length) /* {{{ */
4965{
4966 zval constant;
4967
4968 ZVAL_NEW_STR(&constant, zend_string_init(value, value_length, ce->type & ZEND_INTERNAL_CLASS));
4969 zend_declare_class_constant(ce, name, name_length, &constant);
4970}
4971/* }}} */
4972
4973ZEND_API void zend_declare_class_constant_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value) /* {{{ */
4974{
4976}
4977/* }}} */
4978
4980{
4981 zend_class_entry *old_scope = EG(fake_scope);
4982
4983 EG(fake_scope) = scope;
4984
4985 object->handlers->write_property(object, name, value, NULL);
4986
4987 EG(fake_scope) = old_scope;
4988}
4989/* }}} */
4990
4991ZEND_API void zend_update_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, zval *value) /* {{{ */
4992{
4994 zend_class_entry *old_scope = EG(fake_scope);
4995
4996 EG(fake_scope) = scope;
4997
4998 property = zend_string_init(name, name_length, 0);
4999 object->handlers->write_property(object, property, value, NULL);
5001
5002 EG(fake_scope) = old_scope;
5003}
5004/* }}} */
5005
5006ZEND_API void zend_update_property_null(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length) /* {{{ */
5007{
5008 zval tmp;
5009
5010 ZVAL_NULL(&tmp);
5011 zend_update_property(scope, object, name, name_length, &tmp);
5012}
5013/* }}} */
5014
5015ZEND_API void zend_unset_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length) /* {{{ */
5016{
5018 zend_class_entry *old_scope = EG(fake_scope);
5019
5020 EG(fake_scope) = scope;
5021
5022 property = zend_string_init(name, name_length, 0);
5023 object->handlers->unset_property(object, property, 0);
5025
5026 EG(fake_scope) = old_scope;
5027}
5028/* }}} */
5029
5030ZEND_API void zend_update_property_bool(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, zend_long value) /* {{{ */
5031{
5032 zval tmp;
5033
5034 ZVAL_BOOL(&tmp, value);
5035 zend_update_property(scope, object, name, name_length, &tmp);
5036}
5037/* }}} */
5038
5039ZEND_API void zend_update_property_long(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, zend_long value) /* {{{ */
5040{
5041 zval tmp;
5042
5043 ZVAL_LONG(&tmp, value);
5044 zend_update_property(scope, object, name, name_length, &tmp);
5045}
5046/* }}} */
5047
5048ZEND_API void zend_update_property_double(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, double value) /* {{{ */
5049{
5050 zval tmp;
5051
5052 ZVAL_DOUBLE(&tmp, value);
5053 zend_update_property(scope, object, name, name_length, &tmp);
5054}
5055/* }}} */
5056
5057ZEND_API void zend_update_property_str(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, zend_string *value) /* {{{ */
5058{
5059 zval tmp;
5060
5061 ZVAL_STR(&tmp, value);
5062 zend_update_property(scope, object, name, name_length, &tmp);
5063}
5064/* }}} */
5065
5066ZEND_API void zend_update_property_string(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, const char *value) /* {{{ */
5067{
5068 zval tmp;
5069
5070 ZVAL_STRING(&tmp, value);
5071 Z_SET_REFCOUNT(tmp, 0);
5072 zend_update_property(scope, object, name, name_length, &tmp);
5073}
5074/* }}} */
5075
5076ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, const char *value, size_t value_len) /* {{{ */
5077{
5078 zval tmp;
5079
5080 ZVAL_STRINGL(&tmp, value, value_len);
5081 Z_SET_REFCOUNT(tmp, 0);
5082 zend_update_property(scope, object, name, name_length, &tmp);
5083}
5084/* }}} */
5085
5087{
5088 zval *property, tmp;
5090 zend_class_entry *old_scope = EG(fake_scope);
5091
5092 if (UNEXPECTED(!(scope->ce_flags & ZEND_ACC_CONSTANTS_UPDATED))) {
5094 return FAILURE;
5095 }
5096 }
5097
5098 EG(fake_scope) = scope;
5100 EG(fake_scope) = old_scope;
5101
5102 if (!property) {
5103 return FAILURE;
5104 }
5105
5108 if (ZEND_TYPE_IS_SET(prop_info->type)) {
5109 ZVAL_COPY_VALUE(&tmp, value);
5110 if (!zend_verify_property_type(prop_info, &tmp, /* strict */ 0)) {
5112 return FAILURE;
5113 }
5114 value = &tmp;
5115 }
5116
5117 zend_assign_to_variable(property, value, IS_TMP_VAR, /* strict */ 0);
5118 return SUCCESS;
5119}
5120/* }}} */
5121
5123{
5124 zend_string *key = zend_string_init(name, name_length, 0);
5126 zend_string_efree(key);
5127 return retval;
5128}
5129/* }}} */
5130
5132{
5133 zval tmp;
5134
5135 ZVAL_NULL(&tmp);
5136 return zend_update_static_property(scope, name, name_length, &tmp);
5137}
5138/* }}} */
5139
5141{
5142 zval tmp;
5143
5144 ZVAL_BOOL(&tmp, value);
5145 return zend_update_static_property(scope, name, name_length, &tmp);
5146}
5147/* }}} */
5148
5150{
5151 zval tmp;
5152
5153 ZVAL_LONG(&tmp, value);
5154 return zend_update_static_property(scope, name, name_length, &tmp);
5155}
5156/* }}} */
5157
5158ZEND_API zend_result zend_update_static_property_double(zend_class_entry *scope, const char *name, size_t name_length, double value) /* {{{ */
5159{
5160 zval tmp;
5161
5162 ZVAL_DOUBLE(&tmp, value);
5163 return zend_update_static_property(scope, name, name_length, &tmp);
5164}
5165/* }}} */
5166
5167ZEND_API zend_result zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value) /* {{{ */
5168{
5169 zval tmp;
5170
5171 ZVAL_STRING(&tmp, value);
5172 Z_SET_REFCOUNT(tmp, 0);
5173 return zend_update_static_property(scope, name, name_length, &tmp);
5174}
5175/* }}} */
5176
5177ZEND_API zend_result zend_update_static_property_stringl(zend_class_entry *scope, const char *name, size_t name_length, const char *value, size_t value_len) /* {{{ */
5178{
5179 zval tmp;
5180
5181 ZVAL_STRINGL(&tmp, value, value_len);
5182 Z_SET_REFCOUNT(tmp, 0);
5183 return zend_update_static_property(scope, name, name_length, &tmp);
5184}
5185/* }}} */
5186
5188{
5189 zval *value;
5190 zend_class_entry *old_scope = EG(fake_scope);
5191
5192 EG(fake_scope) = scope;
5193
5194 value = object->handlers->read_property(object, name, silent?BP_VAR_IS:BP_VAR_R, NULL, rv);
5195
5196 EG(fake_scope) = old_scope;
5197 return value;
5198}
5199/* }}} */
5200
5201ZEND_API zval *zend_read_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, bool silent, zval *rv) /* {{{ */
5202{
5203 zval *value;
5204 zend_string *str;
5205
5206 str = zend_string_init(name, name_length, 0);
5207 value = zend_read_property_ex(scope, object, str, silent, rv);
5208 zend_string_release_ex(str, 0);
5209 return value;
5210}
5211/* }}} */
5212
5214{
5215 zval *property;
5216 zend_class_entry *old_scope = EG(fake_scope);
5217
5218 EG(fake_scope) = scope;
5219 property = zend_std_get_static_property(scope, name, silent ? BP_VAR_IS : BP_VAR_R);
5220 EG(fake_scope) = old_scope;
5221
5222 return property;
5223}
5224/* }}} */
5225
5226ZEND_API zval *zend_read_static_property(zend_class_entry *scope, const char *name, size_t name_length, bool silent) /* {{{ */
5227{
5228 zend_string *key = zend_string_init(name, name_length, 0);
5229 zval *property = zend_read_static_property_ex(scope, key, silent);
5230 zend_string_efree(key);
5231 return property;
5232}
5233/* }}} */
5234
5236{
5237 current->handling = EG(error_handling);
5238 current->exception = EG(exception_class);
5239}
5240/* }}} */
5241
5243{
5244 if (current) {
5246 }
5247 ZEND_ASSERT(error_handling == EH_THROW || exception_class == NULL);
5248 EG(error_handling) = error_handling;
5249 EG(exception_class) = exception_class;
5250}
5251/* }}} */
5252
5254{
5255 EG(error_handling) = saved->handling;
5256 EG(exception_class) = saved->exception;
5257}
5258/* }}} */
5259
5260ZEND_API ZEND_COLD const char *zend_get_object_type_case(const zend_class_entry *ce, bool upper_case) /* {{{ */
5261{
5262 if (ce->ce_flags & ZEND_ACC_TRAIT) {
5263 return upper_case ? "Trait" : "trait";
5264 } else if (ce->ce_flags & ZEND_ACC_INTERFACE) {
5265 return upper_case ? "Interface" : "interface";
5266 } else if (ce->ce_flags & ZEND_ACC_ENUM) {
5267 return upper_case ? "Enum" : "enum";
5268 } else {
5269 return upper_case ? "Class" : "class";
5270 }
5271}
5272/* }}} */
5273
5274ZEND_API bool zend_is_iterable(const zval *iterable) /* {{{ */
5275{
5276 switch (Z_TYPE_P(iterable)) {
5277 case IS_ARRAY:
5278 return 1;
5279 case IS_OBJECT:
5281 default:
5282 return 0;
5283 }
5284}
5285/* }}} */
5286
5287ZEND_API bool zend_is_countable(const zval *countable) /* {{{ */
5288{
5289 switch (Z_TYPE_P(countable)) {
5290 case IS_ARRAY:
5291 return 1;
5292 case IS_OBJECT:
5293 if (Z_OBJ_HT_P(countable)->count_elements) {
5294 return 1;
5295 }
5296
5298 default:
5299 return 0;
5300 }
5301}
5302/* }}} */
5303
5304static zend_result get_default_via_ast(zval *default_value_zval, const char *default_value) {
5305 zend_ast *ast;
5306 zend_arena *ast_arena;
5307
5309 "<?php ", sizeof("<?php ") - 1, default_value, strlen(default_value), ";", 1);
5310
5311 ast = zend_compile_string_to_ast(code, &ast_arena, ZSTR_EMPTY_ALLOC());
5312 zend_string_release(code);
5313
5314 if (!ast) {
5315 return FAILURE;
5316 }
5317
5318 zend_ast_list *statement_list = zend_ast_get_list(ast);
5319 zend_ast **const_expr_ast_ptr = &statement_list->child[0];
5320
5321 zend_arena *original_ast_arena = CG(ast_arena);
5322 uint32_t original_compiler_options = CG(compiler_options);
5323 zend_file_context original_file_context;
5324 CG(ast_arena) = ast_arena;
5325 /* Disable constant substitution, to make getDefaultValueConstant() work. */
5327 zend_file_context_begin(&original_file_context);
5328 zend_const_expr_to_zval(default_value_zval, const_expr_ast_ptr, /* allow_dynamic */ true);
5329 CG(ast_arena) = original_ast_arena;
5330 CG(compiler_options) = original_compiler_options;
5331 zend_file_context_end(&original_file_context);
5332
5333 zend_ast_destroy(ast);
5334 zend_arena_destroy(ast_arena);
5335
5336 return SUCCESS;
5337}
5338
5339static zend_string *try_parse_string(const char *str, size_t len, char quote) {
5340 if (len == 0) {
5341 return ZSTR_EMPTY_ALLOC();
5342 }
5343
5344 for (size_t i = 0; i < len; i++) {
5345 if (str[i] == '\\' || str[i] == quote) {
5346 return NULL;
5347 }
5348 }
5349 return zend_string_init(str, len, 0);
5350}
5351
5353 zval *default_value_zval, zend_internal_arg_info *arg_info)
5354{
5355 const char *default_value = arg_info->default_value;
5356 if (!default_value) {
5357 return FAILURE;
5358 }
5359
5360 /* Avoid going through the full AST machinery for some simple and common cases. */
5361 size_t default_value_len = strlen(default_value);
5362 zend_ulong lval;
5363 if (default_value_len == sizeof("null")-1
5364 && !memcmp(default_value, "null", sizeof("null")-1)) {
5365 ZVAL_NULL(default_value_zval);
5366 return SUCCESS;
5367 } else if (default_value_len == sizeof("true")-1
5368 && !memcmp(default_value, "true", sizeof("true")-1)) {
5369 ZVAL_TRUE(default_value_zval);
5370 return SUCCESS;
5371 } else if (default_value_len == sizeof("false")-1
5372 && !memcmp(default_value, "false", sizeof("false")-1)) {
5373 ZVAL_FALSE(default_value_zval);
5374 return SUCCESS;
5375 } else if (default_value_len >= 2
5376 && (default_value[0] == '\'' || default_value[0] == '"')
5377 && default_value[default_value_len - 1] == default_value[0]) {
5378 zend_string *str = try_parse_string(
5379 default_value + 1, default_value_len - 2, default_value[0]);
5380 if (str) {
5381 ZVAL_STR(default_value_zval, str);
5382 return SUCCESS;
5383 }
5384 } else if (default_value_len == sizeof("[]")-1
5385 && !memcmp(default_value, "[]", sizeof("[]")-1)) {
5386 ZVAL_EMPTY_ARRAY(default_value_zval);
5387 return SUCCESS;
5388 } else if (ZEND_HANDLE_NUMERIC_STR(default_value, default_value_len, lval)) {
5389 ZVAL_LONG(default_value_zval, lval);
5390 return SUCCESS;
5391 }
5392
5393#if 0
5394 fprintf(stderr, "Evaluating %s via AST\n", default_value);
5395#endif
5396 return get_default_via_ast(default_value_zval, default_value);
5397}
size_t len
Definition apprentice.c:174
bool exception
Definition assert.c:30
fprintf($stream, string $format, mixed ... $values)
getenv(?string $name=null, bool $local_only=false)
is_null(mixed $value)
constant(string $name)
count(Countable|array $value, int $mode=COUNT_NORMAL)
strchr(string $haystack, string $needle, bool $before_needle=false)
char s[4]
Definition cdf.c:77
DNS_STATUS status
Definition dns_win32.c:49
error($message)
Definition ext_skel.php:22
zend_ffi_type * type
Definition ffi.c:3812
zval * zv
Definition ffi.c:3975
zend_long n
Definition ffi.c:4979
zend_string * res
Definition ffi.c:4692
void * ptr
Definition ffi.c:3814
memcpy(ptr1, ptr2, size)
zval * arg
Definition ffi.c:3975
memset(ptr, 0, type->size)
zval * val
Definition ffi.c:4262
HashTable * ht
Definition ffi.c:4838
buf start
Definition ffi.c:4687
ffi persistent
Definition ffi.c:3633
#define NULL
Definition gdcache.h:45
#define SUCCESS
Definition hash_sha3.c:261
again j
char * arena
Definition php_bcmath.h:37
#define lookup
Definition php_compat.h:98
unsigned const char * end
Definition php_ffi.h:51
php_json_error_code error_code
Definition php_json.h:92
#define UINT32_MAX
php_output_handler * active
Definition php_output.h:140
reflection_object_handlers write_property
unsigned char key[REFLECTION_KEY_LEN]
char * msg
Definition phpdbg.h:289
phpdbg_frame_t frame
Definition phpdbg.h:236
HashTable functions
const char * func_name
zend_string * lcname
zval * current
Definition session.c:1024
zval rv
Definition session.c:1024
p
Definition session.c:1105
spl_handler_SplDoublyLinkedList count_elements
zval val
Definition zend_types.h:381
zend_string * name
zend_ast * child[1]
Definition zend_ast.h:199
zend_class_entry * ce
zend_string * doc_comment
HashTable constants_table
Definition zend.h:165
zend_function * __debugInfo
Definition zend.h:182
zend_object *(* create_object)(zend_class_entry *class_type)
Definition zend.h:195
zend_function * __set
Definition zend.h:176
zend_function * __tostring
Definition zend.h:181
struct _zend_module_entry * module
Definition zend.h:234
zval * default_static_members_table
Definition zend.h:161
struct _zend_class_entry::@126215362204241324314155352336150042254204116267::@166057154351252324007362117353350250255142166322 user
HashTable properties_info
Definition zend.h:164
zend_function * __isset
Definition zend.h:178
zend_string * filename
Definition zend.h:228
zend_function * __unserialize
Definition zend.h:184
zend_string * name
Definition zend.h:149
union _zend_class_entry::@126215362204241324314155352336150042254204116267 info
zend_function * __call
Definition zend.h:179
struct _zend_class_entry::@126215362204241324314155352336150042254204116267::@031207115026352130035014265255253014334154061307 internal
const struct _zend_function_entry * builtin_functions
Definition zend.h:233
zend_function * __unset
Definition zend.h:177
uint32_t ce_flags
Definition zend.h:156
int default_properties_count
Definition zend.h:158
zend_function * __serialize
Definition zend.h:183
char type
Definition zend.h:148
uint32_t line_start
Definition zend.h:229
zend_class_entry ** interfaces
Definition zend.h:212
zend_function *(* get_static_method)(zend_class_entry *ce, zend_string *method)
Definition zend.h:199
zend_function * __get
Definition zend.h:175
int default_static_members_count
Definition zend.h:159
zend_function * constructor
Definition zend.h:172
uint32_t enum_backing_type
Definition zend.h:221
struct _zend_property_info ** properties_info_table
Definition zend.h:170
zend_class_entry * parent
Definition zend.h:152
zval * default_properties_table
Definition zend.h:160
HashTable function_table
Definition zend.h:163
zend_function * __callstatic
Definition zend.h:180
zend_function * clone
Definition zend.h:174
zend_function * destructor
Definition zend.h:173
zval * default_properties_table
Definition zend.h:116
HashTable * constants_table
Definition zend.h:117
zend_object * closure
Definition zend_API.h:64
zend_class_entry * calling_scope
Definition zend_API.h:61
zend_function * function_handler
Definition zend_API.h:60
zend_class_entry * called_scope
Definition zend_API.h:62
zend_object * object
Definition zend_API.h:63
HashTable * named_params
Definition zend_API.h:56
uint32_t param_count
Definition zend_API.h:51
zend_object * object
Definition zend_API.h:50
const zend_property_info * prop_info
zend_class_entry * scope
zend_string * function_name
zend_function * prototype
struct _zend_module_entry * module
const zend_frameless_function_info * frameless_function_infos
void * reserved[ZEND_MAX_RESERVED_RESOURCES]
zend_internal_arg_info * arg_info
zend_string * doc_comment
unsigned char type
const char * name
unsigned char type
const struct _zend_module_dep * deps
const char * name
int module_started
int module_number
zend_object_get_method_t get_method
zend_object_get_constructor_t get_constructor
zend_class_entry * ce
Definition zend_types.h:560
zval properties_table[1]
Definition zend_types.h:563
const zend_object_handlers * handlers
Definition zend_types.h:561
uint32_t fn_flags
const zend_property_info * prototype
zend_string * doc_comment
zend_function ** hooks
zend_string * name
HashTable * attributes
zend_class_entry * ce
zend_error_handling_t handling
Definition zend.h:437
zend_class_entry * exception
Definition zend.h:438
zend_type types[1]
Definition zend_types.h:142
uint32_t num_types
Definition zend_types.h:141
uint32_t type_mask
Definition zend_types.h:136
zend_arg_info * arg_info
zend_class_entry * scope
zend_op_array op_array
zend_string * function_name
struct _zend_function::@236135173067030250234125302313220025134003177336 common
uint32_t fn_flags
zend_internal_function internal_function
uint32_t num_args
ZEND_API void zend_alloc_ce_cache(zend_string *type_name)
Definition zend.c:2070
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_argument_count_error(const char *format,...)
Definition zend.c:1836
ZEND_API ZEND_COLD void zend_throw_error(zend_class_entry *exception_ce, const char *format,...)
Definition zend.c:1772
ZEND_API zend_class_entry * zend_standard_class_def
Definition zend.c:83
ZEND_API ZEND_COLD void zend_error(int type, const char *format,...)
Definition zend.c:1666
ZEND_API ZEND_COLD void zend_illegal_container_offset(const zend_string *container, const zval *offset, int type)
Definition zend.c:1802
ZEND_API size_t zend_spprintf(char **message, size_t max_len, const char *format,...)
Definition zend.c:311
ZEND_API size_t(* zend_printf)(const char *format,...)
Definition zend.c:84
ZEND_API size_t zend_vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap)
Definition zend.c:283
struct _zend_class_mutable_data zend_class_mutable_data
zend_error_handling_t
Definition zend.h:431
@ EH_THROW
Definition zend.h:433
#define zend_try
Definition zend.h:270
#define zend_end_try()
Definition zend.h:280
ZEND_API ZEND_COLD void zend_class_redeclaration_error_ex(int type, zend_string *new_name, zend_class_entry *old_ce)
Definition zend_API.c:448
ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(const zval *arg, zend_long *dest, uint32_t arg_num)
Definition zend_API.c:557
ZEND_API zend_result zend_update_class_constants(zend_class_entry *class_type)
Definition zend_API.c:1518
ZEND_API zend_result add_next_index_null(zval *arg)
Definition zend_API.c:2141
ZEND_API void add_property_zval_ex(zval *arg, const char *key, size_t key_len, zval *value)
Definition zend_API.c:2378
ZEND_API zval * zend_read_property_ex(zend_class_entry *scope, zend_object *object, zend_string *name, bool silent, zval *rv)
Definition zend_API.c:5187
ZEND_API zend_result add_next_index_bool(zval *arg, bool b)
Definition zend_API.c:2150
ZEND_API void add_property_array_ex(zval *arg, const char *key, size_t key_len, zend_array *arr)
Definition zend_API.c:2348
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 bool zend_is_countable(const zval *countable)
Definition zend_API.c:5287
ZEND_API zend_result array_set_zval_key(HashTable *ht, zval *key, zval *value)
Definition zend_API.c:2231
ZEND_API void add_property_object_ex(zval *arg, const char *key, size_t key_len, zend_object *obj)
Definition zend_API.c:2358
ZEND_API zend_result zend_try_assign_typed_ref_null(zend_reference *ref)
Definition zend_API.c:4683
ZEND_API void zend_check_magic_method_implementation(const zend_class_entry *ce, const zend_function *fptr, zend_string *lcname, int error_type)
Definition zend_API.c:2762
ZEND_API zend_class_entry * zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce)
Definition zend_API.c:3506
ZEND_API zend_result zend_copy_parameters_array(uint32_t param_count, zval *argument_array)
Definition zend_API.c:72
ZEND_API ZEND_COLD const char * zend_get_object_type_case(const zend_class_entry *ce, bool upper_case)
Definition zend_API.c:5260
ZEND_API zend_result object_and_properties_init(zval *arg, zend_class_entry *class_type, HashTable *properties)
Definition zend_API.c:1843
ZEND_API const char * zend_zval_value_name(const zval *arg)
Definition zend_API.c:148
ZEND_API void add_assoc_bool_ex(zval *arg, const char *key, size_t key_len, bool b)
Definition zend_API.c:1946
ZEND_API zend_module_entry * zend_register_module_ex(zend_module_entry *module, int module_type)
Definition zend_API.c:2587
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_or_null_error(uint32_t num, char *error)
Definition zend_API.c:374
ZEND_API zend_result zend_parse_parameter(int flags, uint32_t arg_num, zval *arg, const char *spec,...)
Definition zend_API.c:1123
ZEND_API zend_result zend_try_assign_typed_ref_double(zend_reference *ref, double dval)
Definition zend_API.c:4710
ZEND_API const char * zend_get_type_by_const(int type)
Definition zend_API.c:112
ZEND_API zend_module_entry * zend_register_internal_module(zend_module_entry *module)
Definition zend_API.c:2655
ZEND_API zend_result add_next_index_object(zval *arg, zend_object *obj)
Definition zend_API.c:2213
ZEND_API void zend_declare_property_double(zend_class_entry *ce, const char *name, size_t name_length, double value, int access_type)
Definition zend_API.c:4832
ZEND_API void object_properties_init_ex(zend_object *object, HashTable *properties)
Definition zend_API.c:1695
ZEND_API zend_result zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce, bool persistent)
Definition zend_API.c:3563
ZEND_API void zend_activate_modules(void)
Definition zend_API.c:3371
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_type_error(uint32_t num, zend_expected_type expected_type, zval *arg)
Definition zend_API.c:284
ZEND_API void zend_fcall_info_argv(zend_fcall_info *fci, uint32_t argc, va_list *argv)
Definition zend_API.c:4418
ZEND_API HashTable * zend_separate_class_constants_table(zend_class_entry *class_type)
Definition zend_API.c:1429
ZEND_API void zend_declare_property_bool(zend_class_entry *ce, const char *name, size_t name_length, zend_long value, int access_type)
Definition zend_API.c:4814
ZEND_API zend_result add_next_index_stringl(zval *arg, const char *str, size_t length)
Definition zend_API.c:2195
ZEND_API zval * zend_read_static_property_ex(zend_class_entry *scope, zend_string *name, bool silent)
Definition zend_API.c:5213
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_COLD void zend_wrong_param_count(void)
Definition zend_API.c:94
ZEND_API void zend_declare_class_constant_double(zend_class_entry *ce, const char *name, size_t name_length, double value)
Definition zend_API.c:4955
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_long_error(uint32_t num, const char *name, zval *arg)
Definition zend_API.c:325
ZEND_API zend_result add_next_index_double(zval *arg, double d)
Definition zend_API.c:2168
ZEND_API void add_index_array(zval *arg, zend_ulong index, zend_array *arr)
Definition zend_API.c:2105
void zend_unload_modules(void)
Definition zend_API.c:3415
ZEND_API HashTable module_registry
Definition zend_API.c:41
ZEND_API zend_result add_next_index_long(zval *arg, zend_long n)
Definition zend_API.c:2132
ZEND_API zend_result zend_get_default_from_internal_arg_info(zval *default_value_zval, zend_internal_arg_info *arg_info)
Definition zend_API.c:5352
ZEND_API const char * zend_zval_type_name(const zval *arg)
Definition zend_API.c:167
ZEND_API bool ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **pce, uint32_t num, bool check_null)
Definition zend_API.c:468
ZEND_API void zend_collect_module_handlers(void)
Definition zend_API.c:2489
ZEND_API zend_result object_init_ex(zval *arg, zend_class_entry *class_type)
Definition zend_API.c:1849
ZEND_API zend_result zend_disable_class(const char *class_name, size_t class_name_length)
Definition zend_API.c:3707
ZEND_API zend_result zend_get_module_started(const char *module_name)
Definition zend_API.c:3262
ZEND_API zend_result object_init_with_constructor(zval *arg, zend_class_entry *class_type, uint32_t param_count, zval *params, HashTable *named_params)
Definition zend_API.c:1855
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_string_or_null_error(uint32_t num, const char *name, zval *arg)
Definition zend_API.c:355
ZEND_API zend_result zend_fcall_info_init(zval *callable, uint32_t check_flags, zend_fcall_info *fci, zend_fcall_info_cache *fcc, zend_string **callable_name, char **error)
Definition zend_API.c:4310
ZEND_API zval * zend_read_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, bool silent, zval *rv)
Definition zend_API.c:5201
ZEND_API void add_index_stringl(zval *arg, zend_ulong index, const char *str, size_t length)
Definition zend_API.c:2096
ZEND_API void add_assoc_double_ex(zval *arg, const char *key, size_t key_len, double d)
Definition zend_API.c:1964
ZEND_API ZEND_COLD void zend_wrong_property_read(zval *object, zval *property)
Definition zend_API.c:103
ZEND_API void zend_declare_class_constant_null(zend_class_entry *ce, const char *name, size_t name_length)
Definition zend_API.c:4928
ZEND_API void add_property_str_ex(zval *arg, const char *key, size_t key_len, zend_string *str)
Definition zend_API.c:2318
ZEND_API zend_result zend_try_assign_typed_ref_long(zend_reference *ref, zend_long lval)
Definition zend_API.c:4701
ZEND_API void add_assoc_array_ex(zval *arg, const char *key, size_t key_len, zend_array *arr)
Definition zend_API.c:2000
ZEND_API void zend_declare_property_null(zend_class_entry *ce, const char *name, size_t name_length, int access_type)
Definition zend_API.c:4805
ZEND_API zend_result zend_fcall_info_args_ex(zend_fcall_info *fci, zend_function *func, zval *args)
Definition zend_API.c:4364
ZEND_API bool zend_is_callable_at_frame(zval *callable, zend_object *object, zend_execute_data *frame, uint32_t check_flags, zend_fcall_info_cache *fcc, char **error)
Definition zend_API.c:4160
ZEND_API void zend_update_property_double(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, double value)
Definition zend_API.c:5048
ZEND_API void add_assoc_reference_ex(zval *arg, const char *key, size_t key_len, zend_reference *ref)
Definition zend_API.c:2018
ZEND_API void zend_get_callable_zval_from_fcc(const zend_fcall_info_cache *fcc, zval *callable)
Definition zend_API.c:4468
ZEND_API void zend_declare_property_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_len, int access_type)
Definition zend_API.c:4850
ZEND_API zend_result zend_update_static_property_bool(zend_class_entry *scope, const char *name, size_t name_length, zend_long value)
Definition zend_API.c:5140
ZEND_API zend_class_entry * zend_register_internal_interface(zend_class_entry *orig_class_entry)
Definition zend_API.c:3557
ZEND_API ZEND_COLD void zend_argument_error(zend_class_entry *error_ce, uint32_t arg_num, const char *format,...)
Definition zend_API.c:413
ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_slow(const zval *arg, zend_long *dest, uint32_t arg_num)
Definition zend_API.c:627
ZEND_API zend_result zend_update_static_property_stringl(zend_class_entry *scope, const char *name, size_t name_length, const char *value, size_t value_len)
Definition zend_API.c:5177
ZEND_API void zend_unset_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length)
Definition zend_API.c:5015
ZEND_API void zend_update_property_string(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, const char *value)
Definition zend_API.c:5066
ZEND_API void add_index_str(zval *arg, zend_ulong index, zend_string *str)
Definition zend_API.c:2078
ZEND_API bool ZEND_FASTCALL zend_flf_parse_arg_bool_slow(const zval *arg, bool *dest, uint32_t arg_num)
Definition zend_API.c:549
ZEND_API void add_index_string(zval *arg, zend_ulong index, const char *str)
Definition zend_API.c:2087
ZEND_API void add_property_resource_ex(zval *arg, const char *key, size_t key_len, zend_resource *r)
Definition zend_API.c:2299
ZEND_API void zend_update_property_bool(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, zend_long value)
Definition zend_API.c:5030
ZEND_API void zend_startup_modules(void)
Definition zend_API.c:2570
ZEND_API zend_result zend_try_assign_typed_ref_ex(zend_reference *ref, zval *val, bool strict)
Definition zend_API.c:4664
ZEND_API void add_property_bool_ex(zval *arg, const char *key, size_t key_len, zend_long b)
Definition zend_API.c:2281
ZEND_API void zend_declare_property_ex(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment)
Definition zend_API.c:4791
ZEND_API void add_index_object(zval *arg, zend_ulong index, zend_object *obj)
Definition zend_API.c:2114
ZEND_API zend_result add_next_index_reference(zval *arg, zend_reference *ref)
Definition zend_API.c:2222
ZEND_API zend_class_entry * zend_register_internal_class(zend_class_entry *orig_class_entry)
Definition zend_API.c:3551
ZEND_API zend_result zend_set_hash_symbol(zval *symbol, const char *name, size_t name_length, bool is_ref, int num_symbol_tables,...)
Definition zend_API.c:3605
ZEND_API void add_index_resource(zval *arg, zend_ulong index, zend_resource *r)
Definition zend_API.c:2060
ZEND_API void add_assoc_string_ex(zval *arg, const char *key, size_t key_len, const char *str)
Definition zend_API.c:1982
ZEND_API zend_result zend_startup_module_ex(zend_module_entry *module)
Definition zend_API.c:2388
void module_registry_unload(const zend_module_entry *module)
Definition zend_API.c:3360
ZEND_API void add_index_double(zval *arg, zend_ulong index, double d)
Definition zend_API.c:2069
ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, const char *value, size_t value_len)
Definition zend_API.c:5076
ZEND_API void zend_declare_class_constant_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value)
Definition zend_API.c:4973
ZEND_API void add_property_long_ex(zval *arg, const char *key, size_t key_len, zend_long n)
Definition zend_API.c:2272
ZEND_API bool zend_make_callable(zval *callable, zend_string **callable_name)
Definition zend_API.c:4292
ZEND_API zend_result zend_update_static_property_null(zend_class_entry *scope, const char *name, size_t name_length)
Definition zend_API.c:5131
ZEND_API void zend_fcall_info_args_clear(zend_fcall_info *fci, bool free_mem)
Definition zend_API.c:4328
ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec,...)
Definition zend_API.c:1300
ZEND_API void add_assoc_zval_ex(zval *arg, const char *key, size_t key_len, zval *value)
Definition zend_API.c:2027
ZEND_API void add_index_bool(zval *arg, zend_ulong index, bool b)
Definition zend_API.c:2051
ZEND_API zend_string * zend_get_callable_name_ex(zval *callable, zend_object *object)
Definition zend_API.c:4106
ZEND_API void zend_fcall_info_args_restore(zend_fcall_info *fci, uint32_t param_count, zval *params)
Definition zend_API.c:4356
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_error(uint32_t num, const char *name, zval *arg)
Definition zend_API.c:305
ZEND_API zend_class_constant * zend_declare_typed_class_constant(zend_class_entry *ce, zend_string *name, zval *value, int flags, zend_string *doc_comment, zend_type type)
Definition zend_API.c:4859
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_none_error(void)
Definition zend_API.c:214
ZEND_API void add_assoc_stringl_ex(zval *arg, const char *key, size_t key_len, const char *str, size_t length)
Definition zend_API.c:1991
ZEND_API void add_assoc_object_ex(zval *arg, const char *key, size_t key_len, zend_object *obj)
Definition zend_API.c:2009
ZEND_API void zend_unregister_functions(const zend_function_entry *functions, int count, HashTable *function_table)
Definition zend_API.c:3227
ZEND_API zend_result zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value)
Definition zend_API.c:5122
ZEND_API void add_property_string_ex(zval *arg, const char *key, size_t key_len, const char *str)
Definition zend_API.c:2328
ZEND_API void zend_fcall_info_argn(zend_fcall_info *fci, uint32_t argc,...)
Definition zend_API.c:4435
ZEND_API void zend_update_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, zval *value)
Definition zend_API.c:4991
ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_slow(const zval *arg, double *dest, uint32_t arg_num)
Definition zend_API.c:676
ZEND_API zend_result zend_try_assign_typed_ref_zval(zend_reference *ref, zval *zv)
Definition zend_API.c:4773
ZEND_API zend_result zend_try_assign_typed_ref_string(zend_reference *ref, const char *string)
Definition zend_API.c:4737
ZEND_API void zend_deactivate_modules(void)
Definition zend_API.c:3387
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_error(uint32_t min_num_args, uint32_t max_num_args)
Definition zend_API.c:225
ZEND_API void add_index_reference(zval *arg, zend_ulong index, zend_reference *ref)
Definition zend_API.c:2123
ZEND_API void zend_declare_property(zend_class_entry *ce, const char *name, size_t name_length, zval *property, int access_type)
Definition zend_API.c:4797
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_string_error(uint32_t num, const char *name, zval *arg)
Definition zend_API.c:345
ZEND_API zend_string * zend_get_callable_name(zval *callable)
Definition zend_API.c:4154
ZEND_API zend_result zend_try_assign_typed_ref_str(zend_reference *ref, zend_string *str)
Definition zend_API.c:4728
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_error_variadic(zend_class_entry *error_ce, uint32_t arg_num, const char *format, va_list va)
Definition zend_API.c:391
ZEND_API void object_properties_init(zend_object *object, zend_class_entry *class_type)
Definition zend_API.c:1688
ZEND_API ZEND_COLD void zend_argument_must_not_be_empty_error(uint32_t arg_num)
Definition zend_API.c:443
ZEND_API zend_class_entry * zend_register_internal_class_with_flags(zend_class_entry *class_entry, zend_class_entry *parent_ce, uint32_t ce_flags)
Definition zend_API.c:3512
ZEND_API void add_property_stringl_ex(zval *arg, const char *key, size_t key_len, const char *str, size_t length)
Definition zend_API.c:2338
ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_or_str_slow(zval *arg, zval **dest, uint32_t arg_num)
Definition zend_API.c:722
ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_weak(const zval *arg, bool *dest, uint32_t arg_num)
Definition zend_API.c:526
ZEND_API void zend_declare_property_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value, int access_type)
Definition zend_API.c:4841
ZEND_API bool zend_is_callable_ex(zval *callable, zend_object *object, uint32_t check_flags, zend_string **callable_name, zend_fcall_info_cache *fcc, char **error)
Definition zend_API.c:4271
ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_slow(const zval *arg, bool *dest, uint32_t arg_num)
Definition zend_API.c:540
ZEND_API void zend_update_property_long(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, zend_long value)
Definition zend_API.c:5039
ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_weak(const zval *arg, double *dest, uint32_t arg_num)
Definition zend_API.c:644
ZEND_API zend_result add_next_index_resource(zval *arg, zend_resource *r)
Definition zend_API.c:2159
ZEND_API void add_assoc_long_ex(zval *arg, const char *key, size_t key_len, zend_long n)
Definition zend_API.c:1928
ZEND_API void zend_declare_class_constant(zend_class_entry *ce, const char *name, size_t name_length, zval *value)
Definition zend_API.c:4914
ZEND_API const char * zend_get_module_version(const char *module_name)
Definition zend_API.c:4486
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_error(int error_code, uint32_t num, char *name, zend_expected_type expected_type, zval *arg)
Definition zend_API.c:243
ZEND_API zend_result zend_try_assign_typed_ref_bool(zend_reference *ref, bool val)
Definition zend_API.c:4692
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_unexpected_extra_named_error(void)
Definition zend_API.c:383
ZEND_API void add_assoc_resource_ex(zval *arg, const char *key, size_t key_len, zend_resource *r)
Definition zend_API.c:1955
ZEND_API zend_result zend_fcall_info_args(zend_fcall_info *fci, zval *args)
Definition zend_API.c:4397
ZEND_API zend_result zend_update_static_property_long(zend_class_entry *scope, const char *name, size_t name_length, zend_long value)
Definition zend_API.c:5149
ZEND_API zend_result zend_try_assign_typed_ref_arr(zend_reference *ref, zend_array *arr)
Definition zend_API.c:4755
ZEND_API ZEND_COLD void zend_class_redeclaration_error(int type, zend_class_entry *old_ce)
Definition zend_API.c:463
ZEND_API zend_result zend_parse_method_parameters(uint32_t num_args, zval *this_ptr, const char *type_spec,...)
Definition zend_API.c:1314
ZEND_API zend_result zend_try_assign_typed_ref_res(zend_reference *ref, zend_resource *res)
Definition zend_API.c:4764
ZEND_API void add_assoc_str_ex(zval *arg, const char *key, size_t key_len, zend_string *str)
Definition zend_API.c:1973
ZEND_API void zend_add_magic_method(zend_class_entry *ce, zend_function *fptr, zend_string *lcname)
Definition zend_API.c:2859
ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *format,...)
Definition zend_API.c:433
ZEND_API zval * zend_read_static_property(zend_class_entry *scope, const char *name, size_t name_length, bool silent)
Definition zend_API.c:5226
ZEND_API void zend_release_fcall_info_cache(zend_fcall_info_cache *fcc)
Definition zend_API.c:3845
ZEND_API void add_property_reference_ex(zval *arg, const char *key, size_t key_len, zend_reference *ref)
Definition zend_API.c:2368
ZEND_API zend_result zend_parse_method_parameters_ex(int flags, uint32_t num_args, zval *this_ptr, const char *type_spec,...)
Definition zend_API.c:1354
ZEND_API void add_property_double_ex(zval *arg, const char *key, size_t key_len, double d)
Definition zend_API.c:2309
ZEND_API int zend_next_free_module(void)
Definition zend_API.c:3464
ZEND_API zend_string * zend_zval_get_legacy_type(const zval *arg)
Definition zend_API.c:184
ZEND_API zend_result zend_startup_module(zend_module_entry *module)
Definition zend_API.c:3253
ZEND_API void zend_disable_functions(const char *function_list)
Definition zend_API.c:3641
ZEND_API zend_result zend_try_assign_typed_ref_empty_string(zend_reference *ref)
Definition zend_API.c:4719
ZEND_API zend_result add_next_index_array(zval *arg, zend_array *arr)
Definition zend_API.c:2204
ZEND_API void zend_fcall_info_argp(zend_fcall_info *fci, uint32_t argc, zval *argv)
Definition zend_API.c:4403
void module_destructor(zend_module_entry *module)
Definition zend_API.c:3303
ZEND_API zend_result zend_try_assign_typed_ref_stringl(zend_reference *ref, const char *string, size_t len)
Definition zend_API.c:4746
ZEND_API ZEND_COLD void zend_argument_type_error(uint32_t arg_num, const char *format,...)
Definition zend_API.c:423
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_null_error(uint32_t num, const char *name, zval *arg)
Definition zend_API.c:315
ZEND_API void zend_merge_properties(zval *obj, HashTable *properties)
Definition zend_API.c:1392
ZEND_API void zend_update_property_null(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length)
Definition zend_API.c:5006
ZEND_API void zend_update_property_ex(zend_class_entry *scope, zend_object *object, zend_string *name, zval *value)
Definition zend_API.c:4979
ZEND_API zend_result zend_try_assign_typed_ref_zval_ex(zend_reference *ref, zval *zv, bool strict)
Definition zend_API.c:4782
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_long_or_null_error(uint32_t num, const char *name, zval *arg)
Definition zend_API.c:335
ZEND_API zend_result zend_update_class_constant(zend_class_constant *c, const zend_string *name, zend_class_entry *scope)
Definition zend_API.c:1490
ZEND_API void zend_declare_class_constant_long(zend_class_entry *ce, const char *name, size_t name_length, zend_long value)
Definition zend_API.c:4937
ZEND_API void zend_declare_class_constant_bool(zend_class_entry *ce, const char *name, size_t name_length, bool value)
Definition zend_API.c:4946
ZEND_API zend_result add_next_index_string(zval *arg, const char *str)
Definition zend_API.c:2186
ZEND_API zend_result zend_update_static_property_double(zend_class_entry *scope, const char *name, size_t name_length, double value)
Definition zend_API.c:5158
ZEND_API void zend_update_property_str(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, zend_string *value)
Definition zend_API.c:5057
ZEND_API zend_result zend_get_parameters_array_ex(uint32_t param_count, zval *argument_array)
Definition zend_API.c:50
ZEND_API void add_index_null(zval *arg, zend_ulong index)
Definition zend_API.c:2042
ZEND_API zend_result zend_try_assign_typed_ref(zend_reference *ref, zval *val)
Definition zend_API.c:4677
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_slow(zval *arg, zend_string **dest, uint32_t arg_num)
Definition zend_API.c:776
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_or_long_slow(zval *arg, zend_string **dest_str, zend_long *dest_long, uint32_t arg_num)
Definition zend_API.c:793
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **dest, uint32_t arg_num)
Definition zend_API.c:751
ZEND_API zend_result zend_fcall_info_call(zend_fcall_info *fci, zend_fcall_info_cache *fcc, zval *retval_ptr, zval *args)
Definition zend_API.c:4445
ZEND_API void add_assoc_null_ex(zval *arg, const char *key, size_t key_len)
Definition zend_API.c:1937
ZEND_API zend_result zend_update_static_property_ex(zend_class_entry *scope, zend_string *name, zval *value)
Definition zend_API.c:5086
ZEND_API void zend_replace_error_handling(zend_error_handling_t error_handling, zend_class_entry *exception_class, zend_error_handling *current)
Definition zend_API.c:5242
ZEND_API void object_init(zval *arg)
Definition zend_API.c:1922
ZEND_API bool ZEND_FASTCALL zend_flf_parse_arg_str_slow(zval *arg, zend_string **dest, uint32_t arg_num)
Definition zend_API.c:785
ZEND_API void zend_class_implements(zend_class_entry *class_entry, int num_interfaces,...)
Definition zend_API.c:3527
ZEND_API void zend_declare_class_constant_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_length)
Definition zend_API.c:4964
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
ZEND_API void add_index_long(zval *arg, zend_ulong index, zend_long n)
Definition zend_API.c:2033
ZEND_API bool zend_is_iterable(const zval *iterable)
Definition zend_API.c:5274
ZEND_API void object_properties_load(zend_object *object, HashTable *properties)
Definition zend_API.c:1728
ZEND_API void add_property_null_ex(zval *arg, const char *key, size_t key_len)
Definition zend_API.c:2290
ZEND_API void zend_declare_property_long(zend_class_entry *ce, const char *name, size_t name_length, zend_long value, int access_type)
Definition zend_API.c:4823
ZEND_API void zend_destroy_modules(void)
Definition zend_API.c:2577
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(uint32_t num, char *error)
Definition zend_API.c:365
ZEND_API bool zend_is_callable(zval *callable, uint32_t check_flags, zend_string **callable_name)
Definition zend_API.c:4286
ZEND_API void zend_restore_error_handling(zend_error_handling *saved)
Definition zend_API.c:5253
ZEND_API bool ZEND_FASTCALL zend_flf_parse_arg_long_slow(const zval *arg, zend_long *dest, uint32_t arg_num)
Definition zend_API.c:636
ZEND_API zend_result add_next_index_str(zval *arg, zend_string *str)
Definition zend_API.c:2177
ZEND_API void zend_post_deactivate_modules(void)
Definition zend_API.c:3427
ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_slow(zval *arg, zval **dest, uint32_t arg_num)
Definition zend_API.c:688
ZEND_API void zend_save_error_handling(zend_error_handling *current)
Definition zend_API.c:5235
ZEND_API void zend_fcall_info_args_save(zend_fcall_info *fci, uint32_t *param_count, zval **params)
Definition zend_API.c:4347
ZEND_API zend_result zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value)
Definition zend_API.c:5167
ZEND_API zend_result zend_parse_parameters_ex(int flags, uint32_t num_args, const char *type_spec,...)
Definition zend_API.c:1287
#define CE_STATIC_MEMBERS(ce)
Definition zend_API.h:328
struct _zend_fcall_info_cache zend_fcall_info_cache
#define CE_DEFAULT_PROPERTIES_TABLE(ce)
Definition zend_API.h:334
#define ZEND_FE_END
Definition zend_API.h:124
#define Z_EXPECTED_TYPE_STR(id, str)
Definition zend_API.h:1547
#define ZEND_PARSE_PARAMS_QUIET
Definition zend_API.h:361
#define IS_CALLABLE_SUPPRESS_DEPRECATIONS
Definition zend_API.h:412
#define INIT_CLASS_ENTRY_INIT_METHODS(class_container, functions)
Definition zend_API.h:290
#define ZPP_ERROR_WRONG_CLASS_OR_NULL
Definition zend_API.h:1579
struct _zend_function_entry zend_function_entry
#define ZPP_ERROR_WRONG_CLASS_OR_STRING_OR_NULL
Definition zend_API.h:1581
#define ZPP_ERROR_WRONG_CLASS_OR_LONG_OR_NULL
Definition zend_API.h:1583
#define ZVAL_STRING(z, s)
Definition zend_API.h:956
#define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null)
Definition zend_API.h:205
#define Z_EXPECTED_TYPES(_)
Definition zend_API.h:1508
enum _zend_expected_type zend_expected_type
#define ZPP_ERROR_WRONG_CLASS_OR_STRING
Definition zend_API.h:1580
struct _zend_fcall_info zend_fcall_info
#define ZEND_END_ARG_INFO()
Definition zend_API.h:219
#define CE_CONSTANTS_TABLE(ce)
Definition zend_API.h:331
#define ZPP_ERROR_WRONG_CLASS_OR_LONG
Definition zend_API.h:1582
#define ZPP_ERROR_WRONG_CLASS
Definition zend_API.h:1578
#define ZPP_ERROR_WRONG_CALLBACK
Definition zend_API.h:1577
ZEND_API void zend_call_known_function(zend_function *fn, zend_object *object, zend_class_entry *called_scope, zval *retval_ptr, uint32_t param_count, zval *params, HashTable *named_params)
#define ZVAL_STRINGL(z, s, l)
Definition zend_API.h:952
#define ZPP_ERROR_WRONG_ARG
Definition zend_API.h:1584
#define ZPP_ERROR_UNEXPECTED_EXTRA_NAMED
Definition zend_API.h:1586
#define IS_CALLABLE_CHECK_SYNTAX_ONLY
Definition zend_API.h:411
ZEND_API zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache)
#define ZPP_ERROR_FAILURE
Definition zend_API.h:1576
#define array_init(arg)
Definition zend_API.h:537
#define ZVAL_EMPTY_STRING(z)
Definition zend_API.h:961
#define ZPP_ERROR_WRONG_CALLBACK_OR_NULL
Definition zend_API.h:1587
#define perealloc(ptr, size, persistent)
Definition zend_alloc.h:201
#define efree(ptr)
Definition zend_alloc.h:155
#define estrdup(s)
Definition zend_alloc.h:164
#define pemalloc(size, persistent)
Definition zend_alloc.h:189
#define erealloc(ptr, size)
Definition zend_alloc.h:159
struct _zend_arena zend_arena
Definition zend_arena.h:26
ZEND_API void ZEND_FASTCALL zend_ast_destroy(zend_ast *ast)
Definition zend_ast.c:1163
struct _zend_ast_list zend_ast_list
struct _zval_struct zval
strlen(string $string)
exit(string|int $status=0)
strcmp(string $string1, string $string2)
uint32_t num_args
zend_string_release_ex(func->internal_function.function_name, 0)
execute_data func
zval * args
void zend_const_expr_to_zval(zval *result, zend_ast **ast_ptr, bool allow_dynamic)
void zend_assert_valid_class_name(const zend_string *name, const char *type)
ZEND_API void zend_initialize_class_data(zend_class_entry *ce, bool nullify_handlers)
void zend_file_context_begin(zend_file_context *prev_context)
ZEND_API void zend_set_function_arg_flags(zend_function *func)
ZEND_API zend_string * zend_type_to_string(zend_type type)
zend_string * zval_make_interned_string(zval *zv)
ZEND_API zend_string * zend_mangle_property_name(const char *src1, size_t src1_length, const char *src2, size_t src2_length, bool internal)
ZEND_API zend_string * zend_create_member_string(zend_string *class_name, zend_string *member_name)
ZEND_API zend_result zend_unmangle_property_name_ex(const zend_string *name, const char **class_name, const char **prop_name, size_t *prop_len)
void zend_file_context_end(zend_file_context *prev_context)
#define ZEND_SET_FUNC_NAME
#define BP_VAR_R
#define ZEND_CLONE_FUNC_NAME
#define ZEND_CALL_FUNC_NAME
#define ZEND_ACC_NO_DYNAMIC_PROPERTIES
#define ZEND_DESTRUCTOR_FUNC_NAME
#define QUICK_ARG_SHOULD_BE_SENT_BY_REF(zf, arg_num)
#define ZEND_ACC_ENUM
#define OBJ_PROP_TO_NUM(offset)
#define ZEND_USER_CODE(type)
#define ZEND_ACC_FINAL
#define ZEND_FLF_ARG_USES_STRICT_TYPES()
#define ZEND_ACC_UNINSTANTIABLE
ZEND_API zend_ast * zend_compile_string_to_ast(zend_string *code, struct _zend_arena **ast_arena, zend_string *filename)
#define ZEND_UNSET_FUNC_NAME
#define ZEND_ACC_HAS_TYPE_HINTS
#define ZEND_ACC_IMPLICIT_ABSTRACT_CLASS
#define BP_VAR_W
struct _zend_internal_function_info zend_internal_function_info
#define ZEND_ACC_CTOR
#define ZEND_INTERNAL_FUNCTION
#define ZEND_ACC_ABSTRACT
#define ZEND_GET_FUNC_NAME
#define ZEND_ACC_HAS_READONLY_PROPS
#define ZEND_CLASS_CONST_FLAGS(c)
#define ZEND_ACC_LINKED
#define ZEND_ACC_READONLY
#define ZEND_ACC_PROTECTED_SET
#define ZEND_ACC_CHANGED
#define ZEND_ARG_SEND_MODE(arg_info)
#define ZEND_ACC_PPP_SET_MASK
#define ZEND_ACC_EXPLICIT_ABSTRACT_CLASS
struct _zend_file_context zend_file_context
#define ZEND_ACC_INTERFACE
#define ZEND_ACC_PRIVATE_SET
#define ZEND_ACC_CALL_VIA_TRAMPOLINE
#define ZEND_TOSTRING_FUNC_NAME
#define ZEND_ACC_HAS_AST_CONSTANTS
#define ZEND_ISSET_FUNC_NAME
#define OBJ_PROP(obj, offset)
struct _zend_class_constant zend_class_constant
struct _zend_property_info zend_property_info
#define ZEND_CALL_HAS_EXTRA_NAMED_PARAMS
#define ZEND_ACC_HAS_AST_PROPERTIES
#define ZEND_ACC_TRAIT
#define ZEND_ACC_RESOLVED_PARENT
#define ZEND_ACC_USE_GUARDS
#define ZEND_ACC_PRIVATE
#define ZEND_ACC_CONSTANTS_UPDATED
struct _zend_internal_arg_info zend_internal_arg_info
#define ZEND_ACC_HAS_AST_STATICS
#define ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES
#define ZEND_CALL_NUM_ARGS(call)
#define ZEND_ACC_PPP_MASK
#define ZEND_ACC_STATIC
#define ZEND_ARG_IS_VARIADIC(arg_info)
#define ZEND_CALL_INFO(call)
#define ZEND_CALLSTATIC_FUNC_NAME
#define ZEND_ACC_PUBLIC
#define ZEND_ACC_HAS_RETURN_TYPE
struct _zend_arg_info zend_arg_info
#define ZEND_ACC_PUBLIC_SET
ZEND_API void zend_type_release(zend_type type, bool persistent)
#define ZEND_ACC_RESOLVED_INTERFACES
#define ZEND_ACC_VIRTUAL
#define ZEND_ACC_VARIADIC
#define ZEND_USER_CLASS
#define ARG_SHOULD_BE_SENT_BY_REF(zf, arg_num)
void zend_free_internal_arg_info(zend_internal_function *function)
#define IS_TMP_VAR
#define ZEND_DEBUGINFO_FUNC_NAME
#define OBJ_PROP_TO_OFFSET(num)
#define ZEND_COMPILE_NO_PERSISTENT_CONSTANT_SUBSTITUTION
#define ZEND_INTERNAL_CLASS
#define ZEND_CONSTRUCTOR_FUNC_NAME
struct _zend_internal_function zend_internal_function
#define ZEND_ACC_DEPRECATED
#define ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION
#define ZEND_ACC_RETURN_REFERENCE
char * zend_visibility_string(uint32_t fn_flags)
#define ZEND_ACC_PROTECTED
#define BP_VAR_IS
#define ZEND_ARG_USES_STRICT_TYPES()
#define ZEND_CALL_ARG(call, n)
#define strcasecmp(s1, s2)
#define ZEND_API
void clean_module_constants(int module_number)
zend_result zend_enum_build_backed_enum_table(zend_class_entry *ce)
Definition zend_enum.c:196
#define E_COMPILE_ERROR
Definition zend_errors.h:29
#define E_WARNING
Definition zend_errors.h:24
#define E_CORE_ERROR
Definition zend_errors.h:27
#define E_CORE_WARNING
Definition zend_errors.h:28
#define E_DEPRECATED
Definition zend_errors.h:37
ZEND_API zend_class_entry * zend_ce_value_error
ZEND_API zend_class_entry * zend_ce_type_error
ZEND_API zend_function *ZEND_FASTCALL zend_fetch_function(zend_string *name)
ZEND_API bool zend_never_inline zend_verify_property_type(const zend_property_info *info, zval *property, bool strict)
ZEND_API bool zend_never_inline zend_verify_class_constant_type(zend_class_constant *c, const zend_string *name, zval *constant)
ZEND_API bool ZEND_FASTCALL zend_verify_ref_assignable_zval(zend_reference *ref, zval *zv, bool strict)
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_use_resource_as_offset(const zval *dim)
ZEND_API zend_class_entry * zend_get_called_scope(zend_execute_data *ex)
ZEND_API zend_class_entry * zend_lookup_class(zend_string *name)
ZEND_API const char * get_active_function_name(void)
ZEND_API zend_object * zend_get_this_object(zend_execute_data *ex)
ZEND_API const char * get_active_function_arg_name(uint32_t arg_num)
ZEND_API const char * get_active_class_name(const char **space)
ZEND_API zend_result ZEND_FASTCALL zval_update_constant_ex(zval *pp, zend_class_entry *scope)
ZEND_API zend_string * get_active_function_or_method_name(void)
ZEND_API zend_extension * zend_get_extension(const char *extension_name)
ZEND_API size_t zend_internal_run_time_cache_reserved_size(void)
size_t zend_flf_count
zend_function ** zend_flf_functions
ZEND_API void ** zend_flf_handlers
size_t zend_flf_capacity
union _zend_function zend_function
#define CG(v)
#define EG(v)
ZEND_API void ZEND_FASTCALL zend_hash_apply(HashTable *ht, apply_func_t apply_func)
Definition zend_hash.c:2059
ZEND_API void ZEND_FASTCALL zend_hash_rehash(HashTable *ht)
Definition zend_hash.c:1328
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_next_index_insert(HashTable *ht, zval *pData)
Definition zend_hash.c:1224
ZEND_API void ZEND_FASTCALL zend_hash_apply_with_argument(HashTable *ht, apply_func_arg_t apply_func, void *argument)
Definition zend_hash.c:2099
ZEND_API void ZEND_FASTCALL zend_hash_clean(HashTable *ht)
Definition zend_hash.c:1869
ZEND_API void ZEND_FASTCALL zend_hash_del_bucket(HashTable *ht, Bucket *p)
Definition zend_hash.c:1526
ZEND_API void ZEND_FASTCALL zend_hash_graceful_reverse_destroy(HashTable *ht)
Definition zend_hash.c:2015
ZEND_API zval *ZEND_FASTCALL zend_hash_index_update(HashTable *ht, zend_ulong h, zval *pData)
Definition zend_hash.c:1219
ZEND_API void ZEND_FASTCALL zend_hash_extend(HashTable *ht, uint32_t nSize, bool packed)
Definition zend_hash.c:396
ZEND_API zval *ZEND_FASTCALL zend_hash_str_update(HashTable *ht, const char *str, size_t len, zval *pData)
Definition zend_hash.c:1031
ZEND_API zval *ZEND_FASTCALL zend_hash_update(HashTable *ht, zend_string *key, zval *pData)
Definition zend_hash.c:997
ZEND_API zend_result ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key)
Definition zend_hash.c:1534
ZEND_API zend_result ZEND_FASTCALL zend_hash_str_del(HashTable *ht, const char *str, size_t len)
Definition zend_hash.c:1661
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_add(HashTable *ht, zend_string *key, zval *pData)
Definition zend_hash.c:992
ZEND_API zval *ZEND_FASTCALL zend_hash_index_find(const HashTable *ht, zend_ulong h)
Definition zend_hash.c:2701
ZEND_API void ZEND_FASTCALL zend_hash_sort_ex(HashTable *ht, sort_func_t sort, bucket_compare_func_t compar, bool renumber)
Definition zend_hash.c:3068
#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_MAP_REVERSE_FOREACH_STR_KEY_VAL(ht, _key, _val)
Definition zend_hash.h:1384
#define ZEND_HASH_APPLY_REMOVE
Definition zend_hash.h:147
#define HT_IS_PACKED(ht)
Definition zend_hash.h:59
#define ZEND_HANDLE_NUMERIC_STR(key, length, idx)
Definition zend_hash.h:417
#define ZEND_HASH_APPLY_KEEP
Definition zend_hash.h:146
#define ZEND_HASH_FOREACH_KEY_VAL(ht, _h, _key, _val)
Definition zend_hash.h:1181
#define ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(ht, _key, _ptr)
Definition zend_hash.h:1433
#define ZEND_HASH_REVERSE_FOREACH_BUCKET(ht, _bucket)
Definition zend_hash.h:1099
#define ZEND_HASH_MAP_REVERSE_FOREACH_PTR(ht, _ptr)
Definition zend_hash.h:1334
#define ZEND_HASH_FOREACH_END()
Definition zend_hash.h:1086
#define ZEND_HASH_MAP_FOREACH_END_DEL()
Definition zend_hash.h:1276
#define ZVAL_EMPTY_ARRAY(z)
Definition zend_hash.h:87
#define ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(ht, _key, _val)
Definition zend_hash.h:1374
#define ZEND_HASH_FOREACH_VAL(ht, _val)
Definition zend_hash.h:1102
ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry *iface)
void zend_build_properties_info_table(zend_class_entry *ce)
ZEND_API void zend_unregister_ini_entries_ex(int module_number, int module_type)
Definition zend_ini.c:283
ZEND_API zend_class_entry * zend_ce_countable
ZEND_API zend_class_entry * zend_ce_traversable
ZEND_API zend_class_entry * zend_ce_stringable
void zend_clean_module_rsrc_dtors(int module_number)
Definition zend_list.c:259
const char * zend_rsrc_list_get_rsrc_type(zend_resource *res)
Definition zend_list.c:316
int32_t zend_long
Definition zend_long.h:42
uint32_t zend_ulong
Definition zend_long.h:43
#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(ptr)
#define ZEND_MAP_PTR_GET_IMM(ptr)
#define ZEND_MAP_PTR_NEW_STATIC(ptr)
#define ZEND_MAP_PTR_SET_IMM(ptr, val)
#define ZEND_MAP_PTR(ptr)
#define MODULE_DEP_OPTIONAL
#define MODULE_TEMPORARY
struct _zend_module_dep zend_module_dep
#define MODULE_DEP_REQUIRED
struct _zend_module_entry zend_module_entry
#define MODULE_DEP_CONFLICTS
#define MODULE_PERSISTENT
ZEND_API zval * zend_std_get_static_property_with_info(zend_class_entry *ce, zend_string *property_name, int type, zend_property_info **property_info_ptr)
ZEND_API zend_function * zend_get_call_trampoline_func(const zend_class_entry *ce, zend_string *method_name, bool is_static)
ZEND_API void zend_class_init_statics(zend_class_entry *class_type)
ZEND_API bool zend_check_protected(const zend_class_entry *ce, const zend_class_entry *scope)
ZEND_API zend_property_info * zend_get_property_info(const zend_class_entry *ce, zend_string *member, int silent)
ZEND_API zend_function * zend_std_get_static_method(zend_class_entry *ce, zend_string *function_name, const zval *key)
ZEND_API zval * zend_std_get_static_property(zend_class_entry *ce, zend_string *property_name, int type)
#define ZEND_WRONG_PROPERTY_INFO
#define zend_get_function_root_class(fbc)
zval *(* zend_object_write_property_t)(zend_object *object, zend_string *member, zval *value, void **cache_slot)
#define zend_free_trampoline(func)
ZEND_API zend_object *ZEND_FASTCALL zend_objects_new(zend_class_entry *ce)
#define OBJ_RELEASE(obj)
#define ZEND_OBSERVER_ENABLED
ZEND_API void ZEND_COLD zend_incompatible_double_to_long_error(double d)
ZEND_API void ZEND_COLD zend_incompatible_string_to_long_error(const zend_string *s)
ZEND_API char *ZEND_FASTCALL zend_str_tolower_copy(char *dest, const char *source, size_t length)
ZEND_API zend_string *ZEND_FASTCALL zend_string_tolower_ex(zend_string *str, bool persistent)
ZEND_API bool ZEND_FASTCALL zend_is_true(const zval *op)
ZEND_API uint8_t ZEND_FASTCALL is_numeric_str_function(const zend_string *str, zend_long *lval, double *dval)
ZEND_API zend_string *ZEND_FASTCALL zval_get_string_func(zval *op)
ZEND_API bool ZEND_FASTCALL zend_class_implements_interface(const zend_class_entry *class_ce, const zend_class_entry *interface_ce)
#define convert_to_string(op)
#define ZEND_DOUBLE_FITS_LONG(d)
#define ALLOCA_FLAG(name)
#define ZEND_IGNORE_VALUE(x)
#define ZEND_FALLTHROUGH
#define EXPECTED(condition)
#define zend_always_inline
#define ZEND_FASTCALL
#define ZEND_ASSERT(c)
#define ZEND_MAX_RESERVED_RESOURCES
#define zend_isnan(a)
#define ZEND_COLD
#define EMPTY_SWITCH_DEFAULT_CASE()
#define UNEXPECTED(condition)
struct _zend_array zend_array
struct _zend_class_entry zend_class_entry
struct _zend_object zend_object
ZEND_API zend_string * zend_string_concat2(const char *str1, size_t str1_len, const char *str2, size_t str2_len)
ZEND_API zend_string * zend_string_concat3(const char *str1, size_t str1_len, const char *str2, size_t str2_len, const char *str3, size_t str3_len)
ZEND_API zend_string_init_interned_func_t zend_string_init_interned
Definition zend_string.c:31
ZEND_API zend_new_interned_string_func_t zend_new_interned_string
Definition zend_string.c:30
#define ZSTR_ALLOCA_FREE(str, use_heap)
#define ZSTR_IS_INTERNED(s)
Definition zend_string.h:84
#define ZSTR_VAL(zstr)
Definition zend_string.h:68
#define ZSTR_KNOWN(idx)
#define zend_string_equals_literal(str, literal)
#define ZSTR_EMPTY_ALLOC()
#define zend_string_equals_ci(s1, s2)
#define ZSTR_LEN(zstr)
Definition zend_string.h:69
#define zend_string_equals_literal_ci(str, c)
#define ZSTR_ALLOCA_ALLOC(str, _len, use_heap)
#define dval(x)
#define MAY_BE_STRING
#define MAY_BE_BOOL
#define MAY_BE_NULL
#define MAY_BE_STATIC
#define MAY_BE_VOID
#define MAY_BE_NEVER
#define MAY_BE_ANY
#define MAY_BE_OBJECT
#define MAY_BE_ARRAY
#define ZEND_TYPE_IS_ITERABLE_FALLBACK(t)
Definition zend_types.h:183
#define Z_OBJ_HANDLER_P(zv_p, hf)
Definition zend_types.h:996
int(* compare_func_t)(const void *, const void *)
Definition zend_types.h:104
#define Z_TYPE_P(zval_p)
Definition zend_types.h:660
#define IS_TRUE
Definition zend_types.h:603
#define ZVAL_STR(z, s)
#define ZVAL_FALSE(z)
#define ZEND_TYPE_PURE_MASK(t)
Definition zend_types.h:257
#define Z_ISREF_P(zval_p)
Definition zend_types.h:954
#define Z_TRY_ADDREF_P(pz)
#define ZEND_TYPE_NAME(t)
Definition zend_types.h:198
#define ZVAL_UNDEF(z)
#define ZEND_TYPE_INIT_MASK(_type_mask)
Definition zend_types.h:283
#define Z_REFVAL_P(zval_p)
#define IS_FALSE
Definition zend_types.h:602
#define Z_STRVAL_P(zval_p)
Definition zend_types.h:975
#define IS_UNDEF
Definition zend_types.h:600
#define Z_ISUNDEF_P(zval_p)
Definition zend_types.h:957
#define Z_ARRVAL_P(zval_p)
Definition zend_types.h:987
#define ZVAL_TRUE(z)
#define ZVAL_NULL(z)
#define _ZEND_TYPE_LITERAL_NAME_BIT
Definition zend_types.h:150
#define ZVAL_DEREF(z)
#define ZVAL_LONG(z, l)
#define IS_STRING
Definition zend_types.h:606
#define Z_CE(zval)
#define ZEND_TYPE_HAS_LITERAL_NAME(t)
Definition zend_types.h:177
#define Z_REFCOUNTED_P(zval_p)
Definition zend_types.h:921
#define ZVAL_STR_COPY(z, s)
struct _zend_resource zend_resource
Definition zend_types.h:99
#define ZVAL_ALIAS_PTR(z, p)
#define ZVAL_COPY_VALUE_PROP(z, v)
#define ZVAL_INDIRECT(z, v)
struct _zend_array HashTable
Definition zend_types.h:386
#define IS_RESOURCE
Definition zend_types.h:609
#define Z_OBJ_P(zval_p)
Definition zend_types.h:990
#define IS_ARRAY
Definition zend_types.h:607
#define IS_VOID
Definition zend_types.h:617
#define Z_OBJ_HT_P(zval_p)
Definition zend_types.h:993
#define ZEND_TYPE_LIST_SIZE(num_types)
Definition zend_types.h:207
#define ZEND_TYPE_HAS_NAME(t)
Definition zend_types.h:174
#define IS_DOUBLE
Definition zend_types.h:605
#define Z_STR_P(zval_p)
Definition zend_types.h:972
#define Z_PTR_P(zval_p)
#define ZVAL_NEW_REF(z, r)
#define ZSTR_HAS_CE_CACHE(s)
Definition zend_types.h:841
#define GC_ADDREF(p)
Definition zend_types.h:709
#define ZEND_TYPE_FULL_MASK(t)
Definition zend_types.h:254
#define ZEND_TYPE_FOREACH(type, type_ptr)
Definition zend_types.h:223
#define Z_PTR(zval)
#define ZEND_TYPE_HAS_LIST(t)
Definition zend_types.h:180
#define Z_STRLEN_P(zval_p)
Definition zend_types.h:978
#define ZEND_TYPE_INIT_NONE(extra_flags)
Definition zend_types.h:280
#define IS_NULL
Definition zend_types.h:601
#define ZVAL_RES(z, r)
#define Z_OBJCE_P(zval_p)
#define ZVAL_OBJ(z, o)
@ FAILURE
Definition zend_types.h:61
#define Z_TRY_ADDREF(z)
#define IS_OBJECT
Definition zend_types.h:608
#define ZEND_TYPE_SET_LIST(t, list)
Definition zend_types.h:249
#define IS_LONG
Definition zend_types.h:604
#define ZVAL_ARR(z, a)
#define ZEND_TYPE_IS_SET(t)
Definition zend_types.h:166
#define ZSTR_GET_CE_CACHE(s)
Definition zend_types.h:842
#define _ZEND_TYPE_UNION_BIT
Definition zend_types.h:160
#define ZEND_TYPE_FOREACH_END()
Definition zend_types.h:236
#define IS_REFERENCE
Definition zend_types.h:610
#define Z_RES_HANDLE_P(zval_p)
#define IS_MIXED
Definition zend_types.h:619
#define ZVAL_NEW_STR(z, s)
#define ZVAL_MAKE_REF(zv)
#define ZVAL_COPY(z, v)
#define ZEND_TYPE_LITERAL_NAME(t)
Definition zend_types.h:201
#define _ZEND_TYPE_NAME_BIT
Definition zend_types.h:148
#define _IS_BOOL
Definition zend_types.h:629
struct _Bucket Bucket
void(* swap_func_t)(void *, void *)
Definition zend_types.h:105
#define SEPARATE_ZVAL_NOREF(zv)
#define ZEND_TYPE_INIT_CLASS_MASK(class_name, type_mask)
Definition zend_types.h:306
#define ZVAL_DOUBLE(z, d)
#define ZVAL_OBJ_COPY(z, o)
ZEND_RESULT_CODE zend_result
Definition zend_types.h:64
#define IS_PROP_UNINIT
#define IS_CONSTANT_AST
Definition zend_types.h:611
#define ZVAL_COPY_PROP(z, v)
#define ZVAL_REF(z, r)
#define _IS_NUMBER
Definition zend_types.h:630
#define Z_RES_P(zval_p)
#define ZEND_TYPE_SET_PTR(t, _ptr)
Definition zend_types.h:240
#define IS_ITERABLE
Definition zend_types.h:616
#define ZEND_TYPE_INIT_CLASS(class_name, allow_null, extra_flags)
Definition zend_types.h:303
#define Z_PROP_FLAG_P(z)
#define Z_TYPE(zval)
Definition zend_types.h:659
#define Z_SET_REFCOUNT(z, rc)
#define ZEND_TYPE_CONTAINS_CODE(t, code)
Definition zend_types.h:266
#define Z_DVAL_P(zval_p)
Definition zend_types.h:969
struct _zend_ast zend_ast
Definition zend_types.h:102
struct _zend_execute_data zend_execute_data
Definition zend_types.h:91
#define Z_LVAL_P(zval_p)
Definition zend_types.h:966
#define IS_CALLABLE
Definition zend_types.h:615
#define ZVAL_COPY_VALUE(z, v)
struct _zend_reference zend_reference
Definition zend_types.h:100
#define ZVAL_BOOL(z, b)
#define Z_TRY_DELREF_P(pz)
#define ZEND_TYPE_IS_COMPLEX(t)
Definition zend_types.h:171
ZEND_API void zval_ptr_dtor(zval *zval_ptr)
ZEND_API void zval_add_ref(zval *p)
zval retval
zend_property_info * prop_info
retval_ptr
uint32_t arg_num
zend_string * name
bool result
function(EX_VAR(opline->result.var))
object
zval * ret
value
property
new_op_array scope
zend_object * zobj