Skip to content

Commit

Permalink
updated builtin functions (#48)
Browse files Browse the repository at this point in the history
* Removed deleted functions from KPHP

* added new kphp native functions

* added new custom handled and native KPHP functions
  • Loading branch information
Hidanio authored Feb 2, 2024
1 parent 57e3b4d commit 7e14df1
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 81 deletions.
128 changes: 48 additions & 80 deletions src/main/kotlin/com/vk/kphpstorm/helpers/KphpNativeFunctions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,23 @@ val KPHP_NATIVE_FUNCTIONS: SortedSet<String> = sortedSetOf(

// from functions.txt — addons to php standard library
"warning",
"require_lib",
"critical_error",
"register_kphp_on_warning_callback",
"register_kphp_on_oom_callback",
"kphp_backtrace",
"kphp_set_context_on_error",
"require_lib",
"kphp_get_runtime_config",
"memory_get_total_usage",
"memory_get_static_usage",
"memory_perform_defragmentation",
"estimate_memory_usage",
"memory_get_detailed_stats",
"memory_get_allocations",
"ffi_memcpy_string",
"ffi_cast_ptr2addr",
"ffi_cast_addr2ptr",
"ffi_array_set",
"ffi_array_get",
"get_global_vars_memory_stats",
"get_net_time",
"get_script_time",
Expand All @@ -46,7 +55,11 @@ val KPHP_NATIVE_FUNCTIONS: SortedSet<String> = sortedSetOf(
"array_keys_as_ints",
"array_swap_int_keys",
"array_reserve",
"array_reserve_vector",
"array_reserve_map_int_keys",
"array_reserve_map_string_keys",
"array_reserve_from",
"array_unset",
"array_is_vector",
"array_filter_by_key",
"vk_utf8_to_win",
Expand All @@ -61,31 +74,16 @@ val KPHP_NATIVE_FUNCTIONS: SortedSet<String> = sortedSetOf(
"vk_sp_to_upper",
"vk_sp_to_lower",
"vk_sp_sort",
"vk_stats_merge_deviation",
"vk_stats_add_deviation",
"vk_stats_decompress_sample",
"vk_stats_merge_samples",
"vk_stats_parse_sample",
"vk_stats_hll_merge",
"vk_stats_hll_count",
"vk_stats_hll_create",
"vk_stats_hll_add",
"vk_dot_product",
"vkext_full_version",
"likely",
"unlikely",
"err",
"fetch_int",
"fetch_UInt",
"fetch_Long",
"fetch_ULong",
"fetch_unsigned_int",
"fetch_long",
"fetch_unsigned_long",
"fetch_unsigned_int_hex",
"fetch_unsigned_long_hex",
"fetch_unsigned_int_str",
"fetch_unsigned_long_str",
"fetch_double",
"fetch_string",
"fetch_string_as_int",
Expand All @@ -100,23 +98,13 @@ val KPHP_NATIVE_FUNCTIONS: SortedSet<String> = sortedSetOf(
"store_start_gzip_pack",
"store_finish_gzip_pack",
"rpc_clean",
"rpc_get_clean",
"rpc_get_contents",
"store_header",
"store_error",
"store_raw",
"store_int",
"store_UInt",
"store_Long",
"store_ULong",
"store_unsigned_int",
"store_long",
"store_unsigned_long",
"store_unsigned_int_hex",
"store_unsigned_long_hex",
"store_double",
"store_string",
"store_many",
"store_finish",
"rpc_send",
"rpc_send_noflush",
Expand All @@ -129,16 +117,8 @@ val KPHP_NATIVE_FUNCTIONS: SortedSet<String> = sortedSetOf(
"rpc_queue_empty",
"rpc_queue_next",
"rpc_queue_next_synchronously",
"rpc_wait_concurrently",
"rpc_wait",
"rpc_wait_multiple",
"rpc_mc_get",
"rpc_mc_multiget",
"rpc_mc_delete",
"rpc_mc_add",
"rpc_mc_set",
"rpc_mc_replace",
"rpc_mc_decrement",
"rpc_mc_increment",
"rpc_mc_parse_raw_wildcard_with_flags_to_array",
"rpc_tl_query_one",
"rpc_tl_query",
Expand All @@ -153,7 +133,6 @@ val KPHP_NATIVE_FUNCTIONS: SortedSet<String> = sortedSetOf(
"typed_rpc_tl_query_result_synchronously",
"rpc_server_fetch_request",
"rpc_server_store_response",
"rpc_get_last_send_error",
"set_fail_rpc_on_int32_overflow",
"wait_multi",
"wait_synchronously",
Expand All @@ -167,49 +146,7 @@ val KPHP_NATIVE_FUNCTIONS: SortedSet<String> = sortedSetOf(
"sched_yield_sleep",
"get_running_fork_id",
"get_fork_stat",
"labs",
"ldiv",
"lmod",
"lpow",
"ladd",
"lsub",
"lmul",
"lshl",
"lshr",
"lnot",
"lor",
"land",
"lxor",
"lcomp",
"new_Long",
"uldiv",
"ulmod",
"ulpow",
"uladd",
"ulsub",
"ulmul",
"ulshl",
"ulshr",
"ulnot",
"ulor",
"uland",
"ulxor",
"ulcomp",
"new_ULong",
"uidiv",
"uimod",
"uipow",
"uiadd",
"uisub",
"uimul",
"uishl",
"uishr",
"uinot",
"uior",
"uiand",
"uixor",
"uicomp",
"new_UInt",
"get_hash_of_class",
"instance_cast",
"instance_to_array",
"instance_cache_fetch",
Expand All @@ -228,4 +165,35 @@ val KPHP_NATIVE_FUNCTIONS: SortedSet<String> = sortedSetOf(
"profiler_is_enabled",
"profiler_set_function_label",
"profiler_set_log_suffix",
"to_array_debug",
"classof",
"curl_exec_concurrently",
"is_kphp_job_workers_enabled",
"get_job_workers_number",
"get_webserver_stats",
"get_kphp_cluster_name",
"kphp_job_worker_start",
"kphp_job_worker_start_multi",
"kphp_job_worker_start_no_reply",
"kphp_job_worker_fetch_request",
"kphp_job_worker_store_response",
"thread_pool_test_load",
"vk_dot_product",
"send_http_103_early_hints",
"dbg_echo",
"crc32_file",
"ip2ulong",
"thread_pool_test_load",
"fetch_int",
"fetch_long",
"fetch_double",
"fetch_float",
"fetch_string",
"fetch_string_as_int",
"fetch_memcache_value",
"fetch_eof",
"fetch_end",
"fetch_lookup_int",
"fetch_lookup_data",
"rpc_parse"
)
Original file line number Diff line number Diff line change
Expand Up @@ -62,30 +62,86 @@ class FunctionsTypeProvider : PhpTypeProvider4 {
// "array_find" to "manual",

// php stdlib functions which return type is different from kphp's one
"ob_clean" to "void",
"ob_get_contents" to "string",
"print_r" to "string",
"ob_start" to "void",
"ob_flush" to "void",
"sort" to "void",
"rsort" to "void",
"usort" to "void",
"asort" to "void",
"arsort" to "void",
"uasort" to "void",
"ksort" to "void",
"krsort" to "void",
"uksort" to "void",
"natsort" to "void",
"openssl_pkey_get_private" to "string|false",
"openssl_pkey_get_public" to "string|false",
"openssl_verify" to "int",
"openssl_random_pseudo_bytes" to "string|false",
"openssl_x509_parse" to "kmixed[]|false",
"openssl_x509_checkpurpose" to "kmixed",
"openssl_get_cipher_methods" to "string[]",
"headers_list" to "string[]",
"hash_algos" to "string[]",
"hash_hmac_algos" to "string[]",
"setcookie" to "void",
"setrawcookie" to "void",
"ini_set" to "bool",
"bcdiv" to "string",
"bcmod" to "string",
"get_class" to "string",
"date" to "string",
"gmdate" to "string",
"hex2bin" to "string",
"pack" to "string",
"ob_get_contents" to "string",
"substr_replace" to "string",
"var_export" to "string",
"explode" to "string[]",
"unserialize" to "kmixed", // not 'mixed'
"json_decode" to "kmixed",
"error_get_last" to "kmixed",
"mysqli_query" to "kmixed",
"getimagesize" to "kmixed",
"array_rand" to "kmixed",
"parse_url" to "kmixed",
"preg_replace" to "kmixed",
"preg_replace_callback" to "kmixed",
"array_merge_recursive" to "kmixed[]",
"array_search" to "kmixed",
"array_keys" to "kmixed[]",
"array_flip" to "kmixed[]",
"range" to "kmixed[]",
"getdate" to "kmixed[]",
"localtime" to "kmixed[]",
"gmmktime" to "int",
"microtime" to "kmixed",
"mktime" to "kmixed",
"strftime" to "string",
"hrtime" to "kmixed",
"date_parse" to "kmixed[]",
"date_parse_from_format" to "kmixed[]",
"debug_backtrace" to "string[][]",
"posix_getpwuid" to "kmixed[]|false",
"getopt" to "kmixed[]|false",
"gethostbynamel" to "string[]|false",
"array_count_values" to "int[]",
"unpack" to "kmixed[]|false",
"array_sum" to "float",
"curl_init" to "int",
"bindec" to "int",
"mysqli_insert_id" to "int",
"floor" to "float",
"round" to "float",
"count_chars" to "kmixed",
"get_magic_quotes_gpc" to "bool",
"php_sapi_name" to "string",
"fgetcsv" to "kmixed[]|false",
"getimagesize" to "kmixed",
"stream_context_create" to "kmixed",
"stream_socket_client" to "kmixed",

// php stdlib functions as replacement of phpstorm.meta.php
"str_replace" to "^3",
Expand All @@ -100,6 +156,8 @@ class FunctionsTypeProvider : PhpTypeProvider4 {
"array_diff_assoc" to "^1",
"array_reverse" to "^1",
"array_shift" to "^1[*]",
"max" to "^1[*]",
"abs" to "^1|int",
"array_values" to "^1",
"array_unique" to "^1",
"array_fill" to "^3[]",
Expand Down

0 comments on commit 7e14df1

Please sign in to comment.