type-lang / phpdoc-template-tags
Adds support for template PHPDoc tags
1.0.0
2024-06-29 18:02 UTC
Requires
- php: ^8.1
- type-lang/parser: ^1.0
- type-lang/phpdoc: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.53
- phpstan/extension-installer: ^1.3
- phpstan/phpstan: ^1.11
- phpstan/phpstan-strict-rules: ^1.6
- phpunit/phpunit: ^10.5|^11.0
- rector/rector: ^1.0
This package is auto-updated.
Last update: 2024-09-02 07:52:04 UTC
README
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-template-tags
Introduction
Adds support for advanced template annotations.
-
@template
—TypeLang\PHPDoc\Template\TemplateTagFactory
-
@template-covariant
—TypeLang\PHPDoc\Template\TemplateCovariantTagFactory
-
@template-contravariant
—TypeLang\PHPDoc\Template\TemplateContravariantTagFactory
-
@template-extends
(or@extends
) —TypeLang\PHPDoc\Template\TemplateExtendsTagFactory
-
@template-implements
(or@implements
) —TypeLang\PHPDoc\Template\TemplateImplementsTagFactory
-
@template-use
(or@use
) —TypeLang\PHPDoc\Template\TemplateUseTagFactory
Usage
use TypeLang\PHPDoc\Parser; use TypeLang\PHPDoc\Template; use TypeLang\PHPDoc\Tag\Factory\TagFactory; $tags = new TagFactory(); // Add support of template tags $tags->register('template', new Template\TemplateTagFactory()); $tags->register('template-covariant', new Template\TemplateCovariantTagFactory()); $tags->register('template-contravariant', new Template\TemplateContravariantTagFactory()); $tags->register(['extends', 'template-extends'], new Template\TemplateExtendsTagFactory()); $tags->register(['implements', 'template-implements'], new Template\TemplateImplementsTagFactory()); $tags->register(['use', 'template-use'], new Template\TemplateUseTagFactory()); $docblock = (new Parser($tags)) ->parse(<<<'PHPDOC' /** * @template T of object * @template-extends \Traversable<array-key, T> */ PHPDOC); var_dump($docblock);