<?php

if (!file_exists(__DIR__.'/src')) {
    exit(0);
}

return PhpCsFixer\Config::create()
    ->setRules(array(
        '@Symfony' => true,
        '@Symfony:risky' => true,
        '@PHPUnit48Migration:risky' => true,
        'php_unit_no_expectation_annotation' => false, // part of `PHPUnitXYMigration:risky` ruleset, to be enabled when PHPUnit 4.x support will be dropped, as we don't want to rewrite exceptions handling twice
        'array_syntax' => array('syntax' => 'long'),
        'protected_to_private' => false,
        // rule disabled due to https://bugs.php.net/bug.php?id=60573 bug;
        // to be re-enabled (by dropping next line, rule is part of @Symfony already) on branch that requires PHP 5.4+
        'self_accessor' => false,
    ))
    ->setRiskyAllowed(true)
    ->setFinder(
        PhpCsFixer\Finder::create()
            ->in(__DIR__.'/src')
            ->append(array(__FILE__))
            ->exclude(array(
                // directories containing files with content that is autogenerated by `var_export`, which breaks CS in output code
                'Symfony/Component/DependencyInjection/Tests/Fixtures',
                'Symfony/Component/Routing/Tests/Fixtures/dumper',
                // fixture templates
                'Symfony/Component/Templating/Tests/Fixtures/templates',
                'Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom',
                // resource templates
                'Symfony/Bundle/FrameworkBundle/Resources/views/Form',
            ))
            // file content autogenerated by `var_export`
            ->notPath('Symfony/Component/Translation/Tests/fixtures/resources.php')
            // test template
            ->notPath('Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_name_entry_label.html.php')
            // explicit heredoc test
            ->notPath('Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/translation.html.php')
            // explicit trigger_error tests
            ->notPath('Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/default.phpt')
            ->notPath('Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/weak.phpt')
            ->notPath('Symfony/Component/Debug/Tests/DebugClassLoaderTest.php')
    )
;
