Skip to content

Language: promoted constructor public (private(set)) parameter — parse rejected on 8.4 profile (Zend/zend_compile.c) #16495

Description

@PurHur

Category

language · php-src-strict · PHP 8.4 asymmetric visibility

Problem

PHP 8.4 allows asymmetric visibility on promoted constructor parameters, e.g. public function __construct(public (private(set)) int $x = 1) {}. Zend 8.4 accepts and runs the program; with PHP_COMPILER_PROFILE=8.4 this compiler fails at parse/compile with unexpected token "private".

Repro Zend 8.4+ VM profile 8.4 (2026-07-05)
class D { public function __construct(public (private(set)) int $x = 1) {} } compiles; $d->x readable syntax error, unexpected token "private"

(Related but distinct from #16142 — duplicate access modifiers on a plain property.)

php-src reference

PHP implementation target

  • lib/ parser/preprocessor — extend promoted-parameter grammar for parenthesized asymmetric visibility (8.4 profile gate)
  • lib/Compiler.php / property hook + visibility lowering — emit correct read/write scopes for promoted asymmetric fields
  • Prefer PHP lowering; no new C runtime branches

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && PHP_COMPILER_PROFILE=8.4 php bin/vm.php test/repro/maintainer_gap_promoted_private_set.php'

Done when

  • PHP_COMPILER_PROFILE=8.4: promoted public (private(set)) parses and matches Zend read/write access rules
  • Compliance .phpt guard under test/compliance/cases/language/
  • php-src-strict on 8.4 profile; no php-compiler-strict shortcut

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

    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