Skip to content

The supplied range exceeds the maximum array size #6375

@voku

Description

@voku

Bug report

I see this error message The supplied range exceeds the maximum array size: start=-2147483648 end=2147483647 after the update to v1.4.0.

write(3, "Uncaught ValueError: The supplie"..., 199Uncaught ValueError: The supplied range exceeds the maximum array size: start=-2147483648 end=2147483647 in /home/lmoelleken/testing/git/phpstan-
...
#1 /home/lmoelleken/testing/git/phpstan-src/src/Type/Constant/ConstantArrayType.php(462): PHPStan\Type\Constant\ConstantArrayTypeBuilder->setOffsetValueType()
#2 /home/lmoelleken/testing/git/phpstan-src/src/Rules/Arrays/OffsetAccessAssignmentRule.php(75): PHPStan\Type\Constant\ConstantArrayType->setOffsetValueType()
#3 /home/lmoelleken/testing/git/phpstan-src/src/Analyser/FileAnalyser.php(83): PHPStan\Rules\Arrays\OffsetAccessAssignmentRule->processNode()
#4 /home/lmoelleken/testing/git/phpstan-src/src/Node/ClassStatementsGatherer.php(108): PHPStan\Analyser\FileAnalyser->PHPStan\Analyser\{closure}()
#5 /home/lmoelleken/testing/git/phpstan-src/src/Analyser/NodeScopeResolver.php(500): PHPStan\Node\ClassStatementsGatherer->__invoke()
#6 /home/lmoelleken/testing/git/phpstan-src/src/Analyser/NodeScopeResolver.php(3117): PHPStan\Analyser\NodeScopeResolver::PHPStan\Analyser\{closure}()
#7 /home/lmoelleken/testing/git/phpstan-src/src/Analyser/NodeScopeResolver.php(1717): PHPStan\Analyser\NodeScopeResolver->processAssignVar()
#8 /home/lmoelleken/testing/git/phpstan-src/src/Analyser/NodeScopeResolver.php(565): PHPStan\Analyser\NodeScopeResolver->processExprNode()
#9 /home/lmoelleken/testing/git/phpstan-src/src/Analyser/NodeScopeResolver.php(256): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
#10 /home/lmoelleken/testing/git/phpstan-src/src/Analyser/NodeScopeResolver.php(516): PHPStan\Analyser\NodeScopeResolver->processStmtNodes()
#11 /home/lmoelleken/testing/git/phpstan-src/src/Analyser/NodeScopeResolver.php(256): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
#12 /home/lmoelleken/testing/git/phpstan-src/src/Analyser/NodeScopeResolver.php(621): PHPStan\Analyser\NodeScopeResolver->processStmtNodes()
#13 /home/lmoelleken/testing/git/phpstan-src/src/Analyser/NodeScopeResolver.php(216): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
#14 /home/lmoelleken/testing/git/phpstan-src/src/Analyser/FileAnalyser.php(199): PHPStan\Analyser\NodeScopeResolver->processNodes()
#15 /home/lmoelleken/testing/git/phpstan-src/src/Analyser/Analyser.php(71): PHPStan\Analyser\FileAnalyser->analyseFile()
#16 /home/lmoelleken/testing/git/phpstan-src/src/Command/AnalyserRunner.php(73): PHPStan\Analyser\Analyser->analyse()
#17 /home/lmoelleken/testing/git/phpstan-src/src/Command/AnalyseApplication.php(189): PHPStan\Command\AnalyserRunner->runAnalyser()
#18 /home/lmoelleken/testing/git/phpstan-src/src/Command/AnalyseApplication.php(90): PHPStan\Command\AnalyseApplication->runAnalyser()
#19 /home/lmoelleken/testing/git/phpstan-src/src/Command/AnalyseCommand.php(238): PHPStan\Command\AnalyseApplication->analyse()
#20 /home/lmoelleken/testing/git/phpstan-src/vendor/symfony/console/Command/Command.php(298): PHPStan\Command\AnalyseCommand->execute()
#21 /home/lmoelleken/testing/git/phpstan-src/vendor/symfony/console/Application.php(1005): Symfony\Component\Console\Command\Command->run()
#22 /home/lmoelleken/testing/git/phpstan-src/vendor/symfony/console/Application.php(299): Symfony\Component\Console\Application->doRunCommand()
#23 /home/lmoelleken/testing/git/phpstan-src/vendor/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun()
#24 /home/lmoelleken/testing/git/phpstan-src/bin/phpstan(128): Symfony\Component\Console\Application->run()
#25 /home/lmoelleken/testing/git/phpstan-src/bin/phpstan(129): {closure}()

Code snippet that reproduces the problem

Sadly, I can't find the root cause of the problem because it's a legacy class with ~2000 lines of code and the error message says nothing about why or where. :-/ I tried to delete random methods from the class and at some point it works, but if I only delete one of the methods it will fail again?

Expected output

Non error.

Did PHPStan help you today? Did it make you happy in any way?

Not today, but I already had one of those "make one change in codebase and then fix errors until phpstan stops complaining, then run it, and it works first time" moments. :)

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