From 33f7dbb47c4b990195e353b96ff240def1de9474 Mon Sep 17 00:00:00 2001 From: Anatoliy Melnikov <5785276@gmail.com> Date: Thu, 30 May 2024 01:30:40 +0300 Subject: [PATCH] Add description of the project --- README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..629c3dd --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ +## Baseline for PHP CS Fixer + +It's simple baseline for [PHP CS Fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer). + +**Pros:** +- It helps to start using of PHP CS Fixer without preparing of all project. +- It may speed up pipelines on CI for big projects. + +Base project has requires for it but not implemented yet: https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/6451 + +So, it's some work around till baseline will be implemented in the PHP CS Fixer. + +### Installation + +1. Require package by composer: + ```shell + composer require --dev aeliot/php-cs-fixer-baseline + ``` +2. Extract `Finder` from the config of PHP CS Fixer to the separate file. + It expects `.php-cs-fixer-finder.php` at the root of the project. +3. Add filtering of files detected by Finder + ```php + $finder->filter((new FilterFactory())->createFilter(__DIR__ . '/.php-cs-fixer-baseline.json', $config)); + ``` +4. Generate baseline. Just call script without options when all config files uses default names. + ```shell + vendor/bin/pcsf-baseline + ``` + See options of it below. + +You can see how it is configured in this project. + +### Options of baseline generator + +| Short name | Long name | Description | Default value | +|------------|-----------|----------------------------------------|-----------------------------| +| b | baseline | Name of baseline file | .php-cs-fixer-baseline.json | +| c | config | Name of config file | .php-cs-fixer.dist.php | +| f | finder | Name of file with definition of Finder | .php-cs-fixer-finder.php | + +Path to files can be absolute or related or omitted at all. It the last case it is expected that files +in the root directory of project.