Skip to content

Add more specific array return type hints for various extensions - part 2 #7433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Zend/Optimizer/zend_func_infos.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ static const func_info_t func_infos[] = {
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),
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),
F1("filter_list", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
F1("ftp_raw", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_NULL),
F1("ftp_nlist", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
F1("ftp_rawlist", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
F1("ftp_mlsd", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_FALSE),
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),
F1("imagecreatetruecolor", MAY_BE_OBJECT|MAY_BE_FALSE),
#if defined(PHP_WIN32)
Expand Down Expand Up @@ -163,6 +167,10 @@ static const func_info_t func_infos[] = {
#if defined(HAVE_BIND_TEXTDOMAIN_CODESET)
F1("bind_textdomain_codeset", MAY_BE_STRING|MAY_BE_FALSE),
#endif
F1("gmp_div_qr", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_OBJECT),
F1("gmp_sqrtrem", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_OBJECT),
F1("gmp_rootrem", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_OBJECT),
F1("gmp_gcdext", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_OBJECT),
F1("hash", MAY_BE_STRING|MAY_BE_FALSE),
F1("hash_file", MAY_BE_STRING|MAY_BE_FALSE),
F1("hash_hmac", MAY_BE_STRING|MAY_BE_FALSE),
Expand All @@ -189,6 +197,13 @@ static const func_info_t func_infos[] = {
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),
F1("iconv", MAY_BE_STRING|MAY_BE_FALSE),
F1("iconv_get_encoding", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_STRING|MAY_BE_FALSE),
F1("intlcal_get_available_locales", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
F1("datefmt_localtime", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_FALSE),
F1("locale_get_keywords", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE|MAY_BE_NULL),
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),
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),
F1("resourcebundle_locales", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
F1("transliterator_list_ids", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
F1("json_encode", MAY_BE_STRING|MAY_BE_FALSE),
F1("json_last_error_msg", MAY_BE_STRING),
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),
Expand Down
21 changes: 21 additions & 0 deletions ext/ftp/ftp.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,37 @@ function ftp_pwd(FTP\Connection $ftp): string|false {}
function ftp_cdup(FTP\Connection $ftp): bool {}
function ftp_chdir(FTP\Connection $ftp, string $directory): bool {}
function ftp_exec(FTP\Connection $ftp, string $command): bool {}

/**
* @return array<int, string>|null
* @refcount 1
*/
function ftp_raw(FTP\Connection $ftp, string $command): ?array {}
function ftp_mkdir(FTP\Connection $ftp, string $directory): string|false {}
function ftp_rmdir(FTP\Connection $ftp, string $directory): bool {}
function ftp_chmod(FTP\Connection $ftp, int $permissions, string $filename): int|false {}

/** @param string $response */
function ftp_alloc(FTP\Connection $ftp, int $size, &$response = null): bool {}

/**
* @return array<int, string>|false
* @refcount 1
*/
function ftp_nlist(FTP\Connection $ftp, string $directory): array|false {}

/**
* @return array<int, string>|false
* @refcount 1
*/
function ftp_rawlist(FTP\Connection $ftp, string $directory, bool $recursive = false): array|false {}

/**
* @return array<int, array>|false
* @refcount 1
*/
function ftp_mlsd(FTP\Connection $ftp, string $directory): array|false {}

function ftp_systype(FTP\Connection $ftp): string|false {}

/** @param resource $stream */
Expand Down
2 changes: 1 addition & 1 deletion ext/ftp/ftp_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: 6de0997e9f07a8e1079764ab1841d3ac4651cc53 */
* Stub hash: 2b1726dd5652839a37e533e20dfcf6782b3c766d */

ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_ftp_connect, 0, 1, FTP\\Connection, MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, hostname, IS_STRING, 0)
Expand Down
16 changes: 16 additions & 0 deletions ext/gmp/gmp.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ function gmp_sub(GMP|int|string $num1, GMP|int|string $num2): GMP {}

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

/**
* @return array<int, GMP>
* @refcount 1
*/
function gmp_div_qr(GMP|int|string $num1, GMP|int|string $num2, int $rounding_mode = GMP_ROUND_ZERO): array {}

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

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

/**
* @return array<int, GMP>
* @refcount 1
*/
function gmp_sqrtrem(GMP|int|string $num): array {}

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

/**
* @return array<int, GMP>
* @refcount 1
*/
function gmp_rootrem(GMP|int|string $num, int $nth): array {}

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

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

/**
* @return array<string, GMP>
* @refcount 1
*/
function gmp_gcdext(GMP|int|string $num1, GMP|int|string $num2): array {}

function gmp_lcm(GMP|int|string $num1, GMP|int|string $num2): GMP {}
Expand Down
2 changes: 1 addition & 1 deletion ext/gmp/gmp_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: 69215fb94adb4156c974360e5698e842471cb27d */
* Stub hash: 05e618ec428bd8769410153469c42cbc923ea77f */

ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_gmp_init, 0, 1, GMP, 0)
ZEND_ARG_TYPE_MASK(0, num, MAY_BE_LONG|MAY_BE_STRING, NULL)
Expand Down
1 change: 1 addition & 0 deletions ext/intl/calendar/calendar.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public function getActualMaximum(int $field): int|false {}
public function getActualMinimum(int $field): int|false {}

/**
* @return array<int, string>
* @tentative-return-type
* @alias intlcal_get_available_locales
*/
Expand Down
2 changes: 1 addition & 1 deletion ext/intl/calendar/calendar_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: 2265c2a4f478d6ccd576ce09a19a158df38a2bdb */
* Stub hash: 7be0e49d2b898587c4bbefaaf613932ae4786c52 */

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlCalendar___construct, 0, 0, 0)
ZEND_END_ARG_INFO()
Expand Down
10 changes: 8 additions & 2 deletions ext/intl/converter/converter.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ public function convert(string $str, bool $reverse = false): string|false {}
*/
public function fromUCallback(int $reason, array $source, int $codePoint, &$error): string|int|array|null {}

