<?php

declare(strict_types=1);

use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$finder = Finder::create()
    ->in('src')
    ->notName('Kernel.php')
;

$rules = [
    '@Symfony'               => true,
    '@PSR12'                 => true,
    '@PHP84Migration'        => true,
    '@PER-CS'                => true,
    '@PhpCsFixer'            => true,
    'strict_param'           => true,
    'strict_comparison'      => true,
    'no_useless_else'        => true,
    'no_useless_return'      => true,
    'binary_operator_spaces' => [
        'operators' => [
            '='  => 'align_single_space_minimal',
            '||' => 'align_single_space_minimal',
            '=>' => 'align_single_space_minimal',
        ],
    ],
    'global_namespace_import' => [
        'import_classes'   => true,
        'import_constants' => true,
        'import_functions' => true,
    ],
    'modernize_strpos'            => true, // needs PHP 8+ or polyfill
    'no_superfluous_phpdoc_tags'  => true,
    'echo_tag_syntax'             => true,
    'semicolon_after_instruction' => true,
    'combine_consecutive_unsets'  => true,
    'ternary_to_null_coalescing'  => true,
    'declare_strict_types'        => true,
    'operator_linebreak'          => [
        'position' => 'beginning',
    ],
    'no_unused_imports'                   => true,
    'single_line_throw'                   => false,
    'php_unit_test_class_requires_covers' => false,
];

$config = new Config();

return $config
    ->setRiskyAllowed(true)
    ->setRules($rules)
    ->setFinder($finder)
;
