xref: /PHP-7.0/ext/reflection/tests/005.phpt (revision ae88a243)
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===DONE===
50--EXPECT--
51string(19) "Comment for class A"
52string(15) "Method A::bla()"
53bool(false)
54bool(false)
55string(22) "* Comment for A::baz()"
56===DONE===
57