slevomat / coding-standard

Slevomat Coding Standard for PHP_CodeSniffer provides many useful sniffs
MIT License
1.4k stars 178 forks source link

Type mismatch in `EmptyCommentSniff::getCommentContent()` #1655

Closed roslov closed 8 months ago

roslov commented 10 months ago

I received an error using version 8.14.1: Fatal error: Uncaught TypeError: Return value of SlevomatCodingStandard\Sniffs\Commenting\EmptyCommentSniff::getCommentContent() must be of the type string, bool returned in /root/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Commenting/EmptyCommentSniff.php:127

Stack trace:

#0 /root/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Commenting/EmptyCommentSniff.php(48): SlevomatCodingStandard\Sniffs\Commenting\EmptyCommentSniff->getCommentContent(Object(PHP_CodeSniffer\Files\LocalFile), 67, -1)
#1 /root/.composer/vendor/squizlabs/php_codesniffer/src/Files/File.php(518): SlevomatCodingStandard\Sniffs\Commenting\EmptyCommentSniff->process(Object(PHP_CodeSniffer\Files\LocalFile), 67)
#2 /root/.composer/vendor/squizlabs/php_codesniffer/src/Files/LocalFile.php(92): PHP_CodeSniffer\Files\File->process()
#3 /root/.composer/vendor/squizlabs/php_codesniffer/src/Runner.php(632): PHP_CodeSniffer\Files\LocalFile->process()
#4 /root/.composer/vendor/squizlabs/php_codesniffer/src/Runner.p in /root/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Commenting/EmptyCommentSniff.php on line 127

File:

<?php
include_once("inc/itcAggregate.php");
/*$oAggregate = new itcAggregate();
$oAggregate->aggrAll();*/

Important! There is no new line after $oAggregate->aggrAll();*/

Please check all return types in that line.

kukulich commented 8 months ago

Thank you for your report.

Fixed in https://github.com/slevomat/coding-standard/commit/ea3ff0005e78dacb38399be1c884bbbc0c0399db