Repository: symfony/symfony
File: .php-cs-fixer.dist.php (PHP)

Code before:
        For the full copyright and license information, please view the LICENSE
        file that was distributed with this source code.
        EOF,
];

return (new PhpCsFixer\Config())
    ->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
    ->setRules([
        '@PHP8x1Migration' => true, // take lowest version from `git grep -h '"php"' **/composer.json | uniq | sort`
        '@PHPUnit9x1Migration:risky' => true, // take version from src/Symfony/Bridge/PhpUnit/phpunit.xml.dist#L4
        '@Symfony' => true,
        '@Symfony:risky' => true,
        'protected_to_private' => true,
        'header_comment' => [
            'header' => implode('', $fileHeaderParts),
            'validator' => implode('', [
                '/',
                preg_quote($fileHeaderParts[0], '/'),
                '(?P<EXTRA>.*)??',
                preg_quote($fileHeaderParts[1], '/'),
                '/s',
            ]),
        ],
        'php_unit_attributes' => true,
        'random_api_migration' => true,
        // 'static_lambda' => true, // @todo @keradus to fix last issues
    ])
    ->setRuleCustomisationPolicy(new class implements PhpCsFixer\Config\RuleCustomisationPolicyInterface {
        public function getPolicyVersionForCache(): string
        {
            return hash_file('xxh128', __FILE__);
        }

        public function getRuleCustomisers(): array
        {
            return [
                'php_unit_attributes' => static function (SplFileInfo $file) {
                    // temporary hack due to bug: https://github.com/symfony/symfony/issues/62734
                    if (!($file instanceof Symfony\Component\Finder\SplFileInfo)) {
                        return true;
                    }

                    $relativePath = $file->getRelativePath();

                    // those packages can be used with versions of phpunit that only support annotations
                    if (
                        str_starts_with($relativePath, 'Symfony/Bridge/PhpUnit')
                        || str_starts_with($relativePath, 'Symfony/Contracts')
                    ) {
                        $fixer = new PhpCsFixer\Fixer\PhpUnit\PhpUnitAttributesFixer();
                        $fixer->configure(['keep_annotations' => true]);

Review comment (suggestion):
that's cool, can you split that in a new PR on 7.4? this way we won't remove the attributes by mistake there either

Code after:
        For the full copyright and license information, please view the LICENSE
        file that was distributed with this source code.
        EOF,
];

return (new PhpCsFixer\Config())
    ->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
    ->setRules([
        '@PHP8x1Migration' => true, // take lowest version from `git grep -h '"php"' **/composer.json | uniq | sort`
        '@PHPUnit9x1Migration:risky' => true, // take version from src/Symfony/Bridge/PhpUnit/phpunit.xml.dist#L4
        '@Symfony' => true,
        '@Symfony:risky' => true,
        'protected_to_private' => true,
        'header_comment' => [
            'header' => implode('', $fileHeaderParts),
            'validator' => implode('', [
                '/',
                preg_quote($fileHeaderParts[0], '/'),
                '(?P<EXTRA>.*)??',
                preg_quote($fileHeaderParts[1], '/'),
                '/s',
            ]),
        ],
        'php_unit_attributes' => true,
    ])
    ->setRuleCustomisationPolicy(new class implements PhpCsFixer\Config\RuleCustomisationPolicyInterface {
        public function getPolicyVersionForCache(): string
        {
            return hash_file('xxh128', __FILE__);
        }

        public function getRuleCustomisers(): array
        {
            return [
                'php_unit_attributes' => static function (SplFileInfo $file) {
                    // temporary hack due to bug: https://github.com/symfony/symfony/issues/62734
                    if (!$file instanceof Symfony\Component\Finder\SplFileInfo) {
                        return true;
                    }

                    $relativePathname = $file->getRelativePathname();

                    // For packages/namespaces that are part of public API and
                    // as such are not bound to any specific PHPUnit version,
                    // we have to keep both annotations and attributes.
                    if (
                        str_starts_with($relativePathname, 'Symfony/Bridge/PhpUnit/')
                        || str_starts_with($relativePathname, 'Symfony/Contracts/')
                        || str_contains($relativePathname, '/Test/') // public namespace, do not mistake it with `/Tests/`
                    ) {
                        $fixer = new PhpCsFixer\Fixer\PhpUnit\PhpUnitAttributesFixer();