11<?php
22
3+ require_once __DIR__ . '/job-workers.txt';
4+
5+ define('TODO', -1);
6+ define('TODO_OVERLOAD', -1);
7+
8+ define('PHP_INT_MAX', 9223372036854775807);
39define('PHP_INT_MIN', -9223372036854775808);
410define('PHP_INT_SIZE', 8);
511define('PHP_EOL', "\n");
612
13+
714/** @var mixed $_SERVER */
815global $_SERVER;
916/** @var mixed $_GET */
@@ -31,6 +38,7 @@ function strval ($v ::: mixed) ::: string;
3138/** @kphp-extern-func-info interruptible */
3239function exit($code = 0) ::: void;
3340
41+ /** @kphp-extern-func-info interruptible */
3442function die($code = 0) ::: void;
3543
3644function ob_clean() ::: void;
@@ -62,9 +70,6 @@ function is_bool ($v ::: mixed) ::: bool;
6270function is_int ($v ::: mixed) ::: bool;
6371function is_integer ($v ::: mixed) ::: bool;
6472function is_long ($v ::: mixed) ::: bool;
65- function is_finite ($v ::: float) ::: bool;
66- function is_infinite ($v ::: float) ::: bool;
67- function is_nan ($v ::: float) ::: bool;
6873function is_float ($v ::: mixed) ::: bool;
6974function is_double ($v ::: mixed) ::: bool;
7075function is_real ($v ::: mixed) ::: bool;
@@ -76,6 +81,21 @@ function get_hash_of_class (object $klass) ::: int;
7681
7782function strlen ($str ::: string) ::: int;
7883
84+ // === Future =====================================================================================
85+
86+ function get_running_fork_id() ::: future <void>;
87+
88+ /** @kphp-extern-func-info interruptible cpp_template_call */
89+ function wait(future<any> | false $id, float $timeout = -1.0) ::: ^1[*] | null;
90+
91+ // === Fork =======================================================================================
92+
93+ /** @kphp-extern-func-info interruptible */
94+ function sched_yield() ::: void;
95+
96+ /** @kphp-extern-func-info interruptible */
97+ function sched_yield_sleep($duration ::: float) ::: void;
98+
7999// === Rpc ========================================================================================
80100
81101/** @kphp-tl-class */
@@ -120,95 +140,60 @@ function rpc_tl_query_result($query_ids ::: array) ::: mixed[][];
120140/** @kphp-extern-func-info interruptible */
121141function typed_rpc_tl_query_result(int[] $query_ids) ::: @tl\RpcResponse[];
122142
123-
124143// === Component ==================================================================================
125144
126145class ComponentQuery {
127146 private function __construct() ::: \ComponentQuery;
128147}
129148
130149/** @kphp-extern-func-info interruptible */
131- function component_get_http_query( ) ::: void ;
150+ function component_client_send_request($name ::: string, $message ::: string ) ::: ComponentQuery ;
132151
133152/** @kphp-extern-func-info interruptible */
134- function component_client_send_query($name ::: string, $message ::: string) ::: ComponentQuery;
135- /** @kphp-extern-func-info interruptible */
136- function component_client_get_result($query ::: ComponentQuery) ::: string;
153+ function component_client_fetch_response($query ::: ComponentQuery) ::: string;
137154
138155/** @kphp-extern-func-info interruptible */
139- function component_server_get_query() ::: string;
140- /** @kphp-extern-func-info interruptible */
141- function component_server_send_result($message ::: string) ::: void;
142-
143- class ComponentStream {
144- private function __construct() ::: \ComponentStream;
156+ function component_server_accept_query() ::: ComponentQuery;
145157
146- public function is_read_closed() ::: bool;
147- public function is_write_closed() ::: bool;
148- public function is_please_shutdown_write() ::: bool;
149-
150- public function shutdown_write() ::: void;
151- public function please_shutdown_write() ::: void;
152- }
153-
154- function component_open_stream($name ::: string) ::: ComponentStream;
155158/** @kphp-extern-func-info interruptible */
156- function component_accept_stream( ) ::: ComponentStream ;
159+ function component_server_fetch_request($query ::: ComponentQuery ) ::: string ;
157160
158- function component_stream_write_nonblock($stream ::: ComponentStream, $message ::: string) ::: int;
159- function component_stream_read_nonblock($stream ::: ComponentStream) ::: string;
160- /** @kphp-extern-func-info interruptible */
161- function component_stream_write_exact($stream ::: ComponentStream, $message ::: string) ::: int;
162161/** @kphp-extern-func-info interruptible */
163- function component_stream_read_exact($stream ::: ComponentStream, $len ::: int) ::: string;
164-
165- function component_close_stream($stream ::: ComponentStream) ::: void;
166- function component_finish_stream_processing($stream ::: ComponentStream) ::: void;
162+ function component_server_send_response($query ::: ComponentQuery, $message ::: string) ::: void;
167163
168164// === Json =======================================================================================
169165
170- class JsonEncoder {
171- const rename_policy = 'none';
172- const visibility_policy = 'all';
173- const skip_if_default = false;
174- const float_precision = 0;
175-
176- private function __construct();
177-
178- public static function encode(object $instance, int $flags = 0, array $more = []) : string;
179- public static function decode(string $json, string $class_name) : instance<^2>;
180- public static function getLastError() : string;
166+ function json_encode ($v ::: mixed, $options ::: int = 0) ::: string | false;
181167
182- // JsonEncoderOrChild::encode(...) is actually replaced by JsonEncoder::to_json_impl('JsonEncoderOrChild', ...)
183- static function to_json_impl(string $encoder_tag, object $instance, int $flags = 0, array $more = []) ::: string;
168+ function json_decode ($v ::: string, $assoc ::: bool = false) ::: mixed;
184169
185- // JsonEncoderOrChild::decode(...) is actually replaced by JsonEncoder::from_json_impl('JsonEncoderOrChild', ...)
186- /** @kphp-extern-func-info cpp_template_call */
187- static function from_json_impl(string $encoder_tag, string $json, string $class_name) ::: instance<^3>;
188- }
170+ // === Crypto======================================================================================
189171
190- function json_encode ($v ::: mixed, $options ::: int = 0) ::: string | false;
172+ /** @kphp-extern-func-info interruptible */
173+ function openssl_random_pseudo_bytes ($length ::: int) ::: string | false;
191174
192- function json_decode ($v ::: string, $assoc ::: bool = false) ::: mixed;
175+ /** @kphp-extern-func-info interruptible */
176+ function openssl_x509_parse ($x509cert ::: string, $shortnames ::: bool = true) ::: mixed[] | false;
193177
194178// === Misc =======================================================================================
195179
196180/** @kphp-extern-func-info cpp_template_call */
197- function instance_cast(object $instance, $to_type ::: string) ::: instance<^2>;
181+ function instance_cast(any $instance, $to_type ::: string) ::: instance<^2>;
198182
199183function make_clone ($x ::: any) ::: ^1;
200184
201- /** @kphp-extern-func-info interruptible */
202- function testyield() ::: void;
203185function check_shutdown() ::: void;
204186
205187function warning($message ::: string) ::: void;
206188/** @kphp-no-return */
207189function critical_error($message ::: string) ::: void;
208190
209- function debug_print_string($str ::: string) ::: void;
191+ /** @kphp-extern-func-info interruptible */
192+ function set_timer(int $timeout, callable():void $callback) ::: void;
210193
211- function byte_to_int($str ::: string) ::: ?int;
212- function int_to_byte($v ::: int ) ::: ?string ;
194+ // builtin that allows to store objects inside a mixed
195+ function to_mixed(object $instance ) ::: mixed ;
213196
214- function set_timer(int $timeout, callable():void $callback) ::: void;
197+ // === Unsupported =======================================================================================
198+
199+ require_once __DIR__ . '/unsupported-functions.txt';
0 commit comments