Skip to content

php-type-language/phpdoc-standard-tags

Repository files navigation


PHP 8.1+ Latest Stable Version Latest Unstable Version License MIT

Adds support of the PHPDoc standard DocBlock tags.

Read documentation pages for more information.

Installation

TypeLang PHPDoc Standard Tags is available as Composer repository and can be installed using the following command in a root of your project:

$ composer require type-lang/phpdoc-standard-tags

Introduction

Adds support for basic annotations containing descriptions of types that affect their output in static analyzers.

  • @methodTypeLang\PHPDoc\Standard\MethodTagFactory
  • @paramTypeLang\PHPDoc\Standard\ParamTagFactory
  • @propertyTypeLang\PHPDoc\Standard\PropertyTagFactory
  • @property-readTypeLang\PHPDoc\Standard\PropertyReadTagFactory
  • @property-writeTypeLang\PHPDoc\Standard\PropertyWriteTagFactory
  • @returnTypeLang\PHPDoc\Standard\ReturnTagFactory
  • @throwsTypeLang\PHPDoc\Standard\ThrowsTagFactory
  • @varTypeLang\PHPDoc\Standard\VarTagFactory

Usage

use TypeLang\PHPDoc\Parser;
use TypeLang\PHPDoc\Standard;
use TypeLang\PHPDoc\Tag\Factory\TagFactory;

$tags = new TagFactory();

// Add support of standard tags
$tags->register('method', new Standard\MethodTagFactory());
$tags->register('param', new Standard\ParamTagFactory());
$tags->register('property', new Standard\PropertyTagFactory());
$tags->register('property-read', new Standard\PropertyReadTagFactory());
$tags->register('property-write', new Standard\PropertyWriteTagFactory());
$tags->register('return', new Standard\ReturnTagFactory());
$tags->register('throws', new Standard\ThrowsTagFactory());
$tags->register('var', new Standard\VarTagFactory());

$docblock = (new Parser($tags))
    ->parse(<<<'PHPDOC'
        /**
         * @var string example tag.
         */
        PHPDOC);

var_dump($docblock);

About

PHPDoc parser extension library that provides basic tags describing types

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages