Skip to content

Language: reject public+private(set) asymmetric visibility at compile time (#7099) - #7106

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-7099-asymmetric-invalid-modifiers
Jun 6, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-7099-asymmetric-invalid-modifiers

Conversation

@PurHur

@PurHur PurHur commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add rejectExplicitReadBeforeAsymmetricSetModifier() in AsymmetricVisibilityRewriter so explicit get visibility combined with (set) (e.g. public private(set), public (private(set))) fails at compile time with Zend's Multiple access type modifiers are not allowed message.
  • Update compliance/unit tests: runtime parity cases now use standalone private(set); invalid double-modifier forms expect compile fatal.

php-src reference: Zend/zend_compile.c — zend_add_member_modifier()

Test plan

  • Issue repro — compile fatal before user code runs
  • Valid private(set) / promoted private(set) still compile and enforce set visibility at runtime
  • PHPUnit asymmetric visibility suite green

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php -r "class A { public private(set) string \$x = \"a\"; }" 2>&1; echo vm_exit=\$?
vendor/bin/phpunit --filter asymmetric_visibility_invalid_modifiers
vendor/bin/phpunit --filter asymmetric_visibility
'

Output (2026-06-06):

parseAndCompile failure: Multiple access type modifiers are not allowed
vm_exit=255
OK (1 test, 1 assertion)
OK (21 tests, 23 assertions)

Closes #7099

…7099).

Zend/php-src treats `public private(set)` and similar double-modifier forms as
compile fatals; align AsymmetricVisibilityRewriter and update compliance tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
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: asymmetric visibility — public+private(set)/public+protected(set) must compile fatal (zend_compile.c)

1 participant