Skip to content

Spontaneously started crashing for no obvious reason #7601

Closed

Description

@dktapps

Bug report

dylan-work@DYLANS-XPS-17 MINGW64 ~/documents/projects/pocketmine-mp/next-major (next-major|u=)
$ vendor/bin/phpstan
Note: Using configuration file C:\Users\dylan-work\documents\projects\pocketmine-mp\next-major\phpstan.neon.
Warning: Undefined array key "collectedData" in phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/src/Parallel/ParallelAnalyser.php on line 125
Warning: foreach() argument must be of type array|object, null given in phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/src/Parallel/ParallelAnalyser.php on line 125
Warning: Undefined array key "attributes" in phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/src/Dependency/ExportedNode/ExportedParameterNode.php on line 92
Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given in phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/src/Dependency/ExportedNode/ExportedParameterNode.php:92
Stack trace:
#0 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/src/Dependency/ExportedNode/ExportedParameterNode.php(92): array_map(Object(Closure), NULL)
#1 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/src/Dependency/ExportedNode/ExportedMethodNode.php(137): PHPStan\Dependency\ExportedNode\ExportedParameterNode::decode(Array)
#2 [internal function]: PHPStan\Dependency\ExportedNode\ExportedMethodNode::PHPStan\Dependency\ExportedNode\{closure}(Array)
#3 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/src/Dependency/ExportedNode/ExportedMethodNode.php(138): array_map(Object(Closure), Array)
#4 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/src/Dependency/ExportedNode/ExportedClassNode.php(147): PHPStan\Dependency\ExportedNode\ExportedMethodNode::decode(Array)
#5 [internal function]: PHPStan\Dependency\ExportedNode\ExportedClassNode::PHPStan\Dependency\ExportedNode\{closure}(Array)
#6 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/src/Dependency/ExportedNode/ExportedClassNode.php(148): array_map(Object(Closure), Array)
#7 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/src/Parallel/ParallelAnalyser.php(145): PHPStan\Dependency\ExportedNode\ExportedClassNode::decode(Array)
#8 [internal function]: PHPStan\Parallel\ParallelAnalyser::PHPStan\Parallel\{closure}(Array)
#9 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/src/Parallel/ParallelAnalyser.php(146): array_map(Object(Closure), Array)
#10 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/src/Parallel/Process.php(137): PHPStan\Parallel\ParallelAnalyser->PHPStan\Parallel\{closure}(Array)
#11 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97): PHPStan\Parallel\Process->PHPStan\Parallel\{closure}(Array)
#12 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/vendor/clue/ndjson-react/src/Decoder.php(110): _PHPStan_59fb0a3b2\Evenement\EventEmitter->emit('data', Array)
#13 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97): _PHPStan_59fb0a3b2\Clue\React\NDJson\Decoder->handleData(Array)
#14 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/Util.php(62): _PHPStan_59fb0a3b2\Evenement\EventEmitter->emit('data', Array)
#15 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97): _PHPStan_59fb0a3b2\React\Stream\Util::_PHPStan_59fb0a3b2\React\Stream\{closure}('{"action":"resu...')
#16 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/DuplexResourceStream.php(154): _PHPStan_59fb0a3b2\Evenement\EventEmitter->emit('data', Array)
#17 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(201): _PHPStan_59fb0a3b2\React\Stream\DuplexResourceStream->handleData(Resource id #4380)
#18 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(173): _PHPStan_59fb0a3b2\React\EventLoop\StreamSelectLoop->waitForStreamActivity(53431)
#19 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/src/Parallel/ParallelAnalyser.php(175): _PHPStan_59fb0a3b2\React\EventLoop\StreamSelectLoop->run()
#20 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyserRunner.php(61): PHPStan\Parallel\ParallelAnalyser->analyse(Object(PHPStan\Parallel\Schedule), 'vendor/bin/phps...', Object(Closure), 'C:\\Users\\dylan-...', NULL, NULL, Object(_PHPStan_59fb0a3b2\Symfony\Component\Console\Input\ArgvInput))
#21 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseApplication.php(207): PHPStan\Command\AnalyserRunner->runAnalyser(Array, Array, NULL, Object(Closure), false, true, 'C:\\Users\\dylan-...', NULL, NULL, Object(_PHPStan_59fb0a3b2\Symfony\Component\Console\Input\ArgvInput))
#22 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseApplication.php(100): PHPStan\Command\AnalyseApplication->runAnalyser(Array, Array, false, 'C:\\Users\\dylan-...', Object(PHPStan\Command\Symfony\SymfonyOutput), Object(PHPStan\Command\Symfony\SymfonyOutput), Object(_PHPStan_59fb0a3b2\Symfony\Component\Console\Input\ArgvInput))
#23 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseCommand.php(168): PHPStan\Command\AnalyseApplication->analyse(Array, false, Object(PHPStan\Command\Symfony\SymfonyOutput), Object(PHPStan\Command\Symfony\SymfonyOutput), false, false, 'C:\\Users\\dylan-...', Array, Object(_PHPStan_59fb0a3b2\Symfony\Component\Console\Input\ArgvInput))
#24 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Command/Command.php(259): PHPStan\Command\AnalyseCommand->execute(Object(_PHPStan_59fb0a3b2\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_59fb0a3b2\Symfony\Component\Console\Output\ConsoleOutput))
#25 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(856): _PHPStan_59fb0a3b2\Symfony\Component\Console\Command\Command->run(Object(_PHPStan_59fb0a3b2\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_59fb0a3b2\Symfony\Component\Console\Output\ConsoleOutput))
#26 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(259): _PHPStan_59fb0a3b2\Symfony\Component\Console\Application->doRunCommand(Object(PHPStan\Command\AnalyseCommand), Object(_PHPStan_59fb0a3b2\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_59fb0a3b2\Symfony\Component\Console\Output\ConsoleOutput))
#27 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(157): _PHPStan_59fb0a3b2\Symfony\Component\Console\Application->doRun(Object(_PHPStan_59fb0a3b2\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_59fb0a3b2\Symfony\Component\Console\Output\ConsoleOutput))
#28 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(127): _PHPStan_59fb0a3b2\Symfony\Component\Console\Application->run()
#29 phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(128): _PHPStan_59fb0a3b2\{closure}()
#30 C:\Users\dylan-work\Documents\projects\pocketmine-mp\next-major\vendor\phpstan\phpstan\phpstan(8): require('phar://C:/Users...')
#31 C:\Users\dylan-work\Documents\projects\pocketmine-mp\next-major\vendor\bin\phpstan(120): include('C:\\Users\\dylan-...')
#32 {main}
  thrown in phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/src/Dependency/ExportedNode/ExportedParameterNode.php on line 92

