2021-09-06 01:57:12 +02:00
|
|
|
# InvalidEnumCaseValue
|
|
|
|
|
|
|
|
Emitted when case value is invalid (see below).
|
|
|
|
|
|
|
|
## Case with a value on a pure enum
|
|
|
|
|
|
|
|
```php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
enum Status
|
|
|
|
{
|
|
|
|
case Open = "open";
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### How to fix
|
|
|
|
|
|
|
|
Either remove the value or alter the enum to be backed.
|
|
|
|
|
|
|
|
```php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
enum Status: string
|
|
|
|
{
|
|
|
|
case Open = "open";
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Case without a value on a backed enum
|
|
|
|
|
|
|
|
```php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
enum Status: string
|
|
|
|
{
|
|
|
|
case Open;
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### How to fix
|
|
|
|
|
|
|
|
Either alter the enum to be pure, or add a value.
|
|
|
|
|
|
|
|
```php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
enum Status
|
|
|
|
{
|
|
|
|
case Open;
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Case type mismatch
|
|
|
|
|
|
|
|
Case type should match the backing type of the enum.
|
|
|
|
|
|
|
|
```php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
enum Status: string
|
|
|
|
{
|
|
|
|
case Open = 1;
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### How to fix
|
|
|
|
|
|
|
|
Change the types so that they match
|
|
|
|
|
|
|
|
```php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
enum Status: string
|
|
|
|
{
|
|
|
|
case Open = "open";
|
|
|
|
}
|
|
|
|
```
|
2022-11-10 06:59:34 +01:00
|
|
|
|
2022-11-11 01:26:37 +01:00
|
|
|
## Case with a type that cannot back an enum
|
2022-11-10 06:59:34 +01:00
|
|
|
|
|
|
|
Case type should be either `int` or `string`.
|
|
|
|
|
|
|
|
```php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
enum Status: int {
|
|
|
|
case Open = [];
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### How to fix
|
|
|
|
|
|
|
|
Change the case value so that it's one of the allowed types (and matches the backing type)
|
|
|
|
|
|
|
|
```php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
enum Status: int
|
|
|
|
{
|
|
|
|
case Open = 1;
|
|
|
|
}
|
|
|
|
```
|