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