From c76910cd967f498065f50f17dcaad941792e8430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 16 Sep 2020 21:19:36 +0200 Subject: [PATCH] Display types in stubs more uniformly In preparation for generating method signatures for the manual. This change gets rid of bogus false|null return types, a few unnecessary trailing backslashes, and settles on using ? when possible for nullable types. --- ext/dom/php_dom.stub.php | 5 ++--- ext/dom/php_dom_arginfo.h | 2 +- ext/imap/php_imap.stub.php | 12 ++++++------ ext/imap/php_imap_arginfo.h | 2 +- ext/intl/php_intl.stub.php | 2 +- ext/intl/php_intl_arginfo.h | 2 +- ext/oci8/oci8.stub.php | 4 ++-- ext/oci8/oci8_arginfo.h | 2 +- ext/pdo/pdo_stmt.stub.php | 2 +- ext/pdo/pdo_stmt_arginfo.h | 2 +- ext/sockets/sockets.stub.php | 2 +- ext/sockets/sockets_arginfo.h | 2 +- ext/spl/spl_directory.stub.php | 2 +- ext/spl/spl_directory_arginfo.h | 2 +- ext/standard/basic_functions.stub.php | 2 +- ext/standard/basic_functions_arginfo.h | 2 +- ext/zip/php_zip.stub.php | 8 ++++---- ext/zip/php_zip_arginfo.h | 2 +- 18 files changed, 28 insertions(+), 29 deletions(-) diff --git a/ext/dom/php_dom.stub.php b/ext/dom/php_dom.stub.php index 8ed6723250b..5f15f99e174 100644 --- a/ext/dom/php_dom.stub.php +++ b/ext/dom/php_dom.stub.php @@ -56,8 +56,7 @@ class DOMNode /** @return int */ public function getLineNo() {} - /** @return string|null - */ + /** @return string|null */ public function getNodePath() {} /** @return bool */ @@ -211,7 +210,7 @@ class DOMElement implements DOMParentNode, DOMChildNode /** @return DOMAttr|bool */ public function setAttribute(string $qualifiedName, string $value) {} - /** @return null|false */ + /** @return bool|null */ public function setAttributeNS(?string $namespace, string $qualifiedName, string $value) {} /** @return DOMAttr|null|false */ diff --git a/ext/dom/php_dom_arginfo.h b/ext/dom/php_dom_arginfo.h index 7da82ba710f..d5da40e4639 100644 --- a/ext/dom/php_dom_arginfo.h +++ b/ext/dom/php_dom_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 6d25769eb3f8686042dccc55d8d8bd5e3852676f */ + * Stub hash: 8ac9356f9b19b84e98d335bc9d091b022a0f549d */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_dom_import_simplexml, 0, 1, DOMElement, 1) ZEND_ARG_TYPE_INFO(0, node, IS_OBJECT, 0) diff --git a/ext/imap/php_imap.stub.php b/ext/imap/php_imap.stub.php index fb83dc6c549..d707af161c2 100644 --- a/ext/imap/php_imap.stub.php +++ b/ext/imap/php_imap.stub.php @@ -35,7 +35,7 @@ function imap_headerinfo($stream_id, int $msg_no, int $from_length = 0, int $sub */ function imap_header($stream_id, int $msg_no, int $from_length = 0, int $subject_length = 0, string $default_host = UNKNOWN): stdClass|false {} -function imap_rfc822_parse_headers(string $headers, string $default_host = 'UNKNOWN'): \stdClass {} +function imap_rfc822_parse_headers(string $headers, string $default_host = 'UNKNOWN'): stdClass {} function imap_rfc822_write_address(string $mailbox, string $host, string $personal): string|false {} @@ -52,7 +52,7 @@ function imap_fetchtext($stream_id, int $msg_no, int $options = 0): string|false /** * @param resource $stream_id - * @return \stdClass|false + * @return stdClass|false */ function imap_bodystruct($stream_id, int $msg_no, string $section) {} @@ -166,12 +166,12 @@ function imap_utf8(string $mime_encoded_text): string {} /** * @param resource $stream_id - * @return \stdClass|false + * @return stdClass|false */ function imap_status($stream_id, string $mailbox, int $options) {} /** @param resource $stream_id */ -function imap_mailboxmsginfo($stream_id): \stdClass {} +function imap_mailboxmsginfo($stream_id): stdClass {} /** @param resource $stream_id */ function imap_setflag_full($stream_id, string $sequence, string $flag, int $options = 0): bool {} @@ -222,7 +222,7 @@ function imap_errors(): array|false {} function imap_last_error(): string|false {} /** @param resource $stream_id */ -function imap_search($stream_id, string $criteria, int $options = \SE_FREE, string $charset = ''): array|false {} +function imap_search($stream_id, string $criteria, int $options = SE_FREE, string $charset = ''): array|false {} function imap_utf7_decode(string $buf): string|false {} @@ -237,7 +237,7 @@ function imap_mutf7_to_utf8(string $in): string|false {} function imap_mime_header_decode(string $str): array|false {} /** @param resource $stream_id */ -function imap_thread($stream_id, int $options = \SE_FREE): array|false {} +function imap_thread($stream_id, int $options = SE_FREE): array|false {} function imap_timeout(int $timeout_type, int $timeout = -1): int|bool {} diff --git a/ext/imap/php_imap_arginfo.h b/ext/imap/php_imap_arginfo.h index fd679f99538..013ef9096c7 100644 --- a/ext/imap/php_imap_arginfo.h +++ b/ext/imap/php_imap_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 449bab2357a8a83cbe4f630a87776ebb5e0d65f6 */ + * Stub hash: 2c859e2e8d8de83dc517a245b5b34a6dd74e5dab */ ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_open, 0, 0, 3) ZEND_ARG_TYPE_INFO(0, mailbox, IS_STRING, 0) diff --git a/ext/intl/php_intl.stub.php b/ext/intl/php_intl.stub.php index f2a1af1c2e2..67bd27be92a 100644 --- a/ext/intl/php_intl.stub.php +++ b/ext/intl/php_intl.stub.php @@ -5,7 +5,7 @@ /* calendar */ /** @param IntlTimeZone|DateTimeZone|string|null $timeZone */ -function intlcal_create_instance($timeZone = null, ?string $locale = null): IntlCalendar|null {} +function intlcal_create_instance($timeZone = null, ?string $locale = null): ?IntlCalendar {} function intlcal_get_keyword_values_for_locale(string $key, string $locale, bool $commonlyUsed): IntlIterator|false {} diff --git a/ext/intl/php_intl_arginfo.h b/ext/intl/php_intl_arginfo.h index 32f098d0bb8..1b1c0ea84dc 100644 --- a/ext/intl/php_intl_arginfo.h +++ b/ext/intl/php_intl_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 324b7ae3eaab4777117c1c6963bc841088e6b998 */ + * Stub hash: 943baf02eee2f720a45106e379534b3d4adc3072 */ 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") diff --git a/ext/oci8/oci8.stub.php b/ext/oci8/oci8.stub.php index 917225f5626..58eb984f94c 100644 --- a/ext/oci8/oci8.stub.php +++ b/ext/oci8/oci8.stub.php @@ -320,14 +320,14 @@ function ocifreecursor($statement_resource): bool {} /** * @param resource $connection_resource */ -function oci_close($connection_resource): bool|null {} +function oci_close($connection_resource): ?bool {} /** * @param resource $connection_resource * @alias oci_close * @deprecated */ -function ocilogoff($connection_resource): bool|null {} +function ocilogoff($connection_resource): ?bool {} /** * @return resource|false diff --git a/ext/oci8/oci8_arginfo.h b/ext/oci8/oci8_arginfo.h index 0bcc18f06a1..b385554bdfa 100644 --- a/ext/oci8/oci8_arginfo.h +++ b/ext/oci8/oci8_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 6cdc7c967ce80c39eaef1c860ba8f8aa2cb3c979 */ + * Stub hash: 9c680329bc6159aae027df94230c6d2342021271 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_define_by_name, 0, 3, _IS_BOOL, 0) ZEND_ARG_INFO(0, statement_resource) diff --git a/ext/pdo/pdo_stmt.stub.php b/ext/pdo/pdo_stmt.stub.php index d0141ceb45e..b280f73ffdb 100644 --- a/ext/pdo/pdo_stmt.stub.php +++ b/ext/pdo/pdo_stmt.stub.php @@ -19,7 +19,7 @@ class PDOStatement implements IteratorAggregate /** @return int|false */ public function columnCount() {} - /** @return false|null */ + /** @return bool|null */ public function debugDumpParams() {} /** @return string|false|null */ diff --git a/ext/pdo/pdo_stmt_arginfo.h b/ext/pdo/pdo_stmt_arginfo.h index c05606c6faa..116449ad3ae 100644 --- a/ext/pdo/pdo_stmt_arginfo.h +++ b/ext/pdo/pdo_stmt_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 18f2af62bebcbbbf0e298f781860c251cfa07930 */ + * Stub hash: a35e66ccff5e569f07ae8372e661e005943dfbc7 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_bindColumn, 0, 0, 2) ZEND_ARG_TYPE_MASK(0, column, MAY_BE_STRING|MAY_BE_LONG, NULL) diff --git a/ext/sockets/sockets.stub.php b/ext/sockets/sockets.stub.php index 547374fe97b..8acab114e56 100644 --- a/ext/sockets/sockets.stub.php +++ b/ext/sockets/sockets.stub.php @@ -78,7 +78,7 @@ function socket_setopt(Socket $socket, int $level, int $optname, $optval): bool #ifdef HAVE_SOCKETPAIR /** @param array $fd */ -function socket_create_pair(int $domain, int $type, int $protocol, &$fd): bool|null {} +function socket_create_pair(int $domain, int $type, int $protocol, &$fd): ?bool {} #endif #ifdef HAVE_SHUTDOWN diff --git a/ext/sockets/sockets_arginfo.h b/ext/sockets/sockets_arginfo.h index e7f4c047993..0923918a941 100644 --- a/ext/sockets/sockets_arginfo.h +++ b/ext/sockets/sockets_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: f2d1b412bf2e07c3e607aa6ebad25b19d882b98e */ + * Stub hash: f35790f5f703b37c45230e97e8f0ee736727b4bd */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_socket_select, 0, 4, MAY_BE_LONG|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(1, read_fds, IS_ARRAY, 1) diff --git a/ext/spl/spl_directory.stub.php b/ext/spl/spl_directory.stub.php index 4691378ca9b..0e942a2e12b 100755 --- a/ext/spl/spl_directory.stub.php +++ b/ext/spl/spl_directory.stub.php @@ -211,7 +211,7 @@ class SplFileObject extends SplFileInfo implements RecursiveIterator, SeekableIt /** @return int|false */ public function fputcsv(array $fields, string $delimiter = ',', string $enclosure = '"', string $escape = "\\") {} - /** @return null|false */ + /** @return bool|null */ public function setCsvControl(string $delimiter = ",", string $enclosure = "\"", string $escape = "\\") {} /** @return array */ diff --git a/ext/spl/spl_directory_arginfo.h b/ext/spl/spl_directory_arginfo.h index 7442c9c0e88..616f3f138fa 100644 --- a/ext/spl/spl_directory_arginfo.h +++ b/ext/spl/spl_directory_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 9127cb70a84f3e75ed16a17b15940b8a6b5f3937 */ + * Stub hash: fc41da9a307965e501bcc7e912470cf650a3d70d */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplFileInfo___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, file_name, IS_STRING, 0) diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index 0b771fbd491..d0df30c0564 100755 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -745,7 +745,7 @@ function exec(string $command, &$output = null, &$result_code = null): string|fa function system(string $command, &$result_code = null): string|false {} /** @param int $result_code */ -function passthru(string $command, &$result_code = null): bool|null {} +function passthru(string $command, &$result_code = null): ?bool {} function escapeshellcmd(string $command): string {} diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index e27c934c037..5717e5d336c 100644 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 0224dc521c4a8bd49fbcfd26cddb01a2e571cf74 */ + * Stub hash: 7cb3c95b61a57e5b88a37638dd90ff314cc89dd4 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0) diff --git a/ext/zip/php_zip.stub.php b/ext/zip/php_zip.stub.php index cde266261d6..6b81a623b07 100644 --- a/ext/zip/php_zip.stub.php +++ b/ext/zip/php_zip.stub.php @@ -111,17 +111,17 @@ class ZipArchive /** @return string|false */ public function getArchiveComment(int $flags = 0) {} - /** @return null|false */ + /** @return bool|null */ public function setCommentIndex(int $index, string $comment) {} - /** @return null|false */ + /** @return bool|null */ public function setCommentName(string $name, string $comment) {} #ifdef HAVE_SET_MTIME - /** @return null|false */ + /** @return bool|null */ public function setMtimeIndex(int $index, int $timestamp, int $flags = 0) {} - /** @return null|false */ + /** @return bool|null */ public function setMtimeName(string $name, int $timestamp, int $flags = 0) {} #endif diff --git a/ext/zip/php_zip_arginfo.h b/ext/zip/php_zip_arginfo.h index c9f90d57f98..e657511969e 100644 --- a/ext/zip/php_zip_arginfo.h +++ b/ext/zip/php_zip_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 49f168c537e48f8a3998d67812a5e2e6a2463533 */ + * Stub hash: d6e87c137cf1b372619b3890d04285d94d486c82 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_zip_open, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)