Repository navigation
Exception on large array analysis #15510
Copy link
Copy link
Closed
phpstan/phpstan-src
#6774Labels
Milestone
Description
Bug report
Description
Upon analysing a very large associated-array in a file an internal error occurs.
If I reduce the number of top-level keys in the associated arrays, the error does not occur.
PHPStan Version
2.3.1
PHP Version
8.4.27
Stack trace
Error
-- ---------------------------------------------------------------------------------------------------------
Internal error: Internal error. while analysing file
/app/app/<redacted>.php
Post the following stack trace to
https://github.com/phpstan/phpstan/issues/new?template=Bug_report.yaml:
## phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Type/Constant/OversizedArrayBuilder.php(64)
#0 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Type/Constant/OversizedArrayBuilder.php(64):
PHPStanTurbo\NativeClosure->__invoke(Object(PHPStan\Node\Expr\TypeExpr))
#1 [internal function]:
PHPStan\Type\Constant\OversizedArrayBuilder->build(Object(PhpParser\Node\Expr\Array_),
Object(PHPStanTurbo\NativeClosure))
#2 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(123):
PHPStan\Analyser\NodeScopeResolver->processFileNodes(Array, Object(PHPStan\Analyser\MutatingScope),
Object(PHPStan\Analyser\FileAnalyserCallback))
#3 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Parallel/WorkerRunner.php(176):
PHPStan\Analyser\FileAnalyser->analyseFile('/app/app/<redacted>...', Array,
Object(PHPStan\Rules\LazyRegistry), Object(PHPStan\Collectors\Registry), NULL)
#4
phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/EventEmitterTrait.php(11
1): PHPStan\Parallel\WorkerRunner::{closure:PHPStan\Parallel\WorkerRunner::runWorker():150}(Array)
#5 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/clue/ndjson-react/src/Decoder.php(117):
_PHPStan_cb3b7e994\Evenement\EventEmitter->emit('data', Array)
#6
phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/EventEmitterTrait.php(11
1): _PHPStan_cb3b7e994\Clue\React\NDJson\Decoder->handleData(Array)
#7 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/Util.php(62):
_PHPStan_cb3b7e994\Evenement\EventEmitter->emit('data', Array)
#8
phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/EventEmitterTrait.php(11
1):
_PHPStan_cb3b7e994\React\Stream\Util::{closure:_PHPStan_cb3b7e994\React\Stream\Util::forwardEvents():61
}('{"action":"anal...')
#9
phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/DuplexResourceStream.php(168):
_PHPStan_cb3b7e994\Evenement\EventEmitter->emit('data', Array)
#10
phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(201):
_PHPStan_cb3b7e994\React\Stream\DuplexResourceStream->handleData(Resource id #6686)
#11
phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(173):
_PHPStan_cb3b7e994\React\EventLoop\StreamSelectLoop->waitForStreamActivity(NULL)
#12 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Parallel/WorkerRunner.php(132):
_PHPStan_cb3b7e994\React\EventLoop\StreamSelectLoop->run()
#13 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Parallel/ForkedProcess.php(141):
PHPStan\Parallel\WorkerRunner->run(Object(_PHPStan_cb3b7e994\Symfony\Component\Console\Output\StreamOu
tput), Array, 45871, 'dk2s7rjeq5', NULL, NULL)
#14 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Parallel/ParallelAnalyser.php(228):
PHPStan\Parallel\ForkedProcess->start(Object(Closure), Object(Closure), Object(Closure))
#15 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyserRunner.php(61):
PHPStan\Parallel\ParallelAnalyser->analyse(Object(_PHPStan_cb3b7e994\React\EventLoop\StreamSelectLoop)
, Object(PHPStan\Parallel\Schedule), Array, 'vendor/bin/phps...', Object(Closure),
'/app/phpstan.ne...', NULL, NULL, Object(_PHPStan_cb3b7e994\Symfony\Component\Console\Input\ArgvInput),
NULL, Object(PHPStan\Command\Symfony\SymfonyOutput))
#16 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseApplication.php(182):
PHPStan\Command\AnalyserRunner->runAnalyser(Array, Array, NULL, Object(Closure), false, true,
'/app/phpstan.ne...', NULL, NULL, Object(_PHPStan_cb3b7e994\Symfony\Component\Console\Input\ArgvInput),
Object(PHPStan\Command\Symfony\SymfonyOutput))
#17 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseApplication.php(84):
PHPStan\Command\AnalyseApplication->runAnalyser(Array, Array, false, '/app/phpstan.ne...', NULL, NULL,
Object(PHPStan\Command\Symfony\SymfonyOutput), Object(PHPStan\Command\Symfony\SymfonyOutput),
Object(_PHPStan_cb3b7e994\Symfony\Component\Console\Input\ArgvInput))
#18 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseCommand.php(268):
PHPStan\Command\AnalyseApplication->analyse(Array, false,
Object(PHPStan\Command\Symfony\SymfonyOutput), Object(PHPStan\Command\Symfony\SymfonyOutput), false,
false, '/app/phpstan.ne...', Array, NULL, NULL,
Object(_PHPStan_cb3b7e994\Symfony\Component\Console\Input\ArgvInput))
#19 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Command/Command.php(259):
PHPStan\Command\AnalyseCommand->execute(Object(_PHPStan_cb3b7e994\Symfony\Component\Console\Input\Argv
Input), Object(_PHPStan_cb3b7e994\Symfony\Component\Console\Output\ConsoleOutput))
#20 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(868):
_PHPStan_cb3b7e994\Symfony\Component\Console\Command\Command->run(Object(_PHPStan_cb3b7e994\Symfony\Co
mponent\Console\Input\ArgvInput),
Object(_PHPStan_cb3b7e994\Symfony\Component\Console\Output\ConsoleOutput))
#21 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(261):
_PHPStan_cb3b7e994\Symfony\Component\Console\Application->doRunCommand(Object(PHPStan\Command\AnalyseC
ommand), Object(_PHPStan_cb3b7e994\Symfony\Component\Console\Input\ArgvInput),
Object(_PHPStan_cb3b7e994\Symfony\Component\Console\Output\ConsoleOutput))
#22 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(157):
_PHPStan_cb3b7e994\Symfony\Component\Console\Application->doRun(Object(_PHPStan_cb3b7e994\Symfony\Comp
onent\Console\Input\ArgvInput),
Object(_PHPStan_cb3b7e994\Symfony\Component\Console\Output\ConsoleOutput))
#23 phar:///app/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(116):
_PHPStan_cb3b7e994\Symfony\Component\Console\Application->run()
#24 phar:///app/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(117):
{closure:phar:///app/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan:18}()
#25 /app/vendor/phpstan/phpstan/phpstan(8): require('phar:///app/ven...')
#26 /app/vendor/bin/phpstan(119): include('/app/vendor/php...')
#27 {main}
-- ---------------------------------------------------------------------------------------------------------
[ERROR] Found 1 error
⚠️ Result is incomplete because of severe errors. ⚠️
Fix these errors first and then re-run PHPStan
to get all reported errors.
Elapsed time: 1.36 seconds
Peak memory: 84 MB
Code snippet that reproduces the problem
https://phpstan.org/r/d4943124-9df1-4435-82a8-f381c335f4dc
Expected output
Analysis should continue on large arrays without error/exception
Did PHPStan help you today? Did it make you happy in any way?
No response
Reactions are currently unavailable
Activity