Bug #81681 [PATCH]: ReflectionEnum throwing exceptions
| From: | cmb@php.net | Date: | Thu, 02 Dec 2021 18:07:40 +0000 |
| Subject: | Bug #81681 [PATCH]: ReflectionEnum throwing exceptions | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-238117@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81681&edit=1
ID: 81681
Patch added by: cmb@php.net
Reported by: brucekwells at gmail dot com
Summary: ReflectionEnum throwing exceptions
Status: Verified
Type: Bug
Package: Reflection related
Operating System: Windows 10 build 19043.1348
PHP Version: 8.1.0
Block user comment: N
Private report: N
New Comment:
The following pull request has been associated:
Patch Name: Fix #81681: ReflectionEnum throwing exceptions
On GitHub: https://github.com/php/php-src/pull/7707
Patch: https://github.com/php/php-src/pull/7707.patch
Previous Comments:
------------------------------------------------------------------------
[2021-12-01 10:52:05] cmb@php.net
Confirmed: <https://3v4l.org/Etoga>.
------------------------------------------------------------------------
[2021-12-01 03:21:16] brucekwells at gmail dot com
Description:
------------
ReflectionEnum::isInstantiable returns true (should return false)
ReflectionEnum::isCloneable throws exception (should return false)
Probably other issues, but ran into these first, which are obviously wrong. All methods in
ReflectionEnum inherited from ReflectionClass should return reasonable values for an enum.
Test script:
---------------
Status.php:
enum Status
{
case Draft;
case Published;
case Archived;
}
Test script:
include 'yourautoloader.php';
$reflectionClass = new \ReflectionEnum('\Status');
echo $reflectionClass->isInstantiable();
echo "\n";
echo $reflectionClass->isCloneable();
Expected result:
----------------
0
0
Actual result:
--------------
1
Fatal error: Uncaught Error: Cannot instantiate enum Status ....
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81681&edit=1