Skip to content

Commit 2ce2aff

Browse files
authored
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 php/doc-en#1608 Closes GH-8687
1 parent eb022f8 commit 2ce2aff

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ PHP NEWS
5555
- Reflection:
5656
. Added ReflectionFunction::isAnonymous(). (Nicolas Grekas)
5757
. Added ReflectionMethod::hasPrototype(). (Ollie Read)
58+
. Narrow ReflectionEnum::getBackingType() return type to ReflectionNamedType.
59+
(SamMousa)
5860

5961
- Session:
6062
. Fixed bug GH-7787 (Improve session write failure message for user error

ext/reflection/php_reflection.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ public function getCases(): array {}
729729

730730
public function isBacked(): bool {}
731731

732-
public function getBackingType(): ?ReflectionType {}
732+
public function getBackingType(): ?ReflectionNamedType {}
733733
}
734734

735735
class ReflectionEnumUnitCase extends ReflectionClassConstant

ext/reflection/php_reflection_arginfo.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 4191864554b030bea40306c0d30090a8e2c76ab2 */
2+
* Stub hash: 9daec020902840b7f678d787e61e91f7e16ad4da */
33

44
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Reflection_getModifierNames, 0, 1, IS_ARRAY, 0)
55
ZEND_ARG_TYPE_INFO(0, modifiers, IS_LONG, 0)
@@ -568,7 +568,8 @@ ZEND_END_ARG_INFO()
568568

569569
#define arginfo_class_ReflectionEnum_isBacked arginfo_class_ReflectionFunctionAbstract_hasTentativeReturnType
570570

571-
#define arginfo_class_ReflectionEnum_getBackingType arginfo_class_ReflectionFunctionAbstract_getTentativeReturnType
571+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_ReflectionEnum_getBackingType, 0, 0, ReflectionNamedType, 1)
572+
ZEND_END_ARG_INFO()
572573

573574
#define arginfo_class_ReflectionEnumUnitCase___construct arginfo_class_ReflectionClassConstant___construct
574575

0 commit comments

Comments
 (0)