From 2ce2aff50ec43dbc52be6fe755b158f69cd2579b Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 2 Jun 2022 18:13:21 +0200 Subject: [PATCH] Better return types for `getBackingType` (#8687) The only backing types for Enums are int and string. The proper return type for ReflectionEnum::getBackingType() is thus null|ReflectionNamedType. See also https://github.com/php/doc-en/pull/1608 Closes GH-8687 --- NEWS | 2 ++ ext/reflection/php_reflection.stub.php | 2 +- ext/reflection/php_reflection_arginfo.h | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 9116699c92d..91d0c9f9f7a 100644 --- a/NEWS +++ b/NEWS @@ -55,6 +55,8 @@ PHP NEWS - Reflection: . Added ReflectionFunction::isAnonymous(). (Nicolas Grekas) . Added ReflectionMethod::hasPrototype(). (Ollie Read) + . Narrow ReflectionEnum::getBackingType() return type to ReflectionNamedType. + (SamMousa) - Session: . Fixed bug GH-7787 (Improve session write failure message for user error diff --git a/ext/reflection/php_reflection.stub.php b/ext/reflection/php_reflection.stub.php index 33130d568c7..b0c23cb1197 100644 --- a/ext/reflection/php_reflection.stub.php +++ b/ext/reflection/php_reflection.stub.php @@ -729,7 +729,7 @@ class ReflectionEnum extends ReflectionClass public function isBacked(): bool {} - public function getBackingType(): ?ReflectionType {} + public function getBackingType(): ?ReflectionNamedType {} } class ReflectionEnumUnitCase extends ReflectionClassConstant diff --git a/ext/reflection/php_reflection_arginfo.h b/ext/reflection/php_reflection_arginfo.h index a2e598c2105..caac7ec44df 100644 --- a/ext/reflection/php_reflection_arginfo.h +++ b/ext/reflection/php_reflection_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 4191864554b030bea40306c0d30090a8e2c76ab2 */ + * Stub hash: 9daec020902840b7f678d787e61e91f7e16ad4da */ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Reflection_getModifierNames, 0, 1, IS_ARRAY, 0) ZEND_ARG_TYPE_INFO(0, modifiers, IS_LONG, 0) @@ -568,7 +568,8 @@ ZEND_END_ARG_INFO() #define arginfo_class_ReflectionEnum_isBacked arginfo_class_ReflectionFunctionAbstract_hasTentativeReturnType -#define arginfo_class_ReflectionEnum_getBackingType arginfo_class_ReflectionFunctionAbstract_getTentativeReturnType +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_ReflectionEnum_getBackingType, 0, 0, ReflectionNamedType, 1) +ZEND_END_ARG_INFO() #define arginfo_class_ReflectionEnumUnitCase___construct arginfo_class_ReflectionClassConstant___construct