Phpinsights: Exception when analysing file with unterminated comment

Created on 24 May 2019  路  12Comments  路  Source: nunomaduro/phpinsights

| Q | A
| ---------------- | -----
| Bug report? | yes
| Feature request? | no
| Library version | 1.3.1

This error appears while analyzing

`Fatal error: Uncaught TypeError: Return value of SlevomatCodingStandardSniffs\Commenting\EmptyCommentSniff::getCommentContent() must be of the type string, bool returned in /phpinsights/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Commenting/EmptyCommentSniff.php:153
Stack trace:

0 /phpinsights/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Commenting/EmptyCommentSniff.php(48): SlevomatCodingStandardSniffs\Commenting\EmptyCommentSniff->getCommentContent(Object(NunoMaduro\PhpInsights\Domain\File), 20, -1)

1 /phpinsights/src/Domain/File.php(128): SlevomatCodingStandardSniffs\Commenting\EmptyCommentSniff->process(Object(NunoMaduro\PhpInsights\Domain\File), 20)

2 /phpinsights/src/Domain/File.php(171): NunoMaduro\PhpInsights\Domain\File->process()

3 /phpinsights/src/Domain/FileProcessor.php(79): NunoMaduro\PhpInsights\Domain\File->processWithTokenListenersAndFileInfo(Array, Object(Symplify\PackageBuilder\FileSystemSmartFileInfo))

4 /phpinsights/vendor/symplify/easy-coding-standard/src/A in /phpinsights/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Commenting/EmptyCommentSniff.php on line 153

`

bug

All 12 comments

What's the snippet of analyzed code that causes this?
It should be reported at https://github.com/slevomat/coding-standard

@TomasVotruba Here is context: https://github.com/slevomat/coding-standard/pull/688. Thanks for asking.

It's normal behavior there, they sometimes delete my comments when I disagreed :)

In the end you don't need that sniff, fixer does better job. Just replace it

We don鈥檛 have fixer features yet. 馃

It's part of ECS :)

Yeah, I don't leverage that yet. Probably for the next major version.

Why not? It's 1:1 to Sniffer

@TomasVotruba If you are up for it, then create a PR for it. Would be a nice addition.

Something that we must keep in mind is: We must make it really clear and easy for the end user.

@olivernybroe I don't use it and @rectorphp is now full marriage thing taking all my time

Since they did not accept our PR to fix this issue we can fix it ourself in two ways.

  • Create a custom sniff which fixes the code in the original sniff.
  • Remove the sniff from our insight.

Or we can wait and see if it will be fixed later on.

Seems fixed by #249

Was this page helpful?
0 / 5 - 0 ratings