Skip to content

Language: asymmetric visibility public private(set) — compile rejects valid PHP 8.4 (Zend/zend_compile.c) #10199

Description

@PurHur

Category

language · php-src-strict

Problem

PHP 8.4 asymmetric property visibility (public private(set) int $x) is valid syntax. This compiler rejects it at parse/compile with Multiple access type modifiers are not allowed, blocking PHP 8.4 language parity.

Related runtime gaps (#9842 private(set) write message, #6772 reflection) assume the syntax compiles first.

php-src reference

Repro (verified 2026-06-20)

test/repro/maintainer_gap_asymmetric_visibility_compile.php:

<?php
class C {
    public private(set) int $x = 1;
}
$c = new C();
echo $c->x, "\n";

Promoted-parameter variant (test/repro/maintainer_gap_promoted_private_set.php):

<?php
class D {
    public function __construct(public private(set) int $x = 1) {}
}
$d = new D();
echo $d->x, "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro/maintainer_gap_asymmetric_visibility_compile.php 2>&1 | head -3
php bin/vm.php test/repro/maintainer_gap_promoted_private_set.php 2>&1 | head -3
'
Check Zend PHP 8.4+ VM today
Property public private(set) compiles ✅ Multiple access type modifiers are not allowed ❌
Promoted public private(set) compiles ✅ same compile error ❌
External read $c->x prints value not reached

Scope (PHP-in-PHP first)

Area Files
Parser lib/Parser.php / grammar — emit asymmetric visibility CFG ops (partial hooks exist in lib/Compiler.php asymmetric*VisibilityFromCfgOp)
Compiler lib/Compiler.php — property + promoted-parameter declare paths
VM lib/VM.php — enforce get/set visibility asymmetry
JIT lib/JIT/AsymmetricVisibilityGuard.php — route through VM PHP trampoline per #1492

Done when

Links

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    IMPORTANTCritical patharea:compilerCompiler / CFG / JITarea:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions