-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add stabs for unsupported whitelisted functions (#1078)
Add new @kphp-extern-func-info tag `generate-stub` to ask compiler to generate body of function with call to php_critical_error Also add some template stubs in runtime headers
- Loading branch information
1 parent
6e4dcaf
commit 5747f48
Showing
39 changed files
with
1,970 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
require_once __DIR__ . '/unsupported/arrays.txt'; | ||
require_once __DIR__ . '/unsupported/crypto.txt'; | ||
require_once __DIR__ . '/unsupported/curl.txt'; | ||
require_once __DIR__ . '/unsupported/error.txt'; | ||
require_once __DIR__ . '/unsupported/file.txt'; | ||
require_once __DIR__ . '/unsupported/fork.txt'; | ||
require_once __DIR__ . '/unsupported/hash.txt'; | ||
require_once __DIR__ . '/unsupported/job-worker.txt'; | ||
require_once __DIR__ . '/unsupported/kml.txt'; | ||
require_once __DIR__ . '/unsupported/kphp-toggles.txt'; | ||
require_once __DIR__ . '/unsupported/kphp-tracing.txt'; | ||
require_once __DIR__ . '/unsupported/kphp_internal.txt'; | ||
require_once __DIR__ . '/unsupported/math.txt'; | ||
require_once __DIR__ . '/unsupported/regex.txt'; | ||
require_once __DIR__ . '/unsupported/rpc.txt'; | ||
require_once __DIR__ . '/unsupported/serialize.txt'; | ||
require_once __DIR__ . '/unsupported/server.txt'; | ||
require_once __DIR__ . '/unsupported/string.txt'; | ||
require_once __DIR__ . '/unsupported/time.txt'; | ||
require_once __DIR__ . '/unsupported/vkext.txt'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<?php | ||
|
||
function create_vector ($n ::: int, $x ::: any) ::: ^2[]; | ||
|
||
function getKeyByPos ($a ::: array, $n ::: int) ::: mixed; | ||
function getValueByPos ($a ::: array, $n ::: int) ::: ^1[*]; | ||
|
||
function array_first_key ($a ::: array) ::: mixed; | ||
function array_key_first($a ::: array): mixed; | ||
function array_first_value ($a ::: array) ::: ^1[*]; | ||
function array_last_key ($a ::: array) ::: mixed; | ||
function array_key_last($a ::: array): mixed; | ||
function array_last_value ($a ::: array) ::: ^1[*]; | ||
function array_swap_int_keys (&$a ::: array, $idx1 ::: int, $idx2 ::: int) ::: void; | ||
|
||
function array_chunk ($a ::: array, $chunk_size ::: int, $preserve_keys ::: bool = false) ::: ^1[]; | ||
|
||
function array_splice (&$a ::: array, $offset ::: int, $length ::: int, $replacement ::: array = array()) ::: ^1; | ||
/** @kphp-extern-func-info cpp_template_call */ | ||
function array_merge ($a1 ::: array, $a2 ::: array = array(), $a3 ::: array = array(), | ||
$a4 ::: array = array(), $a5 ::: array = array(), $a6 ::: array = array(), | ||
$a7 ::: array = array(), $a8 ::: array = array(), $a9 ::: array = array(), | ||
$a10 ::: array = array(), $a11 ::: array = array(), $a12 ::: array = array()) | ||
::: ^1 | ^2 | ^3 | ^4 | ^5 | ^6 | ^7 | ^8 | ^9 | ^10 | ^11 | ^12; | ||
/** | ||
* @kphp-extern-func-info cpp_template_call cpp_variadic_call | ||
* @kphp-pure-function | ||
*/ | ||
function array_merge_recursive (...$a) ::: mixed[]; | ||
function array_merge_into (&$a ::: array, $another_array ::: array) ::: void; | ||
/** @kphp-extern-func-info cpp_template_call */ | ||
function array_merge_spread ($a1 ::: array, $a2 ::: array = array(), $a3 ::: array = array(), | ||
$a4 ::: array = array(), $a5 ::: array = array(), $a6 ::: array = array(), | ||
$a7 ::: array = array(), $a8 ::: array = array(), $a9 ::: array = array(), | ||
$a10 ::: array = array(), $a11 ::: array = array(), $a12 ::: array = array()) | ||
::: ^1 | ^2 | ^3 | ^4 | ^5 | ^6 | ^7 | ^8 | ^9 | ^10 | ^11 | ^12; | ||
/** @kphp-extern-func-info cpp_template_call */ | ||
function array_replace ($base_array ::: array, | ||
$replacements_1 ::: array = array(), $replacements_2 ::: array = array(), $replacements_3 ::: array = array(), | ||
$replacements_4 ::: array = array(), $replacements_5 ::: array = array(), $replacements_6 ::: array = array(), | ||
$replacements_7 ::: array = array(), $replacements_8 ::: array = array(), $replacements_9 ::: array = array(), | ||
$replacements_10 ::: array = array(), $replacements_11 ::: array = array()) | ||
::: ^1 | ^2 | ^3 | ^4 | ^5 | ^6 | ^7 | ^8 | ^9 | ^10 | ^11 | ^12; | ||
function array_intersect_key ($a1 ::: array, $a2 ::: array) ::: ^1; | ||
function array_intersect ($a1 ::: array, $a2 ::: array) ::: ^1; | ||
function array_intersect_assoc ($a1 ::: array, $a2 ::: array, $a3 ::: array = TODO) ::: ^1; | ||
function array_diff_key ($a1 ::: array, $a2 ::: array) ::: ^1; | ||
function array_diff ($a1 ::: array, $a2 ::: array, $a3 ::: array = TODO) ::: ^1; | ||
function array_diff_assoc ($a1 ::: array, $a2 ::: array, $a3 ::: array = TODO) ::: ^1; | ||
function array_reverse ($a ::: array, $preserve_keys ::: bool = false) ::: ^1; | ||
function array_shift (&$a ::: array) ::: ^1[*]; | ||
function array_unshift (&$a ::: array, $val ::: any) ::: int; | ||
function array_key_exists ($v ::: any, $a ::: array) ::: bool; | ||
function array_search ($val ::: any, $a ::: array, $strict ::: bool = false) ::: mixed; | ||
function array_find ($val ::: array, callable(^1[*] $x):bool $callback) ::: tuple(mixed, ^1[*]); | ||
function array_rand ($a ::: array, $num ::: int = 1) ::: mixed; | ||
function array_keys ($a ::: array) ::: mixed[]; | ||
function array_keys_as_strings ($a ::: array) ::: string[]; | ||
function array_keys_as_ints ($a ::: array) ::: int[]; | ||
function array_values ($a ::: array) ::: ^1; | ||
function array_unique ($a ::: array, int $flags = SORT_STRING) ::: ^1; | ||
function array_count_values ($a ::: array) ::: int[]; | ||
function array_flip ($a ::: array) ::: mixed[]; | ||
function in_array ($value ::: any, $a ::: array, $strict ::: bool = false) ::: bool; | ||
function array_fill ($start_index ::: int, $num ::: int, $value ::: any) ::: ^3[]; | ||
function array_fill_keys ($a ::: array, $value ::: any) ::: ^2[]; | ||
function array_combine ($keys ::: array, $values ::: array) ::: ^2; | ||
function range ($from, $to, $step ::: int = 1) ::: mixed[];//TODO | ||
function array_push (&$a ::: array, $val2 ::: any, $val3 ::: any = TODO, $val4 ::: any = TODO, $val5 ::: any = TODO, $val6 ::: any = TODO) ::: int; | ||
function array_pop (&$a ::: array) ::: ^1[*]; | ||
function array_sum ($a ::: array) ::: float;//TODO | ||
function array_slice ($a ::: array, $offset ::: int, $length = null, $preserve_keys ::: bool = false) ::: ^1; | ||
/** @kphp-extern-func-info cpp_template_call */ | ||
function array_pad ($a ::: array, $size ::: int, $value ::: any) ::: array< ^1[*] | ^3 >; | ||
function array_column ($a ::: array, $column_key, $index_key = null) ::: array< ^1[*][*] > | false; | ||
function array_unset (&$a ::: array, any $key) ::: ^1[*]; | ||
|
||
function array_filter ($a ::: array, callable(^1[*] $x):bool $callback = TODO) ::: ^1; | ||
function array_filter_by_key ($a ::: array, callable(mixed $key):bool $callback) ::: ^1; | ||
function array_map (callable(^2[*] $x):any $callback, $a ::: array) ::: ^1() []; | ||
/** @kphp-extern-func-info cpp_template_call */ | ||
function array_reduce ($a ::: array, callable(^3 | ^2() $carry, ^1[*] $item):any $callback, $initial ::: any) ::: ^2() | ^3; | ||
function array_reserve (&$a ::: array, $int_size ::: int, $string_size ::: int, $make_vector_if_possible ::: bool) ::: void; | ||
function array_reserve_vector (&$a ::: array, $size ::: int) ::: void; | ||
function array_reserve_map_int_keys (&$a ::: array, $size ::: int) ::: void; | ||
function array_reserve_map_string_keys (&$a ::: array, $size ::: int) ::: void; | ||
function array_reserve_from (&$a ::: array, $base ::: array) ::: void; | ||
function array_is_vector ($a ::: array) ::: bool; | ||
function array_is_list ($a ::: array) ::: bool; | ||
|
||
define('SORT_REGULAR', 0); | ||
define('SORT_NUMERIC', 1); | ||
define('SORT_STRING', 2); | ||
|
||
function asort (&$a ::: array, $flag ::: int = SORT_REGULAR) ::: void; | ||
function arsort (&$a ::: array, $flag ::: int = SORT_REGULAR) ::: void; | ||
function ksort (&$a ::: array, $flag ::: int = SORT_REGULAR) ::: void; | ||
function krsort (&$a ::: array, $flag ::: int = SORT_REGULAR) ::: void; | ||
function natsort (&$a ::: array) ::: void; | ||
function rsort (&$a ::: array, $flag ::: int = SORT_REGULAR) ::: void; | ||
function shuffle (&$a ::: array) ::: void; | ||
function sort (&$a ::: array, $flag ::: int = SORT_REGULAR) ::: void; | ||
function uasort (&$a ::: array, callable(^1[*] $x, ^1[*] $y):int $callback) ::: void; | ||
function uksort (&$a ::: array, callable(mixed $x, mixed $y):int $callback) ::: void; | ||
function usort (&$a ::: array, callable(^1[*] $x, ^1[*] $y):int $callback) ::: void; | ||
|
||
|
||
/** @kphp-extern-func-info cpp_template_call */ | ||
function vk_dot_product ($a ::: array, $b ::: array) ::: ^1[*] | ^2[*]; | ||
|
||
|
||
function to_array_debug(any $instance, bool $with_class_names = false) ::: mixed[]; | ||
|
||
function implode ($s ::: string, $v ::: array) ::: string; | ||
|
||
/** @kphp-extern-func-info generate-stub */ | ||
function explode ($delimiter ::: string, $str ::: string, $limit ::: int = PHP_INT_MAX) ::: string[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
|
||
define('X509_PURPOSE_SSL_CLIENT' , 1); | ||
define('X509_PURPOSE_SSL_SERVER' , 2); | ||
define('X509_PURPOSE_NS_SSL_SERVER' , 3); | ||
define('X509_PURPOSE_SMIME_SIGN' , 4); | ||
define('X509_PURPOSE_SMIME_ENCRYPT' , 5); | ||
define('X509_PURPOSE_CRL_SIGN' , 6); | ||
define('X509_PURPOSE_ANY' , 7); | ||
define('X509_PURPOSE_OCSP_HELPER' , 8); | ||
define('X509_PURPOSE_TIMESTAMP_SIGN', 9); | ||
|
||
define('OPENSSL_ALGO_SHA1' , 1); | ||
define('OPENSSL_ALGO_MD5' , 2); | ||
define('OPENSSL_ALGO_MD4' , 3); | ||
define('OPENSSL_ALGO_MD2' , 4); | ||
define('OPENSSL_ALGO_DSS1' , 5); | ||
define('OPENSSL_ALGO_SHA224', 6); | ||
define('OPENSSL_ALGO_SHA256', 7); | ||
define('OPENSSL_ALGO_SHA384', 8); | ||
define('OPENSSL_ALGO_SHA512', 9); | ||
define('OPENSSL_ALGO_RMD160', 10); | ||
|
||
define('OPENSSL_RAW_DATA', 1); | ||
define('OPENSSL_ZERO_PADDING', 2); | ||
define('OPENSSL_DONT_ZERO_PAD_KEY', 4); | ||
|
||
/** @kphp-extern-func-info generate-stub */ | ||
function openssl_public_encrypt ($data ::: string, &$result ::: mixed, $key ::: string) ::: bool; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function openssl_private_decrypt ($data ::: string, &$result ::: mixed, $key ::: string) ::: bool; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function openssl_pkey_get_private ($key ::: string, $passphrase ::: string = '') ::: string | false; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function openssl_pkey_get_public ($key ::: string) ::: string | false; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function openssl_sign ($data ::: string, &$signature ::: string, $priv_key_id ::: string, $signature_alg ::: int = 1) ::: bool; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function openssl_verify ($data ::: string, $signature ::: string, $pub_key_id ::: string, $signature_alg ::: int = 1) ::: int; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function openssl_random_pseudo_bytes ($length ::: int) ::: string | false; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function openssl_x509_parse ($x509cert ::: string, $shortnames ::: bool = true) ::: mixed[] | false; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function openssl_x509_verify ($x509cert ::: string, $public_key ::: string) ::: int; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/** @kphp-extern-func-info generate-stub */ | ||
function curl_init ($url ::: string = "") ::: int; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function curl_reset ($curl_handle ::: int) ::: void; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function curl_setopt ($curl_handle ::: int, $option ::: int, $value ::: mixed) ::: bool; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function curl_setopt_array ($curl_handle ::: int, $options ::: array) ::: bool; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function curl_exec ($curl_handle ::: int) ::: mixed; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function curl_getinfo ($curl_handle ::: int, $option ::: int = 0) ::: mixed; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function curl_error ($curl_handle ::: int) ::: string; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function curl_errno ($curl_handle ::: int) ::: int; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function curl_close ($curl_handle ::: int) ::: void; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function curl_exec_concurrently($curl_handle ::: int, $timeout ::: float = 1.0): string|false; | ||
|
||
/** @kphp-extern-func-info generate-stub */ | ||
function curl_multi_init () ::: int; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function curl_multi_add_handle ($multi_handle ::: int, $curl_handle ::: int) ::: int|false; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function curl_multi_getcontent ($curl_handle ::: int ) ::: string|false|null; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function curl_multi_setopt ($multi_handle ::: int, $option ::: int, $value ::: int) ::: bool; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function curl_multi_exec ($multi_handle ::: int, &$still_running ::: int) ::: int|false; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function curl_multi_select ($multi_handle ::: int, $timeout ::: float = 1.0) ::: int|false; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function curl_multi_info_read ($multi_handle ::: int, &$msgs_in_queue ::: int = TODO) ::: int[]|false; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function curl_multi_remove_handle ($multi_handle ::: int, $curl_handle ::: int) ::: int|false; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function curl_multi_errno ($multi_handle ::: int) ::: int|false; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function curl_multi_close ($multi_handle ::: int) ::: void; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function curl_multi_strerror ($errornum ::: int) ::: string|null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
interface Throwable { | ||
public function getMessage () ::: string; | ||
public function getCode () ::: int; | ||
public function getFile () ::: string; | ||
public function getLine () ::: int; | ||
public function getTrace () ::: string[][]; | ||
public function getTraceAsString () ::: string; | ||
} | ||
|
||
class Exception implements Throwable { | ||
protected $message = ''; | ||
protected $code = 0; | ||
/** @var string */ | ||
protected $file; | ||
/** @var int */ | ||
protected $line; | ||
|
||
public function __construct($message ::: string = '', $code ::: int = 0) ::: Exception; | ||
final public function getMessage () ::: string; | ||
final public function getCode () ::: int; | ||
final public function getFile () ::: string; | ||
final public function getLine () ::: int; | ||
final public function getTrace () ::: string[][]; | ||
final public function getTraceAsString () ::: string; | ||
|
||
final private function __clone() ::: void; | ||
} | ||
|
||
|
||
class Error implements Throwable { | ||
protected $message = ''; | ||
protected $code = 0; | ||
/** @var string */ | ||
protected $file; | ||
/** @var int */ | ||
protected $line; | ||
|
||
public function __construct($message ::: string = '', $code ::: int = 0) ::: Error; | ||
final public function getMessage () ::: string; | ||
final public function getCode () ::: int; | ||
final public function getFile () ::: string; | ||
final public function getLine () ::: int; | ||
final public function getTrace () ::: string[][]; | ||
final public function getTraceAsString () ::: string; | ||
|
||
final private function __clone() ::: void; | ||
} | ||
|
||
/** @kphp-extern-func-info generate-stub */ | ||
function err ($file ::: string, $line ::: int, $code ::: string, $desc ::: string = '') ::: Exception; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function error_get_last() ::: mixed; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function error_reporting ($e ::: int = TODO) ::: int; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function kphp_backtrace($pretty ::: bool = true) ::: string[]; | ||
/** @kphp-extern-func-info generate-stub */ | ||
function kphp_set_context_on_error(mixed[] $tags, mixed $extra_info, string $env = "") ::: void; | ||
|
Oops, something went wrong.