Skip to content

Drop the @phpstan-impure tip and the PossiblyImpureCallExpr entries behind it - #6771

Merged
ondrejmirtes merged 2 commits into
2.3.xfrom
drop-possibly-impure-tips
Oct 21, 2026
Merged

ondrejmirtes merged 2 commits into
2.3.xfrom
drop-possibly-impure-tips

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Member

The "If X::foo() is impure, add @phpstan-impure PHPDoc tag above its declaration" tip was the only reader of the PossiblyImpureCallExpr entries the call handlers put into the scope after every call to a possibly impure user function or method. Those entries were a quarter of all expression-table entries, and every later scope derivation copied, merged, compared and freed them.

This removes the tip together with everything that only fed it:

  • PossiblyImpureCallExpr, its PossiblyImpureCallExprHandler and printer method
  • the remembering in MethodCallHandler, StaticCallHandler and FuncCallScopeEffectsHelper
  • MutatingScope::findPossiblyImpureCallDescriptions() and the special cases in getDifferingVariableRoots()
  • PossiblyImpureTipHelper and its use in the 19 constant-condition and impossible-check rules, which return to their shape from before the tip
  • the native mirrors in turbo-ext

Possibly impure values are still remembered exactly as before (rememberPossiblyImpureFunctionValues). Only the tip text is gone, and reported errors are unchanged. Kept for backward compatibility:

  • tips.possiblyImpure stays in the schema as a no-op, so configs that set it keep working.
  • RuleErrorBuilder::possiblyImpureTip() stays because the class is @api.

Measured against 2.3.x (a7e2b6a), both legs with their own turbo build on PHP 8.5 macOS:

  • Full parallel self-analysis, 5 alternating pairs: user CPU −2.0% (faster in all 5 pairs), RSS −0.2%. Wall time is within noise.
  • Single-process analysis of src/Type, src/Reflection and src/PhpDoc: −1.77% instructions, identical output.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MMNnG2Zo7wgvSZCzjdk17X

ondrejmirtes and others added 2 commits October 21, 2026 09:24
…ehind it

The tip was the only reader of the PossiblyImpureCallExpr entries the call
handlers put into the scope after every call to a possibly impure user
function or method - a quarter of all expression-table entries, copied,
merged, compared and freed by every later scope derivation. Remembering
possibly impure values (rememberPossiblyImpureFunctionValues) is unchanged.

tips.possiblyImpure stays in the schema as a no-op so existing configs keep
working; RuleErrorBuilder::possiblyImpureTip() stays as @api.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MMNnG2Zo7wgvSZCzjdk17X
@ondrejmirtes
ondrejmirtes merged commit 7785596 into 2.3.x Oct 21, 2026
507 of 509 checks passed
@ondrejmirtes
ondrejmirtes deleted the drop-possibly-impure-tips branch October 21, 2026 07:26
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.

1 participant