Skip to content

Faster UnionType->isNull() - #6232

Merged
staabm merged 1 commit into
phpstan:2.2.xfrom
staabm:isnull
Aug 18, 2026
Merged

Faster UnionType->isNull()#6232
staabm merged 1 commit into
phpstan:2.2.xfrom
staabm:isnull

Conversation

@staabm

@staabm staabm commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Type->isNull() is invoked in TypeSpecifier->createForExpr on most expressions.

its shows up in a blackfire profile of https://github.com/phpstan/phpstan-src/blob/380b5ba72fc6bd35fb4f8c27a306a16ea42f24c1/tests/bench/data/big-constant-int-union.php :
grafik

before this PR:

➜  phpstan-src git:(2.2.x) ✗ php bin/phpstan analyze big-constant-int-union.php --debug -vv
Note: Using configuration file /Users/staabm/workspace/phpstan-src/phpstan.neon.dist.
Result cache not used because of debug mode.
/Users/staabm/workspace/phpstan-src/big-constant-int-union.php
Result cache was not saved because only files were passed as analysed paths.

                                                                                                                        
 [OK] No errors                                                                                                         
                                                                                                                        

Elapsed time: 0.42 seconds
Used memory: 58.5 MB

after this PR:

➜  phpstan-src git:(isnull) ✗ php bin/phpstan analyze big-constant-int-union.php --debug -vv
Note: Using configuration file /Users/staabm/workspace/phpstan-src/phpstan.neon.dist.
Result cache not used because of debug mode.
/Users/staabm/workspace/phpstan-src/big-constant-int-union.php
Result cache was not saved because only files were passed as analysed paths.

                                                                                                                        
 [OK] No errors                                                                                                         
                                                                                                                        

Elapsed time: 0.38 seconds
Used memory: 58.5 MB

refs phpstan/phpstan#15088

@staabm
staabm marked this pull request as ready for review August 18, 2026 11:27
@staabm
staabm merged commit 752f83f into phpstan:2.2.x Aug 18, 2026
436 of 438 checks passed
@staabm
staabm deleted the isnull branch August 18, 2026 11:27
@phpstan-bot

Copy link
Copy Markdown
Collaborator

This pull request has been marked as ready for review.

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.

2 participants