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
Category
language· php-src-strict · PHP 8.4 asymmetric visibilityProblem
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; withPHP_COMPILER_PROFILE=8.4this compiler fails at parse/compile withunexpected token "private".class D { public function __construct(public (private(set)) int $x = 1) {} }$d->xreadablesyntax error, unexpected token "private"(Related but distinct from #16142 — duplicate access modifiers on a plain property.)
php-src reference
Zend/zend_compile.c— promoted-parameter asymmetric visibility parsing/loweringZend/zend_language_parser.y— grammar for(private(set))on promoted paramsPHP 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 fieldsRepro
./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: promotedpublic (private(set))parses and matches Zend read/write access rules.phptguard undertest/compliance/cases/language/