Get comments in a php file
You can use token_get_all()
, which "parses a given PHP source string into language tokens using the Zend engine's lexical scanner".
See: http://php.net/token_get_all
Here's an example function I've used once to get the file-doc-comment from the current file:
/**
* Return first doc comment found in this file.
*
* @return string
*/
function getFileDocBlock()
{
$docComments = array_filter(
token_get_all( file_get_contents( __FILE__ ) ), function($entry) {
return $entry[0] == T_DOC_COMMENT;
}
);
$fileDocComment = array_shift( $docComments );
return $fileDocComment[1];
}
Try using http://ca3.php.net/manual/en/class.reflectionclass.php
and http://ca3.php.net/manual/en/class.reflectionfunction.php
This all You need to get function parameters.