phpinsights: Undefined offset: 0 | Fatal error: Uncaught TypeError: Argument 2 passed to SlevomatCodingStandard\Helpers\UseStatementHelper::getUseStatementPointers() must be of the type int, null given

Tried to run it on a Laravel app. Got this fatal error:

 605/910 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░]  66%PHP Notice:  Undefined offset: 0 in /Users/filipac/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/UseStatementHelper.php on line 147

Notice: Undefined offset: 0 in /Users/filipac/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/UseStatementHelper.php on line 147
PHP Fatal error:  Uncaught TypeError: Argument 2 passed to SlevomatCodingStandard\Helpers\UseStatementHelper::getUseStatementPointers() must be of the type int, null given, called in /Users/filipac/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/UseStatementHelper.php on line 149 and defined in /Users/filipac/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/UseStatementHelper.php:193
Stack trace:
#0 /Users/filipac/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/UseStatementHelper.php(149): SlevomatCodingStandard\Helpers\UseStatementHelper::getUseStatementPointers(Object(NunoMaduro\PhpInsights\Domain\File), NULL)
#1 /Users/filipac/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/UseStatementHelper.php(111): SlevomatCodingStandard\Helpers\UseStatementHelper::getFileUseStatements(Object(NunoMaduro\PhpInsights\Domain\File))
#2 /Users/filipac/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/PHP/OptimizedFunctions in /Users/filipac/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/UseStatementHelper.php on line 193

Fatal error: Uncaught TypeError: Argument 2 passed to SlevomatCodingStandard\Helpers\UseStatementHelper::getUseStatementPointers() must be of the type int, null given, called in /Users/filipac/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/UseStatementHelper.php on line 149 and defined in /Users/filipac/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/UseStatementHelper.php:193
Stack trace:
#0 /Users/filipac/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/UseStatementHelper.php(149): SlevomatCodingStandard\Helpers\UseStatementHelper::getUseStatementPointers(Object(NunoMaduro\PhpInsights\Domain\File), NULL)
#1 /Users/filipac/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/UseStatementHelper.php(111): SlevomatCodingStandard\Helpers\UseStatementHelper::getFileUseStatements(Object(NunoMaduro\PhpInsights\Domain\File))
#2 /Users/filipac/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/PHP/OptimizedFunctions in /Users/filipac/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/UseStatementHelper.php on line 193

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 7
  • Comments: 19 (5 by maintainers)

Most upvoted comments

@jadamec @michaeldyrynda Can you try again with v1.9.0?

^ I hit the same error as @jadamec after updating to 1.8.1

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

I had a look through the slevomat/coding-standard package code, and this appears to be to do with php files which do not contain a full opening tag <?php.

I ran insights and found it failed on a template file of mine which contained a short <?= tag, but no full tag, and it failed with this error. I then added a full tag at the start of the file and then closed it immediately (an empty php block) and insights then failed with the same error on the next template it found.

Same issue. When running with verbose -v option I see that problem happens when tool hits certain layout.blade.php file.