type-lang/phpdoc-standard-tags

Adds support for standard PHPDoc tags

dev-master / 1.0.x-dev 2024-04-17 19:20 UTC

This package is auto-updated.

Last update: 2024-05-17 19:33:37 UTC


README

dark.png?raw=true

PHP 8.1+ Latest Stable Version Latest Unstable Version License MIT

badge.svg

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);