<?php

return PhpCsFixer\Config::create()
    ->setFinder(
        PhpCsFixer\Finder::create()
        ->in(__DIR__)
    )
    ->setIndent('    ')
    ->setLineEnding("\n")
    ->setRules([
        '@Symfony'                            => true,
        // Override @Symfony rules
        'pre_increment'                       => false,
        'blank_line_before_statement'         => ['statements' => ['return', 'try', 'throw']],
        'phpdoc_align'                        => ['tags' => ['param', 'throws']],
        'method_argument_space'               => ['ensure_fully_multiline' => false],
        'binary_operator_spaces'              => [
            'align_double_arrow' => true,
            'align_equals'       => false,
        ],
        'phpdoc_annotation_without_dot'       => false,
        'yoda_style'                          => [
            // Symfony writes their conditions backwards; we use normal order.
            'equal'            => false,
            'identical'        => false,
            'less_and_greater' => false,
        ],
        'is_null'                             => [
            // Replaces all is_null() with === null.
            'use_yoda_style' => false,
        ],
        // Custom rules
        'align_multiline_comment'             => true,
        'phpdoc_add_missing_param_annotation' => ['only_untyped' => false],
        'ordered_imports'                     => ['sort_algorithm' => 'alpha'],
        'phpdoc_order'                        => true,
        'array_syntax'                        => ['syntax' => 'short'],
    ]);
