Skip to content

Commit cf1b370

Browse files
committed
docs: add ECSConfig extension examples to documentation
- Add 'Extending ECS Configuration' section to overriding-defaults.rst - Add FAQ entry explaining how to extend ECS configuration Refs: #6
1 parent 92a7505 commit cf1b370

3 files changed

Lines changed: 43 additions & 1 deletion

File tree

docs/configuration/overriding-defaults.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,31 @@ To customize Rector for one library, create ``rector.php`` in the consumer
5151
project root. The ``refactor`` command and the Rector phase inside ``phpdoc``
5252
will use that file instead of the packaged default.
5353

54+
Extending ECS Configuration
55+
----------------------------
56+
57+
Instead of copying the entire ``ecs.php`` file, consumers can extend the
58+
default configuration using the ``ECSConfig`` class:
59+
60+
.. code-block:: php
61+
62+
<?php
63+
64+
use FastForward\DevTools\Config\ECSConfig;
65+
use PhpCsFixer\Fixer\Phpdoc\PhpdocAlignFixer;
66+
67+
$config = ECSConfig::configure();
68+
$config->withRules([CustomRule::class]);
69+
$config->withConfiguredRule(PhpdocAlignFixer::class, ['align' => 'right']);
70+
71+
return $config;
72+
73+
This approach:
74+
75+
- Eliminates duplication of the base configuration
76+
- Automatically receives upstream updates
77+
- Only requires overriding what is needed
78+
5479
What Is Not Overwritten Automatically
5580
-------------------------------------
5681

docs/faq.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,24 @@ Create only the local configuration file you want to customize, such as
7676
``rector.php`` or ``phpunit.xml``. DevTools will prefer that file and keep the
7777
rest on the packaged defaults.
7878

79+
How do I extend the ECS configuration without copying the whole file?
80+
----------------------------------------------------------------------
81+
82+
Use the ``ECSConfig`` class to extend instead of replace:
83+
84+
.. code-block:: php
85+
86+
<?php
87+
88+
use FastForward\DevTools\Config\ECSConfig;
89+
90+
$config = ECSConfig::configure();
91+
$config->withRules([CustomRule::class]);
92+
93+
return $config;
94+
95+
This approach automatically receives upstream updates while allowing additive customization.
96+
7997
Can I generate coverage without running the full ``standards`` pipeline?
8098
------------------------------------------------------------------------
8199

src/Config/ECSConfig.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ final class ECSConfig
5353
public static function configure(): ECSConfigBuilder
5454
{
5555
$cwd = getcwd();
56-
5756
$config = new ECSConfigBuilder();
5857

5958
return $config

0 commit comments

Comments
 (0)