1. Go to this page and download the library: Download rawr/phpdoc-parser library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rawr / phpdoc-parser example snippets
/**
* The description of foo. This function does a lot of thing
* which are described here.
*
* Some more text here.
*
* @important
* @uses FooReader
* @internal Why this isn't part of the API.
* Multi-line is supported.
*
* @param string|callable $first This is the first param
* @param int $second The second one
* @return void
* @throws InvalidArgumentException
* @throws DoaminException if first argument is not found
*/
function foo($first, int $second)
{
// ...
}
use Jasny\PHPDocParser\PHPDocParser;
use Jasny\PhpdocParser\PhpDocumentor;
use Jasny\PHPDocParser\Tag\FlagTag;
$doc = (new ReflectionFunction('foo'))->getDocComment();
$customTags = [
new FlagTag('important')
];
$tags = PhpDocumentor::tags()->with($customTags);
$parser = new PHPDocParser($tags);
$meta = $parser->parse($doc);
[
'summery' => "The description of foo.",
'description' => "This function does a lot of thing which are described here.\n\nSome more text.",
'important' => true,
'uses' => 'FooReader',
'internal' => "Why this isn't part of the API. Mutlti-line is supported",
'params' => [
'first' => [
'type' => "string|callable",
'name' => "first",
'description' => "This is the first parm"
],
'second' => [
'type' => "int",
'name' => "second",
]
],
'return' => 'void'
]
//$doc = ...; Get doc-comment string from reflection
$tags = PhpDocumentor::tags();
$parser = new PhpdocParser($tags);
$meta = $parser->parse($doc);