apache / apache/netbeans

[PHP] Accessing Enum::value on Non Backed Enums should produce warning

Open
#5,073 0 comments 0 reactions 0 assignees View on GitHub
kind:feature PHP
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### Apache NetBeans version

Apache NetBeans 16

### What happened

Enum::value will produce warning if the enum is not Backed Enums

### How to reproduce

```php
name ."\n"; // OK
echo Suit1::Clubs->value ."\n"; // this statement should display warning

$card = Suit1::Diamonds;
echo $card->name ."\n"; // OK
echo $card->value ."\n"; // this statement should display warning

// ----------------------------------

enum Suit2: string {
case Hearts = 'H';
case Diamonds = 'D';
case Clubs = 'C';
case Spades = 'S';
}

echo Suit2::Spades->name ."\n"; // OK
echo Suit2::Clubs->value ."\n"; // OK

$card2 = Suit2::Diamonds;
echo $card2->name ."\n"; // OK
echo $card2->value ."\n"; // OK
```

### Did this work correctly in an earlier version?

No / Don't know

### Operating System

Windows 10

### JDK

Java: 14.0.1; Java HotSpot(TM) 64-Bit Server VM 14.0.1+7 Runtime: Java(TM) SE Runtime Environment 14.0.1+7

### Apache NetBeans packaging

Apache NetBeans provided installer

### Anything else

_No response_

### Are you willing to submit a pull request?

No

### Code of Conduct

Yes

Contributor guide

Open the contributing guide

Research direction

Use the PHP enum example in the issue as the reproduction entry point, checking both non-backed and backed enums and both direct and variable access. Confirm that accessing value on a non-backed enum produces a warning while name remains valid, and verify the corresponding diagnostic in NetBeans' PHP editor.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.