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

Squiz.Commenting.FunctionComment.ThrowsNoFullStop false positive when one line @throws #3503

Closed
vaclavvanik opened this issue Dec 16, 2021 · 1 comment
Milestone

Comments

@vaclavvanik
Copy link

Describe the bug
Squiz.Commenting.FunctionComment sniff throws ThrowsNoFullStop on one line php doc comment with @throws annotation.

Code sample

<?php

declare(strict_types=1);

namespace My;

use Exception;

/** @throws Exception if any other error occurs. */
function foo(string $string): string
{
    return $string;
}

To reproduce
Steps to reproduce the behavior:

  1. Create a file called test.php with the code sample above...
  2. Run phpcs test.php ...
  3. See error message displayed
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------
  9 | ERROR   | @throws tag comment must end with a full stop
    |         | (Squiz.Commenting.FunctionComment.ThrowsNoFullStop)

Expected behavior
No error :-)

Versions (please complete the following information):

  • OS: Ubuntu 18.04
  • PHP: 8.0
  • PHPCS: 3.6.1
  • Standard: Squiz
@gsherwood gsherwood added this to the 3.7.0 milestone Dec 20, 2021
@gsherwood gsherwood changed the title Squiz.Commenting.FunctionComment.ThrowsNoFullStop check failed when one line @throws php doc Squiz.Commenting.FunctionComment.ThrowsNoFullStop false positive when one line @throws Dec 20, 2021
gsherwood added a commit that referenced this issue Dec 20, 2021
gsherwood added a commit that referenced this issue Dec 20, 2021
@gsherwood
Copy link
Member

Thanks for the report. The sniff didn't account for the whitespace after the comment, which only occurs when the comment is closed on the same line. Fixed now, and will be in 3.7.0.

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

2 participants