Phpinsights: Return value of ...getCommentContent must be of the type string, boolean returned

Created on 15 May 2019  路  10Comments  路  Source: nunomaduro/phpinsights

Running against a relatively small Laravel 5.7 app:

$ php artisan insights
  96/126 [鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻撯枒鈻戔枒鈻戔枒鈻戔枒]  76%
In EmptyCommentSniff.php line 153:

  Return value of SlevomatCodingStandard\Sniffs\Commenting\EmptyCommentSniff::getCommentContent() must be of the type string, boolean returned
bug help wanted

All 10 comments

Same reproduced on laravel 5.8. with a small app:
56/60 [鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻戔枒] 93%
Symfony\Component\Debug\Exception\FatalThrowableError : Return value of SlevomatCodingStandard\Sniffs\Commenting\EmptyCommentSniff::getCommentContent() must be of the type string, boolean returned

It's possible to have the source code of your apps? Is open source? Otherwise I can't debug this.

Another option is: Try to understand what is the piece of code where the bug happens, so I can reproduce it locally.

Just before the error: $commentEndPointer is -1
at that point the file is routes/api.php with this content:
`

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

/*

Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});

*/`

IF i run again with removed comment:
`

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});

`

everything works fine.

I hope this helps a little :-)

Well, as it is not readable:

FAIL: https://imgur.com/ykAuUbD

OK: https://imgur.com/5xnGLM9

Have the same issue. Looks like empty comments that don't have a description are the problem. While @akosglue can find the root of his problem, I can't.

Same issue here. :/

The issue happens when you have non closed docs.

As @akosglue already mentioned, this problem appears when the middleware in routes/api.php is commented as shown in screenshoots. After fixing this, there's another error #59

This issue has been fixed on the version v1.8.1.

Was this page helpful?
0 / 5 - 0 ratings