xref: /php-src/ext/reflection/tests/bug71767.phpt (revision 064b4644)
1--TEST--
2Bug #71767 (ReflectionMethod::getDocComment returns the wrong comment)
3--FILE--
4<?php
5
6/** Correct docblock */
7function foo(
8    /** wrong docblock */
9    $arg
10) {
11}
12
13class Foo {
14    /** Correct docblock */
15    public function bar(
16        /** wrong docblock */
17        $arg
18    ) {
19
20    }
21}
22
23/** Correct docblock */
24$func = function(
25    /** wrong docblock */
26    $arg
27) {
28};
29
30/** Correct docblock */
31$func2 = fn(
32    /** wrong docblock */
33    $arg
34) => null;
35
36$reflectionFunction = new ReflectionFunction('foo');
37$reflectionClass = new ReflectionClass(Foo::class);
38$reflectionClosure = new ReflectionFunction($func);
39$reflectionArrowFn = new ReflectionFunction($func2);
40
41echo $reflectionFunction->getDocComment() . PHP_EOL;
42echo $reflectionClass->getMethod('bar')->getDocComment() . PHP_EOL;
43echo $reflectionClosure->getDocComment() . PHP_EOL;
44echo $reflectionArrowFn->getDocComment() . PHP_EOL;
45
46echo "Done\n";
47?>
48--EXPECT--
49/** Correct docblock */
50/** Correct docblock */
51/** Correct docblock */
52/** Correct docblock */
53Done
54