1--TEST-- 2Using Reflection on promoted properties 3--FILE-- 4<?php 5 6class Test { 7 public $z; 8 public function __construct( 9 public int $x, 10 /** @SomeAnnotation() */ 11 public string $y = "123", 12 string $z = "abc", 13 ) {} 14} 15 16$rc = new ReflectionClass(Test::class); 17echo $rc, "\n"; 18 19$y = $rc->getProperty('y'); 20var_dump($y->isPromoted()); 21var_dump($y->getDocComment()); 22$z = $rc->getProperty('z'); 23var_dump($z->isPromoted()); 24 25echo "\n"; 26 27$rp = new ReflectionParameter([Test::class, '__construct'], 'y'); 28var_dump($rp->isPromoted()); 29$rp = new ReflectionParameter([Test::class, '__construct'], 'z'); 30var_dump($rp->isPromoted()); 31 32?> 33--EXPECTF-- 34Class [ <user> class Test ] { 35 @@ %s 3-11 36 37 - Constants [0] { 38 } 39 40 - Static properties [0] { 41 } 42 43 - Static methods [0] { 44 } 45 46 - Properties [3] { 47 Property [ public $z = NULL ] 48 Property [ public int $x ] 49 /** @SomeAnnotation() */ 50 Property [ public string $y ] 51 } 52 53 - Methods [1] { 54 Method [ <user, ctor> public method __construct ] { 55 @@ %s 5 - 10 56 57 - Parameters [3] { 58 Parameter #0 [ <required> int $x ] 59 Parameter #1 [ <optional> string $y = '123' ] 60 Parameter #2 [ <optional> string $z = 'abc' ] 61 } 62 } 63 } 64} 65 66bool(true) 67string(24) "/** @SomeAnnotation() */" 68bool(false) 69 70bool(true) 71bool(false) 72