Skip to content

Comments

TypeSpecifier: Prevent duplicate expression printing#5018

Merged
staabm merged 1 commit intophpstan:2.1.xfrom
staabm:prev
Feb 21, 2026
Merged

TypeSpecifier: Prevent duplicate expression printing#5018
staabm merged 1 commit intophpstan:2.1.xfrom
staabm:prev

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Feb 21, 2026

its invoked a lot

grafik

only very minor improvements


before/after PR diff

blackfire run --ignore-exit-status php bin/phpstan analyse src/Analyser/ -v --debug

grafik

@staabm staabm marked this pull request as ready for review February 21, 2026 11:13
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

$sureNotTypes[$exprString] = [$expr, $type];
if ($exprString !== $originalExprString) {

if ($expr !== $originalExpr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it really saving calls ? The code was comparing the string but now you are comparing the expr.

Also should you still check string after in case two expr has the same string print ? (Dunno if its possible)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated the PR description with a diff

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the 2 expressions involved can be compared this way, because they originate from a assignment a few lines above

https://github.com/phpstan/phpstan-src/pull/5018/files#diff-1076e38598f300a69c9dc998dae31374052f95bd69d0d71c11e9d0a4c188976dL1933

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also note that even if we theoretically would preduce the same string again, we would overwrite the previous existing value with the very same touple again

@staabm staabm merged commit afa988b into phpstan:2.1.x Feb 21, 2026
653 of 662 checks passed
@staabm staabm deleted the prev branch February 21, 2026 12:56
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