php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
test.c
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | https://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Author: |
14 +----------------------------------------------------------------------+
15*/
16
17#include "zend_modules.h"
18#ifdef HAVE_CONFIG_H
19# include "config.h"
20#endif
21
22#include "php.h"
23#include "php_ini.h"
24#include "ext/standard/info.h"
25#include "php_test.h"
26#include "observer.h"
27#include "fiber.h"
28#include "iterators.h"
29#include "object_handlers.h"
30#include "zend_attributes.h"
31#include "zend_enum.h"
32#include "zend_interfaces.h"
33#include "zend_weakrefs.h"
35#include "Zend/zend_alloc.h"
36#include "test_arginfo.h"
37#include "zend_call_stack.h"
38#include "zend_exceptions.h"
40
41// `php.h` sets `NDEBUG` when not `PHP_DEBUG` which will make `assert()` from
42// assert.h a no-op. In order to have `assert()` working on NDEBUG builds, we
43// undefine `NDEBUG` and re-include assert.h
44#undef NDEBUG
45#include "assert.h"
46
47#if defined(HAVE_LIBXML) && !defined(PHP_WIN32)
48# include <libxml/globals.h>
49# include <libxml/parser.h>
50#endif
51
53
54static zend_class_entry *zend_test_interface;
55static zend_class_entry *zend_test_class;
56static zend_class_entry *zend_test_child_class;
57static zend_class_entry *zend_test_gen_stub_flag_compatibility_test;
58static zend_class_entry *zend_attribute_test_class;
59static zend_class_entry *zend_test_trait;
60static zend_class_entry *zend_test_attribute;
61static zend_class_entry *zend_test_repeatable_attribute;
62static zend_class_entry *zend_test_parameter_attribute;
63static zend_class_entry *zend_test_property_attribute;
64static zend_class_entry *zend_test_attribute_with_arguments;
65static zend_class_entry *zend_test_class_with_method_with_parameter_attribute;
66static zend_class_entry *zend_test_child_class_with_method_with_parameter_attribute;
67static zend_class_entry *zend_test_class_with_property_attribute;
68static zend_class_entry *zend_test_forbid_dynamic_call;
69static zend_class_entry *zend_test_ns_foo_class;
70static zend_class_entry *zend_test_ns_unlikely_compile_error_class;
71static zend_class_entry *zend_test_ns_not_unlikely_compile_error_class;
72static zend_class_entry *zend_test_ns2_foo_class;
73static zend_class_entry *zend_test_ns2_ns_foo_class;
74static zend_class_entry *zend_test_unit_enum;
75static zend_class_entry *zend_test_string_enum;
76static zend_class_entry *zend_test_int_enum;
77static zend_class_entry *zend_test_magic_call;
78static zend_object_handlers zend_test_class_handlers;
79
80static int le_throwing_resource;
81
82static ZEND_FUNCTION(zend_test_func)
83{
84 RETVAL_STR_COPY(EX(func)->common.function_name);
85
86 /* Cleanup trampoline */
88 zend_string_release(EX(func)->common.function_name);
90 EX(func) = NULL;
91}
92
94{
96}
97
99{
101
102 RETURN_NULL();
103}
104
106{
107 /* dummy */
109}
110
111static void pass1(zend_script *script, void *context)
112{
113 php_printf("pass1\n");
114}
115
116static void pass2(zend_script *script, void *context)
117{
118 php_printf("pass2\n");
119}
120
122{
123 zval *arg1;
124
126}
127
129{
131}
132
133/* Create a string without terminating null byte. Must be terminated with
134 * zend_terminate_string() before destruction, otherwise a warning is issued
135 * in debug builds. */
137{
138 zend_string *str, *res;
139
140 if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &str) == FAILURE) {
142 }
143
144 res = zend_string_alloc(ZSTR_LEN(str), 0);
145 memcpy(ZSTR_VAL(res), ZSTR_VAL(str), ZSTR_LEN(str));
146 /* No trailing null byte */
147
149}
150
151/* Enforce terminate null byte on string. This avoids a warning in debug builds. */
153{
154 zend_string *str;
155
156 if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &str) == FAILURE) {
158 }
159
160 ZSTR_VAL(str)[ZSTR_LEN(str)] = '\0';
161}
162
163/* Cause an intentional memory leak, for testing/debugging purposes */
165{
166 zend_long leakbytes = 3;
167
168 if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &leakbytes) == FAILURE) {
170 }
171
172 emalloc(leakbytes);
173}
174
175/* Leak a refcounted variable */
177{
178 zval *zv;
179
182 }
183
184 if (!Z_REFCOUNTED_P(zv)) {
185 zend_error(E_WARNING, "Cannot leak variable that is not refcounted");
186 return;
187 }
188
189 Z_ADDREF_P(zv);
190}
191
192/* Tests Z_PARAM_OBJ_OR_STR */
194{
195 zend_string *str;
197
199 Z_PARAM_OBJ_OR_STR(object, str)
201
202 if (str) {
203 RETURN_STR_COPY(str);
204 } else {
205 RETURN_OBJ_COPY(object);
206 }
207}
208
209/* Tests Z_PARAM_OBJ_OR_STR_OR_NULL */
211{
212 zend_string *str;
214
216 Z_PARAM_OBJ_OR_STR_OR_NULL(object, str)
218
219 if (str) {
220 RETURN_STR_COPY(str);
221 } else if (object) {
222 RETURN_OBJ_COPY(object);
223 } else {
224 RETURN_NULL();
225 }
226}
227
228/* Tests Z_PARAM_OBJ_OF_CLASS_OR_STR */
230{
231 zend_string *str;
233
237
238 if (str) {
239 RETURN_STR_COPY(str);
240 } else {
241 RETURN_OBJ_COPY(object);
242 }
243}
244
246{
247 zend_string *source_string = NULL;
248 zend_string *filename = NULL;
250
252 Z_PARAM_STR(source_string)
253 Z_PARAM_STR(filename)
254 Z_PARAM_LONG(position)
256
257 zend_op_array *op_array = NULL;
258
259 op_array = compile_string(source_string, ZSTR_VAL(filename), position);
260
261 if (op_array) {
262 zval retval;
263
264 zend_try {
266 zend_execute(op_array, &retval);
267 } zend_catch {
268 destroy_op_array(op_array);
269 efree_size(op_array, sizeof(zend_op_array));
270 zend_bailout();
271 } zend_end_try();
272
273 destroy_op_array(op_array);
274 efree_size(op_array, sizeof(zend_op_array));
275 }
276
277 return;
278}
279
280/* Tests Z_PARAM_OBJ_OF_CLASS_OR_STR_OR_NULL */
282{
283 zend_string *str;
285
289
290 if (str) {
291 RETURN_STR_COPY(str);
292 } else if (object) {
293 RETURN_OBJ_COPY(object);
294 } else {
295 RETURN_NULL();
296 }
297}
298
299/* Tests Z_PARAM_NUMBER_OR_STR */
301{
302 zval *input;
303
307
308 switch (Z_TYPE_P(input)) {
309 case IS_LONG:
310 RETURN_LONG(Z_LVAL_P(input));
311 case IS_DOUBLE:
312 RETURN_DOUBLE(Z_DVAL_P(input));
313 case IS_STRING:
314 RETURN_STR_COPY(Z_STR_P(input));
316 }
317}
318
319/* Tests Z_PARAM_NUMBER_OR_STR_OR_NULL */
321{
322 zval *input;
323
327
328 if (!input) {
329 RETURN_NULL();
330 }
331
332 switch (Z_TYPE_P(input)) {
333 case IS_LONG:
334 RETURN_LONG(Z_LVAL_P(input));
335 case IS_DOUBLE:
336 RETURN_DOUBLE(Z_DVAL_P(input));
337 case IS_STRING:
338 RETURN_STR_COPY(Z_STR_P(input));
340 }
341}
342
344{
345 zval *value;
346 zend_object *obj;
347
349 Z_PARAM_OBJ(obj)
352
356 }
358}
359
361{
362 zend_object *obj;
363
365 Z_PARAM_OBJ(obj)
367
369}
370
372{
375}
376
378{
380
381 zend_string *function_name = get_function_or_method_name(EG(current_execute_data)->prev_execute_data->func);
382
383 RETURN_STR(function_name);
384}
385
386#if defined(HAVE_LIBXML) && !defined(PHP_WIN32)
388{
390
391 ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations")
392 xmlLoadExtDtdDefaultValue = 1;
393 xmlDoValidityCheckingDefaultValue = 1;
394 (void) xmlPedanticParserDefault(1);
395 (void) xmlSubstituteEntitiesDefault(1);
396 (void) xmlLineNumbersDefault(1);
397 (void) xmlKeepBlanksDefault(0);
399}
400#endif
401
402/* TESTS Z_PARAM_ITERABLE and Z_PARAM_ITERABLE_OR_NULL */
404{
405 zval *arg1, *arg2;
406
412}
413
414static ZEND_FUNCTION(zend_iterable_legacy)
415{
416 zval *arg1, *arg2;
417
423
425}
426
427ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_iterable_legacy, 0, 1, IS_ITERABLE, 0)
431
432static const zend_function_entry ext_function_legacy[] = {
433 ZEND_FE(zend_iterable_legacy, arginfo_zend_iterable_legacy)
435};
436
437/* Call a method on a class or object using zend_call_method() */
439{
440 zend_string *method_name;
441 zval *class_or_object, *arg1 = NULL, *arg2 = NULL;
442 zend_object *obj = NULL;
444 int argc = ZEND_NUM_ARGS();
445
447 Z_PARAM_ZVAL(class_or_object)
448 Z_PARAM_STR(method_name)
453
454 if (Z_TYPE_P(class_or_object) == IS_OBJECT) {
455 obj = Z_OBJ_P(class_or_object);
456 ce = obj->ce;
457 } else if (Z_TYPE_P(class_or_object) == IS_STRING) {
458 ce = zend_lookup_class(Z_STR_P(class_or_object));
459 if (!ce) {
460 zend_error_noreturn(E_ERROR, "Unknown class '%s'", Z_STRVAL_P(class_or_object));
461 return;
462 }
463 } else {
464 zend_argument_type_error(1, "must be of type object|string, %s given", zend_zval_value_name(class_or_object));
465 return;
466 }
467
468 ZEND_ASSERT((argc >= 2) && (argc <= 4));
469 zend_call_method(obj, ce, NULL, ZSTR_VAL(method_name), ZSTR_LEN(method_name), return_value, argc - 2, arg1, arg2);
470}
471
472/* Instantiate a class and run the constructor via object_init_with_constructor */
474{
476 zval *args;
477 uint32_t num_args;
479
481 Z_PARAM_CLASS(ce)
484
485 zval obj;
486 /* We don't use return_value directly to check for memory leaks of the API on failure */
488 if (status == FAILURE) {
490 }
493}
494
496{
498
499 RETURN_OBJ_COPY(zend_enum_get_case_cstr(zend_test_unit_enum, "Foo"));
500}
501
503{
504 zend_string *str;
505 zend_string *errstr;
506
508 Z_PARAM_STR(str)
510
512
513 if (errstr) {
514 zend_error(E_WARNING, "%s", ZSTR_VAL(errstr));
515 zend_string_release(errstr);
516 }
517}
518
520{
521 zend_string *str;
522 zend_string *errstr;
523
525 Z_PARAM_STR(str)
527
529
530 if (errstr) {
531 zend_error(E_WARNING, "%s", ZSTR_VAL(errstr));
532 zend_string_release(errstr);
533 }
534}
535
537{
539
541}
542
544{
545 zend_string *str;
546
548 Z_PARAM_STR(str)
550
552}
553
554static ZEND_FUNCTION(ZendTestNS2_namespaced_func)
555{
558}
559
560static ZEND_FUNCTION(ZendTestNS2_namespaced_deprecated_func)
561{
563}
564
565static ZEND_FUNCTION(ZendTestNS2_ZendSubNS_namespaced_func)
566{
569}
570
571static ZEND_FUNCTION(ZendTestNS2_ZendSubNS_namespaced_deprecated_func)
572{
574}
575
577{
578 zend_string *parameter;
579
581 Z_PARAM_STR(parameter)
583
584 RETURN_LONG(1);
585}
586
588{
590}
591
592#ifdef ZEND_CHECK_STACK_LIMIT
594{
595 zend_call_stack stack;
596
598
599 if (zend_call_stack_get(&stack)) {
600 zend_string *str;
601
603
604 str = strpprintf(0, "%p", stack.base);
605 add_assoc_str(return_value, "base", str);
606
607 str = strpprintf(0, "0x%zx", stack.max_size);
608 add_assoc_str(return_value, "max_size", str);
609
610 str = strpprintf(0, "%p", zend_call_stack_position());
611 add_assoc_str(return_value, "position", str);
612
613 str = strpprintf(0, "%p", EG(stack_limit));
614 add_assoc_str(return_value, "EG(stack_limit)", str);
615
616 return;
617 }
618
619 RETURN_NULL();
620}
621
622zend_long (*volatile zend_call_stack_use_all_fun)(void *limit);
623
624static zend_long zend_call_stack_use_all(void *limit)
625{
626 if (zend_call_stack_overflowed(limit)) {
627 return 1;
628 }
629
630 return 1 + zend_call_stack_use_all_fun(limit);
631}
632
634{
635 zend_call_stack stack;
636
638
639 if (!zend_call_stack_get(&stack)) {
640 return;
641 }
642
643 zend_call_stack_use_all_fun = zend_call_stack_use_all;
644
645 void *limit = zend_call_stack_limit(stack.base, stack.max_size, 4096);
646
647 RETURN_LONG(zend_call_stack_use_all(limit));
648}
649#endif /* ZEND_CHECK_STACK_LIMIT */
650
652{
654 RETURN_LONG(CG(map_ptr_last));
655}
656
658{
659 zend_string *message = NULL;
660
663 Z_PARAM_STR_OR_NULL(message)
665
666 if (message) {
667 php_printf("%s", ZSTR_VAL(message));
668 }
669
670 char *invalid = (char *) 1;
671 php_printf("%s", invalid);
672}
673
674static bool has_opline(zend_execute_data *execute_data)
675{
676 return execute_data
677 && execute_data->func
678 && ZEND_USER_CODE(execute_data->func->type)
679 && execute_data->opline
680 ;
681}
682
684{
685 if (has_opline(EG(current_execute_data))) {
686 assert(EG(current_execute_data)->opline->lineno != (uint32_t)-1);
687 }
689}
690
692{
693 if (has_opline(EG(current_execute_data))) {
694 assert(EG(current_execute_data)->opline->lineno != (uint32_t)-1);
695 }
697}
698
700{
701 if (has_opline(EG(current_execute_data))) {
702 assert(EG(current_execute_data)->opline->lineno != (uint32_t)-1);
703 }
705}
706
707static void zend_test_reset_heap(zend_zend_test_globals *zend_test_globals)
708{
709 if (zend_test_globals->zend_test_heap) {
710 free(zend_test_globals->zend_test_heap);
711 zend_test_globals->zend_test_heap = NULL;
712 zend_mm_set_heap(zend_test_globals->zend_orig_heap);
713 }
714}
715
716static PHP_INI_MH(OnUpdateZendTestObserveOplineInZendMM)
717{
718 if (new_value == NULL) {
719 return FAILURE;
720 }
721
722 int int_value = zend_ini_parse_bool(new_value);
723
724 if (int_value == 1) {
725 // `zend_mm_heap` is a private struct, so we have not way to find the
726 // actual size, but 4096 bytes should be enough
727 ZT_G(zend_test_heap) = malloc(4096);
728 memset(ZT_G(zend_test_heap), 0, 4096);
734 );
737 } else {
738 zend_test_reset_heap(ZEND_MODULE_GLOBALS_BULK(zend_test));
739 }
740 return OnUpdateBool(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
741}
742
744{
745 HashTable *parameter;
746
748 Z_PARAM_ARRAY_HT_EX(parameter, 0, 1)
750
751 if (!HT_IS_PACKED(parameter)) {
752 zend_argument_value_error(1, "must be a packed array");
754 }
755
756 zend_hash_extend(parameter, parameter->nNumUsed + 10, true);
757 ZEND_HASH_FILL_PACKED(parameter) {
758 for (int i = 0; i < 10; i++) {
759 zval value;
760 ZVAL_LONG(&value, i);
762 }
764}
765
767{
769 if (PG(open_basedir)) {
770 RETURN_STRING(PG(open_basedir));
771 } else {
772 RETURN_NULL();
773 }
774}
775
777{
779#ifdef HAVE_BUNDLED_PCRE
781#else
783#endif
784}
785
786#ifdef PHP_WIN32
788{
789 bool binary;
791 Z_PARAM_BOOL(binary)
793
794 _fmode = binary ? _O_BINARY : _O_TEXT;
795}
796#endif
797
799{
800 zval *stream_zv;
801 php_stream *stream;
802 FILE *fp;
803
805 Z_PARAM_RESOURCE(stream_zv);
807
808 php_stream_from_zval(stream, stream_zv);
809
810 if (php_stream_cast(stream, PHP_STREAM_AS_STDIO, (void *) &fp, REPORT_ERRORS) == FAILURE) {
811 return;
812 }
813
814 size_t size = 10240; /* Must be large enough to trigger the issue */
815 char *buf = malloc(size);
816 bool bail = false;
817 zend_try {
818 (void) !fread(buf, 1, size, fp);
819 } zend_catch {
820 bail = true;
821 } zend_end_try();
822
823 free(buf);
824
825 if (bail) {
826 zend_bailout();
827 }
828}
829
831{
833
837
839}
840
842{
843 zend_string *str;
844
846 Z_PARAM_STR(str);
848
850}
851
852static zend_object *zend_test_class_new(zend_class_entry *class_type)
853{
854 zend_object *obj = zend_objects_new(class_type);
855 object_properties_init(obj, class_type);
856 obj->handlers = &zend_test_class_handlers;
857 return obj;
858}
859
860static zend_function *zend_test_class_method_get(zend_object **object, zend_string *name, const zval *key)
861{
862 if (zend_string_equals_literal_ci(name, "test")) {
864
865 if (EXPECTED(EG(trampoline).common.function_name == NULL)) {
866 fptr = (zend_internal_function *) &EG(trampoline);
867 } else {
868 fptr = emalloc(sizeof(zend_internal_function));
869 }
870 memset(fptr, 0, sizeof(zend_internal_function));
872 fptr->num_args = 0;
873 fptr->scope = (*object)->ce;
875 fptr->function_name = zend_string_copy(name);
876 fptr->handler = ZEND_FN(zend_test_func);
877 fptr->doc_comment = NULL;
878
879 return (zend_function*)fptr;
880 }
881 return zend_std_get_method(object, name, key);
882}
883
884static zend_function *zend_test_class_static_method_get(zend_class_entry *ce, zend_string *name)
885{
886 if (zend_string_equals_literal_ci(name, "test")) {
888
889 if (EXPECTED(EG(trampoline).common.function_name == NULL)) {
890 fptr = (zend_internal_function *) &EG(trampoline);
891 } else {
892 fptr = emalloc(sizeof(zend_internal_function));
893 }
894 memset(fptr, 0, sizeof(zend_internal_function));
896 fptr->num_args = 0;
897 fptr->scope = ce;
899 fptr->function_name = zend_string_copy(name);
900 fptr->handler = ZEND_FN(zend_test_func);
901 fptr->doc_comment = NULL;
902
903 return (zend_function*)fptr;
904 }
906}
907
909{
910 if (target != ZEND_ATTRIBUTE_TARGET_CLASS) {
911 zend_error(E_COMPILE_ERROR, "Only classes can be marked with #[ZendTestAttribute]");
912 }
913}
914
915static ZEND_METHOD(_ZendTestClass, __toString)
916{
919}
920
921/* Internal function returns bool, we return int. */
923{
925 RETURN_LONG(42);
926}
927
928static ZEND_METHOD(_ZendTestClass, returnsStatic) {
931}
932
933static ZEND_METHOD(_ZendTestClass, returnsThrowable)
934{
936 zend_throw_error(NULL, "Dummy");
937}
938
939static ZEND_METHOD(_ZendTestClass, variadicTest) {
940 int argc, i;
941 zval *args = NULL;
942
944 Z_PARAM_VARIADIC('*', args, argc)
946
947 for (i = 0; i < argc; i++) {
948 zval *arg = args + i;
949
950 if (Z_TYPE_P(arg) == IS_STRING) {
951 continue;
952 }
953 if (Z_TYPE_P(arg) == IS_OBJECT && instanceof_function(Z_OBJ_P(arg)->ce, zend_ce_iterator)) {
954 continue;
955 }
956
957 zend_argument_type_error(i + 1, "must be of class Iterator or a string, %s given", zend_zval_type_name(arg));
959 }
960
962}
963
964static ZEND_METHOD(_ZendTestChildClass, returnsThrowable)
965{
967 zend_throw_error(NULL, "Dummy");
968}
969
971{
974}
975
977{
980}
981
982static ZEND_METHOD(ZendTestNS_Foo, method)
983{
985
986 RETURN_LONG(0);
987}
988
989static ZEND_METHOD(ZendTestNS_UnlikelyCompileError, method)
990{
992
993 RETURN_NULL();
994}
995
996static ZEND_METHOD(ZendTestNS_NotUnlikelyCompileError, method)
997{
999
1000 RETURN_NULL();
1001}
1002
1003static ZEND_METHOD(ZendTestNS2_Foo, method)
1004{
1006}
1007
1008static ZEND_METHOD(ZendTestNS2_ZendSubNS_Foo, method)
1009{
1011}
1012
1013static ZEND_METHOD(ZendTestParameterAttribute, __construct)
1014{
1015 zend_string *parameter;
1016
1018 Z_PARAM_STR(parameter)
1020
1022}
1023
1024static ZEND_METHOD(ZendTestPropertyAttribute, __construct)
1025{
1026 zend_string *parameter;
1027
1029 Z_PARAM_STR(parameter)
1031
1033}
1034
1036{
1037 zval *arg;
1038
1042
1043 zend_string *property_name = zend_string_init("arg", strlen("arg"), 0);
1044 zend_update_property_ex(zend_test_attribute_with_arguments, Z_OBJ_P(ZEND_THIS), property_name, arg);
1045 zend_string_release(property_name);
1046}
1047
1049{
1050 zend_string *parameter;
1051
1053 Z_PARAM_STR(parameter)
1055
1056 RETURN_LONG(2);
1057}
1058
1060{
1061 zend_string *parameter;
1062
1064 Z_PARAM_STR(parameter)
1066
1067 RETURN_LONG(3);
1068}
1069
1071{
1072 zend_string *parameter;
1073
1075 Z_PARAM_STR(parameter)
1077
1078 RETURN_LONG(4);
1079}
1080
1082{
1084
1085 zend_forbid_dynamic_call();
1086}
1087
1088static ZEND_METHOD(ZendTestForbidDynamicCall, callStatic)
1089{
1091
1092 zend_forbid_dynamic_call();
1093}
1094
1095static ZEND_METHOD(_ZendTestMagicCall, __call)
1096{
1098 zval *arguments;
1099
1102 Z_PARAM_ARRAY(arguments)
1104
1105 zval name_zv;
1106 ZVAL_STR(&name_zv, name);
1107
1108 zend_string_addref(name);
1109 Z_TRY_ADDREF_P(arguments);
1110 RETURN_ARR(zend_new_pair(&name_zv, arguments));
1111}
1112
1114{
1116 zval *arguments;
1117
1120 Z_PARAM_ARRAY(arguments)
1122
1123 ZEND_IGNORE_VALUE(arguments);
1124
1125 zval func, rv;
1126 ZVAL_STR(&func, name);
1128
1130 zval_ptr_dtor(&rv);
1131}
1132
1134 STD_PHP_INI_BOOLEAN("zend_test.replace_zend_execute_ex", "0", PHP_INI_SYSTEM, OnUpdateBool, replace_zend_execute_ex, zend_zend_test_globals, zend_test_globals)
1135 STD_PHP_INI_BOOLEAN("zend_test.register_passes", "0", PHP_INI_SYSTEM, OnUpdateBool, register_passes, zend_zend_test_globals, zend_test_globals)
1136 STD_PHP_INI_BOOLEAN("zend_test.print_stderr_mshutdown", "0", PHP_INI_SYSTEM, OnUpdateBool, print_stderr_mshutdown, zend_zend_test_globals, zend_test_globals)
1137#ifdef HAVE_COPY_FILE_RANGE
1138 STD_PHP_INI_ENTRY("zend_test.limit_copy_file_range", "-1", PHP_INI_ALL, OnUpdateLong, limit_copy_file_range, zend_zend_test_globals, zend_test_globals)
1139#endif
1140 STD_PHP_INI_ENTRY("zend_test.quantity_value", "0", PHP_INI_ALL, OnUpdateLong, quantity_value, zend_zend_test_globals, zend_test_globals)
1141 STD_PHP_INI_ENTRY("zend_test.str_test", "", PHP_INI_ALL, OnUpdateStr, str_test, zend_zend_test_globals, zend_test_globals)
1142 STD_PHP_INI_ENTRY("zend_test.not_empty_str_test", "val", PHP_INI_ALL, OnUpdateStrNotEmpty, not_empty_str_test, zend_zend_test_globals, zend_test_globals)
1143 STD_PHP_INI_BOOLEAN("zend_test.observe_opline_in_zendmm", "0", PHP_INI_ALL, OnUpdateZendTestObserveOplineInZendMM, observe_opline_in_zendmm, zend_zend_test_globals, zend_test_globals)
1145
1147static void custom_zend_execute_ex(zend_execute_data *execute_data)
1148{
1150}
1151
1152static void le_throwing_resource_dtor(zend_resource *rsrc)
1153{
1154 zend_throw_exception(NULL, "Throwing resource destructor called", 0);
1155}
1156
1157static ZEND_METHOD(_ZendTestClass, takesUnionType)
1158{
1159 zend_object *obj;
1161 Z_PARAM_OBJ(obj)
1163 // we have to perform type-checking to avoid arginfo/zpp mismatch error
1164 bool type_matches = (
1165 instanceof_function(obj->ce, zend_standard_class_def)
1166 ||
1167 instanceof_function(obj->ce, zend_ce_iterator)
1168 );
1169 if (!type_matches) {
1170 zend_string *ty = zend_type_to_string(execute_data->func->internal_function.arg_info->type);
1171 zend_argument_type_error(1, "must be of type %s, %s given", ty->val, obj->ce->name->val);
1172 zend_string_release(ty);
1173 RETURN_THROWS();
1174 }
1175
1176 RETURN_NULL();
1177}
1178
1179// Returns a newly allocated DNF type `Iterator|(Traversable&Countable)`.
1180//
1181// We need to generate it "manually" because gen_stubs.php does not support codegen for DNF types ATM.
1182static zend_type create_test_dnf_type(void) {
1183 zend_string *class_Iterator = zend_string_init_interned("Iterator", sizeof("Iterator") - 1, true);
1184 zend_alloc_ce_cache(class_Iterator);
1185 zend_string *class_Traversable = ZSTR_KNOWN(ZEND_STR_TRAVERSABLE);
1186 zend_string *class_Countable = zend_string_init_interned("Countable", sizeof("Countable") - 1, true);
1187 zend_alloc_ce_cache(class_Countable);
1188 //
1189 zend_type_list *intersection_list = malloc(ZEND_TYPE_LIST_SIZE(2));
1190 intersection_list->num_types = 2;
1191 intersection_list->types[0] = (zend_type) ZEND_TYPE_INIT_CLASS(class_Traversable, 0, 0);
1192 intersection_list->types[1] = (zend_type) ZEND_TYPE_INIT_CLASS(class_Countable, 0, 0);
1193 zend_type_list *union_list = malloc(ZEND_TYPE_LIST_SIZE(2));
1194 union_list->num_types = 2;
1195 union_list->types[0] = (zend_type) ZEND_TYPE_INIT_CLASS(class_Iterator, 0, 0);
1196 union_list->types[1] = (zend_type) ZEND_TYPE_INIT_INTERSECTION(intersection_list, 0);
1197 return (zend_type) ZEND_TYPE_INIT_UNION(union_list, 0);
1198}
1199
1200static void register_ZendTestClass_dnf_property(zend_class_entry *ce) {
1201 zend_string *prop_name = zend_string_init_interned("dnfProperty", sizeof("dnfProperty") - 1, true);
1202 zval default_value;
1203 ZVAL_UNDEF(&default_value);
1204 zend_type type = create_test_dnf_type();
1205 zend_declare_typed_property(ce, prop_name, &default_value, ZEND_ACC_PUBLIC, NULL, type);
1206}
1207
1208// arg_info for `zend_test_internal_dnf_arguments`
1209// The types are upgraded to DNF types in `register_dynamic_function_entries()`
1210static zend_internal_arg_info arginfo_zend_test_internal_dnf_arguments[] = {
1211 // first entry is a zend_internal_function_info (see zend_compile.h): {argument_count, return_type, unused}
1212 {(const char*)(uintptr_t)(1), {0}, NULL},
1213 {"arg", {0}, NULL}
1214};
1215
1216static ZEND_NAMED_FUNCTION(zend_test_internal_dnf_arguments)
1217{
1218 zend_object *obj;
1220 Z_PARAM_OBJ(obj)
1222 // we have to perform type-checking to avoid arginfo/zpp mismatch error
1223 bool type_matches = (
1224 instanceof_function(obj->ce, zend_ce_iterator)
1225 || (
1226 instanceof_function(obj->ce, zend_ce_traversable)
1227 && instanceof_function(obj->ce, zend_ce_countable)
1228 )
1229 );
1230 if (!type_matches) {
1231 zend_string *ty = zend_type_to_string(arginfo_zend_test_internal_dnf_arguments[1].type);
1232 zend_argument_type_error(1, "must be of type %s, %s given", ty->val, obj->ce->name->val);
1233 zend_string_release(ty);
1234 RETURN_THROWS();
1235 }
1236
1237 RETURN_OBJ_COPY(obj);
1238}
1239
1240static const zend_function_entry dynamic_function_entries[] = {
1241 {
1242 .fname = "zend_test_internal_dnf_arguments",
1243 .handler = zend_test_internal_dnf_arguments,
1244 .arg_info = arginfo_zend_test_internal_dnf_arguments,
1245 .num_args = 1,
1246 .flags = 0,
1247 },
1249};
1250
1251static void register_dynamic_function_entries(int module_type) {
1252 // return-type is at index 0
1253 arginfo_zend_test_internal_dnf_arguments[0].type = create_test_dnf_type();
1254 arginfo_zend_test_internal_dnf_arguments[1].type = create_test_dnf_type();
1255 //
1256 zend_register_functions(NULL, dynamic_function_entries, NULL, module_type);
1257}
1258
1260{
1261 register_dynamic_function_entries(type);
1262
1263 zend_test_interface = register_class__ZendTestInterface();
1264
1265 zend_test_class = register_class__ZendTestClass(zend_test_interface);
1266 register_ZendTestClass_dnf_property(zend_test_class);
1267 zend_test_class->create_object = zend_test_class_new;
1268 zend_test_class->get_static_method = zend_test_class_static_method_get;
1269
1270 zend_test_child_class = register_class__ZendTestChildClass(zend_test_class);
1271
1272 memcpy(&zend_test_class_handlers, &std_object_handlers, sizeof(zend_object_handlers));
1273 zend_test_class_handlers.get_method = zend_test_class_method_get;
1274
1275 zend_test_gen_stub_flag_compatibility_test = register_class_ZendTestGenStubFlagCompatibilityTest();
1276
1277 zend_attribute_test_class = register_class_ZendAttributeTest();
1278
1279 zend_test_trait = register_class__ZendTestTrait();
1280
1281 register_test_symbols(module_number);
1282
1283 zend_test_attribute = register_class_ZendTestAttribute();
1284 {
1287 }
1288
1289 zend_test_repeatable_attribute = register_class_ZendTestRepeatableAttribute();
1290 zend_mark_internal_attribute(zend_test_repeatable_attribute);
1291
1292 zend_test_parameter_attribute = register_class_ZendTestParameterAttribute();
1293 zend_mark_internal_attribute(zend_test_parameter_attribute);
1294
1295 zend_test_property_attribute = register_class_ZendTestPropertyAttribute();
1296 zend_mark_internal_attribute(zend_test_property_attribute);
1297
1298 zend_test_attribute_with_arguments = register_class_ZendTestAttributeWithArguments();
1299 zend_mark_internal_attribute(zend_test_attribute_with_arguments);
1300
1301 zend_test_class_with_method_with_parameter_attribute = register_class_ZendTestClassWithMethodWithParameterAttribute();
1302 zend_test_child_class_with_method_with_parameter_attribute = register_class_ZendTestChildClassWithMethodWithParameterAttribute(zend_test_class_with_method_with_parameter_attribute);
1303
1304 zend_test_class_with_property_attribute = register_class_ZendTestClassWithPropertyAttribute();
1305 {
1306 zend_property_info *prop_info = zend_hash_str_find_ptr(&zend_test_class_with_property_attribute->properties_info, "attributed", sizeof("attributed") - 1);
1307 zend_add_property_attribute(zend_test_class_with_property_attribute, prop_info, zend_test_attribute->name, 0);
1308 }
1309
1310 zend_test_forbid_dynamic_call = register_class_ZendTestForbidDynamicCall();
1311
1312 zend_test_ns_foo_class = register_class_ZendTestNS_Foo();
1313 zend_test_ns_unlikely_compile_error_class = register_class_ZendTestNS_UnlikelyCompileError();
1314 zend_test_ns_not_unlikely_compile_error_class = register_class_ZendTestNS_NotUnlikelyCompileError();
1315 zend_test_ns2_foo_class = register_class_ZendTestNS2_Foo();
1316 zend_test_ns2_ns_foo_class = register_class_ZendTestNS2_ZendSubNS_Foo();
1317
1318 zend_test_unit_enum = register_class_ZendTestUnitEnum();
1319 zend_test_string_enum = register_class_ZendTestStringEnum();
1320 zend_test_int_enum = register_class_ZendTestIntEnum();
1321
1322 zend_test_magic_call = register_class__ZendTestMagicCall();
1323
1324 register_class__ZendTestMagicCallForward();
1325
1326 zend_register_functions(NULL, ext_function_legacy, NULL, EG(current_module)->type);
1327
1328 // Loading via dl() not supported with the observer API
1329 if (type != MODULE_TEMPORARY) {
1331 } else {
1332 (void)ini_entries;
1333 }
1334
1337 zend_execute_ex = custom_zend_execute_ex;
1338 }
1339
1340 if (ZT_G(register_passes)) {
1343 }
1344
1350
1351 le_throwing_resource = zend_register_list_destructors_ex(le_throwing_resource_dtor, NULL, "throwing resource", module_number);
1352
1353 return SUCCESS;
1354}
1355
1357{
1358 if (type != MODULE_TEMPORARY) {
1360 }
1361
1363
1365 fprintf(stderr, "[zend_test] MSHUTDOWN\n");
1366 }
1367
1368 return SUCCESS;
1369}
1370
1378
1380{
1381 zend_ulong obj_key;
1383 zend_weakrefs_hash_del(&ZT_G(global_weakmap), zend_weakref_key_to_object(obj_key));
1386
1387 if (ZT_G(zend_test_heap)) {
1388 free(ZT_G(zend_test_heap));
1391 }
1392
1394 return SUCCESS;
1395}
1396
1397static PHP_GINIT_FUNCTION(zend_test)
1398{
1399#if defined(COMPILE_DL_ZEND_TEST) && defined(ZTS)
1401#endif
1402 memset(zend_test_globals, 0, sizeof(*zend_test_globals));
1403
1404 zend_test_observer_ginit(zend_test_globals);
1405}
1406
1407static PHP_GSHUTDOWN_FUNCTION(zend_test)
1408{
1409 zend_test_observer_gshutdown(zend_test_globals);
1410 zend_test_reset_heap(zend_test_globals);
1411}
1412
1414{
1416 php_info_print_table_row(2, "zend_test extension", "enabled");
1418
1420}
1421
1424 "zend_test",
1425 ext_functions,
1426 PHP_MINIT(zend_test),
1427 PHP_MSHUTDOWN(zend_test),
1428 PHP_RINIT(zend_test),
1429 PHP_RSHUTDOWN(zend_test),
1430 PHP_MINFO(zend_test),
1432 PHP_MODULE_GLOBALS(zend_test),
1433 PHP_GINIT(zend_test),
1434 PHP_GSHUTDOWN(zend_test),
1435 NULL,
1437};
1438
1439#ifdef COMPILE_DL_ZEND_TEST
1440# ifdef ZTS
1442# endif
1443ZEND_GET_MODULE(zend_test)
1444#endif
1445
1446/* The important part here is the ZEND_FASTCALL. */
1447PHP_ZEND_TEST_API int ZEND_FASTCALL bug78270(const char *str, size_t str_len)
1448{
1449 char * copy = zend_strndup(str, str_len);
1450 int r = (int) ZEND_ATOL(copy);
1451 free(copy);
1452 return r;
1453}
1454
1456{
1457 struct bug79096 b;
1458
1459 b.a = 1;
1460 b.b = 1;
1461 return b;
1462}
1463
1464PHP_ZEND_TEST_API void bug79532(off_t *array, size_t elems)
1465{
1466 for (size_t i = 0; i < elems; i++) {
1467 array[i] = i;
1468 }
1469}
1470
1471PHP_ZEND_TEST_API int *(*bug79177_cb)(void);
1472void bug79177(void)
1473{
1474 bug79177_cb();
1475}
1476
1477typedef struct bug80847_01 {
1478 uint64_t b;
1479 double c;
1484
1486 s.a.b += 10;
1487 s.a.c -= 10.0;
1488 return s;
1489}
1490
1496
1498 php_printf("bug_gh9090_none\n");
1499}
1500
1502 php_printf("bug_gh9090_int_char %d %s\n", i, s);
1503}
1504
1506 va_list args;
1507 char *buffer;
1508
1509 va_start(args, fmt);
1510
1511 zend_vspprintf(&buffer, 0, fmt, args);
1512 php_printf("bug_gh9090_void_int_char_var %s\n", buffer);
1513 efree(buffer);
1514
1515 va_end(args);
1516}
1517
1519
1524
1528
1530 return 'A';
1531}
1532
1534 return true;
1535}
1536
1538 return 12345;
1539}
1540
1542 return 123456789;
1543}
1544
1548
1551 ret.field = 123456789;
1552 return ret;
1553}
1554
1555#ifdef HAVE_COPY_FILE_RANGE
1559#ifdef __MUSL__
1560typedef off_t off64_t;
1561#endif
1562PHP_ZEND_TEST_API ssize_t copy_file_range(int fd_in, off64_t *off_in, int fd_out, off64_t *off_out, size_t len, unsigned int flags)
1563{
1564 ssize_t (*original_copy_file_range)(int, off64_t *, int, off64_t *, size_t, unsigned int) = dlsym(RTLD_NEXT, "copy_file_range");
1565 if (ZT_G(limit_copy_file_range) >= Z_L(0)) {
1567 }
1568 return original_copy_file_range(fd_in, off_in, fd_out, off_out, len, flags);
1569}
1570#endif
1571
1572
1574{
1576 zend_resource *res = zend_register_resource(NULL, le_throwing_resource);
1578}
size_t len
Definition apprentice.c:174
bool bail
Definition assert.c:28
bool exception
Definition assert.c:30
fprintf($stream, string $format, mixed ... $values)
copy(string $from, string $to, $context=null)
is_object(mixed $value)
fread($stream, int $length)
assert(mixed $assertion, Throwable|string|null $description=null)
char s[4]
Definition cdf.c:77
DNS_STATUS status
Definition dns_win32.c:49
zend_ffi_type * type
Definition ffi.c:3812
zval * zv
Definition ffi.c:3975
new_type size
Definition ffi.c:4365
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)
new_type attr
Definition ffi.c:4364
zend_ffi_ctype_name_buf buf
Definition ffi.c:4685
void zend_test_fiber_init(void)
Definition fiber.c:347
#define NULL
Definition gdcache.h:45
#define SUCCESS
Definition hash_sha3.c:261
for( $i=0;$i< 0x1E;$i++)
foreach($dp as $el) foreach( $dp as $el) if( $pass2< 2) echo ""
switch(IR_OPT_TYPE(opt))
Definition ir_fold.h:1194
void zend_test_iterators_init(void)
Definition iterators.c:118
PHPAPI size_t php_printf(const char *format,...)
Definition main.c:938
PHPAPI ZEND_COLD void php_log_err_with_severity(const char *log_message, int syslog_type_int)
Definition main.c:858
void zend_test_object_handlers_init(void)
void zend_test_observer_ginit(zend_zend_test_globals *zend_test_globals)
Definition observer.c:410
void zend_test_observer_init(INIT_FUNC_ARGS)
Definition observer.c:370
void zend_test_observer_gshutdown(zend_zend_test_globals *zend_test_globals)
Definition observer.c:416
void zend_test_observer_shutdown(SHUTDOWN_FUNC_ARGS)
Definition observer.c:403
php_info_print_table_start()
Definition info.c:1064
php_info_print_table_row(2, "PDO Driver for Firebird", "enabled")
php_info_print_table_end()
Definition info.c:1074
#define PHP_GINIT
Definition php.h:397
#define PHP_FUNCTION
Definition php.h:364
#define PHP_MSHUTDOWN_FUNCTION
Definition php.h:401
#define PHP_MINFO
Definition php.h:396
#define PHP_MINIT_FUNCTION
Definition php.h:400
#define PHP_RINIT
Definition php.h:394
#define PHP_MSHUTDOWN
Definition php.h:393
#define PHP_MINFO_FUNCTION
Definition php.h:404
#define PHP_GINIT_FUNCTION
Definition php.h:405
#define PHP_RSHUTDOWN
Definition php.h:395
#define PHP_RINIT_FUNCTION
Definition php.h:402
#define PHP_RSHUTDOWN_FUNCTION
Definition php.h:403
#define PHP_GSHUTDOWN_FUNCTION
Definition php.h:406
#define PHP_MINIT
Definition php.h:392
#define PHP_MODULE_GLOBALS
Definition php.h:408
#define PHP_GSHUTDOWN
Definition php.h:398
#define PG(v)
Definition php_globals.h:31
#define PHP_INI_ALL
Definition php_ini.h:45
#define PHP_INI_BEGIN
Definition php_ini.h:52
#define STD_PHP_INI_ENTRY
Definition php_ini.h:64
#define STD_PHP_INI_BOOLEAN
Definition php_ini.h:66
#define PHP_INI_MH
Definition php_ini.h:49
#define PHP_INI_SYSTEM
Definition php_ini.h:43
#define PHP_INI_END
Definition php_ini.h:53
unsigned char key[REFLECTION_KEY_LEN]
#define php_stream_cast(stream, as, ret, show_err)
struct _php_stream php_stream
Definition php_streams.h:96
#define REPORT_ERRORS
#define php_stream_from_zval(xstr, pzval)
#define PHP_STREAM_AS_STDIO
int replace_zend_execute_ex
Definition php_test.h:54
zend_string * not_empty_str_test
Definition php_test.h:64
#define ZT_G(v)
zend_mm_heap * zend_test_heap
Definition php_test.h:60
int observe_opline_in_zendmm
Definition php_test.h:58
HashTable global_weakmap
Definition php_test.h:53
zend_string * str_test
Definition php_test.h:63
#define PHP_ZEND_TEST_VERSION
Definition php_test.h:25
zend_long limit_copy_file_range
Definition php_test.h:57
#define PHP_ZEND_TEST_API
Definition php_test.h:94
int observer_nesting_depth
Definition php_test.h:48
int register_passes
Definition php_test.h:55
zend_mm_heap * zend_orig_heap
Definition php_test.h:59
PHP_ZEND_TEST_API struct bug79096 bug79096(void)
Definition test.c:1455
zend_long quantity_value
Definition php_test.h:62
bool print_stderr_mshutdown
Definition php_test.h:56
zend_module_entry zend_test_module_entry
Definition test.c:1422
zend_op_array *(* compile_string)(zend_string *source_string, const char *filename, zend_compile_position position)
Definition phpdbg.h:274
zval rv
Definition session.c:1024
#define strpprintf
Definition spprintf.h:30
uint32_t nNumUsed
Definition zend_types.h:406
zend_string * name
Definition zend.h:149
zend_class_entry * scope
zend_string * function_name
zend_string * doc_comment
zend_class_entry * ce
Definition zend_types.h:560
const zend_object_handlers * handlers
Definition zend_types.h:561
char val[1]
Definition zend_types.h:377
Definition file.h:177
double c
Definition test.c:1479
uint64_t b
Definition test.c:1478
bug80847_01 a
Definition test.c:1482
Definition dce.c:49
zend_type types[1]
Definition zend_types.h:142
uint32_t num_types
Definition zend_types.h:141
#define LOG_DEBUG
Definition syslog.h:29
PHP_ZEND_TEST_API void(* bug_gh9090_void_char_int_ptr)(char *, int)
Definition test.c:1494
PHP_ZEND_TEST_API bug80847_02 ffi_bug80847(bug80847_02 s)
Definition test.c:1485
PHP_ZEND_TEST_API void(* bug_gh9090_void_int_char_var_ptr)(int, char *,...)
Definition test.c:1493
void * zend_test_custom_malloc(size_t len ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
Definition test.c:683
PHP_ZEND_TEST_API struct bug_gh16013_int_struct bug_gh16013_return_struct(void)
Definition test.c:1549
PHP_ZEND_TEST_API int bug_gh16013_return_int(void)
Definition test.c:1541
void * zend_test_custom_realloc(void *ptr, size_t len ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
Definition test.c:699
bug_gh16013_enum
Definition test.c:1520
@ BUG_GH16013_A
Definition test.c:1521
@ BUG_GH16013_B
Definition test.c:1522
PHP_ZEND_TEST_API void bug_gh9090_void_none(void)
Definition test.c:1497
PHP_ZEND_TEST_API bool bug_gh16013_return_bool(void)
Definition test.c:1533
PHP_ZEND_TEST_API void(* bug_gh9090_void_int_char_ptr)(int, char *)
Definition test.c:1492
PHP_ZEND_TEST_API void bug_gh9090_void_int_char_var(int i, char *fmt,...)
Definition test.c:1505
PHP_ZEND_TEST_API int *(* bug79177_cb)(void)
Definition test.c:1471
PHP_ZEND_TEST_API char bug_gh16013_return_char(void)
Definition test.c:1529
void zend_test_custom_free(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
Definition test.c:691
PHP_ZEND_TEST_API enum bug_gh16013_enum bug_gh16013_return_enum(void)
Definition test.c:1545
void zend_attribute_validate_zendtestattribute(zend_attribute *attr, uint32_t target, zend_class_entry *scope)
Definition test.c:908
void(* old_zend_execute_ex)(zend_execute_data *execute_data)
Definition test.c:1146
PHP_ZEND_TEST_API int(* bug_gh9090_int_int_char_ptr)(int, char *)
Definition test.c:1495
PHP_ZEND_TEST_API int gh11934b_ffi_var_test_cdata
Definition test.c:1518
PHP_ZEND_TEST_API void(* bug_gh9090_void_none_ptr)(void)
Definition test.c:1491
void bug79177(void)
Definition test.c:1472
PHP_ZEND_TEST_API int ZEND_FASTCALL bug78270(const char *str, size_t str_len)
Definition test.c:1447
PHP_ZEND_TEST_API void bug_gh9090_void_int_char(int i, char *s)
Definition test.c:1501
PHP_ZEND_TEST_API void bug79532(off_t *array, size_t elems)
Definition test.c:1464
PHP_ZEND_TEST_API short bug_gh16013_return_short(void)
Definition test.c:1537
zend_test_zend_call_stack_get()
zend_create_unterminated_string(string $str)
zend_string_or_stdclass($param)
zend_test_zend_call_stack_use_all()
zend_test_is_zend_ptr(int $addr)
zend_test_log_err_debug(string $str)
zend_test_crash(?string $message=null)
zend_iterable(iterable $arg1, ?iterable $arg2=null)
zend_get_map_ptr_last()
zend_test_is_pcre_bundled()
zend_string_or_object(object|string $param)
zend_test_deprecated(mixed $arg=null)
zend_test_parameter_with_attribute(#[ZendTestParameterAttribute("value1")] string $parameter)
zend_string_or_object_or_null(object|string|null $param)
zend_number_or_string(string|int|float $param)
zend_test_nullable_array_return()
zend_test_array_return()
zend_weakmap_remove(object $object)
zend_test_zend_ini_parse_uquantity(string $str)
zend_test_void_return()
zend_terminate_string(string &$str)
trait _ZendTestTrait
zend_leak_variable(mixed $variable)
testMethod()
zend_test_create_throwing_resource()
zend_test_fill_packed_array(array &$array)
zend_test_zend_ini_parse_quantity(string $str)
zend_test_zend_ini_str()
zend_get_current_func_name()
zend_get_unit_enum()
zend_test_override_libxml_global_state()
zend_string_or_stdclass_or_null($param)
get_open_basedir()
zend_weakmap_dump()
zend_test_compile_string(string $source_string, string $filename, int $position)
zend_object_init_with_constructor(string $class, mixed ... $args)
zend_test_set_fmode(bool $binary)
zend_weakmap_attach(object $object, mixed $value)
zend_test_cast_fread($stream)
zend_test_attribute_with_named_argument()
zend_number_or_string_or_null(string|int|float|null $param)
zend_test_is_string_marked_as_valid_utf8(string $string)
zend_leak_bytes(int $bytes=3)
zend_test_deprecated_attr()
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_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 size_t zend_vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap)
Definition zend.c:283
#define ZEND_TSRMLS_CACHE_UPDATE()
Definition zend.h:69
#define zend_catch
Definition zend.h:277
#define zend_try
Definition zend.h:270
#define zend_end_try()
Definition zend.h:280
#define ZEND_TSRMLS_CACHE_DEFINE()
Definition zend.h:68
#define zend_bailout()
Definition zend.h:268
ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend_function_entry *functions, HashTable *function_table, int type)
Definition zend_API.c:2927
ZEND_API const char * zend_zval_value_name(const zval *arg)
Definition zend_API.c:148
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 const char * zend_zval_type_name(const zval *arg)
Definition zend_API.c:167
ZEND_API zend_result object_init_ex(zval *arg, zend_class_entry *class_type)
Definition zend_API.c:1849
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_result zend_parse_parameters(uint32_t num_args, const char *type_spec,...)
Definition zend_API.c:1300
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_value_error(uint32_t arg_num, const char *format,...)
Definition zend_API.c:433
ZEND_API ZEND_COLD void zend_argument_type_error(uint32_t arg_num, const char *format,...)
Definition zend_API.c:423
ZEND_API void zend_update_property_ex(zend_class_entry *scope, zend_object *object, zend_string *name, zval *value)
Definition zend_API.c:4979
#define Z_PARAM_ARRAY_HT_EX(dest, check_null, separate)
Definition zend_API.h:1849
#define ZEND_NUM_ARGS()
Definition zend_API.h:530
#define Z_PARAM_OBJ_OF_CLASS_OR_STR(destination_object, base_ce, destination_string)
Definition zend_API.h:1788
#define ZEND_FE_END
Definition zend_API.h:124
#define Z_PARAM_ITERABLE_OR_NULL(dest)
Definition zend_API.h:1714
#define RETURN_STRING(s)
Definition zend_API.h:1043
#define RETURN_COPY(zv)
Definition zend_API.h:1054
#define ZEND_PARSE_PARAMETERS_END()
Definition zend_API.h:1641
#define RETURN_FALSE
Definition zend_API.h:1058
#define RETURN_DOUBLE(d)
Definition zend_API.h:1038
#define Z_PARAM_RESOURCE(dest)
Definition zend_API.h:2056
struct _zend_function_entry zend_function_entry
#define Z_PARAM_STR_OR_NULL(dest)
Definition zend_API.h:2089
#define ZEND_PARSE_PARAMETERS_NONE()
Definition zend_API.h:1623
#define RETURN_NULL()
Definition zend_API.h:1036
#define ZEND_FN(name)
Definition zend_API.h:71
#define Z_PARAM_OBJ_OR_STR(destination_object, destination_string)
Definition zend_API.h:1768
#define ZEND_DECLARE_MODULE_GLOBALS(module_name)
Definition zend_API.h:268
#define RETVAL_STR_COPY(s)
Definition zend_API.h:1016
#define RETURN_ARR(r)
Definition zend_API.h:1050
#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_PARAM_OPTIONAL
Definition zend_API.h:1667
#define ZEND_GET_MODULE(name)
Definition zend_API.h:241
#define Z_PARAM_STR(dest)
Definition zend_API.h:2086
#define ZEND_PARSE_PARAMETERS_START(min_num_args, max_num_args)
Definition zend_API.h:1620
#define Z_PARAM_NUMBER_OR_STR(dest)
Definition zend_API.h:1925
#define Z_PARAM_NUMBER_OR_STR_OR_NULL(dest)
Definition zend_API.h:1928
#define Z_PARAM_CLASS(dest)
Definition zend_API.h:1740
#define Z_PARAM_LONG(dest)
Definition zend_API.h:1896
#define Z_PARAM_VARIADIC(spec, dest, dest_num)
Definition zend_API.h:2124
#define RETURN_LONG(l)
Definition zend_API.h:1037
#define RETURN_BOOL(b)
Definition zend_API.h:1035
#define RETURN_OBJ_COPY(r)
Definition zend_API.h:1053
#define Z_PARAM_ITERABLE(dest)
Definition zend_API.h:1711
#define ZEND_METHOD(classname, name)
Definition zend_API.h:76
#define RETURN_THROWS()
Definition zend_API.h:1060
#define Z_PARAM_OBJ_OF_CLASS_OR_STR_OR_NULL(destination_object, base_ce, destination_string)
Definition zend_API.h:1791
#define Z_PARAM_OBJ(dest)
Definition zend_API.h:1955
#define ZEND_END_ARG_INFO()
Definition zend_API.h:219
#define ZEND_MODULE_GLOBALS_BULK(module_name)
Definition zend_API.h:275
#define RETURN_STR(s)
Definition zend_API.h:1039
#define ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(pass_by_ref, name, type_hint, allow_null, default_value)
Definition zend_API.h:140
#define ZEND_THIS
Definition zend_API.h:523
#define ZEND_NAMED_FUNCTION(name)
Definition zend_API.h:74
#define call_user_function(function_table, object, function_name, retval_ptr, param_count, params)
Definition zend_API.h:687
#define ZEND_ARG_TYPE_INFO(pass_by_ref, name, type_hint, allow_null)
Definition zend_API.h:138
#define RETVAL_LONG(l)
Definition zend_API.h:1011
#define Z_PARAM_BOOL(dest)
Definition zend_API.h:1726
#define Z_PARAM_OBJ_OR_STR_OR_NULL(destination_object, destination_string)
Definition zend_API.h:1771
#define RETURN_EMPTY_STRING()
Definition zend_API.h:1047
#define Z_PARAM_ARRAY(dest)
Definition zend_API.h:1682
#define ZEND_FE(name, arg_info)
Definition zend_API.h:86
#define Z_PARAM_ZVAL(dest)
Definition zend_API.h:2100
#define RETURN_TRUE
Definition zend_API.h:1059
#define ZEND_FUNCTION(name)
Definition zend_API.h:75
#define RETURN_STR_COPY(s)
Definition zend_API.h:1042
#define array_init(arg)
Definition zend_API.h:537
#define Z_PARAM_VARIADIC_WITH_NAMED(dest, dest_num, dest_named)
Definition zend_API.h:2127
ZEND_API void ZEND_FASTCALL _zend_mm_free(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
ZEND_API char *ZEND_FASTCALL zend_strndup(const char *s, size_t length)
void *ZEND_FASTCALL _zend_mm_realloc(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
ZEND_API void zend_mm_set_custom_handlers(zend_mm_heap *heap, void *(*_malloc)(size_t ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC), void(*_free)(void *ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC), void *(*_realloc)(void *, size_t ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC))
ZEND_API zend_mm_heap * zend_mm_set_heap(zend_mm_heap *new_heap)
ZEND_API bool is_zend_ptr(const void *ptr)
ZEND_API zend_mm_heap * zend_mm_get_heap(void)
ZEND_API void *ZEND_FASTCALL _zend_mm_alloc(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
#define efree_size(ptr, size)
Definition zend_alloc.h:138
#define efree(ptr)
Definition zend_alloc.h:155
#define emalloc(size)
Definition zend_alloc.h:151
ZEND_API zend_internal_attribute * zend_mark_internal_attribute(zend_class_entry *ce)
struct _zend_attribute zend_attribute
struct _zend_internal_attribute zend_internal_attribute
#define ZEND_ATTRIBUTE_TARGET_CLASS
struct _zval_struct zval
strlen(string $string)
uint32_t num_args
HashTable * named_args
execute_data func
zval * args
ZEND_API zend_string * zend_type_to_string(zend_type type)
#define ZEND_USER_CODE(type)
#define OBJ_PROP_NUM(obj, num)
ZEND_API void destroy_op_array(zend_op_array *op_array)
#define ZEND_INTERNAL_FUNCTION
#define EX(element)
#define ZEND_ACC_CALL_VIA_TRAMPOLINE
struct _zend_op_array zend_op_array
struct _zend_property_info zend_property_info
#define ZEND_ACC_CALL_VIA_HANDLER
struct _zend_internal_arg_info zend_internal_arg_info
#define ZEND_ACC_STATIC
#define ZEND_ACC_PUBLIC
@ ZEND_COMPILE_POSITION_AT_OPEN_TAG
struct _zend_internal_function zend_internal_function
ZEND_API zend_object * zend_enum_get_case_cstr(zend_class_entry *ce, const char *name)
Definition zend_enum.c:627
#define E_COMPILE_ERROR
Definition zend_errors.h:29
#define E_ERROR
Definition zend_errors.h:23
#define E_WARNING
Definition zend_errors.h:24
ZEND_API ZEND_COLD zend_object * zend_throw_exception(zend_class_entry *exception_ce, const char *message, zend_long code)
ZEND_API void(ZEND_FASTCALL *zend_touch_vm_stack_data)(void *vm_stack_data)
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 zend_string * get_function_or_method_name(const zend_function *func)
ZEND_API void(* zend_execute_ex)(zend_execute_data *execute_data)
ZEND_API void zend_execute(zend_op_array *op_array, zval *return_value)
union _zend_function zend_function
#define CG(v)
#define EG(v)
ZEND_API void ZEND_FASTCALL zend_hash_destroy(HashTable *ht)
Definition zend_hash.c:1727
ZEND_API void ZEND_FASTCALL zend_hash_extend(HashTable *ht, uint32_t nSize, bool packed)
Definition zend_hash.c:396
ZEND_API HashTable *ZEND_FASTCALL zend_new_pair(zval *val1, zval *val2)
Definition zend_hash.c:296
ZEND_API HashTable *ZEND_FASTCALL zend_array_dup(HashTable *source)
Definition zend_hash.c:2438
#define ZEND_HASH_FILL_ADD(_val)
Definition zend_hash.h:1570
#define zend_hash_init(ht, nSize, pHashFunction, pDestructor, persistent)
Definition zend_hash.h:108
#define ZEND_HASH_FILL_PACKED(ht)
Definition zend_hash.h:1528
#define ZEND_HASH_FOREACH_NUM_KEY(ht, _h)
Definition zend_hash.h:1130
#define ZEND_HASH_FILL_END()
Definition zend_hash.h:1582
#define HT_IS_PACKED(ht)
Definition zend_hash.h:59
#define ZEND_HASH_FOREACH_END()
Definition zend_hash.h:1086
ZEND_API zend_ulong zend_ini_parse_uquantity(zend_string *value, zend_string **errstr)
Definition zend_ini.c:863
ZEND_API bool zend_ini_parse_bool(zend_string *str)
Definition zend_ini.c:573
ZEND_API zend_long zend_ini_parse_quantity(zend_string *value, zend_string **errstr)
Definition zend_ini.c:857
#define UNREGISTER_INI_ENTRIES()
Definition zend_ini.h:204
#define REGISTER_INI_ENTRIES()
Definition zend_ini.h:203
#define DISPLAY_INI_ENTRIES()
Definition zend_ini.h:205
ZEND_API zend_class_entry * zend_ce_countable
ZEND_API zend_class_entry * zend_ce_iterator
ZEND_API zend_class_entry * zend_ce_traversable
ZEND_API zval * zend_call_method(zend_object *object, zend_class_entry *obj_ce, zend_function **fn_proxy, const char *function_name, size_t function_name_len, zval *retval_ptr, uint32_t param_count, zval *arg1, zval *arg2)
ZEND_API zend_resource * zend_register_resource(void *rsrc_pointer, int rsrc_type)
Definition zend_list.c:87
ZEND_API int zend_register_list_destructors_ex(rsrc_dtor_func_t ld, rsrc_dtor_func_t pld, const char *type_name, int module_number)
Definition zend_list.c:265
int32_t zend_long
Definition zend_long.h:42
#define ZEND_ATOL(s)
Definition zend_long.h:101
uint32_t zend_ulong
Definition zend_long.h:43
#define Z_L(i)
Definition zend_long.h:48
struct _zend_string zend_string
void zend_test_mm_custom_handlers_rshutdown(void)
void zend_test_mm_custom_handlers_minit(INIT_FUNC_ARGS)
void zend_test_mm_custom_handlers_rinit(void)
#define STANDARD_MODULE_HEADER
#define SHUTDOWN_FUNC_ARGS_PASSTHRU
#define INIT_FUNC_ARGS_PASSTHRU
#define MODULE_TEMPORARY
struct _zend_module_entry zend_module_entry
#define STANDARD_MODULE_PROPERTIES_EX
ZEND_API zend_function * zend_std_get_method(zend_object **obj_ptr, zend_string *method_name, const zval *key)
ZEND_API const zend_object_handlers std_object_handlers
ZEND_API zend_function * zend_std_get_static_method(zend_class_entry *ce, zend_string *function_name, const zval *key)
#define zend_free_trampoline(func)
ZEND_API zend_object *ZEND_FASTCALL zend_objects_new(zend_class_entry *ce)
ZEND_API int zend_optimizer_register_pass(zend_optimizer_pass_t pass)
struct _zend_script zend_script
#define ZEND_IGNORE_VALUE(x)
#define EXPECTED(condition)
#define ZEND_DIAGNOSTIC_IGNORED_END
#define ZEND_FILE_LINE_DC
#define ZEND_FASTCALL
#define ZEND_ASSERT(c)
#define ZEND_DIAGNOSTIC_IGNORED_START(warning)
#define EMPTY_SWITCH_DEFAULT_CASE()
#define ZEND_FILE_LINE_EMPTY_CC
#define ZEND_FILE_LINE_ORIG_DC
struct _zend_class_entry zend_class_entry
struct _zend_object zend_object
ZEND_API zend_string_init_interned_func_t zend_string_init_interned
Definition zend_string.c:31
#define ZSTR_IS_VALID_UTF8(s)
Definition zend_string.h:85
#define ZSTR_VAL(zstr)
Definition zend_string.h:68
#define ZSTR_KNOWN(idx)
#define ZSTR_LEN(zstr)
Definition zend_string.h:69
#define zend_string_equals_literal_ci(str, c)
#define ZEND_TYPE_INIT_UNION(ptr, extra_flags)
Definition zend_types.h:297
#define Z_TYPE_P(zval_p)
Definition zend_types.h:660
#define ZVAL_STR(z, s)
#define Z_TRY_ADDREF_P(pz)
#define ZVAL_UNDEF(z)
#define Z_STRVAL_P(zval_p)
Definition zend_types.h:975
#define ZVAL_LONG(z, l)
#define IS_STRING
Definition zend_types.h:606
#define Z_REFCOUNTED_P(zval_p)
Definition zend_types.h:921
#define ZVAL_STR_COPY(z, s)
struct _zend_resource zend_resource
Definition zend_types.h:99
struct _zend_array HashTable
Definition zend_types.h:386
#define Z_OBJ_P(zval_p)
Definition zend_types.h:990
#define ZEND_TYPE_LIST_SIZE(num_types)
Definition zend_types.h:207
#define ZVAL_COPY_DEREF(z, v)
#define IS_DOUBLE
Definition zend_types.h:605
#define Z_STR_P(zval_p)
Definition zend_types.h:972
#define Z_ADDREF_P(pz)
#define ZVAL_RES(z, r)
@ FAILURE
Definition zend_types.h:61
#define IS_OBJECT
Definition zend_types.h:608
#define IS_LONG
Definition zend_types.h:604
#define ZEND_TYPE_INIT_INTERSECTION(ptr, extra_flags)
Definition zend_types.h:300
ZEND_RESULT_CODE zend_result
Definition zend_types.h:64
#define IS_ITERABLE
Definition zend_types.h:616
struct _zend_object_handlers zend_object_handlers
Definition zend_types.h:88
#define ZEND_TYPE_INIT_CLASS(class_name, allow_null, extra_flags)
Definition zend_types.h:303
#define Z_DVAL_P(zval_p)
Definition zend_types.h:969
struct _zend_execute_data zend_execute_data
Definition zend_types.h:91
#define Z_LVAL_P(zval_p)
Definition zend_types.h:966
#define ZVAL_COPY_VALUE(z, v)
ZEND_API void zval_ptr_dtor(zval *zval_ptr)
#define ZVAL_PTR_DTOR
zval retval
zval * return_value
zval * arg1
call prev_execute_data
zval * arg2
zend_property_info * prop_info
zend_string * name
execute_data
object
zval * ret
value
zend_execute_data * call
new_op_array scope
ZEND_API zend_result zend_weakrefs_hash_del(HashTable *ht, zend_object *key)
ZEND_API zval * zend_weakrefs_hash_add(HashTable *ht, zend_object *key, zval *pData)