Skip to content

Memoize hasInstanceProperty() into its own cache - #6597

Merged
ondrejmirtes merged 2 commits into
2.3.xfrom
fix-has-instance-property-cache
Sep 25, 2026
Merged

ondrejmirtes merged 2 commits into
2.3.xfrom
fix-has-instance-property-cache

Conversation

@ondrejmirtes

@ondrejmirtes ondrejmirtes commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

ClassReflection::hasInstanceProperty() wrote its last two answers (the require-extends one and the final false) into $this->hasPropertyCache instead of $this->hasInstancePropertyCache.

Consequences:

  • A class with a static property $x answered hasProperty('x') with false once hasInstanceProperty('x') had been asked first.
  • The same happened through @phpstan-require-extends: an interface requiring such a class got an order-dependent hasProperty() answer.
  • A negative hasInstanceProperty() answer was never memoized.

The turbo twin in turbo-ext/src/ClassReflection.cpp mirrored the bug and gets the same fix. The second commit bumps the expected turbo version.

The regression test in ClassReflectionTest fails before the fix both without and with the extension loaded.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GupuyaR5X7EJcxUsWaFzjg

ondrejmirtes and others added 2 commits September 25, 2026 22:18
The last two answers of ClassReflection::hasInstanceProperty() were written
into $this->hasPropertyCache. A class with a static property then answered
hasProperty() with false once hasInstanceProperty() had been asked first,
and the negative instance answer was never memoized at all.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GupuyaR5X7EJcxUsWaFzjg
@ondrejmirtes
ondrejmirtes force-pushed the fix-has-instance-property-cache branch from 3131180 to 74c3942 Compare September 25, 2026 20:18
@ondrejmirtes
ondrejmirtes merged commit 74c3942 into 2.3.x Sep 25, 2026
226 of 250 checks passed
@ondrejmirtes
ondrejmirtes deleted the fix-has-instance-property-cache branch September 25, 2026 20:19
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