Skip to content

Feature(8.4): property hooks#1204

Open
jorgsowa wants to merge 4 commits intomainfrom
feature/property-hooks
Open

Feature(8.4): property hooks#1204
jorgsowa wants to merge 4 commits intomainfrom
feature/property-hooks

Conversation

@jorgsowa
Copy link
Collaborator

@jorgsowa jorgsowa commented Mar 16, 2026

Supersedes original feature implementation #1143

Additional improvements:

  • hooks defaults to []

Missing features implemented

  • Constructor property promotion with hooks - __construct(public string $name { set => strtolower($value); })
  • Attributes on hooks #[SomeAttr] get => ... and set(#[SensitiveParameter] int $value)

Bug fixes:

  • Semicolon early return - abstract/interface hooks (get;, set;) now return immediately instead of falling through and potentially parsing the next hook's name as a body expression
  • EOF guard - read_property_hooks loop checks for EOF to prevent infinite loops on malformed input
  • Error message — fixed "Typed Class Constants requires PHP 8.4+" → "Property hooks require PHP 8.4+"
  • minor typos

Fixes: #1142

jorgsowa and others added 2 commits March 16, 2026 23:44
Implements parsing for PHP 8.4 property hooks (get/set) including
short arrow expressions, block bodies, by-ref, final, abstract,
setter parameters, and interface support.

Co-Authored-By: Thomas Genin <[email protected]>
@jorgsowa jorgsowa force-pushed the feature/property-hooks branch from 7e2b4d3 to f9f79bc Compare March 16, 2026 23:26
@jorgsowa jorgsowa marked this pull request as ready for review March 16, 2026 23:35
@alexander-akait
Copy link
Collaborator

/cc @czosel please take a look

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.

8.4: property hooks

2 participants