Category
language
Problem
PHP 8.4 asymmetric property visibility allows explicit read + set modifiers on the same property, e.g. public private(set) string $name (equivalent to shorthand private(set) string $name). Zend accepts public protected(set) and protected private(set) as well.
Closed #7099 added compile-time rejection in lib/Ast/AsymmetricVisibilityRewriter.php (rejectExplicitReadBeforeAsymmetricSetModifier()), but that diverges from php-src / the RFC: valid PHP 8.4 sources now fail with:
Multiple access type modifiers are not allowed
Shorthand private(set) alone still compiles (#3165).
php-src-strict: illegal combos such as protected public(set) must remain compile fatals.
php-src reference
Repro (failure today)
<?php
class A {
public private(set) string $x = 'a';
}
class B {
public protected(set) string $y = 'b';
}
class C {
protected private(set) string $z = 'c';
}
echo "compiled\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php repro.php; echo vm_exit=$?
# Compare on PHP 8.4+ reference build when available
'
Observed (VM): parseAndCompile failure: Multiple access type modifiers are not allowed for all three classes.
Expected (php-src 8.4): compiles; read/write scopes enforced at runtime.
Implementation hints (PHP-in-PHP)
Pairs
Category
languageProblem
PHP 8.4 asymmetric property visibility allows explicit read + set modifiers on the same property, e.g.
public private(set) string $name(equivalent to shorthandprivate(set) string $name). Zend acceptspublic protected(set)andprotected private(set)as well.Closed #7099 added compile-time rejection in
lib/Ast/AsymmetricVisibilityRewriter.php(rejectExplicitReadBeforeAsymmetricSetModifier()), but that diverges from php-src / the RFC: valid PHP 8.4 sources now fail with:Shorthand
private(set)alone still compiles (#3165).php-src-strict: illegal combos such as
protected public(set)must remain compile fatals.php-src reference
Zend/zend_compile.c— asymmetric visibility flagsZend/zend_language_parser.y—property_modifiergrammarRepro (failure today)
Observed (VM):
parseAndCompile failure: Multiple access type modifiers are not allowedfor all three classes.Expected (php-src 8.4): compiles; read/write scopes enforced at runtime.
Implementation hints (PHP-in-PHP)
lib/Ast/AsymmetricVisibilityRewriter.php: stop rejecting validread + set(set)pairs; keep rejectingsetmore permissive thanget(e.g.protected public(set)).lib/JIT/Builtin/Type/Object_.phpasymmetric set tables (Language: PHP 8.4 asymmetric property visibility (public/private(set), etc.) #3165, Language: asymmetric visibility on interface properties — compile + VM set guard (PHP 8.4, zend_compile.c) #4876).test/compliance/cases/language/asymmetric_visibility_explicit_modifiers.phpt.Pairs
lib/VM.php(Language: PHP 8.4 asymmetric property visibility (public/private(set), etc.) #3165, Language: property hooks with asymmetric set visibility set (protected) => — parse fails (zend_property_hooks.c) #6898)