squizlabs / PHP_CodeSniffer

PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.
BSD 3-Clause "New" or "Revised" License
10.66k stars 1.48k forks source link

`@phpcsSuppress` comment should work #3748

Closed dereuromark closed 1 year ago

dereuromark commented 1 year ago

Describe the bug We wanted to add a suppress together with a meaningful comment on why this is needed: Code sample

    /**
     * Return an instance with the specified uri
     *
     * @param \Psr\Http\Message\UriInterface $uri The new request uri
     * @param bool $preserveHost Whether the host should be retained.
     * @return static
     * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint For $preserveHost type.
     */
    public function withUri(UriInterface $uri, $preserveHost = false): static

But it still outputs

Error: Method \Cake\Http\ServerRequest::withUri() does not have native type hint for its parameter $preserveHost but it should be possible to add it based on @param annotation "bool".

Expected would be that only the first part is seen as the type, and as always there is room for optional free text comment:

@phpcsSuppress X.Y.Z
@phpcsSuppress X.Y.Z Some optional text.
jrfnl commented 1 year ago

@dereuromark @phpcsSuppress is a Slevomat native syntax and not a PHPCS supported comment.

Please report your issue to the Slevomat standard instead or use the PHPCS native ignore annotations instead.