jawira / annotation-updater
PHP-CS-Fixer custom fixer to update annotations
v0.1.0
2026-08-28 15:55 UTC
Requires
- php: ^8.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.95.23
- jawira/skeleton: ^2.31
- phpstan/phpstan: ^2.2.9
- phpunit/phpunit: ^11
This package is auto-updated.
Last update: 2026-08-29 07:23:16 UTC
README
Custom PHP-CS-Fixer fixer for updating PHPDoc annotation.
This project is inspired by header-style DocBlock fixers, but it focuses on a
smaller, more explicit use case: updating specific PHPDoc tags such as
@copyright, @author, @license, and similar annotations without changing
the surrounding description text.
Installation
composer require --dev jawira/annotation-updater
Registering the fixer
In your .php-cs-fixer.php file:
<?php use Jawira\AnnotationUpdater\AnnotationUpdater; use PhpCsFixer\Config; return (new Config()) ->registerCustomFixers([ new AnnotationUpdater(), ]) ->setRules([ 'Jawira/annotation_updater' => [ 'annotations' => [ [ 'tag' => 'license', 'value' => 'MIT', 'mode' => 'preserve'], [ 'tag' => 'copyright', 'value' => '© 2026 John Connor', 'mode' => 'replace'], [ 'tag' => 'todo', 'mode' => 'remove'], ], ], ]);
Configuration
The fixer accepts an annotations list, where each item has:
tag: The PHPDoc tag name without the@, for examplecopyrightvalue: The value to set or append. Do not use forremovemode.mode: One ofreplace,append, orremove
Modes
Tag aka annotations
| Mode | Missing tag | Existing tag | Multiple tags |
|---|---|---|---|
preserve |
Add tag | Do nothing | Do nothing |
replace |
Add tag | Replace tag | Replace with one tag |
remove |
Do nothing | Remove tag | Remove tags |