coding-standard icon indicating copy to clipboard operation
coding-standard copied to clipboard

Incorrect NoSpaceBeforeNullabilitySymbol for typed properties preceded by static return type

Open stefanfisk opened this issue 1 year ago • 1 comments

The following class generates SlevomatCodingStandard.Classes.PropertyDeclaration.NoSpaceBeforeNullabilitySymbol for array.

abstract class Test
{
    abstract public function begin(): static;

    protected array $field = [];
}

The issue does not appear when the return type is self.

I'm running v8.15.0.

stefanfisk avatar Oct 16 '24 10:10 stefanfisk

Just found that this case also generates SlevomatCodingStandard.Classes.PropertyDeclaration.MultipleSpacesBeforeTypeHint for the static return type.

class Test
{
    public static function begin(): static
    {
        return new static();
    }

    /** @var array<string,mixed> */
    protected array $field = [];

    final private function __construct()
    {
    }
}

stefanfisk avatar Oct 16 '24 10:10 stefanfisk

Thank you for your report.

Fixed in https://github.com/slevomat/coding-standard/commit/372cbf249282e70ac7a52e46bc914fe0991325b5

kukulich avatar Feb 01 '25 19:02 kukulich