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