tuple is corresponding key (null if not exists).
tuple is a found value (empty T if not exists).
array_filter() in KPHP doesn't accept
ARRAY_FILTER_USE_KEY, it's an alternative.
(as support of ARRAY_FILTER_USE_KEY can't be done without callback argument type spoiling)
Reserve array memory — if you know in advance, how many elements will be inserted to it.
Effectife especially for vectors, as there will be no reallocations on insertion.
$arr — target array (typically empty)
$int_keys_num — number of int keys
$str_keys_num — number of string keys
$is_vector — should it be a vector (if $str_keys_num is 0)
The same as
array_reserve(), but takes all sizes (length, key type, is vector) from array $base.
Read about coroutines (forks).
Read about TL schema and RPC calls.
Read about shared memory.
Returns an array
["$var_name" => size_in_bytes]
Don't use it in production — only to debug, which globals/statics allocate huge pieces of memory.
While compiling, a special env variable should be set:
Returns currently used and dirty memory (in bytes).
Returns heap memory usage (system heap, not script allocator) (in bytes).
Read about serialization and msgpack.
Read about embedded profiler.
Same as PHP
trigger_error($str, E_USER_WARNING); (KPHP doesn't have a trigger_error() function).
Useful for dev purposes: this callback is invoked when a runtime warning occurs.
It can be shown on screen for the developer, for example.
Do not use it in production! Use json log analyzer and trace C++ → PHP mapper instead.
$callback is invoked with 2 arguments: 1) $message: warning text; 2) $stacktrace: function names demangled from cpp trace, even without debug symbols — but slow, only for dev
Like register_kphp_on_warning_callback(), but it is not linked to any runtime error: instead, it allows getting current demangled backtrace at the execution point.
Note! Demangling works slowly, don't use it in high-loaded places!
Defines a context for runtime warnings (to be written to json error logs).
$tags — key-value tags (treated like an aggregate)
$extra_info — key-value extra arbitrary data (not an aggregator)
$env — environment (e.g.: staging / production)
Special intrinsic to wrap conditions inside if, like
if (likely($x > 10)) — when you suppose that condition is much likely to happen than not (unlikely() is vice versa).
This can slightly pre-warm the CPU branch predictor.
All these functions work in plain PHP also — they are polyfilled to behave exactly like KPHP’s built-in.