Skip to content

Language: asymmetric visibility syntax (PHP 8.4 public private(set)) — parse fails Multiple access type modifiers #6861

Closed

Description

@PurHur

Category

language

Problem

PHP 8.4 asymmetric property visibility (public private(set), protected(set), etc.) is valid syntax in php-src but this compiler rejects it at parse/compile with:

Multiple access type modifiers are not allowed

That blocks all runtime/reflection parity work (#5060, #6772, #6771) because sources using asymmetric visibility never compile.

php-src reference

Repro

<?php
declare(strict_types=1);

class Asym {
    public private(set) string $name = 'x';
}
$a = new Asym();
echo $a->name, "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro/asymmetric_visibility_syntax.php 2>&1 | head -3
php -l test/repro/asymmetric_visibility_syntax.php 2>&1 | head -3  # PHP 8.4+ host if available
'
Engine Result
php-src 8.4+ compiles; getter public, setter private
bin/vm.php (today) parseAndCompile failure: Multiple access type modifiers are not allowed

Scope (PHP-in-PHP)

Layer Path
Parser/php-cfg php-parser overlay or grammar for (set) visibility tokens
Compiler lib/Compiler.php — map asymmetric flags to property metadata
VM enforce get/set visibility in lib/VM.php property access paths
Tests test/compliance/cases/language/asymmetric_visibility_syntax.phpt

Do not add asymmetric rules to runtime/*.c; keep semantics in lib/ + ext/.

Done when

  • Repro compiles and prints x
  • External assignment $a->name = 'y' from global scope throws Error (private(set))
  • ./script/ci-fast.sh --filter asymmetric_visibility_syntax green on VM (+ JIT/AOT lint when lowering exists)

Related

Activity

  1. added
    enhancementNew feature or request
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 6, 2026
  2. PurHur commented on Jun 6, 2026

    @PurHur
    OwnerAuthor

    claim: worker-lane-B — starting this run

  3. PurHur commented on Jun 6, 2026

    @PurHur
    OwnerAuthor

    Merged via #6890.

    Fix: AsymmetricVisibilityRewriter now allows distinct read/set visibility pairs (public private(set), etc.) matching php-src 8.4. Only duplicate same-axis modifiers (public public(set)) compile-fatal. Promoted public private(set) still rejected by AsymmetricVisibilityCompileCheck (#6742).

    Verification:

    • `php bin/vm.php test/repro/asymmetric_visibility_syntax.php` → prints `x`, exit 255 on external write
    • `vendor/bin/phpunit --filter asymmetric_visibility_syntax test/compliance/VMTest.php` → OK
    • Unit tests `AsymmetricVisibilityRewriterTest` + `AsymmetricVisibilityCompileCheckTest` → OK
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

    area: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