From a793e7c685c059edcd25c8b03552308535b9537c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Mon, 6 Sep 2021 11:35:29 +0200 Subject: [PATCH 1/3] Add more specific array return type hints for various extensions - part 3 ext/ldap, ext/libxml, ext/opcache, ext/pdo --- Zend/Optimizer/zend_func_infos.h | 8 ++++++++ ext/ldap/ldap.stub.php | 22 +++++++++++++++++++++- ext/ldap/ldap_arginfo.h | 2 +- ext/libxml/libxml.stub.php | 4 ++++ ext/libxml/libxml_arginfo.h | 2 +- ext/opcache/opcache.stub.php | 8 ++++++++ ext/opcache/opcache_arginfo.h | 2 +- ext/pdo/pdo.stub.php | 4 ++++ ext/pdo/pdo_arginfo.h | 2 +- 9 files changed, 49 insertions(+), 5 deletions(-) diff --git a/Zend/Optimizer/zend_func_infos.h b/Zend/Optimizer/zend_func_infos.h index 260e450a31bd4..47f8f13976763 100644 --- a/Zend/Optimizer/zend_func_infos.h +++ b/Zend/Optimizer/zend_func_infos.h @@ -181,6 +181,11 @@ static const func_info_t func_infos[] = { F1("iconv_get_encoding", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_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), + F1("ldap_get_attributes", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_ARRAY), + F1("ldap_get_values_len", 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_FALSE), + F1("ldap_explode_dn", 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_FALSE), + F1("libxml_get_errors", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_OBJECT), F1("mb_language", MAY_BE_STRING|MAY_BE_BOOL), F1("mb_internal_encoding", MAY_BE_STRING|MAY_BE_BOOL), F1("mb_http_input", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_STRING|MAY_BE_FALSE), @@ -326,12 +331,15 @@ static const func_info_t func_infos[] = { #if !defined(HAVE_DBMAKER) && !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) &&!defined(HAVE_SOLID_35) FN("odbc_columnprivileges", MAY_BE_RESOURCE|MAY_BE_FALSE), #endif + F1("opcache_get_status", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_FALSE), + F1("opcache_get_configuration", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_FALSE), FN("pcntl_signal_get_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_LONG), FN("preg_replace", MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_NULL), FN("preg_filter", MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_NULL), FN("preg_replace_callback", MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_NULL), F1("preg_split", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_FALSE), F1("preg_grep", 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), + F1("pdo_drivers", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING), F1("pg_dbname", MAY_BE_STRING), F1("pg_options", MAY_BE_STRING), F1("pg_port", MAY_BE_STRING), diff --git a/ext/ldap/ldap.stub.php b/ext/ldap/ldap.stub.php index b49d2efe5caf2..7ef28623765cb 100644 --- a/ext/ldap/ldap.stub.php +++ b/ext/ldap/ldap.stub.php @@ -68,21 +68,41 @@ function ldap_first_entry(LDAP\Connection $ldap, LDAP\Result $result): LDAP\Resu function ldap_next_entry(LDAP\Connection $ldap, LDAP\ResultEntry $entry): LDAP\ResultEntry|false {} + /** + * @return array|false + * @refcount 1 + */ function ldap_get_entries(LDAP\Connection $ldap, LDAP\Result $result): array|false {} function ldap_first_attribute(LDAP\Connection $ldap, LDAP\ResultEntry $entry): string|false {} function ldap_next_attribute(LDAP\Connection $ldap, LDAP\ResultEntry $entry): string|false {} + /** + * @return array + * @refcount 1 + */ function ldap_get_attributes(LDAP\Connection $ldap, LDAP\ResultEntry $entry): array {} + /** + * @return array|false + * @refcount 1 + */ function ldap_get_values_len(LDAP\Connection $ldap, LDAP\ResultEntry $entry, string $attribute): array|false {} - /** @alias ldap_get_values_len */ + /** + * @return array|false + * @refcount 1 + * @alias ldap_get_values_len + */ function ldap_get_values(LDAP\Connection $ldap, LDAP\ResultEntry $entry, string $attribute): array|false {} function ldap_get_dn(LDAP\Connection $ldap, LDAP\ResultEntry $entry): string|false {} + /** + * @return array|false + * @refcount 1 + */ function ldap_explode_dn(string $dn, int $with_attrib): array|false {} function ldap_dn2ufn(string $dn): string|false {} diff --git a/ext/ldap/ldap_arginfo.h b/ext/ldap/ldap_arginfo.h index 17f745f8bc9be..9f3407a3be578 100644 --- a/ext/ldap/ldap_arginfo.h +++ b/ext/ldap/ldap_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: a1beb155767af8500567030b493d9d3ec408270a */ + * Stub hash: 16d2c843debf0dcd233d6040d4d326579d490e11 */ #if defined(HAVE_ORALDAP) ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_ldap_connect, 0, 0, LDAP\\Connection, MAY_BE_FALSE) diff --git a/ext/libxml/libxml.stub.php b/ext/libxml/libxml.stub.php index dc55815e6cd49..8c0587ccd2b86 100644 --- a/ext/libxml/libxml.stub.php +++ b/ext/libxml/libxml.stub.php @@ -19,6 +19,10 @@ function libxml_use_internal_errors(?bool $use_errors = null): bool {} function libxml_get_last_error(): LibXMLError|false {} +/** + * @return array + * @refcount 1 + */ function libxml_get_errors(): array {} function libxml_clear_errors(): void {} diff --git a/ext/libxml/libxml_arginfo.h b/ext/libxml/libxml_arginfo.h index ff179c30284fd..43d14c897864f 100644 --- a/ext/libxml/libxml_arginfo.h +++ b/ext/libxml/libxml_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 252fdc1cd83d2d3322cc040baf2bf3c7fde29254 */ + * Stub hash: ebd9e494686a7f3cbe3c2d67c34026ff44e2ae88 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_libxml_set_streams_context, 0, 1, IS_VOID, 0) ZEND_ARG_INFO(0, context) diff --git a/ext/opcache/opcache.stub.php b/ext/opcache/opcache.stub.php index ba65b9a264db3..4eeb76f083bc5 100644 --- a/ext/opcache/opcache.stub.php +++ b/ext/opcache/opcache.stub.php @@ -4,12 +4,20 @@ function opcache_reset(): bool {} +/** + * @return array|false + * @refcount 1 + */ function opcache_get_status(bool $include_scripts = true): array|false {} function opcache_compile_file(string $filename): bool {} function opcache_invalidate(string $filename, bool $force = false): bool {} +/** + * @return array|false + * @refcount 1 + */ function opcache_get_configuration(): array|false {} function opcache_is_script_cached(string $filename): bool {} diff --git a/ext/opcache/opcache_arginfo.h b/ext/opcache/opcache_arginfo.h index 55e867f392906..f35e6132fa2fd 100644 --- a/ext/opcache/opcache_arginfo.h +++ b/ext/opcache/opcache_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 919d85eb3f3e1127ea3911051f1d98340e84654e */ + * Stub hash: 81f337ea4ac5361ca4a0873fcd3b033beaf524c6 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_opcache_reset, 0, 0, _IS_BOOL, 0) ZEND_END_ARG_INFO() diff --git a/ext/pdo/pdo.stub.php b/ext/pdo/pdo.stub.php index c2e4d1edfc92c..39a508bafcb15 100644 --- a/ext/pdo/pdo.stub.php +++ b/ext/pdo/pdo.stub.php @@ -7,4 +7,8 @@ class PDOException extends RuntimeException public ?array $errorInfo = null; } +/** + * @return array + * @refcount 1 + */ function pdo_drivers(): array {} diff --git a/ext/pdo/pdo_arginfo.h b/ext/pdo/pdo_arginfo.h index a29fa2e7013ad..d4c74eef624f8 100644 --- a/ext/pdo/pdo_arginfo.h +++ b/ext/pdo/pdo_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 5cb75e0f0869651dd616b11c3bd0d407deb3c6df */ + * Stub hash: 52ee252fdfc80d4d076f1c49842e333c27ed5102 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pdo_drivers, 0, 0, IS_ARRAY, 0) ZEND_END_ARG_INFO() From 0446af75b0c276176a71df1dc94a41598e733f5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Mon, 6 Sep 2021 11:51:50 +0200 Subject: [PATCH 2/3] Fix refcount of libxml_get_errors() --- Zend/Optimizer/zend_func_infos.h | 2 +- ext/libxml/libxml.stub.php | 5 +---- ext/libxml/libxml_arginfo.h | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Zend/Optimizer/zend_func_infos.h b/Zend/Optimizer/zend_func_infos.h index 47f8f13976763..8e86d44f4ec2c 100644 --- a/Zend/Optimizer/zend_func_infos.h +++ b/Zend/Optimizer/zend_func_infos.h @@ -185,7 +185,7 @@ static const func_info_t func_infos[] = { F1("ldap_get_attributes", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_ARRAY), F1("ldap_get_values_len", 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_FALSE), F1("ldap_explode_dn", 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_FALSE), - F1("libxml_get_errors", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_OBJECT), + FN("libxml_get_errors", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_OBJECT), F1("mb_language", MAY_BE_STRING|MAY_BE_BOOL), F1("mb_internal_encoding", MAY_BE_STRING|MAY_BE_BOOL), F1("mb_http_input", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_STRING|MAY_BE_FALSE), diff --git a/ext/libxml/libxml.stub.php b/ext/libxml/libxml.stub.php index 8c0587ccd2b86..6c63862115d6c 100644 --- a/ext/libxml/libxml.stub.php +++ b/ext/libxml/libxml.stub.php @@ -19,10 +19,7 @@ function libxml_use_internal_errors(?bool $use_errors = null): bool {} function libxml_get_last_error(): LibXMLError|false {} -/** - * @return array - * @refcount 1 - */ +/** @return array */ function libxml_get_errors(): array {} function libxml_clear_errors(): void {} diff --git a/ext/libxml/libxml_arginfo.h b/ext/libxml/libxml_arginfo.h index 43d14c897864f..fb0e5edf75c4f 100644 --- a/ext/libxml/libxml_arginfo.h +++ b/ext/libxml/libxml_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: ebd9e494686a7f3cbe3c2d67c34026ff44e2ae88 */ + * Stub hash: 4bde2f5c4e55b6e0c273b0d8605cb765cc9f8400 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_libxml_set_streams_context, 0, 1, IS_VOID, 0) ZEND_ARG_INFO(0, context) From a5207ae77ad613fc61493d6817f9cf6f0044391d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Mon, 6 Sep 2021 11:54:26 +0200 Subject: [PATCH 3/3] Fix return type of ldap_get_attributes() --- Zend/Optimizer/zend_func_infos.h | 2 +- ext/ldap/ldap.stub.php | 2 +- ext/ldap/ldap_arginfo.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Zend/Optimizer/zend_func_infos.h b/Zend/Optimizer/zend_func_infos.h index 8e86d44f4ec2c..f92ee9b9ade13 100644 --- a/Zend/Optimizer/zend_func_infos.h +++ b/Zend/Optimizer/zend_func_infos.h @@ -182,7 +182,7 @@ static const func_info_t func_infos[] = { 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), - F1("ldap_get_attributes", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_ARRAY), + F1("ldap_get_attributes", 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("ldap_get_values_len", 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_FALSE), F1("ldap_explode_dn", 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_FALSE), FN("libxml_get_errors", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_OBJECT), diff --git a/ext/ldap/ldap.stub.php b/ext/ldap/ldap.stub.php index 7ef28623765cb..faa7edda3dc42 100644 --- a/ext/ldap/ldap.stub.php +++ b/ext/ldap/ldap.stub.php @@ -79,7 +79,7 @@ function ldap_first_attribute(LDAP\Connection $ldap, LDAP\ResultEntry $entry): s function ldap_next_attribute(LDAP\Connection $ldap, LDAP\ResultEntry $entry): string|false {} /** - * @return array + * @return array * @refcount 1 */ function ldap_get_attributes(LDAP\Connection $ldap, LDAP\ResultEntry $entry): array {} diff --git a/ext/ldap/ldap_arginfo.h b/ext/ldap/ldap_arginfo.h index 9f3407a3be578..33a7a922e830d 100644 --- a/ext/ldap/ldap_arginfo.h +++ b/ext/ldap/ldap_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 16d2c843debf0dcd233d6040d4d326579d490e11 */ + * Stub hash: 9f90cc4f751725c503bf4afd2b6c5e5b4e0379c8 */ #if defined(HAVE_ORALDAP) ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_ldap_connect, 0, 0, LDAP\\Connection, MAY_BE_FALSE)