Skip to content

Skip scope type lookup for expressions without nullsafe operators#6104

Closed
staabm wants to merge 1 commit into
phpstan:2.2.xfrom
staabm:nulls
Closed

Skip scope type lookup for expressions without nullsafe operators#6104
staabm wants to merge 1 commit into
phpstan:2.2.xfrom
staabm:nulls

Conversation

@staabm

@staabm staabm commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

getNullsafeShortcircuitedExprRespectingScope() asked the scope for the expression's type before checking whether the expression contains a nullsafe operator at all. When it does not - the common case for the method/property/offset check rules calling this on every access - the result is the unmodified expression either way, and the type lookup (often a cache miss on the asking scope) is wasted. Do the cheap identity check first.

I cannot measure a clear benefit,

getNullsafeShortcircuitedExprRespectingScope() asked the scope for the
expression's type before checking whether the expression contains a
nullsafe operator at all. When it does not - the common case for the
method/property/offset check rules calling this on every access - the
result is the unmodified expression either way, and the type lookup
(often a cache miss on the asking scope) is wasted. Do the cheap
identity check first.
@staabm staabm closed this Jul 26, 2026
@staabm
staabm deleted the nulls branch July 26, 2026 14:32
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