Unfortunately I have no idea what triggered this, but I've seen it often popping up in PhpStorm while working. This is the first time I've seen it on the command line.

My suspicion is that this has soething to do with the PhpStorm integration. After wiping out PHPStan cache, it started working correctly again.

Activity

  1. mergeable commented on Jul 8, 2022

    @mergeable

    This bug report is missing a link to reproduction at phpstan.org/try.

    It will most likely be closed after manual review.

  2. dktapps commented on Jul 8, 2022

    @dktapps
    ContributorAuthor

    It's also started throwing out these errors for no obvious reason:

    dylan-work@DYLANS-XPS-17 MINGW64 ~/documents/projects/pocketmine-mp/next-major (next-major | *|u=)
    $ vendor/bin/phpstan
    Note: Using configuration file C:\Users\dylan-work\documents\projects\pocketmine-mp\next-major\phpstan.neon.
    Invalid configuration:
    Unexpected item 'parameters › checkAlwaysTrueLooseComparison', did you mean 'checkAlwaysTrueStrictComparison'?
    Invalid configuration:
    Unexpected item 'parameters › checkDynamicProperties'.
    Invalid configuration:
    Unexpected item 'parameters › featureToggles › illegalConstructorMethodCall'.
    

    If I disable phpstan-strict-rules, the problem goes away. But this problem came out of nowhere and I haven't updated any dependencies that would cause this.

    phpstan/phpstan                         1.8.0                            PHPStan - PHP Static Analysis Tool
    phpstan/phpstan-phpunit                 1.1.1                            PHPUnit extensions and rules for PHPStan
    phpstan/phpstan-strict-rules            1.3.0                            Extra strict and opinionated rules for PHPStan
    

    Bizarrely, this only occurs on my local server, and works correctly on GH Actions.

  3. dktapps commented on Jul 8, 2022

    @dktapps
    ContributorAuthor

    I feel like there is some kind of crosstalk between different versions of PHPStan here ... I do have multiple PhpStorm projects open with different versions of PHPStan and strict-rules (being constantly invoked automatically by PhpStorm), but this shouldn't cause projects to break each other ...

  4. ondrejmirtes commented on Jul 18, 2022

    @ondrejmirtes
    Member

    Yeah, no idea why, it looks like something gets mixed up with older PHPStan versions, but I need a reproduction to be able to do anything about it.

  5. dktapps commented on Jul 18, 2022

    @dktapps
    ContributorAuthor

    My observation is that having two PhpStorm projects open running different versions of PHPStan is usually enough to trigger it.

    Maybe it would be a good idea to use a different cache directory per PHPStan version, or per project...

  6. ondrejmirtes commented on Jul 18, 2022

    @ondrejmirtes
    Member

    /cc @staabm PHPStan version should be part of the result cache file path hash 😊

  7. staabm commented on Jul 18, 2022

    @staabm
    Contributor
  8. dktapps commented on Jul 18, 2022

    @dktapps
    ContributorAuthor

    I don't feel like the result cache is the problem. The issue generally occurs when PhpStorm is analysing projects with different filesystem locations. Unless the result cache hash is derived using relative source paths, I don't see how there can be a collision.

  9. staabm commented on Jul 19, 2022

    @staabm
    Contributor

    Before the linked PR phpstan is using a single resultCache file for all projects, no matter which phpstan version, which analyzed path etc. (It uses only separate ones, in case you defined a different tempDir in the phpstan.neon per project)

    I think this means in you case that the resultCache might contain exported nodes which do not necessarily exist or have a differen format, depending on the phpstan version is running

  10. ondrejmirtes commented on Jul 19, 2022

    @ondrejmirtes
    Member

     Warning: Undefined array key "collectedData" in phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/src/Parallel/ParallelAnalyser.php on line 125

    This suggests it's actually not about the result cache.

    Warning: Undefined array key "attributes" in phar://C:/Users/dylan-work/Documents/projects/pocketmine-mp/next-major/vendor/phpstan/phpstan/phpstan.phar/src/Dependency/ExportedNode/ExportedParameterNode.php on line 92

    This part suggests it might be actually about the result cache.

    The first warning is weird, it looks like child processes are talking to an incompatible PHPStan version. Not sure how it can happen.

  11. github-actions commented on Oct 23, 2022

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  12. locked as resolved and limited conversation to collaborators on Oct 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions