-
Notifications
You must be signed in to change notification settings - Fork 551
Make ConstantArrayTypeBuilder::ARRAY_COUNT_LIMIT configurable #4850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add new configuration parameter `constantArrayTypeBuilderArrayCountLimit` that allows users to customize the array count limit (default: 256). This follows the existing BleedingEdgeToggle pattern with a static accessor. The original constant is kept for backward compatibility but marked deprecated. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
you should measure the perf impact when using different values for this limit, as it could get very slow depending on your code |
|
Hi, I disagree with this solution. I don't want to let people shoot themselves in the foot by slowing down PHPStan. The right solution to this problem is to improve ConstantArrayType performance so we can raise the limit. If you have some examples where the current limit limits you, please open issues about them and we'll try to make the limit higher by making PHPStan faster. |
|
I understand this option should not be used lightly ; but it seems better to me to have a working analysis that is slow-er than a broken analysis that is fast, for people that do hit that limit for critical pieces of their codebase (in our application, we have a And I'm all for "making PHPStan faster" (surely it benefits everyone, so that's a huge win), but what I see is that you are already doing an amazing job at this and constantly improving the performances, so I don't know what more could be done "specifically for this issue". And yet, I wonder why this hard-coded value was never changed then ? What kind of benchmarks would be needed to check that's the current value is still the "optimal one" with today's PHPStan's performances ? |
|
I just want to see a source code that's impacted by the current limit. We can increase the limit so that the array is not degraded & watch Blackfire performance profiles to see what could be optimized. |
yes, I am also interessted in the examples. I already had a look at existing tests and profiles suggested that
|
|
Unfortunately, the project I'm working on cannot be shared publicly (though to give you an idea, it's ~549k lines of PHP code, which we split in two with different PHPStan configs : legacy got ~183k and new code ~366k). And I guess you need "the whole codebase" to judge if the PHPStan complete analysis is X% or Y% slower when raising that limit ? So extracting just this array, anonymizing its data, wouldn't really help you, right ? |
🤖 Generated by Claude Code
Fixes phpstan/phpstan#8636 (which has happened on our project too)
Summary
constantArrayTypeBuilderArrayCountLimitthat allows users to customize the array count limitBleedingEdgeTogglepattern with a static accessor classUsage
Users can configure the limit in their
phpstan.neon:Test plan
vendor/bin/phpunit tests/PHPStan/Type/Constant/ConstantArrayTypeBuilderTest.php(7 tests, 41 assertions)php -lsyntax checkTest results:
ConstantArrayType)IntersectionType)ConstantArrayType)IntersectionType)