1--TEST-- 2Test ReflectionProperty::getDocComment() usage. 3--INI-- 4opcache.save_comments=1 5opcache.load_comments=1 6--FILE-- 7<?php 8 9class A { 10 /** 11 * My Doc Comment for $a 12 * 13 */ 14 public $a = 2, $b, $c = 1; 15 /** 16 * My Doc Comment for $d 17 */ 18 var $d; 19 /**Not a doc comment */ 20 private $e; 21 /** 22 * Doc comment for $f 23 */ 24 static protected $f; 25} 26 27class B extends A { 28 public $a = 2; 29 /** A doc comment for $b */ 30 var $b, $c = 1; 31 /** A doc comment for $e */ 32 var $e; 33} 34 35foreach(array('A', 'B') as $class) { 36 $rc = new ReflectionClass($class); 37 $rps = $rc->getProperties(); 38 foreach($rps as $rp) { 39 echo "\n\n---> Doc comment for $class::$" . $rp->getName() . ":\n"; 40 var_dump($rp->getDocComment()); 41 } 42} 43 44?> 45--EXPECTF-- 46 47---> Doc comment for A::$a: 48string(%d) "/** 49 * My Doc Comment for $a 50 * 51 */" 52 53 54---> Doc comment for A::$b: 55bool(false) 56 57 58---> Doc comment for A::$c: 59bool(false) 60 61 62---> Doc comment for A::$d: 63string(%d) "/** 64 * My Doc Comment for $d 65 */" 66 67 68---> Doc comment for A::$e: 69bool(false) 70 71 72---> Doc comment for A::$f: 73string(%d) "/** 74 * Doc comment for $f 75 */" 76 77 78---> Doc comment for B::$a: 79bool(false) 80 81 82---> Doc comment for B::$b: 83string(%d) "/** A doc comment for $b */" 84 85 86---> Doc comment for B::$c: 87bool(false) 88 89 90---> Doc comment for B::$e: 91string(%d) "/** A doc comment for $e */" 92 93 94---> Doc comment for B::$d: 95string(%d) "/** 96 * My Doc Comment for $d 97 */" 98 99 100---> Doc comment for B::$f: 101string(%d) "/** 102 * Doc comment for $f 103 */" 104