Skip to content

Commit

Permalink
Generate Zend, ext/spl and ext/json optimizer func info from stubs
Browse files Browse the repository at this point in the history
Closes GH-7397
  • Loading branch information
kocsismate committed Aug 25, 2021
1 parent 6e57711 commit bdfe0ab
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 23 deletions.
17 changes: 0 additions & 17 deletions Zend/Optimizer/zend_func_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,7 @@ static uint32_t zend_range_info(const zend_call_info *call_info, const zend_ssa
static const func_info_t old_func_infos[] = {
/* zend */
F1("get_class_vars", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF),
F1("get_declared_traits", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
F1("get_declared_classes", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
F1("get_declared_interfaces", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
F1("get_defined_functions", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ARRAY),
F1("get_defined_vars", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF),
F1("debug_backtrace", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ARRAY),
F1("get_loaded_extensions", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
F1("get_extension_funcs", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),

/* ext/standard */
F1("bin2hex", MAY_BE_STRING),
Expand Down Expand Up @@ -499,11 +492,6 @@ static const func_info_t old_func_infos[] = {
F1("iconv_mime_decode", MAY_BE_FALSE | MAY_BE_STRING),
F1("iconv_mime_decode_headers", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),

/* ext/json */
F1("json_encode", MAY_BE_FALSE | MAY_BE_STRING),
FN("json_decode", MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
F1("json_last_error_msg", MAY_BE_STRING),

/* ext/xml */
F1("xml_error_string", MAY_BE_NULL | MAY_BE_STRING),
F1("xml_parser_get_option", MAY_BE_LONG | MAY_BE_STRING),
Expand Down Expand Up @@ -754,12 +742,7 @@ static const func_info_t old_func_infos[] = {
F1("imageresolution", MAY_BE_TRUE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_LONG),

/* ext/spl */
F1("class_implements", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING),
F1("class_parents", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING),
F1("class_uses", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING),
F1("iterator_to_array", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
F1("spl_classes", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING),
F1("spl_object_hash", MAY_BE_STRING),

};

Expand Down
15 changes: 15 additions & 0 deletions Zend/Optimizer/zend_func_infos.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,21 @@ static const func_info_t func_infos[] = {
F0("restore_error_handler", MAY_BE_TRUE),
FN("set_exception_handler", MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_OBJECT|MAY_BE_NULL),
F0("restore_exception_handler", MAY_BE_TRUE),
F1("get_declared_classes", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
F1("get_declared_traits", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
F1("get_declared_interfaces", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
F1("get_defined_functions", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ARRAY),
F1("get_resource_type", MAY_BE_STRING),
F1("get_loaded_extensions", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
F1("get_defined_constants", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY),
F1("debug_backtrace", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_ARRAY),
F1("get_extension_funcs", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
F1("gc_status", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG),
F1("class_implements", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
F1("class_parents", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
F1("class_uses", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
F1("spl_classes", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING),
F1("spl_object_hash", MAY_BE_STRING),
FN("socket_export_stream", MAY_BE_RESOURCE|MAY_BE_FALSE),
F1("gzopen", MAY_BE_RESOURCE|MAY_BE_FALSE),
#if HAVE_NANOSLEEP
Expand Down Expand Up @@ -38,6 +51,8 @@ static const func_info_t func_infos[] = {
F1("stream_socket_accept", MAY_BE_RESOURCE|MAY_BE_FALSE),
FN("zip_open", MAY_BE_RESOURCE|MAY_BE_LONG|MAY_BE_FALSE),
FN("zip_read", MAY_BE_RESOURCE|MAY_BE_FALSE),
F1("json_encode", MAY_BE_STRING|MAY_BE_FALSE),
F1("json_last_error_msg", MAY_BE_STRING),
FN("oci_new_connect", MAY_BE_RESOURCE|MAY_BE_FALSE),
FN("oci_connect", MAY_BE_RESOURCE|MAY_BE_FALSE),
FN("oci_pconnect", MAY_BE_RESOURCE|MAY_BE_FALSE),
Expand Down
32 changes: 32 additions & 0 deletions Zend/zend_builtin_functions.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,28 @@ function set_exception_handler(?callable $callback) {}
/** @return true */
function restore_exception_handler(): bool {}

/**
* @return array<int, string>
* @refcount 1
*/
function get_declared_classes(): array {}

/**
* @return array<int, string>
* @refcount 1
*/
function get_declared_traits(): array {}

/**
* @return array<int, string>
* @refcount 1
*/
function get_declared_interfaces(): array {}

/**
* @return array<string, array>
* @refcount 1
*/
function get_defined_functions(bool $exclude_disabled = true): array {}

function get_defined_vars(): array {}
Expand All @@ -124,6 +140,10 @@ function get_resource_id($resource): int {}

function get_resources(?string $type = null): array {}

/**
* @return array<int, string>
* @refcount 1
*/
function get_loaded_extensions(bool $zend_extensions = false): array {}

/**
Expand All @@ -132,12 +152,20 @@ function get_loaded_extensions(bool $zend_extensions = false): array {}
*/
function get_defined_constants(bool $categorize = false): array {}

/**
* @return array<int, array>
* @refcount 1
*/
function debug_backtrace(int $options = DEBUG_BACKTRACE_PROVIDE_OBJECT, int $limit = 0): array {}

function debug_print_backtrace(int $options = 0, int $limit = 0): void {}

function extension_loaded(string $extension): bool {}

/**
* @return array<int, string>|false
* @refcount 1
*/
function get_extension_funcs(string $extension): array|false {}

#if ZEND_DEBUG && defined(ZTS)
Expand All @@ -154,4 +182,8 @@ function gc_enable(): void {}

function gc_disable(): void {}

/**
* @return array<string, int>
* @refcount 1
*/
function gc_status(): array {}
2 changes: 1 addition & 1 deletion Zend/zend_builtin_functions_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: c8a0a1e4cfece42832f737b33e317ba88b91fab5 */
* Stub hash: cf84a097dab1a043133faf0b03f002748b3c8eda */

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_version, 0, 0, IS_STRING, 0)
ZEND_END_ARG_INFO()
Expand Down
2 changes: 2 additions & 0 deletions ext/json/json.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

/** @generate-class-entries */

/** @refcount 1 */
function json_encode(mixed $value, int $flags = 0, int $depth = 512): string|false {}

function json_decode(string $json, ?bool $associative = null, int $depth = 512, int $flags = 0): mixed {}

function json_last_error(): int {}

/** @refcount 1 */
function json_last_error_msg(): string {}

interface JsonSerializable
Expand Down
2 changes: 1 addition & 1 deletion ext/json/json_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: d6577c7d27442643c86e51d462f51dd6e677d509 */
* Stub hash: e59995a9cd647f36164468dd2ae4c11239e3405f */

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_json_encode, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0)
Expand Down
23 changes: 20 additions & 3 deletions ext/spl/php_spl.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,25 @@

/** @generate-class-entries */

/** @param object|string $object_or_class */
/**
* @param object|string $object_or_class
* @return array<string, string>|false
* @refcount 1
*/
function class_implements($object_or_class, bool $autoload = true): array|false {}

/** @param object|string $object_or_class */
/**
* @param object|string $object_or_class
* @return array<string, string>|false
* @refcount 1
*/
function class_parents($object_or_class, bool $autoload = true): array|false {}

/** @param object|string $object_or_class */
/**
* @param object|string $object_or_class
* @return array<string, string>|false
* @refcount 1
*/
function class_uses($object_or_class, bool $autoload = true): array|false {}

function spl_autoload(string $class, ?string $file_extensions = null): void {}
Expand All @@ -23,8 +35,13 @@ function spl_autoload_register(?callable $callback = null, bool $throw = true, b

function spl_autoload_unregister(callable $callback): bool {}

/**
* @return array<string, string>
* @refcount 1
*/
function spl_classes(): array {}

/** @refcount 1 */
function spl_object_hash(object $object): string {}

function spl_object_id(object $object): int {}
Expand Down
2 changes: 1 addition & 1 deletion ext/spl/php_spl_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 54d193c03c2652ce40adabd10d88666a86e32728 */
* Stub hash: 20188120387b006ea0e5833ad20241b73d2e2327 */

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_implements, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE)
ZEND_ARG_INFO(0, object_or_class)
Expand Down

0 comments on commit bdfe0ab

Please sign in to comment.