Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
28 / 28
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
ECSConfig
100.00% covered (success)
100.00%
28 / 28
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 configure
100.00% covered (success)
100.00%
28 / 28
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(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
19namespace FastForward\DevTools\Config;
20
21use PhpCsFixer\Fixer\Import\GlobalNamespaceImportFixer;
22use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer;
23use PhpCsFixer\Fixer\Phpdoc\PhpdocAlignFixer;
24use PhpCsFixer\Fixer\Phpdoc\NoEmptyPhpdocFixer;
25use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
26use PhpCsFixer\Fixer\Phpdoc\PhpdocAddMissingParamAnnotationFixer;
27use PhpCsFixer\Fixer\Phpdoc\PhpdocNoEmptyReturnFixer;
28use PhpCsFixer\Fixer\Phpdoc\PhpdocToCommentFixer;
29use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestCaseStaticMethodCallsFixer;
30use Symplify\EasyCodingStandard\Configuration\ECSConfigBuilder;
31
32use 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 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        $config = new ECSConfigBuilder();
57
58        return $config
59            ->withPaths([$cwd])
60            ->withSkip([
61                $cwd . '/public',
62                $cwd . '/resources',
63                $cwd . '/vendor',
64                $cwd . '/tmp',
65                PhpdocToCommentFixer::class,
66                NoSuperfluousPhpdocTagsFixer::class,
67                NoEmptyPhpdocFixer::class,
68                PhpdocNoEmptyReturnFixer::class,
69                GlobalNamespaceImportFixer::class,
70                GeneralPhpdocAnnotationRemoveFixer::class,
71            ])
72            ->withRootFiles()
73            ->withPhpCsFixerSets(symfony: true, symfonyRisky: true, auto: true, autoRisky: true)
74            ->withPreparedSets(psr12: true, common: true, symplify: true, strict: true, cleanCode: true)
75            ->withConfiguredRule(PhpdocAlignFixer::class, [
76                'align' => 'left',
77            ])
78            ->withConfiguredRule(PhpUnitTestCaseStaticMethodCallsFixer::class, [
79                'call_type' => 'self',
80            ])
81            ->withConfiguredRule(PhpdocAddMissingParamAnnotationFixer::class, [
82                'only_untyped' => false,
83            ]);
84    }
85}