<?php

declare(strict_types=1);

/**
 * PHP-CS-Fixer config — PER-CS (the ruleset PSR-12 evolved into) plus
 * strict-types enforcement, matching this repo's conventions (see CLAUDE.md).
 * Scope mirrors the `composer cs` / `composer stan` file list.
 */

$finder = PhpCsFixer\Finder::create()
    ->in([
        __DIR__ . '/public',
        __DIR__ . '/redirect',
        __DIR__ . '/statistics',
        __DIR__ . '/tests',
    ])
    ->append([
        __DIR__ . '/env.php',
        __DIR__ . '/env-config.php',
        __DIR__ . '/connection_pdo.php',
        __DIR__ . '/Base64URL.php',
        __DIR__ . '/index.php',
        __DIR__ . '/health.php',
        __DIR__ . '/legal.php',
        __DIR__ . '/ip_address.php',
        __DIR__ . '/install.php',
        __DIR__ . '/login_throttle.php',
        __DIR__ . '/robots.php',
        __DIR__ . '/sitemap.php',
        __DIR__ . '/shortlink.php',
        __FILE__,
    ])
    ->notPath('vendor')
    ->exclude(['vendor', 'databases', 'logs', 'temp']);

return (new PhpCsFixer\Config())
    ->setRiskyAllowed(true)
    ->setRules([
        '@PER-CS' => true,
        'declare_strict_types' => true,
        'strict_param' => true,
        'array_syntax' => ['syntax' => 'short'],
        'no_unused_imports' => true,
        'ordered_imports' => ['sort_algorithm' => 'alpha'],
        'single_quote' => true,
        'trailing_comma_in_multiline' => ['elements' => ['arrays', 'arguments', 'parameters']],
    ])
    ->setFinder($finder);
