|
| 1 | +--TEST-- |
| 2 | +Test ReflectionParameter::getDocComment() usage when methods are indented. |
| 3 | +--INI-- |
| 4 | +opcache.save_comments=1 |
| 5 | +--FILE-- |
| 6 | +<?php |
| 7 | + |
| 8 | +class A { |
| 9 | + function method( |
| 10 | + /** |
| 11 | + * My Doc Comment for $a |
| 12 | + * |
| 13 | + */ |
| 14 | + $a, $b, $c, |
| 15 | + /** |
| 16 | + * My Doc Comment for $d |
| 17 | + */ |
| 18 | + $d, |
| 19 | + // Not a doc comment |
| 20 | + /**Not a doc comment */ |
| 21 | + $e, |
| 22 | + /** |
| 23 | + * Doc comment for $f |
| 24 | + */ |
| 25 | + $f, |
| 26 | + $g /** Doc comment for $g after parameter */, |
| 27 | + /** Doc comment for $h */ |
| 28 | + $h /** Doc comment for $h after parameter */, |
| 29 | + ) {} |
| 30 | + |
| 31 | + public string $property { |
| 32 | + set( |
| 33 | + /** Doc Comment for property hook parameter $value */ |
| 34 | + string $value |
| 35 | + ) { $this->property = $value; } |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +foreach([ |
| 40 | + 'A::method' => (new ReflectionClass('A'))->getMethod('method'), |
| 41 | + 'property hook' => (new ReflectionClass('A'))->getProperty('property')->getHook(PropertyHookType::Set), |
| 42 | + ] as $function => $rc) { |
| 43 | + $rps = $rc->getParameters(); |
| 44 | + foreach($rps as $rp) { |
| 45 | + echo "\n---> Doc comment for $function parameter $" . $rp->getName() . ":\n"; |
| 46 | + var_dump($rp->getDocComment()); |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +?> |
| 51 | +--EXPECTF-- |
| 52 | +---> Doc comment for A::method parameter $a: |
| 53 | +string(%d) "/** |
| 54 | + * My Doc Comment for $a |
| 55 | + * |
| 56 | + */" |
| 57 | + |
| 58 | +---> Doc comment for A::method parameter $b: |
| 59 | +bool(false) |
| 60 | + |
| 61 | +---> Doc comment for A::method parameter $c: |
| 62 | +bool(false) |
| 63 | + |
| 64 | +---> Doc comment for A::method parameter $d: |
| 65 | +string(%d) "/** |
| 66 | + * My Doc Comment for $d |
| 67 | + */" |
| 68 | + |
| 69 | +---> Doc comment for A::method parameter $e: |
| 70 | +bool(false) |
| 71 | + |
| 72 | +---> Doc comment for A::method parameter $f: |
| 73 | +string(%d) "/** |
| 74 | + * Doc comment for $f |
| 75 | + */" |
| 76 | + |
| 77 | +---> Doc comment for A::method parameter $g: |
| 78 | +string(%d) "/** Doc comment for $g after parameter */" |
| 79 | + |
| 80 | +---> Doc comment for A::method parameter $h: |
| 81 | +string(%d) "/** Doc comment for $h after parameter */" |
| 82 | + |
| 83 | +---> Doc comment for property hook parameter $value: |
| 84 | +string(%d) "/** Doc Comment for property hook parameter $value */" |
0 commit comments