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 Property [ public string $y ] 50 } 51 52 - Methods [1] { 53 Method [ <user, ctor> public method __construct ] { 54 @@ %s 5 - 10 55 56 - Parameters [3] { 57 Parameter #0 [ <required> int $x ] 58 Parameter #1 [ <optional> string $y = '123' ] 59 Parameter #2 [ <optional> string $z = 'abc' ] 60 } 61 } 62 } 63} 64 65bool(true) 66string(24) "/** @SomeAnnotation() */" 67bool(false) 68 69bool(true) 70bool(false) 71