php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81681 ReflectionEnum throwing exceptions
Submitted: 2021-12-01 03:21 UTC Modified: 2021-12-01 10:52 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: brucekwells at gmail dot com Assigned:
Status: Closed Package: Reflection related
PHP Version: 8.1.0 OS: Windows 10 build 19043.1348
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: brucekwells at gmail dot com
New email:
PHP Version: OS:

 

 [2021-12-01 03:21 UTC] 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 ....

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-12-01 10:52 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2021-12-01 10:52 UTC] cmb@php.net
Confirmed: <https://3v4l.org/Etoga>.
 [2021-12-02 18:07 UTC] cmb@php.net
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
 [2021-12-02 22:23 UTC] git@php.net
Automatic comment on behalf of cmb69
Revision: https://github.com/php/php-src/commit/59dd4fd742ddbbf6a0238e89f427a32918d1dd08
Log: Fix #81681: ReflectionEnum throwing exceptions
 [2021-12-02 22:23 UTC] git@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Feb 04 11:05:48 2023 UTC