/** @tentative-return-type */
/**
* @return array<int, string>|false|null
* @tentative-return-type
*/
public static function getAliases(string $name): array|false|null {}

/** @tentative-return-type */
/**
* @return array<int, string>
* @tentative-return-type
*/
public static function getAvailable(): array {}

/** @tentative-return-type */
Expand Down
2 changes: 1 addition & 1 deletion ext/intl/converter/converter_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: a6b352ba1b6ad2367bd4705ac941e763f74c8fac */
* Stub hash: 2a6d8499e1a2d414130e366783a1c084f47a3293 */

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_UConverter___construct, 0, 0, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, destination_encoding, IS_STRING, 1, "null")
Expand Down
1 change: 1 addition & 0 deletions ext/intl/dateformat/dateformat.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public function parse(string $string, &$offset = null): int|float|false {}

/**
* @param int $offset
* @return array<string, int>|false
* @tentative-return-type
* @alias datefmt_localtime
*/
Expand Down
2 changes: 1 addition & 1 deletion ext/intl/dateformat/dateformat_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: 767e5d064aef6d68f860a79c721eb728436c4eb9 */
* Stub hash: 82f90e7b0528b2b3515c086763dba4de0f92dfa7 */

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter___construct, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 1)
Expand Down
1 change: 1 addition & 0 deletions ext/intl/locale/locale.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static function getScript(string $locale): ?string {}
public static function getRegion(string $locale): ?string {}

/**
* @return array<string, string>|false|null
* @tentative-return-type
* @alias locale_get_keywords
*/
Expand Down
2 changes: 1 addition & 1 deletion ext/intl/locale/locale_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: a0c2cf74b0d2e8309f0cd39fd9969d14586d0988 */
* Stub hash: 539e559bc038e18358540b3b3f4db7b09e532dae */

ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Locale_getDefault, 0, 0, IS_STRING, 0)
ZEND_END_ARG_INFO()
Expand Down
2 changes: 2 additions & 0 deletions ext/intl/msgformat/msgformat.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ public function format(array $values): string|false {}
public static function formatMessage(string $locale, string $pattern, array $values): string|false {}

/**
* @return array<int, int|float|string>|false
* @tentative-return-type
* @alias msgfmt_parse
*/
public function parse(string $string): array|false {}

/**
* @return array<int, int|float|string>|false
* @tentative-return-type
* @alias msgfmt_parse_message
*/
Expand Down
2 changes: 1 addition & 1 deletion ext/intl/msgformat/msgformat_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: 3fc29ffe87caf85a84e97470d0b59a26c801457c */
* Stub hash: 44bc7b87c0b6c674bf94764b3f036006e3933713 */

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MessageFormatter___construct, 0, 0, 2)
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 0)
Expand Down
30 changes: 29 additions & 1 deletion ext/intl/php_intl.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ function intlcal_get_keyword_values_for_locale(string $keyword, string $locale,

function intlcal_get_now(): float {}

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

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

/** @param int $offset */
/**
* @param int $offset
* @return array<string, int>|false
* @refcount 1
*/
function datefmt_localtime(IntlDateFormatter $formatter, string $string, &$offset = null): array|false {}

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

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

/**
* @return array<string, string>|false|null
* @refcount 1
*/
function locale_get_keywords(string $locale): array|false|null {}

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

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

/**
* @return array<int, int|float|string>|false
* @refcount 1
*/
function msgfmt_parse(MessageFormatter $formatter, string $string): array|false {}

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

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

function resourcebundle_count(ResourceBundle $bundle): int {}

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

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

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

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

function transliterator_create_inverse(Transliterator $transliterator): ?Transliterator {}
Expand Down
2 changes: 1 addition & 1 deletion ext/intl/php_intl_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: dc9632b2417200deb39cc5cce25aa26a44128707 */
* Stub hash: 09aa0aa66c78b86c0e6e0e554c3ebe205a0e5f59 */

ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_intlcal_create_instance, 0, 0, IntlCalendar, 1)
ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, timezone, "null")
Expand Down
1 change: 1 addition & 0 deletions ext/intl/resourcebundle/resourcebundle.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function get($index, bool $fallback = true): mixed {}
public function count(): int {}

/**
* @return array<int, string>|false
* @tentative-return-type
* @alias resourcebundle_locales
*/
Expand Down
2 changes: 1 addition & 1 deletion ext/intl/resourcebundle/resourcebundle_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: a299d2a45a3575e6da71560979e2f9301b3c952f */
* Stub hash: d27fa5a4dc092b94e48fc876070f440c247fa6c2 */

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ResourceBundle___construct, 0, 0, 2)
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 1)
Expand Down
1 change: 1 addition & 0 deletions ext/intl/transliterator/transliterator.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static function createFromRules(string $rules, int $direction = Translite
public function createInverse(): ?Transliterator {}

/**
* @return array<int, string>|false
* @tentative-return-type
* @alias transliterator_list_ids
*/
Expand Down
2 changes: 1 addition & 1 deletion ext/intl/transliterator/transliterator_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: fbc9a196271c276e5af658115571cacde2ad3a3a */
* Stub hash: 8a6aaab7dd89a014726bd1fdf1f40f7b6fa98ea5 */

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Transliterator___construct, 0, 0, 0)
ZEND_END_ARG_INFO()
Expand Down