PHPackages                             nekoos/phpdoc-parser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. nekoos/phpdoc-parser

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

nekoos/phpdoc-parser
====================

Jasny skeleton library

07PHP

Since Jun 25Pushed 5y agoCompare

[ Source](https://github.com/NekoOs/phpdoc-meta)[ Packagist](https://packagist.org/packages/nekoos/phpdoc-parser)[ RSS](/packages/nekoos-phpdoc-parser/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (3)Used By (0)

Jasny PHPDoc parser
===================

[](#jasny-phpdoc-parser)

[![Build Status](https://camo.githubusercontent.com/1dd58c9b0a039ad3c9a83dec9ff1a865f7f37fc688fcf8e53c2fd5bc683abd60/68747470733a2f2f7472617669732d63692e6f72672f6a61736e792f616e6e6f746174696f6e732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/jasny/annotations)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/1512bce40bee7b30eb884a266078011d772ee10f6033d61f91bfee031da01e1f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a61736e792f616e6e6f746174696f6e732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jasny/annotations/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/a58a409b80e53c9e92ebd836b63e37f7f2bb1e7468ca61b6d2d2da0fe5d82373/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a61736e792f616e6e6f746174696f6e732f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jasny/annotations/?branch=master)[![Packagist Stable Version](https://camo.githubusercontent.com/0e6cf6bc97fae4a531621f7a400fcd7a4ffa1bcc0f18c5b38f485e50946bb0b9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a61736e792f616e6e6f746174696f6e732e737667)](https://packagist.org/packages/jasny/annotations)[![Packagist License](https://camo.githubusercontent.com/de9631a940618f5d68c333f7d7f617f50bc2b4a3ec673b90192d84b7fb2c2d9f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a61736e792f616e6e6f746174696f6e732e737667)](https://packagist.org/packages/jasny/annotations)

Configurable DocBlock parser from PHP.

Annotations aren't implemented in PHP itself which is why this component offers a way to use the PHP doc-blocks as a place for the well known tag syntax using the `@` char.

The PHPDoc parser allows you to configure tags including the method how to parse and extract information. This is inline with phpDocumentor style annotations and differs from for instance Doctrine type annotations.

Installation
------------

[](#installation)

```
composer require jasny/phpdoc-parser

```

Usage
-----

[](#usage)

```
/**
 * The description of foo. This function does a lot of thing
 *   which are described here.
 *
 * Some more text here.
 *
 * @important
 * @uses FooReader
 * @internal Why this isn't part of the API.
 *   Multi-line is supported.
 *
 * @param string|callable $first   This is the first param
 * @param int             $second  The second one
 * @return void
 * @throws InvalidArgumentException
 * @throws DoaminException if first argument is not found
 */
function foo($first, int $second)
{
   // ...
}
```

Parse annotations

```
use Jasny\PHPDocParser\PHPDocParser;
use Jasny\PHPDocParser\Set\PhpDocumentor;
use Jasny\PHPDocParser\Tag\FlagTag;

$doc = (new ReflectionFunction('foo'))->getDocComment();

$customTags = [
    new FlagTag('important')
];
$tags = PhpDocumentor::tags()->with($customTags);

$parser = new PHPDocParser($tags);
$annotations = $parser->parse($doc);
```

The result will be the following:

```
[
    'summery' => "The description of foo",
    'description' => "The description of foo. This function does a lot of thing which are described here.\n\nSome more text.",
    'important' => true,
    'uses' => 'FooReader',
    'internal' => "Why this isn't part of the API. Mutlti-line is supported",
    'params' => [
        'first' => [
            'type' => "string|callable",
            'name' => "first",
            'description' => "This is the first parm"
        ],
        'second' => [
            'type' => "int",
            'name' => "second",
        ]
    ],
    'return' => 'void'
]
```

Tags
----

[](#tags)

The following tags are already included in `PhpDocumentor::tags()`:

- `@api`
- `@author`
- `@copyright`
- `@deprecated`
- `@example`
- `@ignore`
- `@internal`
- `@link`
- `@method` (all methods will be grouped in `methods` array)
- `@package`
- `@param` (all params will be grouped in `params` array)
- `@property` (all properties will be grouped in `properties` array)
- `@property-read` (also in `properties` array)
- `@property-write` (also in `properties` array)
- `@return`
- `@see`
- `@since`
- `@throws` (all exceptions will be grouped in `throws` array)
- `@todo`
- `@uses`
- `@used-by`
- `@var`

So if you only need to parse those tags, you can simply do:

```
//$doc = ...; Get doc-comment string from reflection

$tags = PhpDocumentor::tags();
$parser = new PhpdocParser($tags);
$annotations = $parser->parse($doc);
```

Tags classes
------------

[](#tags-classes)

Here's a list of available tags classes, that should cover most of the use cases:

- [Summery](docs/tags/summery.md)
- [ArrayTag](docs/tags/array.md)
- [CustomTag](docs/tags/custom.md)
- [DescriptionTag](docs/tags/description.md)
- [ExampleTag](docs/tags/example.md)
- [FlagTag](docs/tags/flag.md)
- [MapTag](docs/tags/map.md)
- [MethodTag](docs/tags/method.md)
- [ModifyTag](docs/tags/modify.md)
- [MultiTag](docs/tags/multi.md)
- [NumberTag](docs/tags/number.md)
- [RegExpTag](docs/tags/regexp.md)
- [VarTag](docs/tags/var.md)
- [WordTag](docs/tags/word.md)

The following function is used in tags documentation, for short reference to parsing:

```
function getNotations(string $doc, array $tags = []) {
    $tags = PhpDocumentor::tags()->add($tags);

    $parser = new PhpdocParser($tags);
    $notations = $parser->parse($doc);

    return $notations;
}
```

FQSEN Convertor
---------------

[](#fqsen-convertor)

FQSEN stands for `Fully Qualified Structural Element Name`. FQSEN convertor is used to expand class name, function name to fully unique name (so with full namespace). For example, `Foo` can be converted to `Zoo\\Foo\\Bar`.

Such convertors are used in this lib. Some tags, that deal with variable types, or classes names, support adding them as a constructor parameter.

For example, `TypeTag`, that can be used for parsing `@return` tag, has the following constructor: `TypeTag($name, $fqsenConvertor = null)`. If provided, convertor expands the type, given as type of returned value in doc-comment. If ommited, the type will stay as it is in doc-comment.

Convertor can be provided in one of two ways:

- `$tags = PhpDocumentor::tags($fqsenConvertor)` - for all the tags, predefined in `PhpDocumentor::tags()`
- `$tags = $tags->add(new TypeTag('footag', $fqsenConvertor))` - for all the tags, that are explicitly added to predefined, it should be passed as a constructor parameter (if it is supported by constructor).

Convertor should be a callable, that accepts a class name, and returns expanded name.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 52.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/14964692?v=4)[Neder Alfonso Fandiño Andrade](/maintainers/NekoOs)[@NekoOs](https://github.com/NekoOs)

---

Top Contributors

[![Minstel](https://avatars.githubusercontent.com/u/6154708?v=4)](https://github.com/Minstel "Minstel (50 commits)")[![jasny](https://avatars.githubusercontent.com/u/100821?v=4)](https://github.com/jasny "jasny (41 commits)")[![NekoOs](https://avatars.githubusercontent.com/u/14964692?v=4)](https://github.com/NekoOs "NekoOs (4 commits)")

### Embed Badge

![Health badge](/badges/nekoos-phpdoc-parser/health.svg)

```
[![Health](https://phpackages.com/badges/nekoos-phpdoc-parser/health.svg)](https://phpackages.com/packages/nekoos-phpdoc-parser)
```

###  Alternatives

[genealabs/laravel-null-carbon

A Laravel Carbon null-class.

56322.7k](/packages/genealabs-laravel-null-carbon)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
