Skip to content

ClassMustBeFinal alter leading to syntax error with attributes #11289

@iquito

Description

@iquito

The new vendor/bin/psalm --alter --issues=ClassMustBeFinal (running v6.6) does not take into account attributes and introduces syntax errors when run.

The following:

#[Entity('addresses')]
readonly class Address
{
}

Gets "fixed" into:

final #[Entity('addresses')]
readonly class Address
{
}

Which then is a syntax error in PHP (and in Psalm too). As class attributes are often used in PHP, this is a huge pain, especially as Psalm now advocates for running this alteration.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions