konradmichalik/php-doc-block-header-fixer
Composer 安装命令:
composer require konradmichalik/php-doc-block-header-fixer
包简介
This package contains a PHP-CS-Fixer rule to automatically fix the class header regarding PHP DocBlocks.
README 文档
README
Php DocBlock Header Fixer
This packages contains a PHP-CS-Fixer rule to automatically fix the header regarding PHP DocBlocks for classes, interfaces, traits and enums.
Before:
<?php class MyClass { public function myMethod() { // ... } } interface MyInterface {} trait MyTrait {} enum MyEnum {}
After:
<?php /** * MyClass. * * @author Your Name <your@email.org> * @license GPL-3.0-or-later */ class MyClass { // ... }
🔥 Installation
composer require --dev konradmichalik/php-doc-block-header-fixer
⚡ Usage
Add the PHP-CS-Fixer rule in your .php-cs-fixer.php file:
Note
This fixer is compatible with standard PHP-CS-Fixer rules. It avoids adding annotations that conflict with rules like phpdoc_no_package and follows spacing conventions compatible with phpdoc_separation.
<?php // ... return (new PhpCsFixer\Config()) // ... ->registerCustomFixers([ new KonradMichalik\PhpDocBlockHeaderFixer\Rules\DocBlockHeaderFixer() ]) ->setRules([ 'KonradMichalik/docblock_header_comment' => [ 'annotations' => [ 'author' => 'Konrad Michalik <hej@konradmichalik.dev>', 'license' => 'GPL-3.0-or-later', ], 'preserve_existing' => true, 'separate' => 'none', 'add_structure_name' => true, ], ]) ;
Alternatively, you can use a object-oriented configuration:
<?php // ... return (new PhpCsFixer\Config()) // ... ->registerCustomFixers([ new KonradMichalik\PhpDocBlockHeaderFixer\Rules\DocBlockHeaderFixer() ]) ->setRules([ KonradMichalik\PhpDocBlockHeaderFixer\Generators\DocBlockHeader::create( [ 'author' => 'Konrad Michalik <hej@konradmichalik.dev>', 'license' => 'GPL-3.0-or-later', ], preserveExisting: true, separate: \KonradMichalik\PhpDocBlockHeaderFixer\Enum\Separate::None, addStructureName: true )->__toArray() ]) ;
Or even simpler, automatically read all authors and license from your composer.json:
<?php // ... return (new PhpCsFixer\Config()) // ... ->registerCustomFixers([ new KonradMichalik\PhpDocBlockHeaderFixer\Rules\DocBlockHeaderFixer() ]) ->setRules([ KonradMichalik\PhpDocBlockHeaderFixer\Generators\DocBlockHeader::fromComposer()->__toArray() ]) ;
⚙️ Configuration
annotations(array): DocBlock annotations to add to classespreserve_existing(boolean, default: true): Keep existing DocBlock annotationsseparate(string, default: 'none'): Add blank lines ('top', 'bottom', 'both', 'none')add_structure_name(boolean, default: false): Add class name as first line in DocBlockensure_spacing(boolean, default: true): Ensure proper spacing after DocBlocks to prevent conflicts with PHP-CS-Fixer rules
🧑💻 Contributing
Please have a look at CONTRIBUTING.md.
⭐ License
This project is licensed under GNU General Public License 3.0 (or later).
konradmichalik/php-doc-block-header-fixer 适用场景与选型建议
konradmichalik/php-doc-block-header-fixer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 28.86k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2025 年 08 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「phpdoc」 「php」 「header」 「docblock」 「Coding Standard」 「fixer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 konradmichalik/php-doc-block-header-fixer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 konradmichalik/php-doc-block-header-fixer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 konradmichalik/php-doc-block-header-fixer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A simple tool for checking that your PHP classes and methods use PHPDocs (PHP DocBlocks Checker fork).
Laravel package that generates RESTful API documentation in Markdown based on PHPDoc.
Validates PHPDoc @param and @return tags against method signatures
A PHPDoc docblock interpreter that is simple, easy to use, and provides Attribute alternatives.
This library parses phpdoc annotations and generates md document that can be parsed by slate
Adds support for template PHPDoc tags
统计信息
- 总下载量: 28.86k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 16
- 依赖项目数: 8
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2025-08-11