[php-src] Issue #8477: Enum definition isn't evaluated as expected

From: Date: Mon, 02 May 2022 02:57:44 +0000
Subject: [php-src] Issue #8477: Enum definition isn't evaluated as expected
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-241359@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8477 Author: jpheldson ### Description Unlike class definitions, it seems that enum definitions currently need to executed before they are used. So far as I could find this is not in the documentation, and leads to very un-intuitive behavior. The following code: ```php <?php $f = new Foo(); var_export($f->returnEnum()); enum FooEnum { case Bar; case Qux; } class Foo { public function returnEnum(): FooEnum { return FooEnum::Bar; } } ``` Resulted in this output: ``` Fatal error: Uncaught Error: Class "FooEnum" not found in /home/tmp/u.php:14 Stack trace: #0 /home/tmp/u.php(4): Foo->returnEnum() #1 {main} thrown in /home/tmp/u.php on line 14 ``` But I expected this output instead: ``` FooEnum::Bar ``` ### PHP Version PHP 8.1.2 ### Operating System FreeBSD 12.3-RELEASE r371270 NFSN64 amd64

« previous php.bugs (#241359) next »