Browse Source

feat: Add sprintf in the list of compiler optimized functions (#8092)

Christophe Coevoet 8 months ago
parent
commit
1251948699

+ 3 - 3
src/Cache/Cache.php

@@ -76,7 +76,7 @@ final class Cache implements CacheInterface
         ]);
         ]);
 
 
         if (JSON_ERROR_NONE !== json_last_error() || false === $json) {
         if (JSON_ERROR_NONE !== json_last_error() || false === $json) {
-            throw new \UnexpectedValueException(sprintf(
+            throw new \UnexpectedValueException(\sprintf(
                 'Cannot encode cache signature to JSON, error: "%s". If you have non-UTF8 chars in your signature, like in license for `header_comment`, consider enabling `ext-mbstring` or install `symfony/polyfill-mbstring`.',
                 'Cannot encode cache signature to JSON, error: "%s". If you have non-UTF8 chars in your signature, like in license for `header_comment`, consider enabling `ext-mbstring` or install `symfony/polyfill-mbstring`.',
                 json_last_error_msg()
                 json_last_error_msg()
             ));
             ));
@@ -93,7 +93,7 @@ final class Cache implements CacheInterface
         $data = json_decode($json, true);
         $data = json_decode($json, true);
 
 
         if (null === $data && JSON_ERROR_NONE !== json_last_error()) {
         if (null === $data && JSON_ERROR_NONE !== json_last_error()) {
-            throw new \InvalidArgumentException(sprintf(
+            throw new \InvalidArgumentException(\sprintf(
                 'Value needs to be a valid JSON string, got "%s", error: "%s".',
                 'Value needs to be a valid JSON string, got "%s", error: "%s".',
                 $json,
                 $json,
                 json_last_error_msg()
                 json_last_error_msg()
@@ -112,7 +112,7 @@ final class Cache implements CacheInterface
         $missingKeys = array_diff_key(array_flip($requiredKeys), $data);
         $missingKeys = array_diff_key(array_flip($requiredKeys), $data);
 
 
         if (\count($missingKeys) > 0) {
         if (\count($missingKeys) > 0) {
-            throw new \InvalidArgumentException(sprintf(
+            throw new \InvalidArgumentException(\sprintf(
                 'JSON data is missing keys %s',
                 'JSON data is missing keys %s',
                 Utils::naturalLanguageJoin(array_keys($missingKeys))
                 Utils::naturalLanguageJoin(array_keys($missingKeys))
             ));
             ));

+ 3 - 3
src/Cache/FileHandler.php

@@ -140,7 +140,7 @@ final class FileHandler implements FileHandlerInterface
 
 
         if ($this->fileInfo->isDir()) {
         if ($this->fileInfo->isDir()) {
             throw new IOException(
             throw new IOException(
-                sprintf('Cannot write cache file "%s" as the location exists as directory.', $this->fileInfo->getRealPath()),
+                \sprintf('Cannot write cache file "%s" as the location exists as directory.', $this->fileInfo->getRealPath()),
                 0,
                 0,
                 null,
                 null,
                 $this->fileInfo->getPathname()
                 $this->fileInfo->getPathname()
@@ -149,7 +149,7 @@ final class FileHandler implements FileHandlerInterface
 
 
         if ($this->fileInfo->isFile() && !$this->fileInfo->isWritable()) {
         if ($this->fileInfo->isFile() && !$this->fileInfo->isWritable()) {
             throw new IOException(
             throw new IOException(
-                sprintf('Cannot write to file "%s" as it is not writable.', $this->fileInfo->getRealPath()),
+                \sprintf('Cannot write to file "%s" as it is not writable.', $this->fileInfo->getRealPath()),
                 0,
                 0,
                 null,
                 null,
                 $this->fileInfo->getPathname()
                 $this->fileInfo->getPathname()
@@ -171,7 +171,7 @@ final class FileHandler implements FileHandlerInterface
 
 
         if (!@is_dir($dir)) {
         if (!@is_dir($dir)) {
             throw new IOException(
             throw new IOException(
-                sprintf('Directory of cache file "%s" does not exists and couldn\'t be created.', $file),
+                \sprintf('Directory of cache file "%s" does not exists and couldn\'t be created.', $file),
                 0,
                 0,
                 null,
                 null,
                 $file
                 $file

+ 1 - 1
src/ConfigurationException/InvalidFixerConfigurationException.php

@@ -30,7 +30,7 @@ class InvalidFixerConfigurationException extends InvalidConfigurationException
     public function __construct(string $fixerName, string $message, ?\Throwable $previous = null)
     public function __construct(string $fixerName, string $message, ?\Throwable $previous = null)
     {
     {
         parent::__construct(
         parent::__construct(
-            sprintf('[%s] %s', $fixerName, $message),
+            \sprintf('[%s] %s', $fixerName, $message),
             FixCommandExitStatusCalculator::EXIT_STATUS_FLAG_HAS_INVALID_FIXER_CONFIG,
             FixCommandExitStatusCalculator::EXIT_STATUS_FLAG_HAS_INVALID_FIXER_CONFIG,
             $previous
             $previous
         );
         );

+ 5 - 5
src/Console/Application.php

@@ -89,7 +89,7 @@ final class Application extends BaseApplication
 
 
             if (\count($warnings) > 0) {
             if (\count($warnings) > 0) {
                 foreach ($warnings as $warning) {
                 foreach ($warnings as $warning) {
-                    $stdErr->writeln(sprintf($stdErr->isDecorated() ? '<bg=yellow;fg=black;>%s</>' : '%s', $warning));
+                    $stdErr->writeln(\sprintf($stdErr->isDecorated() ? '<bg=yellow;fg=black;>%s</>' : '%s', $warning));
                 }
                 }
                 $stdErr->writeln('');
                 $stdErr->writeln('');
             }
             }
@@ -107,7 +107,7 @@ final class Application extends BaseApplication
                 $stdErr->writeln('');
                 $stdErr->writeln('');
                 $stdErr->writeln($stdErr->isDecorated() ? '<bg=yellow;fg=black;>Detected deprecations in use:</>' : 'Detected deprecations in use:');
                 $stdErr->writeln($stdErr->isDecorated() ? '<bg=yellow;fg=black;>Detected deprecations in use:</>' : 'Detected deprecations in use:');
                 foreach ($triggeredDeprecations as $deprecation) {
                 foreach ($triggeredDeprecations as $deprecation) {
-                    $stdErr->writeln(sprintf('- %s', $deprecation));
+                    $stdErr->writeln(\sprintf('- %s', $deprecation));
                 }
                 }
             }
             }
         }
         }
@@ -120,7 +120,7 @@ final class Application extends BaseApplication
      */
      */
     public static function getAbout(bool $decorated = false): string
     public static function getAbout(bool $decorated = false): string
     {
     {
-        $longVersion = sprintf('%s <info>%s</info>', self::NAME, self::VERSION);
+        $longVersion = \sprintf('%s <info>%s</info>', self::NAME, self::VERSION);
 
 
         $commit = '@git-commit@';
         $commit = '@git-commit@';
         $versionCommit = '';
         $versionCommit = '';
@@ -131,8 +131,8 @@ final class Application extends BaseApplication
 
 
         $about = implode('', [
         $about = implode('', [
             $longVersion,
             $longVersion,
-            $versionCommit ? sprintf(' <info>(%s)</info>', $versionCommit) : '', // @phpstan-ignore-line to avoid `Ternary operator condition is always true|false.`
-            self::VERSION_CODENAME ? sprintf(' <info>%s</info>', self::VERSION_CODENAME) : '', // @phpstan-ignore-line to avoid `Ternary operator condition is always true|false.`
+            $versionCommit ? \sprintf(' <info>(%s)</info>', $versionCommit) : '', // @phpstan-ignore-line to avoid `Ternary operator condition is always true|false.`
+            self::VERSION_CODENAME ? \sprintf(' <info>%s</info>', self::VERSION_CODENAME) : '', // @phpstan-ignore-line to avoid `Ternary operator condition is always true|false.`
             ' by <comment>Fabien Potencier</comment>, <comment>Dariusz Ruminski</comment> and <comment>contributors</comment>.',
             ' by <comment>Fabien Potencier</comment>, <comment>Dariusz Ruminski</comment> and <comment>contributors</comment>.',
         ]);
         ]);
 
 

+ 20 - 20
src/Console/Command/DescribeCommand.php

@@ -131,7 +131,7 @@ final class DescribeCommand extends Command
 
 
             $this->describeList($output, $e->getType());
             $this->describeList($output, $e->getType());
 
 
-            throw new \InvalidArgumentException(sprintf(
+            throw new \InvalidArgumentException(\sprintf(
                 '%s "%s" not found.%s',
                 '%s "%s" not found.%s',
                 ucfirst($e->getType()),
                 ucfirst($e->getType()),
                 $name,
                 $name,
@@ -155,24 +155,24 @@ final class DescribeCommand extends Command
 
 
         $definition = $fixer->getDefinition();
         $definition = $fixer->getDefinition();
 
 
-        $output->writeln(sprintf('<fg=blue>Description of the <info>`%s`</info> rule.</>', $name));
+        $output->writeln(\sprintf('<fg=blue>Description of the <info>`%s`</info> rule.</>', $name));
         $output->writeln('');
         $output->writeln('');
 
 
         if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
         if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
-            $output->writeln(sprintf('Fixer class: <comment>%s</comment>.', \get_class($fixer)));
+            $output->writeln(\sprintf('Fixer class: <comment>%s</comment>.', \get_class($fixer)));
             $output->writeln('');
             $output->writeln('');
         }
         }
 
 
         if ($fixer instanceof DeprecatedFixerInterface) {
         if ($fixer instanceof DeprecatedFixerInterface) {
             $successors = $fixer->getSuccessorsNames();
             $successors = $fixer->getSuccessorsNames();
             $message = [] === $successors
             $message = [] === $successors
-                ? sprintf('it will be removed in version %d.0', Application::getMajorVersion() + 1)
-                : sprintf('use %s instead', Utils::naturalLanguageJoinWithBackticks($successors));
+                ? \sprintf('it will be removed in version %d.0', Application::getMajorVersion() + 1)
+                : \sprintf('use %s instead', Utils::naturalLanguageJoinWithBackticks($successors));
 
 
             $endMessage = '. '.ucfirst($message);
             $endMessage = '. '.ucfirst($message);
             Utils::triggerDeprecation(new \RuntimeException(str_replace('`', '"', "Rule \"{$name}\" is deprecated{$endMessage}.")));
             Utils::triggerDeprecation(new \RuntimeException(str_replace('`', '"', "Rule \"{$name}\" is deprecated{$endMessage}.")));
             $message = Preg::replace('/(`[^`]+`)/', '<info>$1</info>', $message);
             $message = Preg::replace('/(`[^`]+`)/', '<info>$1</info>', $message);
-            $output->writeln(sprintf('<error>DEPRECATED</error>: %s.', $message));
+            $output->writeln(\sprintf('<error>DEPRECATED</error>: %s.', $message));
             $output->writeln('');
             $output->writeln('');
         }
         }
 
 
@@ -216,7 +216,7 @@ final class DescribeCommand extends Command
             $configurationDefinition = $fixer->getConfigurationDefinition();
             $configurationDefinition = $fixer->getConfigurationDefinition();
             $options = $configurationDefinition->getOptions();
             $options = $configurationDefinition->getOptions();
 
 
-            $output->writeln(sprintf('Fixer is configurable using following option%s:', 1 === \count($options) ? '' : 's'));
+            $output->writeln(\sprintf('Fixer is configurable using following option%s:', 1 === \count($options) ? '' : 's'));
 
 
             foreach ($options as $option) {
             foreach ($options as $option) {
                 $line = '* <info>'.OutputFormatter::escape($option->getName()).'</info>';
                 $line = '* <info>'.OutputFormatter::escape($option->getName()).'</info>';
@@ -239,7 +239,7 @@ final class DescribeCommand extends Command
                 $line .= ': '.lcfirst(Preg::replace('/\.$/', '', $description)).'; ';
                 $line .= ': '.lcfirst(Preg::replace('/\.$/', '', $description)).'; ';
 
 
                 if ($option->hasDefault()) {
                 if ($option->hasDefault()) {
-                    $line .= sprintf(
+                    $line .= \sprintf(
                         'defaults to <comment>%s</comment>',
                         'defaults to <comment>%s</comment>',
                         Utils::toString($option->getDefault())
                         Utils::toString($option->getDefault())
                     );
                     );
@@ -290,7 +290,7 @@ final class DescribeCommand extends Command
             $differ = new FullDiffer();
             $differ = new FullDiffer();
             $diffFormatter = new DiffConsoleFormatter(
             $diffFormatter = new DiffConsoleFormatter(
                 $output->isDecorated(),
                 $output->isDecorated(),
-                sprintf(
+                \sprintf(
                     '<comment>   ---------- begin diff ----------</comment>%s%%s%s<comment>   ----------- end diff -----------</comment>',
                     '<comment>   ---------- begin diff ----------</comment>%s%%s%s<comment>   ----------- end diff -----------</comment>',
                     PHP_EOL,
                     PHP_EOL,
                     PHP_EOL
                     PHP_EOL
@@ -317,12 +317,12 @@ final class DescribeCommand extends Command
 
 
                 if ($fixer instanceof ConfigurableFixerInterface) {
                 if ($fixer instanceof ConfigurableFixerInterface) {
                     if (null === $configuration) {
                     if (null === $configuration) {
-                        $output->writeln(sprintf(' * Example #%d. Fixing with the <comment>default</comment> configuration.', $index + 1));
+                        $output->writeln(\sprintf(' * Example #%d. Fixing with the <comment>default</comment> configuration.', $index + 1));
                     } else {
                     } else {
-                        $output->writeln(sprintf(' * Example #%d. Fixing with configuration: <comment>%s</comment>.', $index + 1, Utils::toString($codeSample->getConfiguration())));
+                        $output->writeln(\sprintf(' * Example #%d. Fixing with configuration: <comment>%s</comment>.', $index + 1, Utils::toString($codeSample->getConfiguration())));
                     }
                     }
                 } else {
                 } else {
-                    $output->writeln(sprintf(' * Example #%d.', $index + 1));
+                    $output->writeln(\sprintf(' * Example #%d.', $index + 1));
                 }
                 }
 
 
                 $output->writeln([$diffFormatter->format($diff, '   %s'), '']);
                 $output->writeln([$diffFormatter->format($diff, '   %s'), '']);
@@ -338,9 +338,9 @@ final class DescribeCommand extends Command
 
 
             foreach ($ruleSetConfigs as $set => $config) {
             foreach ($ruleSetConfigs as $set => $config) {
                 if (null !== $config) {
                 if (null !== $config) {
-                    $output->writeln(sprintf('* <info>%s</info> with config: <comment>%s</comment>', $set, Utils::toString($config)));
+                    $output->writeln(\sprintf('* <info>%s</info> with config: <comment>%s</comment>', $set, Utils::toString($config)));
                 } else {
                 } else {
-                    $output->writeln(sprintf('* <info>%s</info> with <comment>default</comment> config', $set));
+                    $output->writeln(\sprintf('* <info>%s</info> with <comment>default</comment> config', $set));
                 }
                 }
             }
             }
 
 
@@ -357,7 +357,7 @@ final class DescribeCommand extends Command
         $ruleSetDefinitions = RuleSets::getSetDefinitions();
         $ruleSetDefinitions = RuleSets::getSetDefinitions();
         $fixers = $this->getFixers();
         $fixers = $this->getFixers();
 
 
-        $output->writeln(sprintf('<fg=blue>Description of the <info>`%s`</info> set.</>', $ruleSetDefinitions[$name]->getName()));
+        $output->writeln(\sprintf('<fg=blue>Description of the <info>`%s`</info> set.</>', $ruleSetDefinitions[$name]->getName()));
         $output->writeln('');
         $output->writeln('');
 
 
         $output->writeln($this->replaceRstLinks($ruleSetDefinitions[$name]->getDescription()));
         $output->writeln($this->replaceRstLinks($ruleSetDefinitions[$name]->getDescription()));
@@ -373,7 +373,7 @@ final class DescribeCommand extends Command
         foreach ($ruleSetDefinitions[$name]->getRules() as $rule => $config) {
         foreach ($ruleSetDefinitions[$name]->getRules() as $rule => $config) {
             if (str_starts_with($rule, '@')) {
             if (str_starts_with($rule, '@')) {
                 $set = $ruleSetDefinitions[$rule];
                 $set = $ruleSetDefinitions[$rule];
-                $help .= sprintf(
+                $help .= \sprintf(
                     " * <info>%s</info>%s\n   | %s\n\n",
                     " * <info>%s</info>%s\n   | %s\n\n",
                     $rule,
                     $rule,
                     $set->isRisky() ? ' <error>risky</error>' : '',
                     $set->isRisky() ? ' <error>risky</error>' : '',
@@ -387,12 +387,12 @@ final class DescribeCommand extends Command
             $fixer = $fixers[$rule];
             $fixer = $fixers[$rule];
 
 
             $definition = $fixer->getDefinition();
             $definition = $fixer->getDefinition();
-            $help .= sprintf(
+            $help .= \sprintf(
                 " * <info>%s</info>%s\n   | %s\n%s\n",
                 " * <info>%s</info>%s\n   | %s\n%s\n",
                 $rule,
                 $rule,
                 $fixer->isRisky() ? ' <error>risky</error>' : '',
                 $fixer->isRisky() ? ' <error>risky</error>' : '',
                 $definition->getSummary(),
                 $definition->getSummary(),
-                true !== $config ? sprintf("   <comment>| Configuration: %s</comment>\n", Utils::toString($config)) : ''
+                true !== $config ? \sprintf("   <comment>| Configuration: %s</comment>\n", Utils::toString($config)) : ''
             );
             );
         }
         }
 
 
@@ -448,7 +448,7 @@ final class DescribeCommand extends Command
 
 
             $items = $this->getSetNames();
             $items = $this->getSetNames();
             foreach ($items as $item) {
             foreach ($items as $item) {
-                $output->writeln(sprintf('* <info>%s</info>', $item));
+                $output->writeln(\sprintf('* <info>%s</info>', $item));
             }
             }
         }
         }
 
 
@@ -457,7 +457,7 @@ final class DescribeCommand extends Command
 
 
             $items = array_keys($this->getFixers());
             $items = array_keys($this->getFixers());
             foreach ($items as $item) {
             foreach ($items as $item) {
-                $output->writeln(sprintf('* <info>%s</info>', $item));
+                $output->writeln(\sprintf('* <info>%s</info>', $item));
             }
             }
         }
         }
     }
     }

+ 8 - 8
src/Console/Command/FixCommand.php

@@ -263,10 +263,10 @@ use Symfony\Component\Stopwatch\Stopwatch;
             $stdErr->writeln(Application::getAboutWithRuntime(true));
             $stdErr->writeln(Application::getAboutWithRuntime(true));
             $isParallel = $resolver->getParallelConfig()->getMaxProcesses() > 1;
             $isParallel = $resolver->getParallelConfig()->getMaxProcesses() > 1;
 
 
-            $stdErr->writeln(sprintf(
+            $stdErr->writeln(\sprintf(
                 'Running analysis on %d core%s.',
                 'Running analysis on %d core%s.',
                 $resolver->getParallelConfig()->getMaxProcesses(),
                 $resolver->getParallelConfig()->getMaxProcesses(),
-                $isParallel ? sprintf(
+                $isParallel ? \sprintf(
                     's with %d file%s per process',
                     's with %d file%s per process',
                     $resolver->getParallelConfig()->getFilesPerProcess(),
                     $resolver->getParallelConfig()->getFilesPerProcess(),
                     $resolver->getParallelConfig()->getFilesPerProcess() > 1 ? 's' : ''
                     $resolver->getParallelConfig()->getFilesPerProcess() > 1 ? 's' : ''
@@ -275,26 +275,26 @@ use Symfony\Component\Stopwatch\Stopwatch;
 
 
             /** @TODO v4 remove warnings related to parallel runner */
             /** @TODO v4 remove warnings related to parallel runner */
             $usageDocs = 'https://cs.symfony.com/doc/usage.html';
             $usageDocs = 'https://cs.symfony.com/doc/usage.html';
-            $stdErr->writeln(sprintf(
+            $stdErr->writeln(\sprintf(
                 $stdErr->isDecorated() ? '<bg=yellow;fg=black;>%s</>' : '%s',
                 $stdErr->isDecorated() ? '<bg=yellow;fg=black;>%s</>' : '%s',
                 $isParallel
                 $isParallel
                     ? 'Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!'
                     ? 'Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!'
-                    : sprintf(
+                    : \sprintf(
                         'You can enable parallel runner and speed up the analysis! Please see %s for more information.',
                         'You can enable parallel runner and speed up the analysis! Please see %s for more information.',
                         $stdErr->isDecorated()
                         $stdErr->isDecorated()
-                            ? sprintf('<href=%s;bg=yellow;fg=red;bold>usage docs</>', OutputFormatter::escape($usageDocs))
+                            ? \sprintf('<href=%s;bg=yellow;fg=red;bold>usage docs</>', OutputFormatter::escape($usageDocs))
                             : $usageDocs
                             : $usageDocs
                     )
                     )
             ));
             ));
 
 
             $configFile = $resolver->getConfigFile();
             $configFile = $resolver->getConfigFile();
-            $stdErr->writeln(sprintf('Loaded config <comment>%s</comment>%s.', $resolver->getConfig()->getName(), null === $configFile ? '' : ' from "'.$configFile.'"'));
+            $stdErr->writeln(\sprintf('Loaded config <comment>%s</comment>%s.', $resolver->getConfig()->getName(), null === $configFile ? '' : ' from "'.$configFile.'"'));
 
 
             if ($resolver->getUsingCache()) {
             if ($resolver->getUsingCache()) {
                 $cacheFile = $resolver->getCacheFile();
                 $cacheFile = $resolver->getCacheFile();
 
 
                 if (is_file($cacheFile)) {
                 if (is_file($cacheFile)) {
-                    $stdErr->writeln(sprintf('Using cache file "%s".', $cacheFile));
+                    $stdErr->writeln(\sprintf('Using cache file "%s".', $cacheFile));
                 }
                 }
             }
             }
         }
         }
@@ -303,7 +303,7 @@ use Symfony\Component\Stopwatch\Stopwatch;
 
 
         if (null !== $stdErr && $resolver->configFinderIsOverridden()) {
         if (null !== $stdErr && $resolver->configFinderIsOverridden()) {
             $stdErr->writeln(
             $stdErr->writeln(
-                sprintf($stdErr->isDecorated() ? '<bg=yellow;fg=black;>%s</>' : '%s', 'Paths from configuration file have been overridden by paths provided as command arguments.')
+                \sprintf($stdErr->isDecorated() ? '<bg=yellow;fg=black;>%s</>' : '%s', 'Paths from configuration file have been overridden by paths provided as command arguments.')
             );
             );
         }
         }
 
 

+ 1 - 1
src/Console/Command/ListSetsCommand.php

@@ -80,7 +80,7 @@ final class ListSetsCommand extends Command
             $formats = $factory->getFormats();
             $formats = $factory->getFormats();
             sort($formats);
             sort($formats);
 
 
-            throw new InvalidConfigurationException(sprintf('The format "%s" is not defined, supported are %s.', $format, Utils::naturalLanguageJoin($formats)));
+            throw new InvalidConfigurationException(\sprintf('The format "%s" is not defined, supported are %s.', $format, Utils::naturalLanguageJoin($formats)));
         }
         }
 
 
         return $reporter;
         return $reporter;

+ 7 - 7
src/Console/Command/SelfUpdateCommand.php

@@ -102,7 +102,7 @@ final class SelfUpdateCommand extends Command
             $latestVersion = $this->versionChecker->getLatestVersion();
             $latestVersion = $this->versionChecker->getLatestVersion();
             $latestVersionOfCurrentMajor = $this->versionChecker->getLatestVersionOfMajor($currentMajor);
             $latestVersionOfCurrentMajor = $this->versionChecker->getLatestVersionOfMajor($currentMajor);
         } catch (\Exception $exception) {
         } catch (\Exception $exception) {
-            $output->writeln(sprintf(
+            $output->writeln(\sprintf(
                 '<error>Unable to determine newest version: %s</error>',
                 '<error>Unable to determine newest version: %s</error>',
                 $exception->getMessage()
                 $exception->getMessage()
             ));
             ));
@@ -122,8 +122,8 @@ final class SelfUpdateCommand extends Command
             0 !== $this->versionChecker->compareVersions($latestVersionOfCurrentMajor, $latestVersion)
             0 !== $this->versionChecker->compareVersions($latestVersionOfCurrentMajor, $latestVersion)
             && true !== $input->getOption('force')
             && true !== $input->getOption('force')
         ) {
         ) {
-            $output->writeln(sprintf('<info>A new major version of PHP CS Fixer is available</info> (<comment>%s</comment>)', $latestVersion));
-            $output->writeln(sprintf('<info>Before upgrading please read</info> https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/%s/UPGRADE-v%s.md', $latestVersion, $currentMajor + 1));
+            $output->writeln(\sprintf('<info>A new major version of PHP CS Fixer is available</info> (<comment>%s</comment>)', $latestVersion));
+            $output->writeln(\sprintf('<info>Before upgrading please read</info> https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/%s/UPGRADE-v%s.md', $latestVersion, $currentMajor + 1));
             $output->writeln('<info>If you are ready to upgrade run this command with</info> <comment>-f</comment>');
             $output->writeln('<info>If you are ready to upgrade run this command with</info> <comment>-f</comment>');
             $output->writeln('<info>Checking for new minor/patch version...</info>');
             $output->writeln('<info>Checking for new minor/patch version...</info>');
 
 
@@ -143,7 +143,7 @@ final class SelfUpdateCommand extends Command
         }
         }
 
 
         if (!is_writable($localFilename)) {
         if (!is_writable($localFilename)) {
-            $output->writeln(sprintf('<error>No permission to update</error> "%s" <error>file.</error>', $localFilename));
+            $output->writeln(\sprintf('<error>No permission to update</error> "%s" <error>file.</error>', $localFilename));
 
 
             return 1;
             return 1;
         }
         }
@@ -152,7 +152,7 @@ final class SelfUpdateCommand extends Command
         $remoteFilename = $this->toolInfo->getPharDownloadUri($remoteTag);
         $remoteFilename = $this->toolInfo->getPharDownloadUri($remoteTag);
 
 
         if (false === @copy($remoteFilename, $tempFilename)) {
         if (false === @copy($remoteFilename, $tempFilename)) {
-            $output->writeln(sprintf('<error>Unable to download new version</error> %s <error>from the server.</error>', $remoteTag));
+            $output->writeln(\sprintf('<error>Unable to download new version</error> %s <error>from the server.</error>', $remoteTag));
 
 
             return 1;
             return 1;
         }
         }
@@ -162,7 +162,7 @@ final class SelfUpdateCommand extends Command
         $pharInvalidityReason = $this->pharChecker->checkFileValidity($tempFilename);
         $pharInvalidityReason = $this->pharChecker->checkFileValidity($tempFilename);
         if (null !== $pharInvalidityReason) {
         if (null !== $pharInvalidityReason) {
             unlink($tempFilename);
             unlink($tempFilename);
-            $output->writeln(sprintf('<error>The download of</error> %s <error>is corrupt (%s).</error>', $remoteTag, $pharInvalidityReason));
+            $output->writeln(\sprintf('<error>The download of</error> %s <error>is corrupt (%s).</error>', $remoteTag, $pharInvalidityReason));
             $output->writeln('<error>Please re-run the "self-update" command to try again.</error>');
             $output->writeln('<error>Please re-run the "self-update" command to try again.</error>');
 
 
             return 1;
             return 1;
@@ -170,7 +170,7 @@ final class SelfUpdateCommand extends Command
 
 
         rename($tempFilename, $localFilename);
         rename($tempFilename, $localFilename);
 
 
-        $output->writeln(sprintf('<info>PHP CS Fixer updated</info> (<comment>%s</comment> -> <comment>%s</comment>)', $currentVersion, $remoteTag));
+        $output->writeln(\sprintf('<info>PHP CS Fixer updated</info> (<comment>%s</comment> -> <comment>%s</comment>)', $currentVersion, $remoteTag));
 
 
         return 0;
         return 0;
     }
     }

+ 2 - 2
src/Console/Command/WorkerCommand.php

@@ -110,7 +110,7 @@ final class WorkerCommand extends Command
         $loop = new StreamSelectLoop();
         $loop = new StreamSelectLoop();
         $tcpConnector = new TcpConnector($loop);
         $tcpConnector = new TcpConnector($loop);
         $tcpConnector
         $tcpConnector
-            ->connect(sprintf('127.0.0.1:%d', $port))
+            ->connect(\sprintf('127.0.0.1:%d', $port))
             ->then(
             ->then(
                 /** @codeCoverageIgnore */
                 /** @codeCoverageIgnore */
                 function (ConnectionInterface $connection) use ($loop, $runner, $identifier): void {
                 function (ConnectionInterface $connection) use ($loop, $runner, $identifier): void {
@@ -148,7 +148,7 @@ final class WorkerCommand extends Command
 
 
                         if (ParallelAction::RUNNER_REQUEST_ANALYSIS !== $action) {
                         if (ParallelAction::RUNNER_REQUEST_ANALYSIS !== $action) {
                             // At this point we only expect analysis requests, if any other action happen, we need to fix the code.
                             // At this point we only expect analysis requests, if any other action happen, we need to fix the code.
-                            throw new \LogicException(sprintf('Unexpected action ParallelAction::%s.', $action));
+                            throw new \LogicException(\sprintf('Unexpected action ParallelAction::%s.', $action));
                         }
                         }
 
 
                         /** @var iterable<int, string> $files */
                         /** @var iterable<int, string> $files */

+ 16 - 16
src/Console/ConfigurationResolver.php

@@ -348,7 +348,7 @@ final class ConfigurationResolver
                 );
                 );
 
 
                 if (\count($riskyFixers) > 0) {
                 if (\count($riskyFixers) > 0) {
-                    throw new InvalidConfigurationException(sprintf('The rules contain risky fixers (%s), but they are not allowed to run. Perhaps you forget to use --allow-risky=yes option?', Utils::naturalLanguageJoin($riskyFixers)));
+                    throw new InvalidConfigurationException(\sprintf('The rules contain risky fixers (%s), but they are not allowed to run. Perhaps you forget to use --allow-risky=yes option?', Utils::naturalLanguageJoin($riskyFixers)));
                 }
                 }
             }
             }
         }
         }
@@ -392,7 +392,7 @@ final class ConfigurationResolver
                             : $cwd.\DIRECTORY_SEPARATOR.$path;
                             : $cwd.\DIRECTORY_SEPARATOR.$path;
 
 
                         if (!file_exists($absolutePath)) {
                         if (!file_exists($absolutePath)) {
-                            throw new InvalidConfigurationException(sprintf(
+                            throw new InvalidConfigurationException(\sprintf(
                                 'The path "%s" is not readable.',
                                 'The path "%s" is not readable.',
                                 $path
                                 $path
                             ));
                             ));
@@ -422,7 +422,7 @@ final class ConfigurationResolver
                         ? ProgressOutputType::NONE
                         ? ProgressOutputType::NONE
                         : ProgressOutputType::BAR;
                         : ProgressOutputType::BAR;
                 } elseif (!\in_array($progressType, ProgressOutputType::all(), true)) {
                 } elseif (!\in_array($progressType, ProgressOutputType::all(), true)) {
-                    throw new InvalidConfigurationException(sprintf(
+                    throw new InvalidConfigurationException(\sprintf(
                         'The progress type "%s" is not defined, supported are %s.',
                         'The progress type "%s" is not defined, supported are %s.',
                         $progressType,
                         $progressType,
                         Utils::naturalLanguageJoin(ProgressOutputType::all())
                         Utils::naturalLanguageJoin(ProgressOutputType::all())
@@ -452,7 +452,7 @@ final class ConfigurationResolver
                 $formats = $reporterFactory->getFormats();
                 $formats = $reporterFactory->getFormats();
                 sort($formats);
                 sort($formats);
 
 
-                throw new InvalidConfigurationException(sprintf('The format "%s" is not defined, supported are %s.', $format, Utils::naturalLanguageJoin($formats)));
+                throw new InvalidConfigurationException(\sprintf('The format "%s" is not defined, supported are %s.', $format, Utils::naturalLanguageJoin($formats)));
             }
             }
         }
         }
 
 
@@ -551,7 +551,7 @@ final class ConfigurationResolver
 
 
         if (null !== $configFile) {
         if (null !== $configFile) {
             if (false === file_exists($configFile) || false === is_readable($configFile)) {
             if (false === file_exists($configFile) || false === is_readable($configFile)) {
-                throw new InvalidConfigurationException(sprintf('Cannot read config file "%s".', $configFile));
+                throw new InvalidConfigurationException(\sprintf('Cannot read config file "%s".', $configFile));
             }
             }
 
 
             return [$configFile];
             return [$configFile];
@@ -660,7 +660,7 @@ final class ConfigurationResolver
             $rules = json_decode($rules, true);
             $rules = json_decode($rules, true);
 
 
             if (JSON_ERROR_NONE !== json_last_error()) {
             if (JSON_ERROR_NONE !== json_last_error()) {
-                throw new InvalidConfigurationException(sprintf('Invalid JSON rules input: "%s".', json_last_error_msg()));
+                throw new InvalidConfigurationException(\sprintf('Invalid JSON rules input: "%s".', json_last_error_msg()));
             }
             }
 
 
             return $rules;
             return $rules;
@@ -701,7 +701,7 @@ final class ConfigurationResolver
 
 
         foreach ($rules as $key => $value) {
         foreach ($rules as $key => $value) {
             if (\is_int($key)) {
             if (\is_int($key)) {
-                throw new InvalidConfigurationException(sprintf('Missing value for "%s" rule/set.', $value));
+                throw new InvalidConfigurationException(\sprintf('Missing value for "%s" rule/set.', $value));
             }
             }
 
 
             $ruleSet[$key] = true;
             $ruleSet[$key] = true;
@@ -777,7 +777,7 @@ final class ConfigurationResolver
             foreach ($unknownFixers as $unknownFixer) {
             foreach ($unknownFixers as $unknownFixer) {
                 if (isset($renamedRules[$unknownFixer])) { // Check if present as old renamed rule
                 if (isset($renamedRules[$unknownFixer])) { // Check if present as old renamed rule
                     $hasOldRule = true;
                     $hasOldRule = true;
-                    $message .= sprintf(
+                    $message .= \sprintf(
                         '"%s" is renamed (did you mean "%s"?%s), ',
                         '"%s" is renamed (did you mean "%s"?%s), ',
                         $unknownFixer,
                         $unknownFixer,
                         $renamedRules[$unknownFixer]['new_name'],
                         $renamedRules[$unknownFixer]['new_name'],
@@ -786,7 +786,7 @@ final class ConfigurationResolver
                 } else { // Go to normal matcher if it is not a renamed rule
                 } else { // Go to normal matcher if it is not a renamed rule
                     $matcher = new WordMatcher($availableFixers);
                     $matcher = new WordMatcher($availableFixers);
                     $alternative = $matcher->match($unknownFixer);
                     $alternative = $matcher->match($unknownFixer);
-                    $message .= sprintf(
+                    $message .= \sprintf(
                         '"%s"%s, ',
                         '"%s"%s, ',
                         $unknownFixer,
                         $unknownFixer,
                         null === $alternative ? '' : ' (did you mean "'.$alternative.'"?)'
                         null === $alternative ? '' : ' (did you mean "'.$alternative.'"?)'
@@ -808,8 +808,8 @@ final class ConfigurationResolver
             if (isset($rules[$fixerName]) && $fixer instanceof DeprecatedFixerInterface) {
             if (isset($rules[$fixerName]) && $fixer instanceof DeprecatedFixerInterface) {
                 $successors = $fixer->getSuccessorsNames();
                 $successors = $fixer->getSuccessorsNames();
                 $messageEnd = [] === $successors
                 $messageEnd = [] === $successors
-                    ? sprintf(' and will be removed in version %d.0.', Application::getMajorVersion() + 1)
-                    : sprintf('. Use %s instead.', str_replace('`', '"', Utils::naturalLanguageJoinWithBackticks($successors)));
+                    ? \sprintf(' and will be removed in version %d.0.', Application::getMajorVersion() + 1)
+                    : \sprintf('. Use %s instead.', str_replace('`', '"', Utils::naturalLanguageJoinWithBackticks($successors)));
 
 
                 Utils::triggerDeprecation(new \RuntimeException("Rule \"{$fixerName}\" is deprecated{$messageEnd}"));
                 Utils::triggerDeprecation(new \RuntimeException("Rule \"{$fixerName}\" is deprecated{$messageEnd}"));
             }
             }
@@ -836,7 +836,7 @@ final class ConfigurationResolver
             $modes,
             $modes,
             true
             true
         )) {
         )) {
-            throw new InvalidConfigurationException(sprintf(
+            throw new InvalidConfigurationException(\sprintf(
                 'The path-mode "%s" is not defined, supported are %s.',
                 'The path-mode "%s" is not defined, supported are %s.',
                 $this->options['path-mode'],
                 $this->options['path-mode'],
                 Utils::naturalLanguageJoin($modes)
                 Utils::naturalLanguageJoin($modes)
@@ -926,7 +926,7 @@ final class ConfigurationResolver
     private function setOption(string $name, $value): void
     private function setOption(string $name, $value): void
     {
     {
         if (!\array_key_exists($name, $this->options)) {
         if (!\array_key_exists($name, $this->options)) {
-            throw new InvalidConfigurationException(sprintf('Unknown option name: "%s".', $name));
+            throw new InvalidConfigurationException(\sprintf('Unknown option name: "%s".', $name));
         }
         }
 
 
         $this->options[$name] = $value;
         $this->options[$name] = $value;
@@ -937,7 +937,7 @@ final class ConfigurationResolver
         $value = $this->options[$optionName];
         $value = $this->options[$optionName];
 
 
         if (!\is_string($value)) {
         if (!\is_string($value)) {
-            throw new InvalidConfigurationException(sprintf('Expected boolean or string value for option "%s".', $optionName));
+            throw new InvalidConfigurationException(\sprintf('Expected boolean or string value for option "%s".', $optionName));
         }
         }
 
 
         if ('yes' === $value) {
         if ('yes' === $value) {
@@ -948,7 +948,7 @@ final class ConfigurationResolver
             return false;
             return false;
         }
         }
 
 
-        throw new InvalidConfigurationException(sprintf('Expected "yes" or "no" for option "%s", got "%s".', $optionName, $value));
+        throw new InvalidConfigurationException(\sprintf('Expected "yes" or "no" for option "%s", got "%s".', $optionName, $value));
     }
     }
 
 
     private static function separatedContextLessInclude(string $path): ConfigInterface
     private static function separatedContextLessInclude(string $path): ConfigInterface
@@ -957,7 +957,7 @@ final class ConfigurationResolver
 
 
         // verify that the config has an instance of Config
         // verify that the config has an instance of Config
         if (!$config instanceof ConfigInterface) {
         if (!$config instanceof ConfigInterface) {
-            throw new InvalidConfigurationException(sprintf('The config file: "%s" does not return a "PhpCsFixer\ConfigInterface" instance. Got: "%s".', $path, \is_object($config) ? \get_class($config) : \gettype($config)));
+            throw new InvalidConfigurationException(\sprintf('The config file: "%s" does not return a "PhpCsFixer\ConfigInterface" instance. Got: "%s".', $path, \is_object($config) ? \get_class($config) : \gettype($config)));
         }
         }
 
 
         return $config;
         return $config;

Some files were not shown because too many files changed in this diff