Skip to content

Fix constructor-promoted asymmetric visibility (public private(set)) (#6981) - #6988

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-6981-asymmetric-visibility-promoted-ctor
Jun 6, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-6981-asymmetric-visibility-promoted-ctor

Conversation

@PurHur

@PurHur PurHur commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Remove overly broad duplicate-modifier check in AsymmetricVisibilityCompileCheck::verifyPromotedParam() that rejected valid PHP 8.4 public private(set) constructor promotion
  • Add compliance PHPT asymmetric_visibility_promoted_ctor.phpt and issue repro script
  • Update unit test to expect compile success for promoted asymmetric visibility

php-src reference

  • Zend/zend_compile.c — promoted parameter → property with asymmetric set visibility (RFC asymmetric-visibility-v2)
  • PHP implementation: lib/Ast/AsymmetricVisibilityRewriter.php (source rewrite), lib/Compiler/AsymmetricVisibilityCompileCheck.php (validation), lib/Compiler.php (promotion lowering)

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro/asymmetric_visibility_promoted_ctor.php
vendor/bin/phpunit --filter "AsymmetricVisibilityCompileCheckTest|asymmetric_visibility_promoted"
./script/ci-fast.sh --filter asymmetric_visibility_promoted
'

Output:

alice
Cannot modify private(set) property User::$name from global scope
OK (8 tests, 8 assertions)

Closes #6981

Made with Cursor

Allow public private(set) on promoted constructor parameters per PHP 8.4
zend_compile.c parity; the prior check wrongly treated read+set as duplicate
modifiers. Add compliance PHPT and update unit test.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit c8307c0 into master Jun 6, 2026
@PurHur
PurHur deleted the agent/issue-6981-asymmetric-visibility-promoted-ctor branch June 6, 2026 17: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.

Regression: constructor-promoted asymmetric visibility public private(set) — compile fatal (re-#4690)

1 participant