GithubHelp home page GithubHelp logo

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

nunomaduro avatar nunomaduro commented on May 16, 2024 7
Undefined offset: 0 | Fatal error: Uncaught TypeError: Argument 2 passed to SlevomatCodingStandard\Helpers\UseStatementHelper::getUseStatementPointers() must be of the type int, null given

from phpinsights.

Comments (19)

liepumartins avatar liepumartins commented on May 16, 2024 1

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

from phpinsights.

acurrieclark avatar acurrieclark commented on May 16, 2024 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.

from phpinsights.

nunomaduro avatar nunomaduro commented on May 16, 2024 1

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

from phpinsights.

michaeldyrynda avatar michaeldyrynda commented on May 16, 2024 1

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

from phpinsights.

nunomaduro avatar nunomaduro commented on May 16, 2024 1

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

from phpinsights.

liepumartins avatar liepumartins commented on May 16, 2024

Yes, short tag is likely explanation.
In my case template contained some legacy spaghetti code such as:
<?=(preg_match(PRIVILEGES['something'],$user['privileges'])?'<a href="..">aa</a>':'')?>

Does this tool understand .blade.php files anyway? I could not get my head around if there is a way to exclude some file name patterns / directories. If not, there should be.

from phpinsights.

nunomaduro avatar nunomaduro commented on May 16, 2024

The folder resources is ignored on the Laravel preset, so your blade views should be ignored. No?

from phpinsights.

liepumartins avatar liepumartins commented on May 16, 2024

Oh, sorry. My project is not Laravel, just blade template component, so the path is different.
I will have to learn how to create project settings/presets. :)

from phpinsights.

nunomaduro avatar nunomaduro commented on May 16, 2024

You just have to: cp vendor/nunomaduro/phpinsights/stubs/config.php phpinsights.php, than add the blade folder to the exclude key.

from phpinsights.

nunomaduro avatar nunomaduro commented on May 16, 2024

Actually, we should exclude all *.blade.php extensions. Can someone do a pull request on this? Here is the file: https://github.com/nunomaduro/phpinsights/blob/master/src/Infrastructure/Repositories/LocalFilesRepository.php

Don't forget to add tests on this.

from phpinsights.

TheFrankman avatar TheFrankman commented on May 16, 2024

For me it was jquery.repeater in node_modules. Luckily I don't really need it so just removed it.

from phpinsights.

olivernybroe avatar olivernybroe commented on May 16, 2024

@TheFrankman Hmm that's weird, we should be ignoring node_modules.

from phpinsights.

TheFrankman avatar TheFrankman commented on May 16, 2024

@olivernybroe I wouldn't concern yourself too much with it, It might be down to a theme that we are importing, it's a rather unusual laravel installation.

from phpinsights.

jadamec avatar jadamec commented on May 16, 2024
λ php artisan insights
?[2K 53/65 [======================>-----]  81%
  ?[41;1m Symfony\Component\Debug\Exception\FatalThrowableError ?[49;22m : ?[33mArgument 1 passed to NunoMaduro\PhpInsights\Doma
in\File::resolveFullyQualifiedCode() must be of the type string, int given, called in C:\Users\jadam\bsgup\vendor\nunomaduro\php
insights\src\Domain\File.php on line 191?[39m

  at ?[32mC:\Users\jadam\bsgup\vendor\nunomaduro\phpinsights\src\Domain\File.php?[39m:?[32m222?[39m
    218|      * @param  string  $sniffClassOrCode
    219|      *
    220|      * @return string
    221|      */
  > 222|     private function resolveFullyQualifiedCode(string $sniffClassOrCode): string
    223|     {
    224|         if (class_exists($sniffClassOrCode)) {
    225|             return $sniffClassOrCode;
    226|         }

  ?[33mException trace:?[39m

  ?[36m1   ?[39m?[33mNunoMaduro\PhpInsights\Domain\File::resolveFullyQualifiedCode()?[39m
      ?[32mC:\Users\jadam\bsgup\vendor\nunomaduro\phpinsights\src\Domain\File.php?[39m:?[32m191?[39m

  ?[36m2   ?[39m?[33mNunoMaduro\PhpInsights\Domain\File::addMessage("Unparsable php code: syntax error or wrong phpdocs.", [])?[
39m
      ?[32mC:\Users\jadam\bsgup\vendor\squizlabs\php_codesniffer\src\Files\File.php?[39m:?[32m663?[39m

  ?[32mPlease use the argument ?[39m?[31m-v?[39m?[32m to see more details.?[39m

from phpinsights.

jadamec avatar jadamec commented on May 16, 2024

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

Works now, great! Thank you.

from phpinsights.

michaeldyrynda avatar michaeldyrynda commented on May 16, 2024

I did get a notice with 1.9, but it finished running.

from phpinsights.

olivernybroe avatar olivernybroe commented on May 16, 2024

@michaeldyrynda Could you share the notice, having some difficulties reproducing it.

from phpinsights.

michaeldyrynda avatar michaeldyrynda commented on May 16, 2024

PHP Notice: Undefined offset: 0 in /Users/mdyrynda/code/crm/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/UseStatementHelper.php on line 147

from phpinsights.

olivernybroe avatar olivernybroe commented on May 16, 2024

@michaeldyrynda Thanks. Found the cause.
PR #253 should silence the php messages

from phpinsights.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.