Category
Language: · php-src-strict · typed properties (self / parent)
Problem
Instance properties declared with a bare self or parent type must accept assignments that satisfy the early-bound class (same class / subclass for self; parent class / subclass for parent), including constructor-promoted public self $x. On master 2026-08-17, VM throws TypeError: Cannot assign A to property A::$x of type self (and the analogous parent error) even when assigning $this / a valid parent instance.
Control: ?self and self|string / parent|string already match Zend on this tree — only the bare self / parent forms are wrong. Param/return self types also match (not this bug).
Probed 2026-08-17 — host Zend PHP 8.2 vs php bin/vm.php.
| Repro |
Zend 8.2+ |
VM (2026-08-17) |
$a->x = $a with public self $x |
self_ok A |
TypeError “… of type self” |
$b->x = $b on subclass inheriting self |
child_ok B |
TypeError |
$c->x = new P with public parent $x |
parent_ok P |
TypeError “… of type parent” |
promoted public function __construct(public self $x) |
promoted_ok |
TypeError |
public ?self $x assign $this |
OK |
OK (control) |
php-src reference
PHP implementation target
Repro
./script/docker-exec.sh -- bash -lc 'php test/repro/maintainer_gap_prop_type_self.php'
./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_prop_type_self.php'
Done when
Category
Language:· php-src-strict · typed properties (self/parent)Problem
Instance properties declared with a bare
selforparenttype must accept assignments that satisfy the early-bound class (same class / subclass forself; parent class / subclass forparent), including constructor-promotedpublic self $x. On master 2026-08-17, VM throwsTypeError: Cannot assign A to property A::$x of type self(and the analogousparenterror) even when assigning$this/ a valid parent instance.Control:
?selfandself|string/parent|stringalready match Zend on this tree — only the bareself/parentforms are wrong. Param/returnselftypes also match (not this bug).Probed 2026-08-17 — host Zend PHP 8.2 vs
php bin/vm.php.$a->x = $awithpublic self $xself_ok ATypeError“… of type self”$b->x = $bon subclass inheritingselfchild_ok BTypeError$c->x = new Pwithpublic parent $xparent_ok PTypeError“… of type parent”public function __construct(public self $x)promoted_okTypeErrorpublic ?self $xassign$thisphp-src reference
Zend/zend_execute.c— typed property assign /ZEND_ASSIGN_OBJZend/zend_object_handlers.c— property store type checkZend/zend_types.h—self/parenttype resolution for properties (early binding;staticnot allowed on properties)PHP implementation target
lib/VM/type-check /TypeCheck/ property assign — resolve bareself/parentproperty types to the declaring class (same path?selfalready uses) before instanceof-style checksselfbinding work (Language: trait self param/return types bind to trait name — Zend using class (Zend/zend_inheritance.c) #31744) but this is property types on ordinary classesRepro
Done when
self/parentproperty assigns match Zend (instance, inherited, promoted)?self/ union controls and wrong-typeTypeErrors stay correct.phptguard undertest/compliance/cases/for propertyself/parent