public string $x {
get => 'g';
set (protected) => $value;
}
<?php
declare(strict_types=1);
class C {
public string $x {
get => 'g';
set (protected) => $value;
}
}
$c = new C();
echo $c->x, "\n"; // g
$c->x = 'n'; // Error from global scope (protected set)
Category
language· php-src-strict · PHP 8.4Problem
PHP 8.4 property hooks may declare asymmetric set visibility on the
sethook:php-src accepts this; this compiler fails to parse (
Syntax error, unexpected '('on thesethook line). Other property-hook gaps (#4821, #4701, …) assume hooks parse; this blocks asymmetric hook visibility entirely.php-src reference
Zend/zend_compile.c— property hook parse + asymmetric set modifierZend/zend_property_hooks.c— hook dispatch with visibilityRepro
Scope (PHP-in-PHP first)
AsymmetricVisibilityRewriter)Errorparity)test/compliance/cases/language/property_hook_asymmetric_set.phptDone when
gError(protected set)./script/ci-fast.sh --filter property_hook_asymmetricgreen on VMRelated