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

A phpDoc template closing tag is mistakenly considered belonging to the following function #2838

Open
morozov opened this issue Jan 25, 2020 · 3 comments

Comments

@morozov
Copy link
Contributor

morozov commented Jan 25, 2020

Some sniffs from the "Squiz" collection are used in doctrine/coding-standard. The standard does not enforce a phpDoc block for each symbol and, furthermore, forbids the usage of useless doc blocks.

Consider the code example:

<?php

class Test
{
    /**#@+
     * Error codes.
     */
    const ERR_1 = 1;
    const ERR_2 = 2;
    /**#@-*/

    private function doStuff() : void
    {
    }
}

If a phpDoc template (example) is followed by a method without a docblock, then the "Squiz.Commenting.FunctionComment" sniff mistakenly attributes the closing template block to the method and marks it as invalid:

phpcs --standard=Squiz Test.inc -s

FILE: /home/morozov/Projects/dbal/Test.inc
------------------------------------------------------------------------------------------------
FOUND 14 ERRORS AFFECTING 7 LINES
------------------------------------------------------------------------------------------------
...
 10 | ERROR | [ ] There must be no blank lines after the function comment
    |       |     (Squiz.Commenting.FunctionComment.SpacingAfter)
...
------------------------------------------------------------------------------------------------
@gsherwood
Copy link
Member

Docblock templates are completely unsupported by the Squiz coding standard as they are never used within Squiz code. Adding proper support would be more than just ignoring the closing comment here, and it would certainly generate a lot more errors that you wont want. The Squiz standard tries to enforce a docblock for everything, so any changes that move it away from that direction would not be considered.

What you really need is a generic collection of docblock sniffs that are flexible enough to implement your own rules, but it's not something that is being worked on.

@gsherwood gsherwood added this to Idea Bank in PHPCS v3 Development via automation Jan 25, 2020
@morozov
Copy link
Contributor Author

morozov commented Jan 25, 2020

What you really need is a generic collection of docblock sniffs that are flexible enough to implement your own rules, but it's not something that is being worked on.

Agree. I believe that this is the idea behind slevomat/coding-standard. Instead of reusing code from the "Squiz" standard, maybe there's a better way to implement the same rules.

@jrfnl
Copy link
Contributor

jrfnl commented Jan 26, 2020

What you really need is a generic collection of docblock sniffs that are flexible enough to implement your own rules, but it's not something that is being worked on.

Actually, this is being worked on, just not yet public ;-)

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

No branches or pull requests

3 participants