plugin-php icon indicating copy to clipboard operation
plugin-php copied to clipboard

Class attribute gets duplicated on another class property

Open hackel opened this issue 7 months ago • 1 comments

The Deprecated attribute is being copied from the TYPES constant to the neighbouring $attributes property for some reason. I have to remove it manually whenever I format this file.

@prettier/plugin-php v0.22.4 Playground link

Input:

<?php

namespace App\Models;

class QuoteSearch extends Model
{
    #[Deprecated(message: 'use \App\Enums\MoveType')]
    public const TYPES = [
        'IMPORT' => 'import',
        'EXPORT' => 'export',
    ];

    protected $attributes = [
        'search_job_completed' => false,
    ];
}

Output:

<?php

namespace App\Models;

class QuoteSearch extends Model
{
    #[Deprecated(message: "use \App\Enums\MoveType")]
    public const TYPES = [
        "IMPORT" => "import",
        "EXPORT" => "export",
    ];

    #[Deprecated(message: "use \App\Enums\MoveType")]
    protected $attributes = [
        "search_job_completed" => false,
    ];
}

hackel avatar Jul 11 '25 13:07 hackel

Thanks for the bug report @hackel!

czosel avatar Jul 11 '25 19:07 czosel