Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/.php-cs-fixer.cache
/.phpunit.result.cache
/.build
/coverage-report
/php-cs-fixer.xml
/phpstan.xml
/site
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class MyClass
* MyClass.
*
* @author Your Name <your@email.org>
* @package MyPackage
*/
class MyClass
{
Expand All @@ -58,6 +57,9 @@ composer require --dev konradmichalik/php-doc-block-header-fixer

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
<?php
// ...
Expand All @@ -71,7 +73,6 @@ return (new PhpCsFixer\Config())
'annotations' => [
'author' => 'Konrad Michalik <hej@konradmichalik.dev>',
'license' => 'GPL-3.0-or-later',
'package' => 'PhpDocBlockHeaderFixer',
],
'preserve_existing' => true,
'separate' => 'none',
Expand All @@ -96,7 +97,6 @@ return (new PhpCsFixer\Config())
[
'author' => 'Konrad Michalik <hej@konradmichalik.dev>',
'license' => 'GPL-3.0-or-later',
'package' => 'PhpDocBlockHeaderFixer',
],
preserveExisting: true,
separate: \KonradMichalik\PhpDocBlockHeaderFixer\Enum\Separate::None,
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "konradmichalik/php-doc-block-header-fixer",
"description": "",
"description": "This packages contains a PHP-CS-Fixer rule to automatically fix the class header regarding PHP DocBlocks.",
"license": "GPL-3.0-or-later",
"type": "library",
"authors": [
Expand Down
1 change: 0 additions & 1 deletion tests/src/Generators/DocBlockHeaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ public function testValidateAnnotationsWithValidKeys(): void
'license' => 'MIT',
'version' => '1.0.0',
'since' => '1.0.0',
'package' => 'MyPackage',
'subpackage' => 'SubPackage',
'see' => 'https://example.com',
'link' => 'https://example.com',
Expand Down
3 changes: 1 addition & 2 deletions tests/src/Rules/DocBlockHeaderFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,9 @@ public function testBuildDocBlockWithMultipleAnnotations(): void
$result = $method->invoke($this->fixer, [
'author' => 'John Doe <john@example.com>',
'license' => 'MIT',
'package' => 'MyPackage',
], '');

$expected = "/**\n * @author John Doe <john@example.com>\n * @license MIT\n * @package MyPackage\n */";
$expected = "/**\n * @author John Doe <john@example.com>\n * @license MIT\n */";
self::assertSame($expected, $result);
}

Expand Down