note 115286 added to reflectionclass.getdoccomment
| From: | sun | Date: | Sat, 28 Jun 2014 14:11:05 +0000 |
| Subject: | note 115286 added to reflectionclass.getdoccomment | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-199777@lists.php.net to get a copy of this message | ||
Note that \ReflectionClass::getDocComment() ignores all other PHP code and all white-space between
the last encountered T_DOC_COMMENT and the class/element definition.
The only exceptions appear to be T_NAMESPACE declarations and T_FUNCTION definitions.
<?php
/**
* Before namespace.
*/
namespace Foo;
/**
* After namespace.
*/
// ^^ contains excessive leading + trailing white-space.
use Bar\Baz;
const FOO = 'BAR';
$ns = 'bar';
# function foo() {}
$a = 2 + 1;
#/** what? */
// ^^ A single-line T_DOC_COMMENT is invisible when commented out.
count(array());
class Foo {
}
$reflector = new \ReflectionClass('Foo\Foo');
var_dump($reflector->getDocComment());
?>
yields, despite all the garbage in between:
string(28) "/**
* After namespace.
*/"
To sum up:
1. If there are multiple doc comments, the last encountered applies.
2. Removing the "After namespace." docblock yields FALSE.
(The namespace delimits the scope.)
3. Uncommenting the function definition yields FALSE.
(The doc comment applies to the function instead.)
4. Despite being an own language construct, the "const" constant declaration does not
delimit the scope.
5. Any leading and trailing white-space before and after the T_DOC_COMMENT ("/**...*/") is
ignored, but the entire string content within (including all white-space) is consumed
literally/verbatim.
[PHP 5.4.29]
----
Server IP: 87.106.1.137
Probable Submitter: 91.19.28.210
----
Manual Page -- http://php.net/manual/en/reflectionclass.getdoccomment.php
Edit -- https://master.php.net/note/edit/115286
Del: integrated -- https://master.php.net/note/delete/115286/integrated
Del: useless -- https://master.php.net/note/delete/115286/useless
Del: bad code -- https://master.php.net/note/delete/115286/bad+code
Del: spam -- https://master.php.net/note/delete/115286/spam
Del: non-english -- https://master.php.net/note/delete/115286/non-english
Del: in docs -- https://master.php.net/note/delete/115286/in+docs
Del: other reasons-- https://master.php.net/note/delete/115286
Reject -- https://master.php.net/note/reject/115286
Search -- https://master.php.net/manage/user-notes.php