Skip to content

Commit 2342155

Browse files
committed
Add more specific array return type hints for various extensions - part 2
ext/ftp, ext/gmp, ext/intl
1 parent 2e65c8e commit 2342155

23 files changed

+80
-15
lines changed

Zend/Optimizer/zend_func_infos.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ static const func_info_t func_infos[] = {
8585
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),
8686
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),
8787
F1("filter_list", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
88+
F1("ftp_raw", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_NULL),
89+
F1("ftp_nlist", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
90+
F1("ftp_rawlist", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
91+
F1("ftp_mlsd", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_FALSE),
8892
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),
8993
F1("imagecreatetruecolor", MAY_BE_OBJECT|MAY_BE_FALSE),
9094
#if defined(PHP_WIN32)
@@ -153,6 +157,10 @@ static const func_info_t func_infos[] = {
153157
#if defined(HAVE_BIND_TEXTDOMAIN_CODESET)
154158
F1("bind_textdomain_codeset", MAY_BE_STRING|MAY_BE_FALSE),
155159
#endif
160+
FN("gmp_div_qr", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_OBJECT),
161+
FN("gmp_sqrtrem", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_OBJECT),
162+
FN("gmp_rootrem", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_OBJECT),
163+
FN("gmp_gcdext", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_OBJECT),
156164
F1("hash", MAY_BE_STRING|MAY_BE_FALSE),
157165
F1("hash_file", MAY_BE_STRING|MAY_BE_FALSE),
158166
F1("hash_hmac", MAY_BE_STRING|MAY_BE_FALSE),
@@ -179,6 +187,13 @@ static const func_info_t func_infos[] = {
179187
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),
180188
F1("iconv", MAY_BE_STRING|MAY_BE_FALSE),
181189
F1("iconv_get_encoding", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_STRING|MAY_BE_FALSE),
190+
FN("intlcal_get_available_locales", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
191+
FN("datefmt_localtime", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_FALSE),
192+
FN("locale_get_keywords", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE|MAY_BE_NULL),
193+
FN("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),
194+
FN("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),
195+
FN("resourcebundle_locales", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
196+
FN("transliterator_list_ids", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
182197
F1("json_encode", MAY_BE_STRING|MAY_BE_FALSE),
183198
F1("json_last_error_msg", MAY_BE_STRING),
184199
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),

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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ 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+
/** @return array<int, GMP> */
2526
function gmp_div_qr(GMP|int|string $num1, GMP|int|string $num2, int $rounding_mode = GMP_ROUND_ZERO): array {}
2627

2728
function gmp_div_q(GMP|int|string $num1, GMP|int|string $num2, int $rounding_mode = GMP_ROUND_ZERO): GMP {}
@@ -43,10 +44,12 @@ function gmp_fact(GMP|int|string $num): GMP {}
4344

4445
function gmp_sqrt(GMP|int|string $num): GMP {}
4546

47+
/** @return array<int, GMP> */
4648
function gmp_sqrtrem(GMP|int|string $num): array {}
4749

4850
function gmp_root(GMP|int|string $num, int $nth): GMP {}
4951

52+
/** @return array<int, GMP> */
5053
function gmp_rootrem(GMP|int|string $num, int $nth): array {}
5154

5255
function gmp_pow(GMP|int|string $num, int $exponent): GMP {}
@@ -61,6 +64,7 @@ function gmp_prob_prime(GMP|int|string $num, int $repetitions = 10): int {}
6164

6265
function gmp_gcd(GMP|int|string $num1, GMP|int|string $num2): GMP {}
6366

67+
/** @return array<string, GMP> */
6468
function gmp_gcdext(GMP|int|string $num1, GMP|int|string $num2): array {}
6569

6670
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: 7e2458ac4958923dfd43bde52cb111dd1c59f032 */
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: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ function intlcal_get_keyword_values_for_locale(string $keyword, string $locale,
1515

1616
function intlcal_get_now(): float {}
1717

18+
/** @return array<int, string> */
1819
function intlcal_get_available_locales(): array {}
1920

2021
function intlcal_get(IntlCalendar $calendar, int $field): int|false {}
@@ -206,7 +207,10 @@ function datefmt_format_object($datetime, $format = null, ?string $locale = null
206207
/** @param int $offset */
207208
function datefmt_parse(IntlDateFormatter $formatter, string $string, &$offset = null): int|float|false {}
208209

209-
/** @param int $offset */
210+
/**
211+
* @param int $offset
212+
* @return array<string, int>|false
213+
*/
210214
function datefmt_localtime(IntlDateFormatter $formatter, string $string, &$offset = null): array|false {}
211215

212216
function datefmt_get_error_code(IntlDateFormatter $formatter): int {}
@@ -294,6 +298,7 @@ function locale_get_script(string $locale): ?string {}
294298

295299
function locale_get_region(string $locale): ?string {}
296300

301+
/** @return array<string, string>|false|null */
297302
function locale_get_keywords(string $locale): array|false|null {}
298303

299304
function locale_get_display_script(string $locale, ?string $displayLocale = null): string|false {}
@@ -328,8 +333,10 @@ function msgfmt_format(MessageFormatter $formatter, array $values): string|false
328333

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

336+
/** @return array<int, int|float|string>|false */
331337
function msgfmt_parse(MessageFormatter $formatter, string $string): array|false {}
332338

339+
/** @return array<int, int|float|string>|false */
333340
function msgfmt_parse_message(string $locale, string $pattern, string $message): array|false {}
334341

335342
function msgfmt_set_pattern(MessageFormatter $formatter, string $pattern): bool {}
@@ -361,6 +368,7 @@ function resourcebundle_get(ResourceBundle $bundle, $index, bool $fallback = tru
361368

362369
function resourcebundle_count(ResourceBundle $bundle): int {}
363370

371+
/** @return array<int, string>|false */
364372
function resourcebundle_locales(string $bundle): array|false {}
365373

366374
function resourcebundle_get_error_code(ResourceBundle $bundle): int {}
@@ -431,6 +439,7 @@ function transliterator_create(string $id, int $direction = Transliterator::FORW
431439

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

442+
/** @return array<int, string>|false */
434443
function transliterator_list_ids(): array|false {}
435444

436445
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: 05a78c68f7bc5156cccecf4a8088bf8e3f4fdb4f */
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()

ext/intl/uchar/uchar.stub.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ public static function getPropertyValueEnum(int $property, string $name): int {}
8484
/** @tentative-return-type */
8585
public static function getPropertyValueName(int $property, int $value, int $type = IntlChar::LONG_PROPERTY_NAME): string|false {}
8686

87-
/** @tentative-return-type */
87+
/**
88+
* @return array<int, int>
89+
* @tentative-return-type
90+
*/
8891
public static function getUnicodeVersion(): array {}
8992

9093
/** @tentative-return-type */

ext/intl/uchar/uchar_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: 2b8605be915f05929dc0ade2edfb6f6ab942218c */
2+
* Stub hash: 8ec0d325c5108a66b45a5749591b685f22cac454 */
33

44
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_IntlChar_hasBinaryProperty, 0, 2, _IS_BOOL, 1)
55
ZEND_ARG_TYPE_MASK(0, codepoint, MAY_BE_LONG|MAY_BE_STRING, NULL)

0 commit comments

Comments
 (0)