Skip to content

PHP8 - Multi line attributes - No trailing comma although trailingCommaPHP is true #1885

Description

@AndreasA

Maybe related to this issue #1884 but multi line attributes do not add the trailing comma, which is added everywhere else including constructor arguments. However, it is not added to multi line attributes.

Using PHP8 with mutli line attributes result in formatting like this by prettier:

    #[
        ORM\Column(...),
        ORM\CustomIdGenerator(class: ...),
        ORM\GeneratedValue(strategy: 'CUSTOM'),
        ORM\Id
    ]

    private string $id;

but I think it should be:

    #[
        ORM\Column(...),
        ORM\CustomIdGenerator(class: ...),
        ORM\GeneratedValue(strategy: 'CUSTOM'),
        ORM\Id,
    ]

    private string $id;

or actually if #1884 is taken into account:

    #[
        ORM\Column(...),
        ORM\CustomIdGenerator(class: ...),
        ORM\GeneratedValue(strategy: 'CUSTOM'),
        ORM\Id,
    ]
    private string $id;

Prettier 2.5.1

PHP Plugin 0.17.6

.prettierrc

{
    "$schema": "http://json.schemastore.org/prettierrc",
    "arrowParens": "always",
    "braceStyle": "psr-2",
    "bracketSameLine": false,
    "bracketSpacing": true,
    "phpVersion": "8.0",
    "printWidth": 120,
    "singleQuote": true,
    "tabWidth": 4,
    "trailingComma": "es5",
    "trailingCommaPHP": true
}

I think it is a bug, isn't it?

Activity

  1. AndreasA commented on Dec 16, 2021

    @AndreasA
    ContributorAuthor

    I think the playground example provided by @czosel works here as well:

    #1884 (comment)

    and modified by me to select the correct php version #1884 (comment)

  2. czosel commented on Mar 8, 2022

    @czosel
    Collaborator

    This has been fixed in #1886 and released with v0.18.0.

  3. AndreasA commented on Mar 8, 2022

    @AndreasA
    ContributorAuthor

    @czosel Thanks. I will try it out tomorrow in combination with the fix for #1884

    I guess this issue still occurs though: #1870 ?

  4. czosel commented on Mar 9, 2022

    @czosel
    Collaborator

    Yes, #1870 is still open.

  5. AndreasA commented on Mar 9, 2022

    @AndreasA
    ContributorAuthor

    @czosel Tested this fix today and #1884 and both seem to work fine now. Thanks again.

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