Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPCS fails when using PHP 8 Constructor property promotion with attributes #3424

Closed
tarlepp opened this issue Sep 3, 2021 · 2 comments · Fixed by #3427
Closed

PHPCS fails when using PHP 8 Constructor property promotion with attributes #3424

tarlepp opened this issue Sep 3, 2021 · 2 comments · Fixed by #3427

Comments

@tarlepp
Copy link

tarlepp commented Sep 3, 2021

Describe the bug
PHPCS fails when using PHP 8 Constructor property promotion with attributes.

FILE: /app/src/Entity/LogLoginFailure.php
---------------------------------------------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 4 LINES
---------------------------------------------------------------------------------------------------------
 75 | ERROR | [x] Multi-line function declaration not indented correctly; expected 8 spaces but found 12
 76 | ERROR | [x] Multi-line function declaration not indented correctly; expected 8 spaces but found 12
 79 | ERROR | [x] Multi-line function declaration not indented correctly; expected 8 spaces but found 12
 80 | ERROR | [x] Multi-line function declaration not indented correctly; expected 8 spaces but found 12
---------------------------------------------------------------------------------------------------------

Code sample

public function __construct(
    #[ORM\ManyToOne(
        targetEntity: User::class, // <-- line 75
        inversedBy: 'logsLoginFailure', // <-- line 76
    )]
    #[ORM\JoinColumn(
        name: 'user_id', // <-- line 79
        nullable: false, // <-- line 80
    )]
    #[Groups([
        'LogLoginFailure',
        'LogLoginFailure.user',
    ])]
    private User $user
) {
    $this->id = $this->createUuid();
    $this->timestamp = new DateTimeImmutable(timezone: new DateTimeZone('UTC'));
}

Expected behavior
No errors

Versions (please complete the following information):

  • PHP: 8.0.10
  • PHPCS: 3.6.0
  • Standard: PSR2, PSR12
@jrfnl
Copy link
Contributor

jrfnl commented Sep 4, 2021

Thanks for reporting this. Reproduced. The issue comes from is with the PEAR.Functions.FunctionDeclaration.Indent error code.

I think that sniff should probably either skip over attributes or just do a minimum indent check for anything between an attribute opener and closer.

@jrfnl
Copy link
Contributor

jrfnl commented Sep 5, 2021

PR #3427 should fix this. Testing appreciated.

@gsherwood gsherwood added this to Idea Bank in PHPCS v3 Development via automation Sep 27, 2021
@gsherwood gsherwood added this to the 3.6.1 milestone Sep 27, 2021
gsherwood added a commit that referenced this issue Sep 27, 2021
PHPCS v3 Development automation moved this from Idea Bank to Ready for Release Sep 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
PHPCS v3 Development
Ready for Release
Development

Successfully merging a pull request may close this issue.

3 participants