The ReflectionMethod class reports information about a method.
Method name
Class name
Indicates that the method is static.
Indicates that the method is public.
Indicates that the method is protected.
Indicates that the method is private.
Indicates that the method is abstract.
Indicates that the method is final.
I have written a function which returns the value of a given DocComment tag.
Full example:
<?php
header('Content-Type: text/plain');
class Example
{
/**
* This is my DocComment!
*
* @DocTag: prints Hello World!
*/
public function myMethod()
{
echo 'Hello World!';
}
}
function getDocComment($str, $tag = '')
{
if (empty($tag))
{
return $str;
}
$matches = array();
preg_match("/".$tag.":(.*)(\\r\\n|\\r|\\n)/U", $str, $matches);
if (isset($matches[1]))
{
return trim($matches[1]);
}
return '';
}
$method = new ReflectionMethod('Example', 'myMethod');
// will return Hello World!
echo getDocComment($method->getDocComment(), '@DocTag');
?>
Maybe you can add this functionality to the getDocComment methods of the reflection classes.