Category
language
Problem
PHP 8.4 asymmetric property visibility allows only private(set) or protected(set) on a property — not combined with an explicit get visibility modifier (public, protected, or private). Zend rejects invalid combos at compile time:
Multiple access type modifiers are not allowed
This compiler accepts invalid declarations such as public private(set) and public protected(set), then runs user code. That diverges from php-src and lets illegal APIs ship.
php-src-strict: valid private(set) string $x (get public by default) must continue to work; this issue is invalid modifier pairs only.
php-src reference
Repro (failure today)
repro-asymmetric-modifiers.php:
<?php
class A { public private(set) string $x = 'a'; }
echo "compiled\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php repro-asymmetric-modifiers.php; echo vm_exit=$?
php -l repro-asymmetric-modifiers.php; echo zend_parse=$?
'
| Case |
Zend |
This compiler (2026-06-06) |
public private(set) string $x |
parse/compile fatal |
compiles, prints compiled |
public protected(set) string $x |
parse/compile fatal |
compiles, prints compiled |
private(set) string $x |
OK |
OK (out of scope) |
Scope (this repo)
| Area |
Path |
| Parser / php-cfg |
reject or flag double visibility in property declaration |
| Compiler |
lib/Compiler.php — asymmetricSetVisibilityFromCfgOp / property declare: fatal if get visibility + (set) modifier both explicit |
| Preprocessor |
lib/SourcePreprocessor/PropertyHooks.php if hooks rewrite modifiers |
| Tests |
test/compliance/cases/language/asymmetric_visibility_invalid_modifiers.phpt (VM + JIT lint + AOT lint) |
PHP-in-PHP: compile-time guard in lib/; no new runtime/*.c branches.
Done when
Related
Category
languageProblem
PHP 8.4 asymmetric property visibility allows only
private(set)orprotected(set)on a property — not combined with an explicit get visibility modifier (public,protected, orprivate). Zend rejects invalid combos at compile time:This compiler accepts invalid declarations such as
public private(set)andpublic protected(set), then runs user code. That diverges from php-src and lets illegal APIs ship.php-src-strict: valid
private(set) string $x(get public by default) must continue to work; this issue is invalid modifier pairs only.php-src reference
Zend/zend_compile.c— property visibility / asymmetric set flag validationZend/zend_language_parser.y—property_modifiergrammarRepro (failure today)
repro-asymmetric-modifiers.php:public private(set) string $xcompiledpublic protected(set) string $xcompiledprivate(set) string $xScope (this repo)
lib/Compiler.php—asymmetricSetVisibilityFromCfgOp/ property declare: fatal if get visibility +(set)modifier both explicitlib/SourcePreprocessor/PropertyHooks.phpif hooks rewrite modifierstest/compliance/cases/language/asymmetric_visibility_invalid_modifiers.phpt(VM + JIT lint + AOT lint)PHP-in-PHP: compile-time guard in
lib/; no newruntime/*.cbranches.Done when
private(set)/protected(set)without extra get modifier still compile./script/ci-fast.sh --filter asymmetric_visibility_invalid_modifiersgreen on VMbin/jit.php --lintandbin/compile.php --linton the PHPT case exit non-zeroRelated