There is a false positive in src\Standards\Squiz\Sniffs\Commenting\FunctionCommentSniff.php
This code throws error: Function return type is not void, but function is returning void here
/**
* Test function
*
* @return array
*/
public function test()
{
function () {
return;
};
return [];
}
The same issue we have also in case:
function test()
{
new class() {
public function test() {
return;
}
};
return [];
}
@josephzidell Here is my PR with fix for both cases: #1551
Thanks for coming up with a fix so quickly
@webimpress Found another, related issue
Code:
/**
* Test function
*
* @return void
*/
public function test()
{
function () {
return 4;
};
}
Error: Function return type is void, but function contains return statement
@josephzidell I've added more tests https://github.com/squizlabs/PHP_CodeSniffer/pull/1551/commits/4a28555dd1536cb95bddc8ba09edf4a487c6154c
and all of them pass:
https://travis-ci.org/squizlabs/PHP_CodeSniffer/builds/252693542?utm_source=github_status&utm_medium=notification
It seems that my previous solution also covers these cases.
:+1:
This has now been fixed. Thanks a lot for reporting this.
Most helpful comment
The same issue we have also in case:
@josephzidell Here is my PR with fix for both cases: #1551