1. Go to this page and download the library: Download type-lang/phpdoc 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/ */
type-lang / phpdoc example snippets
$parser = new \TypeLang\PHPDoc\Parser();
$result = $parser->parse(<<<'PHPDOC'
/**
* Example description {@see some} and blah-blah-blah.
*
* @Example\Annotation("foo")
* @return array<non-empty-string, TypeStatement>
* @throws \Throwable
*/
PHPDOC);
var_dump($result);
/** |
* Hello world | ← DocBlock's description.
* |
* @param int $example | ← DocBlock's tag #1.
* @throws \Throwable Description | ← DocBlock's tag #2.
*/ |
/** @template-implements \Traversable<array-key, Tag> */
class DocBlock implements \Traversable
{
public function getDescription(): Description;
/** @return list<Tag> */
public function getTags(): array;
}
/**
↓↓↓↓↓↓↓↓↓↓↓ | ← This is a nested tag of the description.
* Hello world {@see some} and blah-blah-blah. |
↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ | ← This is part of the template.
*/
/** @template-implements \Traversable<array-key, Tag> */
class Description implements \Traversable, \Stringable
{
public function getTemplate(): string;
/** @return list<Tag> */
public function getTags(): array;
}
/**
↓↓↓↓↓↓ | ← This is a tag name.
* @throws \Throwable An error occurred. |
↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ | ← This is tag description.
*/
class Tag implements \Stringable
{
public function getName(): string;
public function getDescription(): ?Description;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.