@@ -44,10 +44,6 @@ typedef struct _func_info_t {
44
44
{name, sizeof(name)-1, (MAY_BE_RC1 | (info)), NULL}
45
45
#define FN(name, info) \
46
46
{name, sizeof(name)-1, (MAY_BE_RC1 | MAY_BE_RCN | (info)), NULL}
47
- #define FR(name, info) \
48
- {name, sizeof(name)-1, (MAY_BE_REF | (info)), NULL}
49
- #define FX(name, info) \
50
- {name, sizeof(name)-1, (MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_REF | (info)), NULL}
51
47
#define FC(name, callback) \
52
48
{name, sizeof(name)-1, 0, callback}
53
49
@@ -89,12 +85,9 @@ static uint32_t zend_range_info(const zend_call_info *call_info, const zend_ssa
89
85
}
90
86
}
91
87
92
- #define UNKNOWN_INFO (MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF)
93
-
94
88
static const func_info_t func_infos[] = {
95
89
/* zend */
96
90
F1("zend_version", MAY_BE_STRING),
97
- FN("func_get_arg", UNKNOWN_INFO),
98
91
FN("func_get_args", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ANY),
99
92
F1("get_class_vars", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF),
100
93
F1("get_class_methods", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
@@ -211,7 +204,7 @@ static const func_info_t func_infos[] = {
211
204
F1("base64_decode", MAY_BE_FALSE | MAY_BE_STRING),
212
205
F1("base64_encode", MAY_BE_STRING),
213
206
F1("password_hash", MAY_BE_STRING),
214
- F1("password_get_info", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
207
+ F1("password_get_info", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
215
208
F1("convert_uuencode", MAY_BE_STRING),
216
209
F1("convert_uudecode", MAY_BE_FALSE | MAY_BE_STRING),
217
210
F1("pow", MAY_BE_LONG | MAY_BE_DOUBLE | MAY_BE_OBJECT),
@@ -249,14 +242,7 @@ static const func_info_t func_infos[] = {
249
242
F1("get_current_user", MAY_BE_STRING),
250
243
F1("get_cfg_var", MAY_BE_FALSE | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
251
244
F1("error_get_last", MAY_BE_NULL | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING),
252
- FN("call_user_func", UNKNOWN_INFO),
253
- FN("call_user_func_array", UNKNOWN_INFO),
254
- FN("call_user_method", UNKNOWN_INFO),
255
- FN("call_user_method_array", UNKNOWN_INFO),
256
- FN("forward_static_call", UNKNOWN_INFO),
257
- FN("forward_static_call_array", UNKNOWN_INFO),
258
245
F1("serialize", MAY_BE_STRING),
259
- FN("unserialize", UNKNOWN_INFO),
260
246
F1("var_export", MAY_BE_NULL | MAY_BE_STRING),
261
247
F1("print_r", MAY_BE_TRUE | MAY_BE_STRING),
262
248
F0("register_shutdown_function", MAY_BE_NULL | MAY_BE_FALSE),
@@ -359,19 +345,10 @@ static const func_info_t func_infos[] = {
359
345
F0("usort", MAY_BE_TRUE),
360
346
F0("uasort", MAY_BE_TRUE),
361
347
F0("uksort", MAY_BE_TRUE),
362
- FN("end", UNKNOWN_INFO),
363
- FN("prev", UNKNOWN_INFO),
364
- FN("next", UNKNOWN_INFO),
365
- FN("reset", UNKNOWN_INFO),
366
- FN("current", UNKNOWN_INFO),
367
- FN("min", UNKNOWN_INFO),
368
- FN("max", UNKNOWN_INFO),
369
348
F1("compact", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
370
349
F1("array_fill", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ANY),
371
350
F1("array_fill_keys", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
372
351
FC("range", zend_range_info),
373
- FN("array_pop", UNKNOWN_INFO),
374
- FN("array_shift", UNKNOWN_INFO),
375
352
F1("array_splice", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
376
353
F1("array_slice", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
377
354
F1("array_replace", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
@@ -381,7 +358,6 @@ static const func_info_t func_infos[] = {
381
358
F1("array_count_values", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_LONG),
382
359
F1("array_column", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
383
360
F1("array_reverse", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
384
- F1("array_reduce", UNKNOWN_INFO),
385
361
F1("array_flip", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING),
386
362
F1("array_change_key_case", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
387
363
FN("array_rand", MAY_BE_LONG | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING),
@@ -403,8 +379,6 @@ static const func_info_t func_infos[] = {
403
379
F1("array_filter", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
404
380
F1("array_chunk", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
405
381
F1("array_combine", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
406
- F1("pos", UNKNOWN_INFO),
407
- F1("assert_options", MAY_BE_NULL | MAY_BE_LONG | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_OBJECT | MAY_BE_OBJECT),
408
382
F1("str_rot13", MAY_BE_STRING),
409
383
F1("stream_get_filters", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
410
384
F1("stream_bucket_make_writeable", MAY_BE_NULL | MAY_BE_OBJECT),
@@ -417,7 +391,7 @@ static const func_info_t func_infos[] = {
417
391
F1("strftime", MAY_BE_FALSE | MAY_BE_STRING),
418
392
F1("gmstrftime", MAY_BE_FALSE | MAY_BE_STRING),
419
393
F1("localtime", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_LONG),
420
- F1("getdate", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING),
394
+ F1("getdate", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING),
421
395
F1("date_create", MAY_BE_FALSE | MAY_BE_OBJECT),
422
396
F1("date_create_immutable", MAY_BE_FALSE | MAY_BE_OBJECT),
423
397
F1("date_create_from_format", MAY_BE_FALSE | MAY_BE_OBJECT),
@@ -460,7 +434,7 @@ static const func_info_t func_infos[] = {
460
434
F1("mysqli_query", MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_OBJECT),
461
435
F1("mysqli_get_charset", MAY_BE_NULL | MAY_BE_OBJECT),
462
436
F1("mysqli_fetch_array", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
463
- F1("mysqli_fetch_assoc", MAY_BE_NULL | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY),
437
+ F1("mysqli_fetch_assoc", MAY_BE_NULL | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
464
438
F1("mysqli_fetch_all", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
465
439
F1("mysqli_fetch_object", MAY_BE_NULL | MAY_BE_OBJECT),
466
440
F1("mysqli_affected_rows", MAY_BE_LONG | MAY_BE_STRING),
@@ -684,10 +658,9 @@ static const func_info_t func_infos[] = {
684
658
F1("session_encode", MAY_BE_FALSE | MAY_BE_STRING),
685
659
686
660
/* ext/pgsql */
687
- F1 ("pg_connect", MAY_BE_FALSE | MAY_BE_RESOURCE),
661
+ FN ("pg_connect", MAY_BE_FALSE | MAY_BE_RESOURCE),
688
662
FN("pg_pconnect", MAY_BE_FALSE | MAY_BE_RESOURCE),
689
663
F1("pg_dbname", MAY_BE_STRING),
690
- F1("pg_last_error", MAY_BE_STRING),
691
664
F1("pg_options", MAY_BE_STRING),
692
665
F1("pg_port", MAY_BE_STRING),
693
666
F1("pg_tty", MAY_BE_STRING),
@@ -699,13 +672,11 @@ static const func_info_t func_infos[] = {
699
672
F1("pg_prepare", MAY_BE_FALSE | MAY_BE_RESOURCE),
700
673
F1("pg_execute", MAY_BE_FALSE | MAY_BE_RESOURCE),
701
674
FN("pg_last_notice", MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY ),
702
- F1("pg_field_table", MAY_BE_FALSE | MAY_BE_LONG | MAY_BE_STRING),
703
675
F1("pg_field_name", MAY_BE_STRING),
704
- F1("pg_field_type", MAY_BE_STRING),
705
676
F1("pg_field_type_oid", MAY_BE_LONG | MAY_BE_STRING),
706
677
F1("pg_fetch_result", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING),
707
678
F1("pg_fetch_row", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING),
708
- F1("pg_fetch_assoc", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING),
679
+ F1("pg_fetch_assoc", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING),
709
680
F1("pg_fetch_array", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING),
710
681
F1("pg_fetch_object", MAY_BE_FALSE | MAY_BE_OBJECT),
711
682
F1("pg_fetch_all", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ARRAY),
@@ -750,10 +721,8 @@ static const func_info_t func_infos[] = {
750
721
F1("exif_thumbnail", MAY_BE_FALSE | MAY_BE_STRING),
751
722
752
723
/* ext/filter */
753
- FN("filter_input", UNKNOWN_INFO),
754
- FN("filter_var", UNKNOWN_INFO),
755
724
F1("filter_input_array", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
756
- F1("filter_var_array", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
725
+ F1("filter_var_array", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF ),
757
726
F1("filter_list", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
758
727
759
728
/* ext/gettext */
@@ -839,13 +808,14 @@ static HashTable func_info;
839
808
ZEND_API int zend_func_info_rid = -1;
840
809
841
810
static uint32_t get_internal_func_info(
842
- const zend_call_info *call_info, const zend_ssa *ssa, zend_string *lcname) {
843
- if (call_info->callee_func->common.scope) {
811
+ const zend_call_info *call_info, const zend_ssa *ssa) {
812
+ zend_function *callee_func = call_info->callee_func;
813
+ if (callee_func->common.scope) {
844
814
/* This is a method, not a function. */
845
815
return 0;
846
816
}
847
817
848
- zval *zv = zend_hash_find_ex(&func_info, lcname , 1);
818
+ zval *zv = zend_hash_find_ex(&func_info, callee_func->common.function_name , 1);
849
819
if (!zv) {
850
820
return 0;
851
821
}
@@ -868,9 +838,7 @@ ZEND_API uint32_t zend_get_func_info(
868
838
*ce_is_instanceof = 0;
869
839
870
840
if (callee_func->type == ZEND_INTERNAL_FUNCTION) {
871
- zend_string *lcname = Z_STR_P(CRT_CONSTANT_EX(call_info->caller_op_array, call_info->caller_init_opline, call_info->caller_init_opline->op2));
872
-
873
- uint32_t internal_ret = get_internal_func_info(call_info, ssa, lcname);
841
+ uint32_t internal_ret = get_internal_func_info(call_info, ssa);
874
842
#if !ZEND_DEBUG
875
843
if (internal_ret) {
876
844
return internal_ret;
@@ -882,15 +850,15 @@ ZEND_API uint32_t zend_get_func_info(
882
850
883
851
#if ZEND_DEBUG
884
852
if (internal_ret) {
853
+ zend_string *name = callee_func->common.function_name;
885
854
/* Check whether the func_info information is a subset of the information we can
886
855
* compute from the specified return type, otherwise it contains redundant types. */
887
856
if (internal_ret & ~ret) {
888
- fprintf(stderr, "Inaccurate func info for %s()\n", ZSTR_VAL(lcname ));
857
+ fprintf(stderr, "Inaccurate func info for %s()\n", ZSTR_VAL(name ));
889
858
}
890
- /* Check whether the func info is completely redundant with arginfo.
891
- * Ignore UNKNOWN_INFO for now. */
892
- if (internal_ret == ret && (internal_ret & MAY_BE_ANY) != MAY_BE_ANY) {
893
- fprintf(stderr, "Useless func info for %s()\n", ZSTR_VAL(lcname));
859
+ /* Check whether the func info is completely redundant with arginfo. */
860
+ if (internal_ret == ret) {
861
+ fprintf(stderr, "Useless func info for %s()\n", ZSTR_VAL(name));
894
862
}
895
863
/* If the return type is not mixed, check that the types match exactly if we exclude
896
864
* RC and array information. */
@@ -900,7 +868,7 @@ ZEND_API uint32_t zend_get_func_info(
900
868
/* Func info may contain "true" types as well as isolated "null" and "false". */
901
869
if (diff && !(diff == MAY_BE_FALSE && (ret & MAY_BE_FALSE))
902
870
&& (internal_ret_any & ~(MAY_BE_NULL|MAY_BE_FALSE))) {
903
- fprintf(stderr, "Incorrect func info for %s()\n", ZSTR_VAL(lcname ));
871
+ fprintf(stderr, "Incorrect func info for %s()\n", ZSTR_VAL(name ));
904
872
}
905
873
}
906
874
return internal_ret;
0 commit comments