Skip to content

Conversation

@DanielEScherzer
Copy link
Member

Previously, the assignment op line was only emitted when one of the other flags allowed for promoted properties (visibility, set visibility, or readonly) was also used, or when the property had hooks. The property was still added to the class, but the magical assignment $this->prop = $prop was missing. Add that assignment even when no visibility is explicitly specified, and a test to confirm the fix.

Previously, the assignment op line was only emitted when one of the other flags
allowed for promoted properties (visibility, set visibility, or readonly) was
also used, or when the property had hooks. The property was still added to the
class, but the magical assignment `$this->prop = $prop` was missing. Add that
assignment even when no visibility is explicitly specified, and a test to
confirm the fix.
@DanielEScherzer
Copy link
Member Author

I'll add NEWS once this is approved, to hopefully avoid merge conflicts
CC @TimWolla @iluuu1994 who reviewed the original RFC implementation

@DanielEScherzer DanielEScherzer linked an issue Nov 3, 2025 that may be closed by this pull request
@DanielEScherzer DanielEScherzer merged commit e5c6456 into php:PHP-8.5 Nov 3, 2025
10 checks passed
DanielEScherzer added a commit that referenced this pull request Nov 3, 2025
* PHP-8.5:
  Fix GH-20377: emit assignment for all final promoted properties (#20378)
@DanielEScherzer DanielEScherzer deleted the final-promotion-no-vis branch November 3, 2025 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Final property promotion not used without visibility

4 participants