What's new? (Versions history)


  • Modulite + Composer integration
  • allow unpacking into positional arguments f(...[1,2]) for function f($x,$y)
  • reorder class fields at codegeneration considering C++ fields padding to reduce object size
  • class DateTime
  • added argument $rest_index to getopt()
  • added strspn() and strcspn()
  • optimize switch codegen if all cases are constant strings/ints
  • compatible with leak sanitizer
  • optimize strtolower() and strtoupper() to produce less allocations
  • g++ is launched with -O2 by default


  • FFI callbacks supported, Lua modules can now be embedded (doc)
  • added ignore_user_abort() to prevent script terminations in distributed transactions
  • constants with leading slash now work
  • parse array<int, string> in phpdocs, type of key is just dropped off
  • added stripcslashes()
  • added argument $scale to bcpow() and bcmod()
  • whitespace identation at heredoc/nowdoc
  • class ArrayIterator (for mixed[] arrays only)
  • dirname() works inside require when compile-time resolved
  • support psr-0 autoload in composer.json


  • generic functions @kphp-generic: next gen template functions (doc)
  • deprecate @kphp-template, @kphp-param, and @kphp-return
  • support Modulite inside kphp (everything except composer)
  • http 103 headers, send_http_103_early_hints()
  • added array_is_list()
  • added instance_deserialize_safe() and instance_serialize_safe()


  • reduce binary size with debug symbols by embedding common template specializations at runtime compilation
  • JsonEncoder and @kphp-json (doc)
  • FFI improvements: nested pointers, arrays, native strings
  • added argument $offset to preg_match_all()
  • unpack() returns false on error


  • shutdown functions are invoked even after script timeout
  • embedded msgpack instead of an external dependency
  • pack() and unpack() support e and E formats


  • some optimizations reducing binary size for vkcom
  • microtime(true) returns float (support specializations for built-in functions)
  • added date_parse() and date_parse_from_format()
  • added option --sigterm-wait-time


  • better CPU utilization (NUMA, CPU affinity, multiple socket backlogs)
  • added class CompileTimeLocation (doc)
  • added array_unset($arr, $key)
  • added memory_get_allocations() to be used in ktest
  • intval() ingores spaces at string start
  • on json encoding error, output a full path to that key
  • compatible with clang++-11
  • support FFI pointers (doc)


  • added to_array_debug(object|tuple|shape)
  • handle phpdoc above lambdas
  • better deal with phpdoc/typehints mixture on inheritance
  • MySQL resumable support and basic PDO implementation
  • callbacks passed to internal functions restricted to be resumable
  • optimize phpdoc parsing
  • added str_starts_with() and str_ends_with()


  • use lld instead of ld for partial linking
  • support indexing in constants declaration
  • fire compilation errors for invalid indexing typing
  • some changes in precompiled headers for nocc integration
  • added array_merge_recursive()


  • lambdas re-implemented completely, almost all relative issues resolved
  • template functions re-implemented completely, almost all relative issues resolved
  • a new syntax for @kphp-template, we're heading towards generics
  • argument $flags in array_unique()


  • output some metrics to statshouse instead of grafana
  • $exception->getFile() returns relative paths for stable codegen in TeamCity
  • Exception and other built-in classes became copyable into shared memory
  • KPHP can now be compiled for Apple M1


  • fix a race condition in KphpJobWorkerMemoryPiece
  • initial FFI support (doc)


  • dropped Jessie support, C++ 17 is available for development
  • full UTF-8 and complex emoji support
  • increased http server limits
  • existing bcmath functions work like PHP in corner cases


  • added set_migration_php8_warning($bitmask) that will trigger warnings on PHP 7/8 behavior mismatch
  • some fixes around sigsegv in kubernetes restart


  • links to equal instances remain after copying to shared memory
  • supported copying hierarchical classes to shared memory
  • smart casts for ternary expressions


  • spread operator ...$array
  • numeric literal separator: 107_925_284.88
  • all tests correctly work with PHP 7.4


  • job workers released: separate processes working in parallel with http workers (doc)


  • use shared memory instead of pipes for stats collecting from workers into master
  • some compile-time optimizations
  • added str_ireplace()
  • added constants M_E, M_PI_2, and similar
  • support for token INF


  • fix memory leak in curl library for long-running processes
  • support __toString() magic method
  • beta version of job workers
  • compatible with g++-11
  • generate pch header for clang, same as gch for g++


  • lots of codegeneration optimizations, 20% speedup for vkcom
  • colored functions @kphp-color (doc)
  • some fixes around lambdas, interfaces and traits
  • consider type hints compatibility on inheritance, the same way as PHP does


  • reorganized runtime code to achieve more accurate cpp backtraces in Sentry
  • strtotime() now behaves exactly like in PHP due to integrated timelib
  • support zstd functions
  • @kphp-warn-performance above classes (doc)


  • support field type hints in classes
  • declare(strict_types=1) prevents auto casts passing arguments to built-in functions
  • a bit more exact typing for built-in preg functions
  • strip_tags() supports self-closing tags like
  • hash() and hash_hmac() support sha224, sha384, sha512
  • added hash_hmac_algos()
  • pseudo-vectors encoded as regular vectors in msgpack serialization


  • significant reduced memory consumption for large codebases
  • void functions are forbidden to fork, future<void|null> is invalid
  • introduced set_wait_all_forks_on_finish()
  • aliases for array_reserve() (for vector, map int keys, map string keys)
  • added acosh(), asin(), asinh(), cosh(), sinh(), rad2deg()
  • support dereferencing like "asdf"[$i] and (function(){...})()


  • pretty errors and call stack on type mismatch
  • prevent chain reaction polluting types on type mismatch when restricted by phpdoc
  • exception inheritance
  • all standard exception classes implemented, including Error and Throwable
  • @kphp-throws and @kphp-should-not-throw annotations
  • significant codegeneration speedup for large codebases
  • to_array_debug() accepts the second argument bool $with_classnames=false
  • added hrtime()
  • parse_url() behaves like PHP 7.4


  • @return now infers the type, not just checks it
  • union type hints and mixed type hint are now valid not only in phpdoc
  • @kphp-serialized-float32 annotation above fields for msgpack (4 bytes, not 8)
  • compatible with MacOS


  • json logs are also written from signal handlers and uncaught exceptions
  • @kphp-analyze-performance and @kphp-warn-performance (doc)
  • finalization of 64 bit support
  • correctly handle calls with a leading slash \funcName()
  • correctly handle "${var}" interpolation (previously, only "{$var}" worked)


  • TL Long is now int at codegen, not mixed
  • use critical sections around OpenSSL runtime


  • SIGTERM invokes graceful shutdown
  • dropped polyfills from the repo, use Composer
  • now $a->b and $a[$i] are supported inside double quotes and HEREDOC


  • composer.json and PSR-4 autoload
  • added gzdeflate() and gzinflate()


  • Uber H3 support in KPHP and vkext
  • CMake build
  • added openssl_pkcs7_sign()
  • fixed profiler and resumable functions called from different contexts
  • profiler reports from different workers can be merged with QCacheGrind


  • typed callables
  • an embedded profiler
  • fixed template functions and instances in non-template params
  • int64 in Protobuf


  • all functions must be typed if KPHP_REQUIRE_FUNCTIONS_TYPING
  • mt_rand() uses Mersenne Twister
  • added filectime(), filemtime()
  • added kphp_backtrace()


  • KPHP is now 64-bit
  • func_get_args() not supported anymore


  • if a field has no @var, use its default value for inferring
  • all class fields must be typed if KPHP_REQUIRE_CLASS_TYPING
  • ?: and ?? correctly infer instances without PHPDocs


  • smart casts, not_null(), not_false()
  • added array_filter_by_key()
  • a pretty table after compilation with a big verbosity
  • more CURLINFO_ options
  • added hash_equals()
  • reduces compiled binary size
  • automatically inline simple functions
  • instance fields inited by an empty string or an empty array use default C++ constructors


  • multiple implements, extends and implements simultaneously
  • less limitations __construct() and extends
  • ?T in PHPDoc
  • instance cache optimizations: fewer locks in the allocator
  • codegeneration and TypeData optimizations
  • serializable classes now can implement interfaces
  • don't generate const references for primitives
  • @kphp-should-not-throw now outputs a whole chain, why a functions throws


  • HTTP/2 and gRPC client


  • mix lambdas and interfaces with __invoke()
  • float type in TL
  • fixed various hangs due to multithreading


  • shapes: named tuples
  • binary serialization, msgpack, @kphp-serializable
  • more compilation errors on strange type casts


  • added array_find()
  • removed /*:=...*/ syntax: use PHPDoc
  • named bits in typed tl with fields_mask.N?%True syntax
  • JSON error logs
  • NAN support


  • PHP 7 support
  • options for ini_get() with a file, not just command-line
  • auth basic support
  • automatic allocator defragmentation on memory limit
  • SIMD number to string algorithm


  • @kphp-should-not-throw annotation
  • array_is_vector() + @kphp-flatten + const array<T>& pattern analyzing


  • false can not be assigned to instances from now
  • KPHP as an RPC server (microservices)
  • support new static
  • fastmod and arrays internals
  • @kphp-flatten annotation
  • instance_cache_update_ttl() to more accurate shared memory defragmentation control


  • PHPDoc for local and global variables, supports variables splitting


  • added curl_multi_...() functions
  • added array_merge_into()
  • @kphp-warn-unused-result annotation
  • const references in read-only parameters in C++ codegeneration


  • null supported with instances
  • optimized interface/abstract calls dispatching


  • Optional<T> = T|false|null (before, there was an *OrFalse*, but *null* leaded to *mixed*)


  • changes in behavior to seem more like PHP 7
  • spaces inside tuples and other complex PHPDoc types
  • added register_kphp_on_warning_callback()
  • added get_global_vars_memory_stats()


  • traits, with minor limitations
  • added array_replace()
  • array_map(‘intval', $arr) now int[], not mixed[]


  • typed RPC (about a year of development)
  • final / abstract
  • indexfile and codegeneration speedup
  • more metrics to grafana
  • added array_keys_as_ints(), array_keys_as_strings() as typed array_keys()


  • shared memory between workers (instance cache)
  • fixes around extends


  • extends, with the main limitation: either extends or (one) implements
  • array type hint
  • added array_first_key() and similar
  • added array_reserve_from()
  • added wait_multi() for an array of resumables
  • spaceship operator <=>
  • pack and unpack support J/P/Q formats
  • supported PHP_QUERY_RFC3986 in http_build_query()
  • fixed PHPDoc and variadic args
  • various bugfixes and improvements


  • fork() returns future<T> (before this update it was mixed)
  • instances and tuples can be returned from forks
  • wait_queue is future_queue<T>
  • @kphp-infer annotations above classes (like it's above all methods)
  • empty classes optimizations
  • added openssl_sign(), headers_list()
  • added HEAD HTTP method


  • to_array_debug()
  • smart instanceof
  • __FUNCTION__ and others
  • script allocator refactoring
  • require __DIR__ . '/some.php' now works
  • parse_url() works like in PHP 7
  • deny changing fields/methods visibility on inheritance


  • Interfaces enhancements
  • @kphp-immutable-class annotation
  • @kphp-const annotation
  • a progress bar while compilation
  • for array_pop() and others, no PHPDoc required for instances
  • network refactoring


  • interface / implements, with the current limitation one implements only
  • instance cache inside a worker across scripts invocations (but not across workers)
  • TL codegeneration — all types and functions are stored/fetched by codegenerated C++ internal classes
  • final keyword supported


  • optimized globals and statics vars reset between script reinitializations


  • variadic functions ...$args
  • patched distcc with precompiled headers (not open-sourced yet)
  • clone keyword support with __clone() magic method
  • ddded sched_yield_sleep()
  • PHPDoc of static fields is now also analyzed
  • @kphp-return tag for template functions
  • void functions support (before this update, they were mixed with null inside)


  • @kphp-infer analyzes @return, not only @param
  • tuples supported in PHPDoc (without spaces currently)
  • T|bool in PHPDoc is denied: probably you want T|false
  • callables can accept a string with a function name
  • ddded openssl_get_cipher_methods(), openssl_cipher_iv_length(), openssl_encrypt(), openssl_decrypt()
  • support several classes in a file (non-autoloadable classes can be created only within the declaring file)
  • @kphp-inline functions can now have static variables
  • deny equal use statements at the top of the file
  • abs() function is correctly typed, not mixed
  • various fixes and improvements, as usual


  • use inside lambdas (only by value)
  • added array_diff_assoc(), array_intersect_assoc(), array_column()
  • check all static fields to either have a default value or be inferred as mixed
  • check all callbacks passed to built-in functions return a correct type and be exceptionless
  • more correct stack traces accessed from forks
  • power operator ** support


  • callable keyword support as function arguments
  • lambdas support (without capturing by use yet)
  • callbacks passed to built-in functions correctly infer types of arrays
  • === 0/0.0/false/''/[] does not force mixed
  • added openssl_pkey_get_public()
  • tuples can now be used inside forks
  • more heuristics of classes detection to write less PHPDoc


  • tuples support
  • @kphp-template functions support
  • added array_pad()
  • lint global keyword usage
  • support ClassName::class
  • read access by index $a[$i] doesn't force $a to be an array (it can be a string)
  • better stack traces when typing restrictions unmet
  • better error messages in various places
  • instances can now be used inside forks


  • check for uninitized variables
  • added openssl_x509_checkpurpose(), openssl_x509_parse()
  • lots of runtime functions behaves like PHP 5.6, not PHP “as happens”


  • PHPDoc of instance fields /** @var */ is analyzed and checked
  • mkdir() accepts $recursive argument
  • const in global scope
  • various bugfixes around instances and circular dependencies recompilation


  • classes with static functions, static fields, and constants
  • static inheritance and late static binding
  • classes with instance fields and methods (no OOP, just structures) and lots of limitations
  • @kphp-infer annotation telling the compiler to analyze PHPDoc

Classes first-version limitations

  • instances are not compatible with mixed
  • access only declared fields, no dynamic fields creation
  • null is unassignable to instances, but false is
  • no magic methods
  • no extends, implements, traits
  • instances are not convertible to arrays
  • you can't pass instances to built-in functions like json_encode() and others accepting mixed
  • $this isn't captured by lambdas passed to built-in functions inside methods
  • sometimes you should hint KPHP with PHPDoc (not all usage patterns recognized)
  • and many minor others


Before 2018, the Changelog was not maintained.