mirror of
https://github.com/php/php-src.git
synced 2024-11-24 02:15:04 +08:00
Fixed bug #81457
When Reflection internally instantiates a ReflectionClass, it should create a more specific ReflectionEnum instance if the class is actually an enum.
This commit is contained in:
parent
55582a2527
commit
ea11e79a43
4
NEWS
4
NEWS
@ -2,6 +2,10 @@ PHP NEWS
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
?? ??? ????, PHP 8.1.0RC3
|
||||
|
||||
- Reflection:
|
||||
. Fixed bug #81457 (Enum: ReflectionMethod->getDeclaringClass() return a
|
||||
ReflectionClass). (Nikita)
|
||||
|
||||
- XML:
|
||||
. Fixed bug #70962 (XML_OPTION_SKIP_WHITE strips embedded whitespace).
|
||||
(Aliaksandr Bystry, cmb)
|
||||
|
@ -1231,7 +1231,9 @@ PHPAPI void zend_reflection_class_factory(zend_class_entry *ce, zval *object)
|
||||
{
|
||||
reflection_object *intern;
|
||||
|
||||
reflection_instantiate(reflection_class_ptr, object);
|
||||
zend_class_entry *reflection_ce =
|
||||
ce->ce_flags & ZEND_ACC_ENUM ? reflection_enum_ptr : reflection_class_ptr;
|
||||
reflection_instantiate(reflection_ce, object);
|
||||
intern = Z_REFLECTION_P(object);
|
||||
intern->ptr = ce;
|
||||
intern->ref_type = REF_TYPE_OTHER;
|
||||
@ -1240,18 +1242,6 @@ PHPAPI void zend_reflection_class_factory(zend_class_entry *ce, zval *object)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static void zend_reflection_enum_factory(zend_class_entry *ce, zval *object)
|
||||
{
|
||||
reflection_object *intern;
|
||||
|
||||
reflection_instantiate(reflection_enum_ptr, object);
|
||||
intern = Z_REFLECTION_P(object);
|
||||
intern->ptr = ce;
|
||||
intern->ref_type = REF_TYPE_OTHER;
|
||||
intern->ce = ce;
|
||||
ZVAL_STR_COPY(reflection_prop_name(object), ce->name);
|
||||
}
|
||||
|
||||
/* {{{ reflection_extension_factory */
|
||||
static void reflection_extension_factory(zval *object, const char *name_str)
|
||||
{
|
||||
@ -6849,7 +6839,7 @@ ZEND_METHOD(ReflectionEnumUnitCase, getEnum)
|
||||
}
|
||||
GET_REFLECTION_OBJECT_PTR(ref);
|
||||
|
||||
zend_reflection_enum_factory(ref->ce, return_value);
|
||||
zend_reflection_class_factory(ref->ce, return_value);
|
||||
}
|
||||
|
||||
ZEND_METHOD(ReflectionEnumBackedCase, __construct)
|
||||
|
26
ext/reflection/tests/bug81457.phpt
Normal file
26
ext/reflection/tests/bug81457.phpt
Normal file
@ -0,0 +1,26 @@
|
||||
--TEST--
|
||||
Bug #81457: Enum ReflectionMethod->getDeclaringClass() return a ReflectionClass
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
enum testEnum {
|
||||
case A;
|
||||
case B;
|
||||
|
||||
public function foo () {}
|
||||
}
|
||||
|
||||
$re = new ReflectionEnum(testEnum::class);
|
||||
$me = $re->getMethod('foo');
|
||||
|
||||
echo $me->getDeclaringClass()::class, "\n";
|
||||
|
||||
$rc = new ReflectionClass(testEnum::class);
|
||||
$mc = $re->getMethod('foo');
|
||||
|
||||
echo $mc->getDeclaringClass()::class, "\n";
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
ReflectionEnum
|
||||
ReflectionEnum
|
Loading…
Reference in New Issue
Block a user