Skip to content

Enum Fatal Error Highlighting #199

Description

@Disservin

PHPantom version

phpantom_lsp 0.8.0-86-gefdc9ae4

Installation method

Pre-built binary from GitHub Releases

Operating system

macOS aarch64 (Apple Silicon)

Editor

VS Code

Bug description

The following cases should report at least some sort of error, because they aren't valid php.

Steps to reproduce

Invalid enum declaration will raise a fatal php error, missing scalar type in declaration.

enum MyType {
    case Any = 0;
    case Array = 2;
}

Invalid enum declaration will raise a fatal php error, missing backed value for enum case.

enum MyType: int {
    case Any = 0;
    case Array;
}

Invalid enum declaration will raise a fatal php error, backed value type can only be string or int.

enum TypeDescriptor: bool {
    case Any = false;
    case Array = true;
}

Invalid enum declaration will raise a fatal php error when it is first used (runtime error, the others are compile errors), duplicate values are invalid, not only for values but also for the keys.

enum Test: string {
    case FOO = 'baz';
    case BAR = 'baz';
}

echo Test::FOO->value;

Error output or panic trace


.phpantom.toml

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions