[php-src] Issue #9941: Enum syntax error when using `$this` inside a method
| From: | foremtehan | Date: | Sat, 12 Nov 2022 07:46:49 +0000 |
| Subject: | [php-src] Issue #9941: Enum syntax error when using `$this` inside a method | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-242798@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/9941
Author: foremtehan
### Description
The following code:
```php
<?php
enum Language: int
{
case English = 1;
public function isEnglish(): bool
{
return $this instanceof self::English;
}
}
echo Language::English->value;
```
Resulted in this output:
```
Parse error: syntax error, unexpected identifier "English", expecting variable or
"$" in php shell code on line 1
```
But I expected this output instead:
```
1
```
Using
$this is not allowed inside a enum?
### PHP Version
PHP 8.1.12
### Operating System
ubuntu:latest