Skip to content

Commit 7e14df1

Browse files
authored
updated builtin functions (#48)
* Removed deleted functions from KPHP * added new kphp native functions * added new custom handled and native KPHP functions
1 parent 57e3b4d commit 7e14df1

2 files changed

Lines changed: 107 additions & 81 deletions

File tree

src/main/kotlin/com/vk/kphpstorm/helpers/KphpNativeFunctions.kt

Lines changed: 48 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,23 @@ val KPHP_NATIVE_FUNCTIONS: SortedSet<String> = sortedSetOf(
1818

1919
// from functions.txt — addons to php standard library
2020
"warning",
21+
"require_lib",
22+
"critical_error",
2123
"register_kphp_on_warning_callback",
24+
"register_kphp_on_oom_callback",
2225
"kphp_backtrace",
2326
"kphp_set_context_on_error",
24-
"require_lib",
27+
"kphp_get_runtime_config",
2528
"memory_get_total_usage",
2629
"memory_get_static_usage",
27-
"memory_perform_defragmentation",
2830
"estimate_memory_usage",
31+
"memory_get_detailed_stats",
32+
"memory_get_allocations",
33+
"ffi_memcpy_string",
34+
"ffi_cast_ptr2addr",
35+
"ffi_cast_addr2ptr",
36+
"ffi_array_set",
37+
"ffi_array_get",
2938
"get_global_vars_memory_stats",
3039
"get_net_time",
3140
"get_script_time",
@@ -46,7 +55,11 @@ val KPHP_NATIVE_FUNCTIONS: SortedSet<String> = sortedSetOf(
4655
"array_keys_as_ints",
4756
"array_swap_int_keys",
4857
"array_reserve",
58+
"array_reserve_vector",
59+
"array_reserve_map_int_keys",
60+
"array_reserve_map_string_keys",
4961
"array_reserve_from",
62+
"array_unset",
5063
"array_is_vector",
5164
"array_filter_by_key",
5265
"vk_utf8_to_win",
@@ -61,31 +74,16 @@ val KPHP_NATIVE_FUNCTIONS: SortedSet<String> = sortedSetOf(
6174
"vk_sp_to_upper",
6275
"vk_sp_to_lower",
6376
"vk_sp_sort",
64-
"vk_stats_merge_deviation",
65-
"vk_stats_add_deviation",
66-
"vk_stats_decompress_sample",
67-
"vk_stats_merge_samples",
68-
"vk_stats_parse_sample",
6977
"vk_stats_hll_merge",
7078
"vk_stats_hll_count",
7179
"vk_stats_hll_create",
7280
"vk_stats_hll_add",
7381
"vk_dot_product",
74-
"vkext_full_version",
7582
"likely",
7683
"unlikely",
7784
"err",
7885
"fetch_int",
79-
"fetch_UInt",
80-
"fetch_Long",
81-
"fetch_ULong",
82-
"fetch_unsigned_int",
8386
"fetch_long",
84-
"fetch_unsigned_long",
85-
"fetch_unsigned_int_hex",
86-
"fetch_unsigned_long_hex",
87-
"fetch_unsigned_int_str",
88-
"fetch_unsigned_long_str",
8987
"fetch_double",
9088
"fetch_string",
9189
"fetch_string_as_int",
@@ -100,23 +98,13 @@ val KPHP_NATIVE_FUNCTIONS: SortedSet<String> = sortedSetOf(
10098
"store_start_gzip_pack",
10199
"store_finish_gzip_pack",
102100
"rpc_clean",
103-
"rpc_get_clean",
104-
"rpc_get_contents",
105101
"store_header",
106102
"store_error",
107103
"store_raw",
108104
"store_int",
109-
"store_UInt",
110-
"store_Long",
111-
"store_ULong",
112-
"store_unsigned_int",
113105
"store_long",
114-
"store_unsigned_long",
115-
"store_unsigned_int_hex",
116-
"store_unsigned_long_hex",
117106
"store_double",
118107
"store_string",
119-
"store_many",
120108
"store_finish",
121109
"rpc_send",
122110
"rpc_send_noflush",
@@ -129,16 +117,8 @@ val KPHP_NATIVE_FUNCTIONS: SortedSet<String> = sortedSetOf(
129117
"rpc_queue_empty",
130118
"rpc_queue_next",
131119
"rpc_queue_next_synchronously",
120+
"rpc_wait_concurrently",
132121
"rpc_wait",
133-
"rpc_wait_multiple",
134-
"rpc_mc_get",
135-
"rpc_mc_multiget",
136-
"rpc_mc_delete",
137-
"rpc_mc_add",
138-
"rpc_mc_set",
139-
"rpc_mc_replace",
140-
"rpc_mc_decrement",
141-
"rpc_mc_increment",
142122
"rpc_mc_parse_raw_wildcard_with_flags_to_array",
143123
"rpc_tl_query_one",
144124
"rpc_tl_query",
@@ -153,7 +133,6 @@ val KPHP_NATIVE_FUNCTIONS: SortedSet<String> = sortedSetOf(
153133
"typed_rpc_tl_query_result_synchronously",
154134
"rpc_server_fetch_request",
155135
"rpc_server_store_response",
156-
"rpc_get_last_send_error",
157136
"set_fail_rpc_on_int32_overflow",
158137
"wait_multi",
159138
"wait_synchronously",
@@ -167,49 +146,7 @@ val KPHP_NATIVE_FUNCTIONS: SortedSet<String> = sortedSetOf(
167146
"sched_yield_sleep",
168147
"get_running_fork_id",
169148
"get_fork_stat",
170-
"labs",
171-
"ldiv",
172-
"lmod",
173-
"lpow",
174-
"ladd",
175-
"lsub",
176-
"lmul",
177-
"lshl",
178-
"lshr",
179-
"lnot",
180-
"lor",
181-
"land",
182-
"lxor",
183-
"lcomp",
184-
"new_Long",
185-
"uldiv",
186-
"ulmod",
187-
"ulpow",
188-
"uladd",
189-
"ulsub",
190-
"ulmul",
191-
"ulshl",
192-
"ulshr",
193-
"ulnot",
194-
"ulor",
195-
"uland",
196-
"ulxor",
197-
"ulcomp",
198-
"new_ULong",
199-
"uidiv",
200-
"uimod",
201-
"uipow",
202-
"uiadd",
203-
"uisub",
204-
"uimul",
205-
"uishl",
206-
"uishr",
207-
"uinot",
208-
"uior",
209-
"uiand",
210-
"uixor",
211-
"uicomp",
212-
"new_UInt",
149+
"get_hash_of_class",
213150
"instance_cast",
214151
"instance_to_array",
215152
"instance_cache_fetch",
@@ -228,4 +165,35 @@ val KPHP_NATIVE_FUNCTIONS: SortedSet<String> = sortedSetOf(
228165
"profiler_is_enabled",
229166
"profiler_set_function_label",
230167
"profiler_set_log_suffix",
168+
"to_array_debug",
169+
"classof",
170+
"curl_exec_concurrently",
171+
"is_kphp_job_workers_enabled",
172+
"get_job_workers_number",
173+
"get_webserver_stats",
174+
"get_kphp_cluster_name",
175+
"kphp_job_worker_start",
176+
"kphp_job_worker_start_multi",
177+
"kphp_job_worker_start_no_reply",
178+
"kphp_job_worker_fetch_request",
179+
"kphp_job_worker_store_response",
180+
"thread_pool_test_load",
181+
"vk_dot_product",
182+
"send_http_103_early_hints",
183+
"dbg_echo",
184+
"crc32_file",
185+
"ip2ulong",
186+
"thread_pool_test_load",
187+
"fetch_int",
188+
"fetch_long",
189+
"fetch_double",
190+
"fetch_float",
191+
"fetch_string",
192+
"fetch_string_as_int",
193+
"fetch_memcache_value",
194+
"fetch_eof",
195+
"fetch_end",
196+
"fetch_lookup_int",
197+
"fetch_lookup_data",
198+
"rpc_parse"
231199
)

src/main/kotlin/com/vk/kphpstorm/typeProviders/FunctionsTypeProvider.kt

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,30 +62,86 @@ class FunctionsTypeProvider : PhpTypeProvider4 {
6262
// "array_find" to "manual",
6363

6464
// php stdlib functions which return type is different from kphp's one
65+
"ob_clean" to "void",
66+
"ob_get_contents" to "string",
67+
"print_r" to "string",
68+
"ob_start" to "void",
69+
"ob_flush" to "void",
70+
"sort" to "void",
71+
"rsort" to "void",
72+
"usort" to "void",
73+
"asort" to "void",
74+
"arsort" to "void",
75+
"uasort" to "void",
76+
"ksort" to "void",
77+
"krsort" to "void",
78+
"uksort" to "void",
79+
"natsort" to "void",
80+
"openssl_pkey_get_private" to "string|false",
81+
"openssl_pkey_get_public" to "string|false",
82+
"openssl_verify" to "int",
83+
"openssl_random_pseudo_bytes" to "string|false",
84+
"openssl_x509_parse" to "kmixed[]|false",
85+
"openssl_x509_checkpurpose" to "kmixed",
86+
"openssl_get_cipher_methods" to "string[]",
87+
"headers_list" to "string[]",
88+
"hash_algos" to "string[]",
89+
"hash_hmac_algos" to "string[]",
90+
"setcookie" to "void",
91+
"setrawcookie" to "void",
92+
"ini_set" to "bool",
6593
"bcdiv" to "string",
6694
"bcmod" to "string",
6795
"get_class" to "string",
6896
"date" to "string",
6997
"gmdate" to "string",
7098
"hex2bin" to "string",
71-
"pack" to "string",
7299
"ob_get_contents" to "string",
73100
"substr_replace" to "string",
74101
"var_export" to "string",
75102
"explode" to "string[]",
76103
"unserialize" to "kmixed", // not 'mixed'
77104
"json_decode" to "kmixed",
105+
"error_get_last" to "kmixed",
78106
"mysqli_query" to "kmixed",
79107
"getimagesize" to "kmixed",
80108
"array_rand" to "kmixed",
81109
"parse_url" to "kmixed",
82110
"preg_replace" to "kmixed",
83111
"preg_replace_callback" to "kmixed",
112+
"array_merge_recursive" to "kmixed[]",
113+
"array_search" to "kmixed",
114+
"array_keys" to "kmixed[]",
115+
"array_flip" to "kmixed[]",
116+
"range" to "kmixed[]",
117+
"getdate" to "kmixed[]",
118+
"localtime" to "kmixed[]",
119+
"gmmktime" to "int",
120+
"microtime" to "kmixed",
121+
"mktime" to "kmixed",
122+
"strftime" to "string",
123+
"hrtime" to "kmixed",
124+
"date_parse" to "kmixed[]",
125+
"date_parse_from_format" to "kmixed[]",
126+
"debug_backtrace" to "string[][]",
127+
"posix_getpwuid" to "kmixed[]|false",
128+
"getopt" to "kmixed[]|false",
129+
"gethostbynamel" to "string[]|false",
130+
"array_count_values" to "int[]",
131+
"unpack" to "kmixed[]|false",
132+
"array_sum" to "float",
84133
"curl_init" to "int",
85134
"bindec" to "int",
86135
"mysqli_insert_id" to "int",
87136
"floor" to "float",
88137
"round" to "float",
138+
"count_chars" to "kmixed",
139+
"get_magic_quotes_gpc" to "bool",
140+
"php_sapi_name" to "string",
141+
"fgetcsv" to "kmixed[]|false",
142+
"getimagesize" to "kmixed",
143+
"stream_context_create" to "kmixed",
144+
"stream_socket_client" to "kmixed",
89145

90146
// php stdlib functions as replacement of phpstorm.meta.php
91147
"str_replace" to "^3",
@@ -100,6 +156,8 @@ class FunctionsTypeProvider : PhpTypeProvider4 {
100156
"array_diff_assoc" to "^1",
101157
"array_reverse" to "^1",
102158
"array_shift" to "^1[*]",
159+
"max" to "^1[*]",
160+
"abs" to "^1|int",
103161
"array_values" to "^1",
104162
"array_unique" to "^1",
105163
"array_fill" to "^3[]",

0 commit comments

Comments
 (0)