Skip to content

Commit

Permalink
Add more specific array return type hints for various extensions - pa…
Browse files Browse the repository at this point in the history
…rt 1

ext/bz2, ext/calendar, ext/dba, ext/enchant

Closes GH-7432
  • Loading branch information
kocsismate committed Nov 7, 2021
1 parent a2fe8d4 commit d02b9b9
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 5 deletions.
10 changes: 10 additions & 0 deletions Zend/Optimizer/zend_func_infos.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ static const func_info_t func_infos[] = {
F1("bcpow", MAY_BE_STRING),
F1("bcsqrt", MAY_BE_STRING),
FN("bzopen", MAY_BE_RESOURCE|MAY_BE_FALSE),
F1("bzerror", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING),
F1("cal_from_jd", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_NULL),
F1("cal_info", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_ARRAY),
F1("curl_copy_handle", MAY_BE_OBJECT|MAY_BE_FALSE),
F1("curl_error", MAY_BE_STRING),
F1("curl_escape", MAY_BE_STRING|MAY_BE_FALSE),
Expand Down Expand Up @@ -75,6 +78,13 @@ static const func_info_t func_infos[] = {
F1("date_sun_info", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_FALSE|MAY_BE_ARRAY_OF_TRUE|MAY_BE_ARRAY_OF_LONG),
FN("dba_popen", MAY_BE_RESOURCE|MAY_BE_FALSE),
FN("dba_open", MAY_BE_RESOURCE|MAY_BE_FALSE),
FN("dba_key_split", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
F1("dba_handlers", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING),
FN("dba_list", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
F1("enchant_broker_list_dicts", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_ARRAY),
F1("enchant_broker_describe", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_ARRAY),
F1("enchant_dict_suggest", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
F1("enchant_dict_describe", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING),
F1("exif_tagname", MAY_BE_STRING|MAY_BE_FALSE),
F1("exif_read_data", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_FALSE),
F1("exif_thumbnail", MAY_BE_STRING|MAY_BE_FALSE),
Expand Down
6 changes: 5 additions & 1 deletion ext/bz2/bz2.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ function bzerrno($bz): int {}
/** @param resource $bz */
function bzerrstr($bz): string {}

/** @param resource $bz */
/**
* @param resource $bz
* @return array<string, int|string>
* @refcount 1
*/
function bzerror($bz): array {}

function bzcompress(string $data, int $block_size = 4, int $work_factor = 0): string|int {}
Expand Down
2 changes: 1 addition & 1 deletion ext/bz2/bz2_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: 8116780e328f137ca15ae445c9d6b45cf2f41f06 */
* Stub hash: ebd3dc9902075c276828c17dc7a1c3bdc5401f8e */

ZEND_BEGIN_ARG_INFO_EX(arginfo_bzopen, 0, 0, 2)
ZEND_ARG_INFO(0, file)
Expand Down
8 changes: 8 additions & 0 deletions ext/calendar/calendar.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@

function cal_days_in_month(int $calendar, int $month, int $year): int {}

/**
* @return array<string, int|string|null>
* @refcount 1
*/
function cal_from_jd(int $julian_day, int $calendar): array {}

/**
* @return array<int|string, int|string|array>
* @refcount 1
*/
function cal_info(int $calendar = -1): array {}

function cal_to_jd(int $calendar, int $month, int $day, int $year): int {}
Expand Down
2 changes: 1 addition & 1 deletion ext/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: d383ac249ddc88aee4cfaaefd37e85d913281f8e */
* Stub hash: 574dfd0c871b5c71677a3bfa07fd605aea343477 */

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_cal_days_in_month, 0, 3, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, calendar, IS_LONG, 0)
Expand Down
6 changes: 6 additions & 0 deletions ext/dba/dba.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function dba_exists($key, $dba): bool {}
*/
function dba_fetch($key, $skip, $dba = UNKNOWN): string|false {}

/** @return array<int, string>|false */
function dba_key_split(string|false|null $key): array|false {}

/** @param resource $dba */
Expand Down Expand Up @@ -68,6 +69,11 @@ function dba_optimize($dba): bool {}
/** @param resource $dba */
function dba_sync($dba): bool {}

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

/** @return array<int, string> */
function dba_list(): array {}
2 changes: 1 addition & 1 deletion ext/dba/dba_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: 092664d2d3fa28578e6c8e82160319678c211f0f */
* Stub hash: 670f79f43896b4f0cfd45396bdd8d7a06af1b613 */

ZEND_BEGIN_ARG_INFO_EX(arginfo_dba_popen, 0, 0, 2)
ZEND_ARG_INFO(0, path)
Expand Down
16 changes: 16 additions & 0 deletions ext/enchant/enchant.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ function enchant_broker_set_dict_path(EnchantBroker $broker, int $type, string $
/** @deprecated */
function enchant_broker_get_dict_path(EnchantBroker $broker, int $type): string|false {}

/**
* @return array<int, array>
* @refcount 1
*/
function enchant_broker_list_dicts(EnchantBroker $broker): array {}

function enchant_broker_request_dict(EnchantBroker $broker, string $tag): EnchantDictionary|false {}
Expand All @@ -44,13 +48,21 @@ function enchant_broker_dict_exists(EnchantBroker $broker, string $tag): bool {}

function enchant_broker_set_ordering(EnchantBroker $broker, string $tag, string $ordering): bool {}

/**
* @return array<int, array>
* @refcount 1
*/
function enchant_broker_describe(EnchantBroker $broker): array {}

/** @param array $suggestions */
function enchant_dict_quick_check(EnchantDictionary $dictionary, string $word, &$suggestions = null): bool {}

function enchant_dict_check(EnchantDictionary $dictionary, string $word): bool {}

/**
* @return array<int, string>
* @refcount 1
*/
function enchant_dict_suggest(EnchantDictionary $dictionary, string $word): array {}

function enchant_dict_add(EnchantDictionary $dictionary, string $word): void {}
Expand All @@ -75,4 +87,8 @@ function enchant_dict_store_replacement(EnchantDictionary $dictionary, string $m

function enchant_dict_get_error(EnchantDictionary $dictionary): string|false {}

/**
* @return array<string, string>
* @refcount 1
*/
function enchant_dict_describe(EnchantDictionary $dictionary): array {}
2 changes: 1 addition & 1 deletion ext/enchant/enchant_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: 27bafa980508d1a30073d9b009060a7a1953f5af */
* Stub hash: 751d42c599a97854a00ddae296e9b20efeee6a3e */

ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_enchant_broker_init, 0, 0, EnchantBroker, MAY_BE_FALSE)
ZEND_END_ARG_INFO()
Expand Down

0 comments on commit d02b9b9

Please sign in to comment.