Skip to content

Allow readonly properties with hooks (PHP 8.4) — Closes #9835 - #10593

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-9835-readonly-property-hooks
Jun 22, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-9835-readonly-property-hooks

Conversation

@PurHur

@PurHur PurHur commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Remove compile-time Hooked properties cannot be readonly rejection in PropertyHooks preprocessor — PHP 8.4 allows readonly properties with set hooks initialized from the constructor.
  • Existing VM readonly enforcement already handles runtime: constructor init via set hook succeeds; post-construct external writes throw catchable Error.
  • Update compliance guards and unit test to match php-src-strict behavior (supersedes stale Language: property hook + same-name backing field — must parse-error (Zend/zend_compile.c) #9805 compile-fatal expectation).

php-src reference

  • Zend/zend_compile.c — readonly + hook validation (PHP 8.4)
  • Zend/zend_property_hooks.c — set hook during construction vs post-init write Error

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_gap_readonly_hook_write_exception.php'
# caught: Error

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && ./vendor/bin/phpunit --filter "readonly_property_hook|property_hook_readonly|testReadonlyHookedPropertyLowers"'
# OK (3 tests, 5 assertions)

Closes #9835

Made with Cursor

Remove compile-time rejection so readonly hooked properties compile;
existing VM readonly enforcement already blocks post-construct writes
via set hooks while allowing constructor initialization.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 449ce32 into master Jun 22, 2026
@PurHur
PurHur deleted the agent/issue-9835-readonly-property-hooks branch June 22, 2026 19:04
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.

Language: readonly property with hooks — compile rejects valid PHP 8.4 pattern (Zend/zend_compile.c)

1 participant