From 64d0f2fdfdad4be345146e5a1926debb574af3d6 Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Thu, 3 Oct 2024 21:37:28 -0700 Subject: [PATCH] `PhpToken::is()`: switch `@param` to typehint The type is enforced, and `TypeError`s are already thrown, but the information about the required type is not provided to Reflection. Replace the `@param` comment with a real typehint so that the information is also available via Reflection. --- ext/tokenizer/tokenizer.stub.php | 3 +-- ext/tokenizer/tokenizer_arginfo.h | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/ext/tokenizer/tokenizer.stub.php b/ext/tokenizer/tokenizer.stub.php index 6017e704aa26a..42b78cfc18b1c 100644 --- a/ext/tokenizer/tokenizer.stub.php +++ b/ext/tokenizer/tokenizer.stub.php @@ -24,8 +24,7 @@ public static function tokenize(string $code, int $flags = 0): array {} final public function __construct(int $id, string $text, int $line = -1, int $pos = -1) {} - /** @param int|string|array $kind */ - public function is($kind): bool {} + public function is(int|string|array $kind): bool {} public function isIgnorable(): bool {} diff --git a/ext/tokenizer/tokenizer_arginfo.h b/ext/tokenizer/tokenizer_arginfo.h index b98a5655b6c74..277648189cfc4 100644 --- a/ext/tokenizer/tokenizer_arginfo.h +++ b/ext/tokenizer/tokenizer_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: a89f03303f8a7d254509ae2bc46a36bb79a3c900 */ + * Stub hash: 4fe0369b727f35576db0e8c99a348d11b8f507b8 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_token_get_all, 0, 1, IS_ARRAY, 0) ZEND_ARG_TYPE_INFO(0, code, IS_STRING, 0) @@ -20,7 +20,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PhpToken___construct, 0, 0, 2) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_PhpToken_is, 0, 1, _IS_BOOL, 0) - ZEND_ARG_INFO(0, kind) + ZEND_ARG_TYPE_MASK(0, kind, MAY_BE_LONG|MAY_BE_STRING|MAY_BE_ARRAY, NULL) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_PhpToken_isIgnorable, 0, 0, _IS_BOOL, 0)