loot / phpdoc-reader
Package can parse phpdoc comments
Installs: 26
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/loot/phpdoc-reader
README
usage
$class = \App\Models\User::class; $method = 'getChild'; $comment = (new \ReflectionMethod($class, $method))->getDocComment(); $res = new Loot\PhpDocReader\PhpDocReader($comment); var_dump($res->getAnnotationsByName('@param'));
or just
$comment = ' /** * @param int $var Description */'; $res = new Loot\PhpDocReader\PhpDocReader($comment); var_dump($res->getAnnotation('@param')->getDescription());
Classes
Class PhpDocReader
Method getAnnotation
Получить первую аннотацию по названию.
$res = new Loot\PhpDocReader\PhpDocReader(' /** * @return int */'); var_dump($res->getAnnotation('@return')->getType());
Method getAnnotationsByName
Получить все аннотации по названию.
$res = new Loot\PhpDocReader\PhpDocReader(' /** * @param int $int * @param string $string */'); var_dump($res->getAnnotationsByName('@param'));
Method getAnnotations
Получить первую аннотацию.
$res = new Loot\PhpDocReader\PhpDocReader(' /** * @param int $int * @param string $string */'); var_dump($res->getAnnotations());
Class PhpDocLine
Method getName()
Возвращает название аннотации.
Method getType()
Возвращает тип аннотации.
Method getDescription()
Возвращает описание аннотации.
Method getVariable()
Возвращает переменную в аннотации.