PHPackages                             rawr/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. rawr/phpdoc-parser

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

rawr/phpdoc-parser
==================

Jasny skeleton library

1.0.2(3y ago)017MITPHPPHP ~8.0.0 | &gt;=7.1.0

Since Nov 16Pushed 3y agoCompare

[ Source](https://github.com/t-regx/phpdoc-parser)[ Packagist](https://packagist.org/packages/rawr/phpdoc-parser)[ RSS](/packages/rawr-phpdoc-parser/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (2)Versions (4)Used By (0)

[![](t.regx.png)](https://t-regx.com/)

PhpDoc parser
=============

[](#phpdoc-parser)

Lightweight parser of PhpDoc.

[![Build Status](https://github.com/T-Regx/phpdoc-parser/workflows/build/badge.svg?branch=master)](https://github.com/T-Regx/phpdoc-parser/actions/)[![Coverage Status](https://camo.githubusercontent.com/735f2d87c033b10ba87d44dcb361f3448011a6b3ececf334943b9d3d9591a206/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f542d526567782f706870646f632d7061727365722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/T-Regx/phpdoc-parser?branch=master)[![Repository Size](https://camo.githubusercontent.com/ca443ee77bc8fa593fcbb9bf52137617c40c39b0247e23b8ec7c6e6e70b4f188/68747470733a2f2f6769746875622d73697a652d62616467652e6865726f6b756170702e636f6d2f542d526567782f706870646f632d7061727365722e737667)](https://github.com/T-Regx/phpdoc-parser)[![License](https://camo.githubusercontent.com/cf29006157fc6f085dc2a64d87b7ce51286cbd0eb2e5d3c4e9faa029ce95e48f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f542d526567782f706870646f632d7061727365722e737667)](https://github.com/T-Regx/phpdoc-parser/blob/master/LICENSE)[![Composer lock](https://camo.githubusercontent.com/0bd6507f0299009d2952dd4e127b86982adf10e3660294d160686b896b279974/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2e6c6f636b2d756e636f6d6d697465642d677265656e2e737667)](https://github.com/T-Regx/phpdoc-parser)

[![PHP Version](https://camo.githubusercontent.com/d29ceb6206232af72a55b5ed3e6fab0a1f2d6cb6c728a088c9c18c4b035a0765/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372e312d626c75652e737667)](https://github.com/T-Regx/phpdoc-parser/runs/2375602376)[![PHP Version](https://camo.githubusercontent.com/5180a354acf28fb748fbeddd95219b60e0145d1e0eac9f976ca9a1bc9bc0337b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372e322d626c75652e737667)](https://github.com/T-Regx/phpdoc-parser/runs/2375602376)[![PHP Version](https://camo.githubusercontent.com/de6ad351fa59d9e301ffc48de85e4ca23954b4ba5746f324991a43aab522f893/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372e332d626c75652e737667)](https://github.com/T-Regx/phpdoc-parser/runs/2375602376)[![PHP Version](https://camo.githubusercontent.com/8a0234efb25bffbee74e0444a52c7796dee73c2785c9908a8c05ecf6eb0f5ff3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372e342d626c75652e737667)](https://github.com/T-Regx/phpdoc-parser/runs/2375602376)[![PHP Version](https://camo.githubusercontent.com/82887c22962d0022d20f61e17b76e949b7c813ca52cd0b00e794487a1a951169/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e302d626c75652e737667)](https://github.com/T-Regx/phpdoc-parser/runs/2375602376)[![PHP Version](https://camo.githubusercontent.com/55119e0553f52e25200843d20c0b7f94802872deee3c7737d4dcd41a851167c6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312d626c75652e737667)](https://github.com/T-Regx/phpdoc-parser/runs/2375602376)

[![PRs Welcome](https://camo.githubusercontent.com/f521b8a3c3a0d013c2d37bfdc56de0a513e491926e02c6166a9dd36097d62145/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f50522d77656c636f6d652d627269676874677265656e2e7376673f7374796c653d706f706f7574)](http://makeapullrequest.com)

1. [Installation](#installation)
    - [Composer](#installation)
2. [Usage](#usage)
3. [Tags](#tags)
4. [Tag classes](#tag-classes)
5. [FQSEN Resolve](#fqsen-resolver)
6. [Current limitations](#current-limitations)
7. [Fixed from the original](#fixed-from-the-original)

Installation
============

[](#installation)

Installation for PHP 7.1 and later:

```
composer require rawr/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\PhpDocumentor;
use Jasny\PHPDocParser\Tag\FlagTag;

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

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

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

The result is the following:

```
[
    'summery' => "The description of foo.",
    'description' => "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);
$meta = $parser->parse($doc);
```

Tag classes
-----------

[](#tag-classes)

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

- `Summery`
- `ArrayTag`
- `CustomTag`
- `DescriptionTag`
- `ExampleTag`
- `FlagTag`
- `MapTag`
- `MethodTag`
- `ModifyTag`
- `MultiTag`
- `NumberTag`
- `RegExpTag`
- `VarTag`
- `WordTag`

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 Resolver
--------------

[](#fqsen-resolver)

FQSEN stands for `Fully Qualified Structural Element Name`. FQSEN convertor is used to expand class name or 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($fn)` - for all the tags, predefined in `PhpDocumentor::tags()`
- `$tags = $tags->add(new TypeTag('footag', $fn))` - for all the tags, that are explicitly added to predefined, it should be passed as a constructor parameter ( if it is supported by constructor).

After that create the parser from the tags as `$parser = new PhpdocParser($tags)`.

The resolver function should accept a class name and return an expanded name.

### Example

[](#example)

This example uses [phpDocumentor/TypeResolver](https://github.com/phpDocumentor/TypeResolver).

```
$reflection = new ReflectionClass('\My\Example\Classy');

$contextFactory = new \phpDocumentor\Reflection\Types\ContextFactory();
$context = $contextFactory->createFromReflector($reflection);

$resolver = new \phpDocumentor\Reflection\FqsenResolver();
$fn = fn(string $class): string => $resolver->resolve($class, $context);

$tags = PhpDocumentor::tags($fn);
$parser = new PhpdocParser($tags);

$doc = $reflection->getDocComment();
$meta = $parser->parse($doc);
```

Current limitations
-------------------

[](#current-limitations)

- Certain tags aren't yet supported, such as `@license` or `@category`.
- Annotations aren't supported, for example ```
    /**
     * @ORM\Entity(repositoryClass="MyProject\UserRepository")
     */
    ```
- As far as I'm aware this project does not support parsing inline tags yet
- Tag `@see` is only parsed once, instead of all occurrences
- Tag `@since` ignores description
- Tag `@version` ignores description
- Tag `@var` doesn't allow for ignoring variable name
- Tag `@link` ignores description
- Tag `@deprecated` ignores description
- `CustomTag` is not extensible enough, perhaps a new implementation is needed

Fixed from the original
-----------------------

[](#fixed-from-the-original)

The original implementation is in .

Features fixed and improved so far:

- Tags `@param` failed to handle multiline tags properly, now it's fixed
- Typo `"summery"` to `"summary"`
- Improper parsing summary in multiple lines
- Added support for `@version` tag
- `@method` interprets `static` properly
- Fixed improper parsing of unclosed or improperly closed doc block
- Previous parser failed parsing for line endings `CR` and `CRLF`, now it supports: `LF`, `CR`, `CRLF`.

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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.

###  Release Activity

Cadence

Every ~22 days

Total

3

Last Release

1280d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0f388dbecf863b7cf5131dbac972514dab843f609977315694b9f25e0e63332d?d=identicon)[danon](/maintainers/danon)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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