Skip to content

Bug on Attributes! #2437

Open
Open

Description

@siMobin

@prettier/plugin-php v0.23.0
Playground link

Input:

<?php
new
#[Lazy]
#[Computed] 
#[Title('Staff')]
class extends Component {
    public $editing = [];
    public $branches;
};

Output:

<?php
new #[Lazy] #[Computed] #[Title("Staff")] class extends Component {
    public $editing = [];
    public $branches;
};

I tried to figure out how to fix this broken attribute formatting, but I couldn't find any information about it.

Activity

  1. hackel commented on May 21, 2026

    @hackel
    Contributor

    It's not a "bug" or "broken" just because it doesn't match your preferred formatting style. This matches Prettier's general philosophy, which is to put it all on one line if it fits. I don't particularly care for this style either, but that's the way it is.

    Edit: I take that back. It looks like this is going to become a part of the next PER standard, but will require an indent to clarify what is going on.

    $example = new
        #[Attribute]
        class {
            ...
        };

    php-fig/per-coding-style#136

  2. nicoder commented on May 21, 2026

    @nicoder
    Contributor

    ah, interesting, I was trying to see what PER recommended but it was not clear to me in the case of an anonymous class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions