xref: /PHP-8.3/ext/reflection/tests/005.phpt (revision f8d79582)
1--TEST--
2ReflectionMethod::getDocComment() uses wrong comment block
3--INI--
4opcache.save_comments=1
5--FILE--
6<?php
7
8function strip_doc_comment($c)
9{
10    if (!strlen($c) || $c === false) return $c;
11    return trim(substr($c, 3, -2));
12}
13
14/** Comment for class A */
15class A
16{
17    /** Method A::bla()
18     */
19    function bla()
20    {
21    }
22
23    function foo() {
24        /**
25        * This is a valid comment inside a method
26        */
27    }
28
29    function bar() {
30        // I don't have a doc comment....
31    }
32
33    /**
34     * Comment for A::baz()
35     */
36    function baz() {
37    }
38}
39
40$r = new ReflectionClass('A');
41var_dump(strip_doc_comment($r->getDocComment()));
42
43foreach($r->getMethods() as $m)
44{
45    var_dump(strip_doc_comment($m->getDocComment()));
46}
47
48?>
49--EXPECT--
50string(19) "Comment for class A"
51string(15) "Method A::bla()"
52bool(false)
53bool(false)
54string(22) "* Comment for A::baz()"
55