1--TEST-- 2ReflectionProperty::isInitialized() on hooked properties 3--FILE-- 4<?php 5 6class Test { 7 // Plain 8 public $p1; 9 public string $p2; 10 // Virtual 11 public $v1 { get => throw new Exception(); } 12 public $v2 { set { throw new Exception(); } } 13 // Backed 14 public $b1 { get => throw new Exception($this->b1); } 15 public string $b2 { get => throw new Exception($this->b2); } 16 public $b3 { set => throw new Exception(); } 17 public string $b4 { set => throw new Exception(); } 18} 19 20$test = new Test(); 21$rc = new ReflectionClass(Test::class); 22foreach ($rc->getProperties() as $rp) { 23 echo $rp->getName(), "\n"; 24 var_dump($rp->isInitialized($test)); 25 try { 26 $rp->setRawValue($test, 42); 27 } catch (Error $e) {} 28 var_dump($rp->isInitialized($test)); 29} 30 31?> 32--EXPECT-- 33p1 34bool(true) 35bool(true) 36p2 37bool(false) 38bool(true) 39v1 40bool(true) 41bool(true) 42v2 43bool(true) 44bool(true) 45b1 46bool(true) 47bool(true) 48b2 49bool(false) 50bool(true) 51b3 52bool(true) 53bool(true) 54b4 55bool(false) 56bool(true) 57