|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +use PhpCsFixer\Config\RuleCustomisationPolicyInterface; |
| 6 | +use PhpCsFixer\Fixer\FunctionNotation\NativeFunctionInvocationFixer; |
| 7 | + |
| 8 | +$finder = PhpCsFixer\Finder::create() |
| 9 | + ->in(__DIR__) |
| 10 | + ->append([__FILE__]) |
| 11 | +; |
| 12 | + |
| 13 | +return (new PhpCsFixer\Config()) |
| 14 | + ->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect()) |
| 15 | + ->setUsingCache(true) |
| 16 | + ->setRules([ |
| 17 | + '@PHP8x1Migration' => true, |
| 18 | + '@PHPUnit10x0Migration:risky' => true, |
| 19 | + '@Symfony' => true, |
| 20 | + '@Symfony:risky' => true, |
| 21 | + 'attribute_empty_parentheses' => true, |
| 22 | + 'declare_strict_types' => true, |
| 23 | + 'heredoc_to_nowdoc' => true, |
| 24 | + 'no_superfluous_phpdoc_tags' => true, |
| 25 | + 'php_unit_test_case_static_method_calls' => ['call_type' => 'self'], |
| 26 | + 'self_static_accessor' => true, |
| 27 | + 'single_line_throw' => false, |
| 28 | + 'trailing_comma_in_multiline' => [ |
| 29 | + 'after_heredoc' => true, |
| 30 | + 'elements' => ['arguments', 'array_destructuring', 'arrays', 'match', 'parameters'], |
| 31 | + ], |
| 32 | + 'whitespace_after_comma_in_array' => ['ensure_single_space' => true], |
| 33 | + ]) |
| 34 | + ->setRiskyAllowed(true) |
| 35 | + ->setRuleCustomisationPolicy(new class implements RuleCustomisationPolicyInterface { |
| 36 | + public function getPolicyVersionForCache(): string |
| 37 | + { |
| 38 | + return hash_file('xxh128', __FILE__); |
| 39 | + } |
| 40 | + |
| 41 | + public function getRuleCustomisers(): array |
| 42 | + { |
| 43 | + return [ |
| 44 | + 'native_function_invocation' => static function (SplFileInfo $file) { |
| 45 | + if (str_starts_with($file->getPathname(), __DIR__.'/src/')) { |
| 46 | + $fixer = new NativeFunctionInvocationFixer(); |
| 47 | + $fixer->configure(['include' => ['@all']]); |
| 48 | + |
| 49 | + return $fixer; |
| 50 | + } |
| 51 | + |
| 52 | + return true; |
| 53 | + }, |
| 54 | + ]; |
| 55 | + } |
| 56 | + }) |
| 57 | + ->setFinder($finder) |
| 58 | +; |
0 commit comments