Skip to content

Commit d608319

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Add more specific array return type hints for various extensions - part 2 Add the --generate-optimizer-info option to the help of gen_stub.php
2 parents f34a3d3 + baac970 commit d608319

22 files changed

+107
-14
lines changed

Zend/Optimizer/zend_func_infos.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ static const func_info_t func_infos[] = {
9595
F1("filter_input_array", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF|MAY_BE_FALSE|MAY_BE_NULL),
9696
F1("filter_var_array", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF|MAY_BE_FALSE|MAY_BE_NULL),
9797
F1("filter_list", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
98+
F1("ftp_raw", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_NULL),
99+
F1("ftp_nlist", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
100+
F1("ftp_rawlist", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
101+
F1("ftp_mlsd", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_FALSE),
98102
F1("gd_info", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_FALSE|MAY_BE_ARRAY_OF_TRUE),
99103
F1("imagecreatetruecolor", MAY_BE_OBJECT|MAY_BE_FALSE),
100104
#if defined(PHP_WIN32)
@@ -163,6 +167,10 @@ static const func_info_t func_infos[] = {
163167
#if defined(HAVE_BIND_TEXTDOMAIN_CODESET)
164168
F1("bind_textdomain_codeset", MAY_BE_STRING|MAY_BE_FALSE),
165169
#endif
170+
F1("gmp_div_qr", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_OBJECT),
171+
F1("gmp_sqrtrem", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_OBJECT),
172+
F1("gmp_rootrem", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_OBJECT),
173+
F1("gmp_gcdext", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_OBJECT),
166174
F1("hash", MAY_BE_STRING|MAY_BE_FALSE),
167175
F1("hash_file", MAY_BE_STRING|MAY_BE_FALSE),
168176
F1("hash_hmac", MAY_BE_STRING|MAY_BE_FALSE),
@@ -189,6 +197,13 @@ static const func_info_t func_infos[] = {
189197
F1("iconv_mime_decode_headers", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_FALSE),
190198
F1("iconv", MAY_BE_STRING|MAY_BE_FALSE),
191199
F1("iconv_get_encoding", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_STRING|MAY_BE_FALSE),
200+
F1("intlcal_get_available_locales", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
201+
F1("datefmt_localtime", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_FALSE),
202+
F1("locale_get_keywords", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE|MAY_BE_NULL),
203+
F1("msgfmt_parse", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_DOUBLE|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
204+
F1("msgfmt_parse_message", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_DOUBLE|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
205+
F1("resourcebundle_locales", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
206+
F1("transliterator_list_ids", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
192207
F1("json_encode", MAY_BE_STRING|MAY_BE_FALSE),
193208
F1("json_last_error_msg", MAY_BE_STRING),
194209
F1("ldap_get_entries", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_FALSE),

build/gen_stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3310,7 +3310,7 @@ function initPhpParser() {
33103310
}
33113311

33123312
if (isset($options["h"]) || isset($options["help"])) {
3313-
die("\nusage: gen_stub.php [ -f | --force-regeneration ] [ --generate-classsynopses ] [ --replace-classsynopses ] [ --generate-methodsynopses ] [ --replace-methodsynopses ] [ --parameter-stats ] [ --verify ] [ -h | --help ] [ name.stub.php | directory ] [ directory ]\n\n");
3313+
die("\nusage: gen_stub.php [ -f | --force-regeneration ] [ --generate-classsynopses ] [ --replace-classsynopses ] [ --generate-methodsynopses ] [ --replace-methodsynopses ] [ --parameter-stats ] [ --verify ] [ --generate-optimizer-info ] [ -h | --help ] [ name.stub.php | directory ] [ directory ]\n\n");
33143314
}
33153315

33163316
$fileInfos = [];

ext/ftp/ftp.stub.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,37 @@ function ftp_pwd(FTP\Connection $ftp): string|false {}
2727
function ftp_cdup(FTP\Connection $ftp): bool {}
2828
function ftp_chdir(FTP\Connection $ftp, string $directory): bool {}
2929
function ftp_exec(FTP\Connection $ftp, string $command): bool {}
30+
31+
/**
32+
* @return array<int, string>|null
33+
* @refcount 1
34+
*/
3035
function ftp_raw(FTP\Connection $ftp, string $command): ?array {}
3136
function ftp_mkdir(FTP\Connection $ftp, string $directory): string|false {}
3237
function ftp_rmdir(FTP\Connection $ftp, string $directory): bool {}
3338
function ftp_chmod(FTP\Connection $ftp, int $permissions, string $filename): int|false {}
3439

3540
/** @param string $response */
3641
function ftp_alloc(FTP\Connection $ftp, int $size, &$response = null): bool {}
42+
43+
/**
44+
* @return array<int, string>|false
45+
* @refcount 1
46+
*/
3747
function ftp_nlist(FTP\Connection $ftp, string $directory): array|false {}
48+
49+
/**
50+
* @return array<int, string>|false
51+
* @refcount 1
52+
*/
3853
function ftp_rawlist(FTP\Connection $ftp, string $directory, bool $recursive = false): array|false {}
54+
55+
/**
56+
* @return array<int, array>|false
57+
* @refcount 1
58+
*/
3959
function ftp_mlsd(FTP\Connection $ftp, string $directory): array|false {}
60+
4061
function ftp_systype(FTP\Connection $ftp): string|false {}
4162

4263
/** @param resource $stream */

ext/ftp/ftp_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: 6de0997e9f07a8e1079764ab1841d3ac4651cc53 */
2+
* Stub hash: 2b1726dd5652839a37e533e20dfcf6782b3c766d */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_ftp_connect, 0, 1, FTP\\Connection, MAY_BE_FALSE)
55
ZEND_ARG_TYPE_INFO(0, hostname, IS_STRING, 0)

ext/gmp/gmp.stub.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ function gmp_sub(GMP|int|string $num1, GMP|int|string $num2): GMP {}
2222

2323
function gmp_mul(GMP|int|string $num1, GMP|int|string $num2): GMP {}
2424

25+
/**
26+
* @return array<int, GMP>
27+
* @refcount 1
28+
*/
2529
function gmp_div_qr(GMP|int|string $num1, GMP|int|string $num2, int $rounding_mode = GMP_ROUND_ZERO): array {}
2630

2731
function gmp_div_q(GMP|int|string $num1, GMP|int|string $num2, int $rounding_mode = GMP_ROUND_ZERO): GMP {}
@@ -43,10 +47,18 @@ function gmp_fact(GMP|int|string $num): GMP {}
4347

4448
function gmp_sqrt(GMP|int|string $num): GMP {}
4549

50+
/**
51+
* @return array<int, GMP>
52+
* @refcount 1
53+
*/
4654
function gmp_sqrtrem(GMP|int|string $num): array {}
4755

4856
function gmp_root(GMP|int|string $num, int $nth): GMP {}
4957

58+
/**
59+
* @return array<int, GMP>
60+
* @refcount 1
61+
*/
5062
function gmp_rootrem(GMP|int|string $num, int $nth): array {}
5163

5264
function gmp_pow(GMP|int|string $num, int $exponent): GMP {}
@@ -61,6 +73,10 @@ function gmp_prob_prime(GMP|int|string $num, int $repetitions = 10): int {}
6173

6274
function gmp_gcd(GMP|int|string $num1, GMP|int|string $num2): GMP {}
6375

76+
/**
77+
* @return array<string, GMP>
78+
* @refcount 1
79+
*/
6480
function gmp_gcdext(GMP|int|string $num1, GMP|int|string $num2): array {}
6581

6682
function gmp_lcm(GMP|int|string $num1, GMP|int|string $num2): GMP {}

ext/gmp/gmp_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: 69215fb94adb4156c974360e5698e842471cb27d */
2+
* Stub hash: 05e618ec428bd8769410153469c42cbc923ea77f */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_gmp_init, 0, 1, GMP, 0)
55
ZEND_ARG_TYPE_MASK(0, num, MAY_BE_LONG|MAY_BE_STRING, NULL)

ext/intl/calendar/calendar.stub.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public function getActualMaximum(int $field): int|false {}
7474
public function getActualMinimum(int $field): int|false {}
7575

7676
/**
77+
* @return array<int, string>
7778
* @tentative-return-type
7879
* @alias intlcal_get_available_locales
7980
*/

ext/intl/calendar/calendar_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: 2265c2a4f478d6ccd576ce09a19a158df38a2bdb */
2+
* Stub hash: 7be0e49d2b898587c4bbefaaf613932ae4786c52 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlCalendar___construct, 0, 0, 0)
55
ZEND_END_ARG_INFO()

ext/intl/converter/converter.stub.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,16 @@ public function convert(string $str, bool $reverse = false): string|false {}
1515
*/
1616
public function fromUCallback(int $reason, array $source, int $codePoint, &$error): string|int|array|null {}
1717

18-
/** @tentative-return-type */
18+
/**
19+
* @return array<int, string>|false|null
20+
* @tentative-return-type
21+
*/
1922
public static function getAliases(string $name): array|false|null {}
2023

21-
/** @tentative-return-type */
24+
/**
25+
* @return array<int, string>
26+
* @tentative-return-type
27+
*/
2228
public static function getAvailable(): array {}
2329

2430
/** @tentative-return-type */

ext/intl/converter/converter_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: a6b352ba1b6ad2367bd4705ac941e763f74c8fac */
2+
* Stub hash: 2a6d8499e1a2d414130e366783a1c084f47a3293 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_UConverter___construct, 0, 0, 0)
55
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, destination_encoding, IS_STRING, 1, "null")

ext/intl/dateformat/dateformat.stub.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ public function parse(string $string, &$offset = null): int|float|false {}
134134

135135
/**
136136
* @param int $offset
137+
* @return array<string, int>|false
137138
* @tentative-return-type
138139
* @alias datefmt_localtime
139140
*/

ext/intl/dateformat/dateformat_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: 767e5d064aef6d68f860a79c721eb728436c4eb9 */
2+
* Stub hash: 82f90e7b0528b2b3515c086763dba4de0f92dfa7 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter___construct, 0, 0, 1)
55
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 1)

ext/intl/locale/locale.stub.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public static function getScript(string $locale): ?string {}
3535
public static function getRegion(string $locale): ?string {}
3636

3737
/**
38+
* @return array<string, string>|false|null
3839
* @tentative-return-type
3940
* @alias locale_get_keywords
4041
*/

ext/intl/locale/locale_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: a0c2cf74b0d2e8309f0cd39fd9969d14586d0988 */
2+
* Stub hash: 539e559bc038e18358540b3b3f4db7b09e532dae */
33

44
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Locale_getDefault, 0, 0, IS_STRING, 0)
55
ZEND_END_ARG_INFO()

ext/intl/msgformat/msgformat.stub.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ public function format(array $values): string|false {}
2525
public static function formatMessage(string $locale, string $pattern, array $values): string|false {}
2626

2727
/**
28+
* @return array<int, int|float|string>|false
2829
* @tentative-return-type
2930
* @alias msgfmt_parse
3031
*/
3132
public function parse(string $string): array|false {}
3233

3334
/**
35+
* @return array<int, int|float|string>|false
3436
* @tentative-return-type
3537
* @alias msgfmt_parse_message
3638
*/

ext/intl/msgformat/msgformat_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: 3fc29ffe87caf85a84e97470d0b59a26c801457c */
2+
* Stub hash: 44bc7b87c0b6c674bf94764b3f036006e3933713 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MessageFormatter___construct, 0, 0, 2)
55
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 0)

ext/intl/php_intl.stub.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ function intlcal_get_keyword_values_for_locale(string $keyword, string $locale,
1515

1616
function intlcal_get_now(): float {}
1717

18+
/**
19+
* @return array<int, string>
20+
* @refcount 1
21+
*/
1822
function intlcal_get_available_locales(): array {}
1923

2024
function intlcal_get(IntlCalendar $calendar, int $field): int|false {}
@@ -206,7 +210,11 @@ function datefmt_format_object($datetime, $format = null, ?string $locale = null
206210
/** @param int $offset */
207211
function datefmt_parse(IntlDateFormatter $formatter, string $string, &$offset = null): int|float|false {}
208212

209-
/** @param int $offset */
213+
/**
214+
* @param int $offset
215+
* @return array<string, int>|false
216+
* @refcount 1
217+
*/
210218
function datefmt_localtime(IntlDateFormatter $formatter, string $string, &$offset = null): array|false {}
211219

212220
function datefmt_get_error_code(IntlDateFormatter $formatter): int {}
@@ -294,6 +302,10 @@ function locale_get_script(string $locale): ?string {}
294302

295303
function locale_get_region(string $locale): ?string {}
296304

305+
/**
306+
* @return array<string, string>|false|null
307+
* @refcount 1
308+
*/
297309
function locale_get_keywords(string $locale): array|false|null {}
298310

299311
function locale_get_display_script(string $locale, ?string $displayLocale = null): string|false {}
@@ -328,8 +340,16 @@ function msgfmt_format(MessageFormatter $formatter, array $values): string|false
328340

329341
function msgfmt_format_message(string $locale, string $pattern, array $values): string|false {}
330342

343+
/**
344+
* @return array<int, int|float|string>|false
345+
* @refcount 1
346+
*/
331347
function msgfmt_parse(MessageFormatter $formatter, string $string): array|false {}
332348

349+
/**
350+
* @return array<int, int|float|string>|false
351+
* @refcount 1
352+
*/
333353
function msgfmt_parse_message(string $locale, string $pattern, string $message): array|false {}
334354

335355
function msgfmt_set_pattern(MessageFormatter $formatter, string $pattern): bool {}
@@ -361,6 +381,10 @@ function resourcebundle_get(ResourceBundle $bundle, $index, bool $fallback = tru
361381

362382
function resourcebundle_count(ResourceBundle $bundle): int {}
363383

384+
/**
385+
* @return array<int, string>|false
386+
* @refcount 1
387+
*/
364388
function resourcebundle_locales(string $bundle): array|false {}
365389

366390
function resourcebundle_get_error_code(ResourceBundle $bundle): int {}
@@ -431,6 +455,10 @@ function transliterator_create(string $id, int $direction = Transliterator::FORW
431455

432456
function transliterator_create_from_rules(string $rules, int $direction = Transliterator::FORWARD): ?Transliterator {}
433457

458+
/**
459+
* @return array<int, string>|false
460+
* @refcount 1
461+
*/
434462
function transliterator_list_ids(): array|false {}
435463

436464
function transliterator_create_inverse(Transliterator $transliterator): ?Transliterator {}

ext/intl/php_intl_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: dc9632b2417200deb39cc5cce25aa26a44128707 */
2+
* Stub hash: 09aa0aa66c78b86c0e6e0e554c3ebe205a0e5f59 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_intlcal_create_instance, 0, 0, IntlCalendar, 1)
55
ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, timezone, "null")

ext/intl/resourcebundle/resourcebundle.stub.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public function get($index, bool $fallback = true): mixed {}
2626
public function count(): int {}
2727

2828
/**
29+
* @return array<int, string>|false
2930
* @tentative-return-type
3031
* @alias resourcebundle_locales
3132
*/

ext/intl/resourcebundle/resourcebundle_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: a299d2a45a3575e6da71560979e2f9301b3c952f */
2+
* Stub hash: d27fa5a4dc092b94e48fc876070f440c247fa6c2 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ResourceBundle___construct, 0, 0, 2)
55
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 1)

ext/intl/transliterator/transliterator.stub.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public static function createFromRules(string $rules, int $direction = Translite
2727
public function createInverse(): ?Transliterator {}
2828

2929
/**
30+
* @return array<int, string>|false
3031
* @tentative-return-type
3132
* @alias transliterator_list_ids
3233
*/

ext/intl/transliterator/transliterator_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: fbc9a196271c276e5af658115571cacde2ad3a3a */
2+
* Stub hash: 8a6aaab7dd89a014726bd1fdf1f40f7b6fa98ea5 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Transliterator___construct, 0, 0, 0)
55
ZEND_END_ARG_INFO()

0 commit comments

Comments
 (0)