PHPackages                             zero-to-prod/docblock-annotator - 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. zero-to-prod/docblock-annotator

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

zero-to-prod/docblock-annotator
===============================

An annotator for PHP docblocks.

v4.1.1(1y ago)1533[1 PRs](https://github.com/zero-to-prod/docblock-annotator/pulls)1MITPHPPHP &gt;=8.1CI passing

Since Feb 16Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/zero-to-prod/docblock-annotator)[ Packagist](https://packagist.org/packages/zero-to-prod/docblock-annotator)[ Docs](https://github.com/zero-to-prod/docblock-annotator)[ Fund](https://github.com/sponsors/zero-to-prod)[ RSS](/packages/zero-to-prod-docblock-annotator/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (6)Versions (13)Used By (1)

Zerotoprod\\DocblockAnnotator
=============================

[](#zerotoproddocblockannotator)

[![](art/logo.png)](art/logo.png)

[![Repo](https://camo.githubusercontent.com/9a90a3efeee26aed7d7f2feee9cd84566a26f9c362cc773b184d076210906e1c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6769746875622d677261793f6c6f676f3d676974687562)](https://github.com/zero-to-prod/docblock-annotator)[![GitHub Actions Workflow Status](https://camo.githubusercontent.com/86f3bb44a5f7853bc2f581e31042d695ed617aaed93cf81493029bf85e5817e6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7a65726f2d746f2d70726f642f646f63626c6f636b2d616e6e6f7461746f722f746573742e796d6c3f6c6162656c3d74657374)](https://github.com/zero-to-prod/docblock-annotator/actions)[![GitHub Actions Workflow Status](https://camo.githubusercontent.com/b599759381dbe04d1e617bdfb4de7486641b0e676178a0eb8b133efa6c32e9cf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7a65726f2d746f2d70726f642f646f63626c6f636b2d616e6e6f7461746f722f6261636b77617264735f636f6d7061746962696c6974792e796d6c3f6c6162656c3d6261636b77617264735f636f6d7061746962696c697479)](https://github.com/zero-to-prod/docblock-annotator/actions)[![Packagist Downloads](https://camo.githubusercontent.com/06f12003711e8e73609cde8dd8caafa985ffa947e2005466f593a76041ef9f5e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a65726f2d746f2d70726f642f646f63626c6f636b2d616e6e6f7461746f723f636f6c6f723d626c7565)](https://packagist.org/packages/zero-to-prod/docblock-annotator/stats)[![php](https://camo.githubusercontent.com/ec8e174c73b830bd7cf60fd756aa24ce515f800a03901cc54b4e01b8b54c1211/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7a65726f2d746f2d70726f642f646f63626c6f636b2d616e6e6f7461746f722e7376673f636f6c6f723d707572706c65)](https://packagist.org/packages/zero-to-prod/docblock-annotator/stats)[![Packagist Version](https://camo.githubusercontent.com/74403b88e45f3d24830a9996533d22906778163f0cc840cde42003a824afabc2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a65726f2d746f2d70726f642f646f63626c6f636b2d616e6e6f7461746f723f636f6c6f723d663238643161)](https://packagist.org/packages/zero-to-prod/docblock-annotator)[![License](https://camo.githubusercontent.com/d22c902d874988f357cb678bdbb2f3307764b6a429a67f54d4b2b900f41d16c4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7a65726f2d746f2d70726f642f646f63626c6f636b2d616e6e6f7461746f723f636f6c6f723d70696e6b)](https://github.com/zero-to-prod/docblock-annotator/blob/main/LICENSE.md)[![wakatime](https://camo.githubusercontent.com/9afb577c7854f43b98965471e9e58559703655ca93051c73104613d3c60b4f0b/68747470733a2f2f77616b6174696d652e636f6d2f62616467652f6769746875622f7a65726f2d746f2d70726f642f646f63626c6f636b2d616e6e6f7461746f722e737667)](https://wakatime.com/badge/github/zero-to-prod/docblock-annotator)[![Hits-of-Code](https://camo.githubusercontent.com/b9d40595b310e0608600137a3c08d15fe38dd20aad20f516c63afb0a543b3c3a/68747470733a2f2f686974736f66636f64652e636f6d2f6769746875622f7a65726f2d746f2d70726f642f646f63626c6f636b2d616e6e6f7461746f723f6272616e63683d6d61696e)](https://hitsofcode.com/github/zero-to-prod/docblock-annotator/view?branch=main)

Contents
--------

[](#contents)

- [Introduction](#introduction)
- [Requirements](#requirements)
- [Installation](#installation)
- [Documentation Publishing](#documentation-publishing)
    - [Automatic Documentation Publishing](#automatic-documentation-publishing)
- [Usage](#usage)
    - [Instantiation](#Instantiation)
    - [updateDirectory](#updatedirectory)
    - [updateFiles](#updatefiles)
- [Local Development](./LOCAL_DEVELOPMENT.md)
- [Contributing](#contributing)

Introduction
------------

[](#introduction)

An annotator for PHP docblocks.

Requirements
------------

[](#requirements)

- PHP 7.4 or higher.

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

[](#installation)

Install `Zerotoprod\DocblockAnnotator` via [Composer](https://getcomposer.org/):

```
composer require zero-to-prod/docblock-annotator
```

This will add the package to your project's dependencies and create an autoloader entry for it.

Documentation Publishing
------------------------

[](#documentation-publishing)

You can publish this README to your local documentation directory.

This can be useful for providing documentation for AI agents.

This can be done using the included script:

```
# Publish to default location (./docs/zero-to-prod/docblock-annotator)
vendor/bin/zero-to-prod-docblock-annotator

# Publish to custom directory
vendor/bin/zero-to-prod-docblock-annotator /path/to/your/docs
```

### Automatic Documentation Publishing

[](#automatic-documentation-publishing)

You can automatically publish documentation by adding the following to your `composer.json`:

```
{
    "scripts": {
        "post-install-cmd": [
            "zero-to-prod-docblock-annotator"
        ],
        "post-update-cmd": [
            "zero-to-prod-docblock-annotator"
        ]
    }
}
```

Usage
-----

[](#usage)

### Instantiation

[](#instantiation)

Create a new `DocblockAnnotator` instance with your desired configuration:

```
use Zerotoprod\DocblockAnnotator\DocblockAnnotator;
use Zerotoprod\DocblockAnnotator\Statement;
use Zerotoprod\DocblockAnnotator\Modifier;
use PhpParser\ParserFactory;

$DocblockAnnotator = new DocblockAnnotator(
    modifiers: [Modifier::public],
    statements: [Statement::ClassMethod], // can also handle raw string: class_method
    success: fn(string $file, string $value) => echo "Updated: $file",
    failure: fn(Throwable $e) => echo $e->getMessage(),
    (new ParserFactory)->createForHostVersion()
);
```

Arguments:

- `modifiers`: Array of visibility modifiers to target
    - `public`
    - `protected`
    - `private`
- `statements`: Array of statement types to process
    - `class_method`
    - `const`
    - `class`
    - `class_const`
    - `enum_case`
    - `enum`
    - `function`
    - `trait`
    - `property`
    - `interface`
- `success`: Callback function executed after successful file processing
- `failure`: Callback function executed when an error occurs
- `Parser`: Optional PHP-Parser instance (defaults to host PHP version)

### updateDirectory

[](#updatedirectory)

Updates docblocks in all PHP files within a directory.

```
use Zerotoprod\DocblockAnnotator\DocblockAnnotator;

/* @var DocblockAnnotator $DocblockAnnotator */
$DocblockAnnotator->updateDirectory(
    comments: ['@link https://github.com/zero-to-prod/docblock-annotator'],
    directory: 'src',
    recursive: true
);
```

### updateFiles

[](#updatefiles)

Updates docblocks for a specified array of files.

```
use Zerotoprod\DocblockAnnotator\DocblockAnnotator;

/* @var DocblockAnnotator $DocblockAnnotator */
$DocblockAnnotator->updateFiles(
    comments: ['@link https://github.com/zero-to-prod/docblock-annotator'],
    files: ['src/MyClass.php', 'src/AnotherClass.php']
);
```

Contributing
------------

[](#contributing)

Contributions, issues, and feature requests are welcome! Feel free to check the [issues](https://github.com/zero-to-prod/docblock-annotator/issues) page if you want to contribute.

1. Fork the repository.
2. Create a new branch (`git checkout -b feature-branch`).
3. Commit changes (`git commit -m 'Add some feature'`).
4. Push to the branch (`git push origin feature-branch`).
5. Create a new Pull Request.

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance49

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

###  Release Activity

Cadence

Every ~0 days

Total

10

Last Release

502d ago

Major Versions

v0.1.0 → v1.0.02025-02-16

v1.1.0 → v2.0.02025-02-16

v2.0.0 → v3.0.02025-02-16

v3.1.0 → v4.0.02025-02-16

PHP version history (2 changes)v0.1.0PHP &gt;=7.4

v2.0.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/502649f05d36c87d494988bd99193a4d908d345335d99c080928a726277371f5?d=identicon)[zero-to-prod](/maintainers/zero-to-prod)

---

Top Contributors

[![zero-to-prod](https://avatars.githubusercontent.com/u/61474950?v=4)](https://github.com/zero-to-prod "zero-to-prod (12 commits)")

---

Tags

zero-to-proddocblock-annotator

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/zero-to-prod-docblock-annotator/health.svg)

```
[![Health](https://phpackages.com/badges/zero-to-prod-docblock-annotator/health.svg)](https://phpackages.com/packages/zero-to-prod-docblock-annotator)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[v.chetkov/php-clean-architecture

PHP Clean Architecture

14661.1k](/packages/vchetkov-php-clean-architecture)[zero-to-prod/data-model

Transforms Data into Type-Safe DTOs.

14231.6k32](/packages/zero-to-prod-data-model)[brianhenryie/strauss

Prefixes dependencies namespaces so they are unique to your plugin

190438.1k36](/packages/brianhenryie-strauss)[typo3/cms-install

TYPO3 CMS Install Tool - The Install Tool is used for installation, upgrade, system administration and setup tasks.

1812.3M495](/packages/typo3-cms-install)

PHPackages © 2026

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