Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
63 changes: 21 additions & 42 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,32 @@
declare(strict_types=1);

/*
* This file is part of the Composer package "php-doc-block-header-fixer".
* This file is part of the "php-doc-block-header-fixer" Composer package.
*
* Copyright (C) 2025 Konrad Michalik <hej@konradmichalik.dev>
* (c) Konrad Michalik <hej@konradmichalik.dev>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use EliasHaeussler\PhpCsFixerConfig\Config;
use EliasHaeussler\PhpCsFixerConfig\Package;
use EliasHaeussler\PhpCsFixerConfig\Rules;
use Symfony\Component\Finder;

$header = Rules\Header::create(
'php-doc-block-header-fixer',
Package\Type::ComposerPackage,
Package\Author::create('Konrad Michalik', 'hej@konradmichalik.dev'),
Package\CopyrightRange::from(2025),
Package\License::GPL3OrLater,
);
use KonradMichalik\PhpCsFixerPreset\Config;
use KonradMichalik\PhpCsFixerPreset\Rules\Header;
use KonradMichalik\PhpCsFixerPreset\Rules\Set\Set;
use KonradMichalik\PhpDocBlockHeaderFixer\Generators\DocBlockHeader;
use KonradMichalik\PhpDocBlockHeaderFixer\Rules\DocBlockHeaderFixer;
use Symfony\Component\Finder\Finder;

return Config::create()
->withRule($header)
// ->withRule(
// RuleSet::fromArray(
// DocBlockHeader::create(
// [
// 'author' => 'Konrad Michalik <hej@konradmichalik.dev>',
// 'license' => 'GPL-3.0-or-later',
// 'package' => 'PhpDocBlockHeaderFixer',
// ]
// )->__toArray()
// )
// )
// ->registerCustomFixers([new KonradMichalik\PhpDocBlockHeaderFixer\Rules\DocBlockHeaderFixer()]) // Temporarily disabled
->withFinder(static fn (Finder\Finder $finder) => $finder
->in(__DIR__)
->exclude('vendor'),
->registerCustomFixers([
new DocBlockHeaderFixer(),
])
->withRule(
Header::fromComposer(),
)
->withRule(
Set::fromArray(
DocBlockHeader::fromComposer()->__toArray(),
),
)
->withFinder(static fn (Finder $finder) => $finder->in(__DIR__))
;
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,22 @@ return (new PhpCsFixer\Config())
;
```

Or even simpler, automatically read all authors and license from your `composer.json`:

```php
<?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 classes
Expand Down
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
},
"require-dev": {
"armin/editorconfig-cli": "^1.0 || ^2.0",
"eliashaeussler/php-cs-fixer-config": "2.3.0",
"eliashaeussler/rector-config": "^3.0",
"ergebnis/composer-normalize": "^2.44",
"konradmichalik/php-cs-fixer-preset": "^0.1.0",
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/phpstan-symfony": "^2.0",
Expand All @@ -40,6 +40,11 @@
"KonradMichalik\\PhpDocBlockHeaderFixer\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"KonradMichalik\\PhpDocBlockHeaderFixer\\Tests\\": "tests/src"
}
},
"config": {
"allow-plugins": {
"ergebnis/composer-normalize": true
Expand Down
153 changes: 79 additions & 74 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 4 additions & 14 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,12 @@
declare(strict_types=1);

/*
* This file is part of the Composer package "php-doc-block-header-fixer".
* This file is part of the "php-doc-block-header-fixer" Composer package.
*
* Copyright (C) 2025 Konrad Michalik <hej@konradmichalik.dev>
* (c) Konrad Michalik <hej@konradmichalik.dev>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use EliasHaeussler\RectorConfig\Config\Config;
Expand Down
Loading