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 #152

Closed
morozov opened this issue Jan 25, 2020 · 0 comments

Comments

@morozov
Copy link
Member

morozov commented Jan 25, 2020

Consider the code example:

<?php

declare(strict_types=1);

namespace Test;

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

    public 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 Test.php

------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------
 14 | ERROR | There must be no blank lines after the function comment
    |       | (Squiz.Commenting.FunctionComment.SpacingAfter)
------------------------------------------------------------------------------------------------

Although this specific rule is implemented using a component from the "Squiz" standard,

<rule ref="Squiz.Commenting.FunctionComment">

As per squizlabs/PHP_CodeSniffer#2838 (comment), the "Squiz" standard enforces docblocks and doesn't support docblock templates.

I'm filing the issue here to see if this specific rule can be reimplemented using some Slevomat building blocks which are better composable by design.

@morozov morozov closed this as completed May 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant