mirror of
https://github.com/php/php-src.git
synced 2024-11-24 02:15:04 +08:00
Fix #81681: ReflectionEnum throwing exceptions
Enums are neither instantiable nor cloneable. Closes GH-7707.
This commit is contained in:
parent
9a3ca278b3
commit
59dd4fd742
2
NEWS
2
NEWS
@ -2,6 +2,8 @@ PHP NEWS
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
?? ??? ????, PHP 8.1.2
|
||||
|
||||
- Reflection:
|
||||
. Fixed bug #81681 (ReflectionEnum throwing exceptions). (cmb)
|
||||
|
||||
02 Dec 2021, PHP 8.1.1
|
||||
|
||||
|
@ -4751,7 +4751,7 @@ ZEND_METHOD(ReflectionClass, isInstantiable)
|
||||
RETURN_THROWS();
|
||||
}
|
||||
GET_REFLECTION_OBJECT_PTR(ce);
|
||||
if (ce->ce_flags & (ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_IMPLICIT_ABSTRACT_CLASS)) {
|
||||
if (ce->ce_flags & (ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_IMPLICIT_ABSTRACT_CLASS | ZEND_ACC_ENUM)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@ -4776,7 +4776,7 @@ ZEND_METHOD(ReflectionClass, isCloneable)
|
||||
RETURN_THROWS();
|
||||
}
|
||||
GET_REFLECTION_OBJECT_PTR(ce);
|
||||
if (ce->ce_flags & (ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_IMPLICIT_ABSTRACT_CLASS)) {
|
||||
if (ce->ce_flags & (ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_IMPLICIT_ABSTRACT_CLASS | ZEND_ACC_ENUM)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if (!Z_ISUNDEF(intern->obj)) {
|
||||
|
18
ext/reflection/tests/bug81681.phpt
Normal file
18
ext/reflection/tests/bug81681.phpt
Normal file
@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
Bug #81681 (ReflectionEnum throwing exceptions)
|
||||
--FILE--
|
||||
<?php
|
||||
enum Status
|
||||
{
|
||||
case Draft;
|
||||
case Published;
|
||||
case Archived;
|
||||
}
|
||||
|
||||
$reflectionEnum = new \ReflectionEnum('\Status');
|
||||
var_dump($reflectionEnum->isInstantiable());
|
||||
var_dump($reflectionEnum->isCloneable());
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
bool(false)
|
Loading…
Reference in New Issue
Block a user