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

Fix PHP Fatal error in Squiz.Commenting.FunctionComment #3785

Merged

Conversation

fredden
Copy link
Contributor

@fredden fredden commented Mar 29, 2023

Today I have seen an invalid @param tag in a docblock, and Squiz.Commenting.FunctionComment returned a PHP Fatal error while parsing the file. The error was:

There was 1 error:

1) PHP_CodeSniffer\Standards\Squiz\Tests\Commenting\FunctionCommentUnitTest::testSniff
Uninitialized string offset 0

/path/to/squizlabs-php-codesniffer/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php:413
/path/to/squizlabs-php-codesniffer/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php:152
/path/to/squizlabs-php-codesniffer/src/Files/File.php:498
/path/to/squizlabs-php-codesniffer/src/Files/LocalFile.php:92
/path/to/squizlabs-php-codesniffer/tests/Standards/AbstractSniffUnitTest.php:173
/path/to/squizlabs-php-codesniffer/tests/TestSuite7.php:28

I have tracked this down, added a test case to cover this, and fixed the bug.

Update 2023-06-08: by fixing the bug with a different technique (as suggested by @jrfnl on a call - thanks!), the sniff now complains about this case correctly and can auto-fix it.

@fredden fredden requested a review from jrfnl June 8, 2023 15:28
@fredden fredden marked this pull request as ready for review June 8, 2023 15:28
Copy link
Contributor

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed & tested. All good ✅

@jrfnl jrfnl added this to the 3.8.0 milestone Jun 21, 2023
@jrfnl jrfnl merged commit a5d085f into squizlabs:master Jul 11, 2023
jrfnl added a commit that referenced this pull request Jul 11, 2023
@fredden fredden deleted the php-fatal/squiz-commeting-function-comment branch July 11, 2023 06:56
@jrfnl
Copy link
Contributor

jrfnl commented Dec 8, 2023

FYI: this fix is included in today's PHP_CodeSniffer 3.8.0 release.

As per #3932, development on PHP_CodeSniffer will continue in the PHPCSStandards/PHP_CodeSniffer repository. If you want to stay informed, you may want to start "watching" that repo (or watching releases from that repo).

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

Successfully merging this pull request may close these issues.

2 participants