Skip to content

Squiz.WhiteSpace.ScopeKeywordSpacing false positive for static return type #3188

@mathieutu

Description

@mathieutu

Describe the bug
Php8 allows static as a valid return type. I've seen the PHPCS PR which allows that.
However I still have an issue with the Squiz.WhiteSpace.ScopeKeywordSpacing.Incorrect rule.

Code sample

public static function fCreate($attributes = []): static
{
    return static::factory()->create($attributes);
}

Error

 35 | ERROR | [x] Scope keyword "static" must be followed by a single space; found 0 (Squiz.WhiteSpace.ScopeKeywordSpacing.Incorrect)
 43 | ERROR | [x] Scope keyword "static" must be followed by a single space; found newline
    |       |     (Squiz.WhiteSpace.ScopeKeywordSpacing.Incorrect)

Expected behavior
Phpcs should not emit an error for a space after static.
And actually static as a return type should be considerated by phpcs as a Scope Keyword.

Versions:

  • OS: MacOS 10.15.7
  • PHP: 8
  • PHPCS: 3.5.8
  • Standard: [PSR2, PSR12]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions