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:ignore annotation doesnt work inside a docblock #2868

Closed
edwardspec opened this issue Feb 12, 2020 · 3 comments
Closed

phpcs:ignore annotation doesnt work inside a docblock #2868

edwardspec opened this issue Feb 12, 2020 · 3 comments
Milestone

Comments

@edwardspec
Copy link

I'm trying to suppress "Line exceeds 100 characters" warning in the following code:

	/**
	 * @phan-param array{src:string,dst:string,headers?:array<string,string>,ignoreMissingSource?:bool} $params
	 */
	public function something( array $params ) {
	}
2 | WARNING | Line exceeds 100 characters; contains 108 characters

Even with // phpcs:ignore before the @phan-param line (or at the end of this line) the warning was still emitted.

@gsherwood gsherwood added this to the 3.5.5 milestone Feb 23, 2020
@gsherwood gsherwood changed the title "// phpcs:ignore" not recognized within the multiline comment (needed to suppress Generic.Files.LineLength.TooLong on unbreakable comment). phpcs:ignore annotation doesnt work inside a docblock Feb 23, 2020
@gsherwood
Copy link
Member

The phpcs:ignore annotation (and related ones) were not being detected properly inside docblocks, which is why this wasn't working. The following code will work in 3.5.5:

<?php
/**
 * @phpcs:ignore Generic.Files.LineLength.TooLong
 * @phan-param array{src:string,dst:string,headers?:array<string,string>,ignoreMissingSource?:bool} $params
 */
public function something( array $params ) {
}

Thanks for the report.

@plumthedev
Copy link

plumthedev commented Jul 16, 2021

hey @gsherwood, that is not working for class method

I have phpcs 3.5.8

❯ vendor/bin/phpcs --version                                                                                                                            
PHP_CodeSniffer version 3.5.8 (stable) by Squiz (http://www.squiz.net)

for that code

class Role {
    /**
     * @phpcs:ignore Generic.NamingConventions.ConstructorName.OldStyle
     * @return RoleEnum
     */
    public function role(): RoleEnum
    {
        return $this->role;
    }
]

It is still generating error

❯ vendor/bin/phpcs --standard=ruleset.xml --tab-width=4 -sp /Users/plumthedev/super-secret-path/Valuing/Role.php
E 1 / 1 (100%)

FILE: /Users/plumthedev/super-secret-path/Valuing/Role.php
-----------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------
 54 | ERROR | PHP4 style constructors are not allowed; use "__construct()" instead
    |       | (Generic.NamingConventions.ConstructorName.OldStyle)
-----------------------------------------------------------------------------------------------------------------------------

I'm not sure, but I think is your code is covering token only in global indent in Tokenizer and tests

Can you check that? Maybe I make a mistake?

@daften
Copy link

daften commented Aug 4, 2021

I can confirm it doesn't work on properties inside classes either. I'll open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants