Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

jackd248/php-doc-block-header-fixer

Repository files navigation

Php DocBlock Header Fixer

Coverage CGL Tests Supported PHP Versions

This packages contains a PHP-CS-Fixer rule to automatically fix the class header regarding PHP DocBlocks.

Warning

This package is in early development stage and may change significantly in the future. Use it at your own risk.

Before:

<?php
class MyClass
{
 public function myMethod()
 {
 // ...
 }
}

After:

<?php
/**
 * MyClass.
 *
 * @author Your Name <your@email.org>
 * @package MyPackage
 */
class MyClass
{
 // ...
}

πŸ”₯ Installation

Packagist Packagist Downloads

composer require --dev konradmichalik/php-doc-block-header-fixer

⚑ Usage

Add the PHP-CS-Fixer rule in your .php-cs-fixer.php file:

<?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',
 'package' => 'PhpDocBlockHeaderFixer',
 ],
 'preserve_existing' => true,
 'separate' => 'none',
 'add_class_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',
 'package' => 'PhpDocBlockHeaderFixer',
 ],
 preserveExisting: true,
 separate: \KonradMichalik\PhpDocBlockHeaderFixer\Enum\Separate::None,
 addClassName: true
 )->__toArray()
 ])
;

πŸ§‘β€πŸ’» Contributing

Please have a look at CONTRIBUTING.md.

⭐ License

This project is licensed under GNU General Public License 3.0 (or later).

About

πŸ“ PHP CS Fixer rule for fix the class header regarding PHP DocBlocks

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Languages

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /