Repository: symfony/symfony
File: src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php (PHP)

Code before:
error_reporting(-1);

global $argv, $argc;
$argv = $_SERVER['argv'] ?? [];
$argc = $_SERVER['argc'] ?? 0;
$getEnvVar = static function ($name, $default = false) use ($argv) {
    if (false !== $value = getenv($name)) {
        return $value;
    }

    static $phpunitConfig = null;
    if (null === $phpunitConfig) {
        $phpunitConfigFilename = null;
        $getPhpUnitConfig = static function ($probableConfig) use (&$getPhpUnitConfig) {
            if (!$probableConfig) {
                return null;
            }

            if (is_dir($probableConfig)) {
                return $getPhpUnitConfig($probableConfig.\DIRECTORY_SEPARATOR.'phpunit');
            }

            foreach (['.xml', '.dist.xml', '.xml.dist'] as $suffix) {
                $candidate = $probableConfig.$suffix;

                if (file_exists($candidate)) {
                    return $candidate;
                }
            }

            return null;
        };

        foreach ($argv as $cliArgumentIndex => $cliArgument) {
            if ('--' === $cliArgument) {
                break;
            }
            // long option
            if ('--configuration' === $cliArgument && array_key_exists($cliArgumentIndex + 1, $argv)) {
                $phpunitConfigFilename = $getPhpUnitConfig($argv[$cliArgumentIndex + 1]);
                break;
            }
            // short option
            if (str_starts_with($cliArgument, '-c')) {
                if ('-c' === $cliArgument && array_key_exists($cliArgumentIndex + 1, $argv)) {
                    $phpunitConfigFilename = $getPhpUnitConfig($argv[$cliArgumentIndex + 1]);
                } else {
                    $phpunitConfigFilename = $getPhpUnitConfig(substr($cliArgument, 2));
                }
                break;
            }

Review comment (suggestion):
```suggestion
            foreach (['.xml', '.xml.dist', '.dist.xml'] as $suffix) {
                if (file_exists($candidate = $probableConfig.$suffix)) {
```

Code after:
error_reporting(-1);

global $argv, $argc;
$argv = $_SERVER['argv'] ?? [];
$argc = $_SERVER['argc'] ?? 0;
$getEnvVar = static function ($name, $default = false) use ($argv) {
    if (false !== $value = getenv($name)) {
        return $value;
    }

    static $phpunitConfig = null;
    if (null === $phpunitConfig) {
        $phpunitConfigFilename = null;
        $getPhpUnitConfig = static function ($probableConfig) use (&$getPhpUnitConfig) {
            if (!$probableConfig) {
                return null;
            }

            if (is_dir($probableConfig)) {
                return $getPhpUnitConfig($probableConfig.\DIRECTORY_SEPARATOR.'phpunit');
            }

            foreach (['.xml', '.xml.dist', '.dist.xml'] as $suffix) {
                if (file_exists($candidate = $probableConfig.$suffix)) {
                    return $candidate;
                }
            }

            return null;
        };

        foreach ($argv as $cliArgumentIndex => $cliArgument) {
            if ('--' === $cliArgument) {
                break;
            }
            // long option
            if ('--configuration' === $cliArgument && array_key_exists($cliArgumentIndex + 1, $argv)) {
                $phpunitConfigFilename = $getPhpUnitConfig($argv[$cliArgumentIndex + 1]);
                break;
            }
            // short option
            if (str_starts_with($cliArgument, '-c')) {
                if ('-c' === $cliArgument && array_key_exists($cliArgumentIndex + 1, $argv)) {
                    $phpunitConfigFilename = $getPhpUnitConfig($argv[$cliArgumentIndex + 1]);
                } else {
                    $phpunitConfigFilename = $getPhpUnitConfig(substr($cliArgument, 2));
                }
                break;
            }
        }