-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConfig.php
More file actions
53 lines (48 loc) · 1.72 KB
/
Config.php
File metadata and controls
53 lines (48 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php declare(strict_types=1);
namespace IxDFCodingStandard\PhpCsFixer;
use PhpCsFixer\Config as BaseConfig;
use PhpCsFixer\Finder;
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
/**
* Pre-configured PHP-CS-Fixer config factory for IxDF projects.
* @see README.md for usage examples
*/
final class Config
{
// phpcs:ignore SlevomatCodingStandard.TypeHints.DisallowMixedTypeHint.DisallowedMixedTypeHint
/** @param array<string, array<string, mixed>|bool> $ruleOverrides Rules to merge on top of the shared ruleset */
public static function create(string $projectDir, array $ruleOverrides = [], ?Finder $finder = null): BaseConfig
{
$finder ??= self::defaultFinder($projectDir);
return (new BaseConfig())
->setParallelConfig(ParallelConfigFactory::detect())
->setUsingCache(true)
->setCacheFile($projectDir.'/.cache/.php-cs-fixer.cache')
->setRiskyAllowed(true)
->setIndent(' ')
->setLineEnding("\n")
->setRules(array_merge(Rules::get(), $ruleOverrides))
->setFinder($finder);
}
private static function defaultFinder(string $projectDir): Finder
{
return Finder::create()
->in($projectDir)
->exclude([
'.cache',
'.docker',
'bootstrap/cache',
'node_modules',
'public',
'storage',
'vendor',
])
->name('*.php')
->notName('*.blade.php')
->notName('_ide_helper.php')
->notName('.phpstorm.meta.php')
->ignoreDotFiles(false)
->ignoreVCS(true)
->ignoreVCSIgnored(true);
}
}