Skip to content

Lazier verbosity in ConstantArrayType->checkOurKeys() - #6649

Merged
staabm merged 1 commit into
phpstan:2.3.xfrom
staabm:lazier
Oct 2, 2026
Merged

staabm merged 1 commit into
phpstan:2.3.xfrom
staabm:lazier

Conversation

@staabm

@staabm staabm commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

as can be seen on a profile:

grafik

2.3.x@339e91e25d0dde9ad137a091de05fddc29102161

../phpstan-src/bin/phpstan analyse -c phpstan-nested.neon --debug -v
/Users/staabm/workspace/sf-ux-css-phpstan-reproducer/src/Ui/Button.php
                                                                                                                        
Elapsed time: 12.22 seconds
Peak memory: 48 MB

this PR:

../phpstan-src/bin/phpstan analyse -c phpstan-nested.neon --debug -v
PHPStan - PHP Static Analysis Tool 2.3.x-dev@223a01f
/Users/staabm/workspace/sf-ux-css-phpstan-reproducer/src/Ui/Button.php

 [OK] No errors                                                                                                                                                                                                                            

Elapsed time: 10.07 seconds
Peak memory: 48 MB

measured without turbo

refs phpstan/phpstan#15348

@staabm
staabm marked this pull request as ready for review October 1, 2026 20:33
@staabm staabm changed the title Lazier verbosity in ConstantArrayType->checkOurKeys() Lazier verbosity in ConstantArrayType->checkOurKeys() Oct 1, 2026
@phpstan-bot

Copy link
Copy Markdown
Collaborator

This pull request has been marked as ready for review.


$result = $result->and($hasOffset);
$otherValueType = $type->getOffsetValueType($keyType);
$verbosity = VerbosityLevel::getRecommendedLevelByType($valueType, $otherValueType);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

creates the verbosity only when a error-message needs to be rendered. since VerbosityLevel::getRecommendedLevelByType requires type-traversal it can be slow on big types.

@staabm
staabm merged commit 5ae1e59 into phpstan:2.3.x Oct 2, 2026
893 of 915 checks passed
@staabm
staabm deleted the lazier branch October 2, 2026 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants