Skip to content

Commit bdfe0ab

Browse files
committed
Generate Zend, ext/spl and ext/json optimizer func info from stubs
Closes GH-7397
1 parent 6e57711 commit bdfe0ab

File tree

8 files changed

+72
-23
lines changed

8 files changed

+72
-23
lines changed

Zend/Optimizer/zend_func_info.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,7 @@ static uint32_t zend_range_info(const zend_call_info *call_info, const zend_ssa
9090
static const func_info_t old_func_infos[] = {
9191
/* zend */
9292
F1("get_class_vars", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF),
93-
F1("get_declared_traits", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
94-
F1("get_declared_classes", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
95-
F1("get_declared_interfaces", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
96-
F1("get_defined_functions", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ARRAY),
9793
F1("get_defined_vars", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF),
98-
F1("debug_backtrace", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ARRAY),
99-
F1("get_loaded_extensions", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
100-
F1("get_extension_funcs", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
10194

10295
/* ext/standard */
10396
F1("bin2hex", MAY_BE_STRING),
@@ -499,11 +492,6 @@ static const func_info_t old_func_infos[] = {
499492
F1("iconv_mime_decode", MAY_BE_FALSE | MAY_BE_STRING),
500493
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),
501494

502-
/* ext/json */
503-
F1("json_encode", MAY_BE_FALSE | MAY_BE_STRING),
504-
FN("json_decode", MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
505-
F1("json_last_error_msg", MAY_BE_STRING),
506-
507495
/* ext/xml */
508496
F1("xml_error_string", MAY_BE_NULL | MAY_BE_STRING),
509497
F1("xml_parser_get_option", MAY_BE_LONG | MAY_BE_STRING),
@@ -754,12 +742,7 @@ static const func_info_t old_func_infos[] = {
754742
F1("imageresolution", MAY_BE_TRUE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_LONG),
755743

756744
/* ext/spl */
757-
F1("class_implements", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING),
758-
F1("class_parents", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING),
759-
F1("class_uses", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING),
760745
F1("iterator_to_array", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
761-
F1("spl_classes", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING),
762-
F1("spl_object_hash", MAY_BE_STRING),
763746

764747
};
765748

Zend/Optimizer/zend_func_infos.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,21 @@ static const func_info_t func_infos[] = {
99
F0("restore_error_handler", MAY_BE_TRUE),
1010
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),
1111
F0("restore_exception_handler", MAY_BE_TRUE),
12+
F1("get_declared_classes", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
13+
F1("get_declared_traits", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
14+
F1("get_declared_interfaces", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
15+
F1("get_defined_functions", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ARRAY),
1216
F1("get_resource_type", MAY_BE_STRING),
17+
F1("get_loaded_extensions", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
1318
F1("get_defined_constants", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY),
19+
F1("debug_backtrace", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_ARRAY),
20+
F1("get_extension_funcs", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
21+
F1("gc_status", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG),
22+
F1("class_implements", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
23+
F1("class_parents", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
24+
F1("class_uses", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
25+
F1("spl_classes", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING),
26+
F1("spl_object_hash", MAY_BE_STRING),
1427
FN("socket_export_stream", MAY_BE_RESOURCE|MAY_BE_FALSE),
1528
F1("gzopen", MAY_BE_RESOURCE|MAY_BE_FALSE),
1629
#if HAVE_NANOSLEEP
@@ -38,6 +51,8 @@ static const func_info_t func_infos[] = {
3851
F1("stream_socket_accept", MAY_BE_RESOURCE|MAY_BE_FALSE),
3952
FN("zip_open", MAY_BE_RESOURCE|MAY_BE_LONG|MAY_BE_FALSE),
4053
FN("zip_read", MAY_BE_RESOURCE|MAY_BE_FALSE),
54+
F1("json_encode", MAY_BE_STRING|MAY_BE_FALSE),
55+
F1("json_last_error_msg", MAY_BE_STRING),
4156
FN("oci_new_connect", MAY_BE_RESOURCE|MAY_BE_FALSE),
4257
FN("oci_connect", MAY_BE_RESOURCE|MAY_BE_FALSE),
4358
FN("oci_pconnect", MAY_BE_RESOURCE|MAY_BE_FALSE),

Zend/zend_builtin_functions.stub.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,28 @@ function set_exception_handler(?callable $callback) {}
103103
/** @return true */
104104
function restore_exception_handler(): bool {}
105105

106+
/**
107+
* @return array<int, string>
108+
* @refcount 1
109+
*/
106110
function get_declared_classes(): array {}
107111

112+
/**
113+
* @return array<int, string>
114+
* @refcount 1
115+
*/
108116
function get_declared_traits(): array {}
109117

118+
/**
119+
* @return array<int, string>
120+
* @refcount 1
121+
*/
110122
function get_declared_interfaces(): array {}
111123

124+
/**
125+
* @return array<string, array>
126+
* @refcount 1
127+
*/
112128
function get_defined_functions(bool $exclude_disabled = true): array {}
113129

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

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

143+
/**
144+
* @return array<int, string>
145+
* @refcount 1
146+
*/
127147
function get_loaded_extensions(bool $zend_extensions = false): array {}
128148

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

155+
/**
156+
* @return array<int, array>
157+
* @refcount 1
158+
*/
135159
function debug_backtrace(int $options = DEBUG_BACKTRACE_PROVIDE_OBJECT, int $limit = 0): array {}
136160

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

139163
function extension_loaded(string $extension): bool {}
140164

165+
/**
166+
* @return array<int, string>|false
167+
* @refcount 1
168+
*/
141169
function get_extension_funcs(string $extension): array|false {}
142170

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

155183
function gc_disable(): void {}
156184

185+
/**
186+
* @return array<string, int>
187+
* @refcount 1
188+
*/
157189
function gc_status(): array {}

Zend/zend_builtin_functions_arginfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: c8a0a1e4cfece42832f737b33e317ba88b91fab5 */
2+
* Stub hash: cf84a097dab1a043133faf0b03f002748b3c8eda */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_version, 0, 0, IS_STRING, 0)
55
ZEND_END_ARG_INFO()

ext/json/json.stub.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
/** @generate-class-entries */
44

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

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

910
function json_last_error(): int {}
1011

12+
/** @refcount 1 */
1113
function json_last_error_msg(): string {}
1214

1315
interface JsonSerializable

ext/json/json_arginfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: d6577c7d27442643c86e51d462f51dd6e677d509 */
2+
* Stub hash: e59995a9cd647f36164468dd2ae4c11239e3405f */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_json_encode, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
55
ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0)

ext/spl/php_spl.stub.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,25 @@
22

33
/** @generate-class-entries */
44

5-
/** @param object|string $object_or_class */
5+
/**
6+
* @param object|string $object_or_class
7+
* @return array<string, string>|false
8+
* @refcount 1
9+
*/
610
function class_implements($object_or_class, bool $autoload = true): array|false {}
711

8-
/** @param object|string $object_or_class */
12+
/**
13+
* @param object|string $object_or_class
14+
* @return array<string, string>|false
15+
* @refcount 1
16+
*/
917
function class_parents($object_or_class, bool $autoload = true): array|false {}
1018

11-
/** @param object|string $object_or_class */
19+
/**
20+
* @param object|string $object_or_class
21+
* @return array<string, string>|false
22+
* @refcount 1
23+
*/
1224
function class_uses($object_or_class, bool $autoload = true): array|false {}
1325

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

2436
function spl_autoload_unregister(callable $callback): bool {}
2537

38+
/**
39+
* @return array<string, string>
40+
* @refcount 1
41+
*/
2642
function spl_classes(): array {}
2743

44+
/** @refcount 1 */
2845
function spl_object_hash(object $object): string {}
2946

3047
function spl_object_id(object $object): int {}

ext/spl/php_spl_arginfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 54d193c03c2652ce40adabd10d88666a86e32728 */
2+
* Stub hash: 20188120387b006ea0e5833ad20241b73d2e2327 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_implements, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE)
55
ZEND_ARG_INFO(0, object_or_class)

0 commit comments

Comments
 (0)