Skip to content

Commit 92a7505

Browse files
committed
feat: make ecs.php extensible with ECSConfig class
- Add ECSConfig class with static configure() method returning ECSConfigBuilder - Update ecs.php to use ECSConfig::configure() - Remove CodeStyleCommand changes (extra-config option) - Add PHPDoc explaining extension pattern in ECSConfig class Usage example in consumer project: $config = \FastForward\DevTools\Config\ECSConfig::configure(); $config->withRules([CustomRule::class]); $config->withConfiguredRule(PhpdocAlignFixer::class, ['align' => 'right']); return $config; Implements: #6
1 parent 39d3384 commit 92a7505

2 files changed

Lines changed: 88 additions & 38 deletions

File tree

ecs.php

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,42 +16,6 @@
1616
* @see https://datatracker.ietf.org/doc/html/rfc2119
1717
*/
1818

19-
use PhpCsFixer\Fixer\Import\GlobalNamespaceImportFixer;
20-
use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer;
21-
use PhpCsFixer\Fixer\Phpdoc\PhpdocAlignFixer;
22-
use PhpCsFixer\Fixer\Phpdoc\NoEmptyPhpdocFixer;
23-
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
24-
use PhpCsFixer\Fixer\Phpdoc\PhpdocAddMissingParamAnnotationFixer;
25-
use PhpCsFixer\Fixer\Phpdoc\PhpdocNoEmptyReturnFixer;
26-
use PhpCsFixer\Fixer\Phpdoc\PhpdocToCommentFixer;
27-
use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestCaseStaticMethodCallsFixer;
28-
use Symplify\EasyCodingStandard\Config\ECSConfig;
19+
use FastForward\DevTools\Config\ECSConfig;
2920

30-
use function Safe\getcwd;
31-
32-
return ECSConfig::configure()
33-
->withPaths([getcwd()])
34-
->withSkip([
35-
getcwd() . '/public',
36-
getcwd() . '/resources',
37-
getcwd() . '/vendor',
38-
getcwd() . '/tmp',
39-
PhpdocToCommentFixer::class,
40-
NoSuperfluousPhpdocTagsFixer::class,
41-
NoEmptyPhpdocFixer::class,
42-
PhpdocNoEmptyReturnFixer::class,
43-
GlobalNamespaceImportFixer::class,
44-
GeneralPhpdocAnnotationRemoveFixer::class,
45-
])
46-
->withRootFiles()
47-
->withPhpCsFixerSets(symfony: true, symfonyRisky: true, auto: true, autoRisky: true)
48-
->withPreparedSets(psr12: true, common: true, symplify: true, strict: true, cleanCode: true)
49-
->withConfiguredRule(PhpdocAlignFixer::class, [
50-
'align' => 'left',
51-
])
52-
->withConfiguredRule(PhpUnitTestCaseStaticMethodCallsFixer::class, [
53-
'call_type' => 'self',
54-
])
55-
->withConfiguredRule(PhpdocAddMissingParamAnnotationFixer::class, [
56-
'only_untyped' => false,
57-
]);
21+
return ECSConfig::configure();

src/Config/ECSConfig.php

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of fast-forward/dev-tools.
7+
*
8+
* This source file is subject to the license bundled
9+
* with this source code in the file LICENSE.
10+
*
11+
* @copyright Copyright (c) 2026 Felipe Sayão Lobato Abreu <github@mentordosnerds.com>
12+
* @license https://opensource.org/licenses/MIT MIT License
13+
*
14+
* @see https://github.com/php-fast-forward/dev-tools
15+
* @see https://github.com/php-fast-forward
16+
* @see https://datatracker.ietf.org/doc/html/rfc2119
17+
*/
18+
19+
namespace FastForward\DevTools\Config;
20+
21+
use PhpCsFixer\Fixer\Import\GlobalNamespaceImportFixer;
22+
use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer;
23+
use PhpCsFixer\Fixer\Phpdoc\PhpdocAlignFixer;
24+
use PhpCsFixer\Fixer\Phpdoc\NoEmptyPhpdocFixer;
25+
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
26+
use PhpCsFixer\Fixer\Phpdoc\PhpdocAddMissingParamAnnotationFixer;
27+
use PhpCsFixer\Fixer\Phpdoc\PhpdocNoEmptyReturnFixer;
28+
use PhpCsFixer\Fixer\Phpdoc\PhpdocToCommentFixer;
29+
use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestCaseStaticMethodCallsFixer;
30+
use Symplify\EasyCodingStandard\Configuration\ECSConfigBuilder;
31+
32+
use function Safe\getcwd;
33+
34+
/**
35+
* Provides the default ECS configuration.
36+
*
37+
* Consumers can use this as a starting point and extend it:
38+
*
39+
* $config = \FastForward\DevTools\Config\ECSConfig::configure();
40+
* $config->withRules([CustomRule::class]);
41+
* $config->withConfiguredRule(PhpdocAlignFixer::class, ['align' => 'right']);
42+
* return $config;
43+
*
44+
* @see https://github.com/symplify/easy-coding-standard
45+
*/
46+
final class ECSConfig
47+
{
48+
/**
49+
* Creates the default ECS configuration.
50+
*
51+
* @return ECSConfigBuilder the configured ECS configuration builder
52+
*/
53+
public static function configure(): ECSConfigBuilder
54+
{
55+
$cwd = getcwd();
56+
57+
$config = new ECSConfigBuilder();
58+
59+
return $config
60+
->withPaths([$cwd])
61+
->withSkip([
62+
$cwd . '/public',
63+
$cwd . '/resources',
64+
$cwd . '/vendor',
65+
$cwd . '/tmp',
66+
PhpdocToCommentFixer::class,
67+
NoSuperfluousPhpdocTagsFixer::class,
68+
NoEmptyPhpdocFixer::class,
69+
PhpdocNoEmptyReturnFixer::class,
70+
GlobalNamespaceImportFixer::class,
71+
GeneralPhpdocAnnotationRemoveFixer::class,
72+
])
73+
->withRootFiles()
74+
->withPhpCsFixerSets(symfony: true, symfonyRisky: true, auto: true, autoRisky: true)
75+
->withPreparedSets(psr12: true, common: true, symplify: true, strict: true, cleanCode: true)
76+
->withConfiguredRule(PhpdocAlignFixer::class, [
77+
'align' => 'left',
78+
])
79+
->withConfiguredRule(PhpUnitTestCaseStaticMethodCallsFixer::class, [
80+
'call_type' => 'self',
81+
])
82+
->withConfiguredRule(PhpdocAddMissingParamAnnotationFixer::class, [
83+
'only_untyped' => false,
84+
]);
85+
}
86+
}

0 commit comments

Comments
 (0)