N°8834 - Add compatibility with PHP 8.4 (#819)

* N°8834 - Add compatibility with PHP 8.4

* Rollback of scssphp/scssphp version upgrade due to compilation error
This commit is contained in:
Lenaick
2026-02-26 10:36:32 +01:00
committed by GitHub
parent d4821b7edc
commit fc967c06ce
961 changed files with 12298 additions and 7130 deletions

View File

@@ -117,7 +117,7 @@ abstract class AbstractConfigCommand extends ContainerDebugCommand
foreach ($bundles as $bundle) {
if ($name === $bundle->getName()) {
if (!$bundle->getContainerExtension()) {
throw new \LogicException(sprintf('Bundle "%s" does not have a container extension.', $name));
throw new \LogicException(\sprintf('Bundle "%s" does not have a container extension.', $name));
}
return $bundle->getContainerExtension();
@@ -147,13 +147,13 @@ abstract class AbstractConfigCommand extends ContainerDebugCommand
}
if (!str_ends_with($name, 'Bundle')) {
$message = sprintf('No extensions with configuration available for "%s".', $name);
$message = \sprintf('No extensions with configuration available for "%s".', $name);
} else {
$message = sprintf('No extension with alias "%s" is enabled.', $name);
$message = \sprintf('No extension with alias "%s" is enabled.', $name);
}
if (isset($guess) && $minScore < 3) {
$message .= sprintf("\n\nDid you mean \"%s\"?", $guess);
$message .= \sprintf("\n\nDid you mean \"%s\"?", $guess);
}
throw new LogicException($message);
@@ -165,11 +165,11 @@ abstract class AbstractConfigCommand extends ContainerDebugCommand
public function validateConfiguration(ExtensionInterface $extension, mixed $configuration)
{
if (!$configuration) {
throw new \LogicException(sprintf('The extension with alias "%s" does not have its getConfiguration() method setup.', $extension->getAlias()));
throw new \LogicException(\sprintf('The extension with alias "%s" does not have its getConfiguration() method setup.', $extension->getAlias()));
}
if (!$configuration instanceof ConfigurationInterface) {
throw new \LogicException(sprintf('Configuration class "%s" should implement ConfigurationInterface in order to be dumpable.', get_debug_type($configuration)));
throw new \LogicException(\sprintf('Configuration class "%s" should implement ConfigurationInterface in order to be dumpable.', get_debug_type($configuration)));
}
}

View File

@@ -97,7 +97,7 @@ EOT
$targetArg = $kernel->getProjectDir().'/'.$targetArg;
if (!is_dir($targetArg)) {
throw new InvalidArgumentException(sprintf('The target directory "%s" does not exist.', $targetArg));
throw new InvalidArgumentException(\sprintf('The target directory "%s" does not exist.', $targetArg));
}
}
@@ -134,7 +134,7 @@ EOT
$validAssetDirs[] = $assetDir;
if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
$message = sprintf("%s\n-> %s", $bundle->getName(), $targetDir);
$message = \sprintf("%s\n-> %s", $bundle->getName(), $targetDir);
} else {
$message = $bundle->getName();
}
@@ -155,13 +155,13 @@ EOT
}
if ($method === $expectedMethod) {
$rows[] = [sprintf('<fg=green;options=bold>%s</>', '\\' === \DIRECTORY_SEPARATOR ? 'OK' : "\xE2\x9C\x94" /* HEAVY CHECK MARK (U+2714) */), $message, $method];
$rows[] = [\sprintf('<fg=green;options=bold>%s</>', '\\' === \DIRECTORY_SEPARATOR ? 'OK' : "\xE2\x9C\x94" /* HEAVY CHECK MARK (U+2714) */), $message, $method];
} else {
$rows[] = [sprintf('<fg=yellow;options=bold>%s</>', '\\' === \DIRECTORY_SEPARATOR ? 'WARNING' : '!'), $message, $method];
$rows[] = [\sprintf('<fg=yellow;options=bold>%s</>', '\\' === \DIRECTORY_SEPARATOR ? 'WARNING' : '!'), $message, $method];
}
} catch (\Exception $e) {
$exitCode = 1;
$rows[] = [sprintf('<fg=red;options=bold>%s</>', '\\' === \DIRECTORY_SEPARATOR ? 'ERROR' : "\xE2\x9C\x98" /* HEAVY BALLOT X (U+2718) */), $message, $e->getMessage()];
$rows[] = [\sprintf('<fg=red;options=bold>%s</>', '\\' === \DIRECTORY_SEPARATOR ? 'ERROR' : "\xE2\x9C\x98" /* HEAVY BALLOT X (U+2718) */), $message, $e->getMessage()];
}
}
// remove the assets of the bundles that no longer exist
@@ -234,7 +234,7 @@ EOT
}
$this->filesystem->symlink($originDir, $targetDir);
if (!file_exists($targetDir)) {
throw new IOException(sprintf('Symbolic link "%s" was created but appears to be broken.', $targetDir), 0, null, $targetDir);
throw new IOException(\sprintf('Symbolic link "%s" was created but appears to be broken.', $targetDir), 0, null, $targetDir);
}
}

View File

@@ -40,7 +40,7 @@ class CacheClearCommand extends Command
private CacheClearerInterface $cacheClearer;
private Filesystem $filesystem;
public function __construct(CacheClearerInterface $cacheClearer, Filesystem $filesystem = null)
public function __construct(CacheClearerInterface $cacheClearer, ?Filesystem $filesystem = null)
{
parent::__construct();
@@ -80,7 +80,7 @@ EOF
$fs->remove($oldCacheDir);
if (!is_writable($realCacheDir)) {
throw new RuntimeException(sprintf('Unable to write in the "%s" directory.', $realCacheDir));
throw new RuntimeException(\sprintf('Unable to write in the "%s" directory.', $realCacheDir));
}
$useBuildDir = $realBuildDir !== $realCacheDir;
@@ -89,7 +89,7 @@ EOF
$fs->remove($oldBuildDir);
if (!is_writable($realBuildDir)) {
throw new RuntimeException(sprintf('Unable to write in the "%s" directory.', $realBuildDir));
throw new RuntimeException(\sprintf('Unable to write in the "%s" directory.', $realBuildDir));
}
if ($this->isNfs($realCacheDir)) {
@@ -100,7 +100,7 @@ EOF
$fs->mkdir($realCacheDir);
}
$io->comment(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
$io->comment(\sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
if ($useBuildDir) {
$this->cacheClearer->clear($realBuildDir);
}
@@ -146,6 +146,16 @@ EOF
}
$this->warmupOptionals($useBuildDir ? $realCacheDir : $warmupDir, $warmupDir, $io);
}
// fix references to cached files with the real cache directory name
$search = [$warmupDir, str_replace('/', '\\/', $warmupDir), str_replace('\\', '\\\\', $warmupDir)];
$replace = str_replace('\\', '/', $realBuildDir);
foreach (Finder::create()->files()->in($warmupDir) as $file) {
$content = str_replace($search, $replace, file_get_contents($file), $count);
if ($count) {
file_put_contents($file, $content);
}
}
}
if (!$fs->exists($warmupDir.'/'.$containerDir)) {
@@ -154,7 +164,7 @@ EOF
}
if ($this->isNfs($realBuildDir)) {
$io->note('For better performances, you should move the cache and log directories to a non-shared folder of the VM.');
$io->note('For better performance, you should move the cache and log directories to a non-shared folder of the VM.');
$fs->remove($realBuildDir);
} else {
$fs->rename($realBuildDir, $oldBuildDir);
@@ -189,7 +199,7 @@ EOF
$io->comment('Finished');
}
$io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully cleared.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
$io->success(\sprintf('Cache for the "%s" environment (debug=%s) was successfully cleared.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
return 0;
}
@@ -200,7 +210,7 @@ EOF
if (null === $mounts) {
$mounts = [];
if ('/' === \DIRECTORY_SEPARATOR && $files = @file('/proc/mounts')) {
if ('/' === \DIRECTORY_SEPARATOR && @is_readable('/proc/mounts') && $files = @file('/proc/mounts')) {
foreach ($files as $mount) {
$mount = \array_slice(explode(' ', $mount), 1, -3);
if (!\in_array(array_pop($mount), ['vboxsf', 'nfs'])) {
@@ -227,16 +237,6 @@ EOF
throw new \LogicException('Calling "cache:clear" with a kernel that does not implement "Symfony\Component\HttpKernel\RebootableInterface" is not supported.');
}
$kernel->reboot($warmupDir);
// fix references to cached files with the real cache directory name
$search = [$warmupDir, str_replace('\\', '\\\\', $warmupDir)];
$replace = str_replace('\\', '/', $realBuildDir);
foreach (Finder::create()->files()->in($warmupDir) as $file) {
$content = str_replace($search, $replace, file_get_contents($file), $count);
if ($count) {
file_put_contents($file, $content);
}
}
}
private function warmupOptionals(string $cacheDir, string $warmupDir, SymfonyStyle $io): void

View File

@@ -38,7 +38,7 @@ final class CachePoolClearCommand extends Command
/**
* @param string[]|null $poolNames
*/
public function __construct(Psr6CacheClearer $poolClearer, array $poolNames = null)
public function __construct(Psr6CacheClearer $poolClearer, ?array $poolNames = null)
{
parent::__construct();
@@ -72,7 +72,7 @@ EOF
$poolNames = $input->getArgument('pools');
$excludedPoolNames = $input->getOption('exclude');
if ($input->getOption('all')) {
if ($clearAll = $input->getOption('all')) {
if (!$this->poolNames) {
throw new InvalidArgumentException('Could not clear all cache pools, try specifying a specific pool or cache clearer.');
}
@@ -91,7 +91,7 @@ EOF
foreach ($poolNames as $id) {
if ($this->poolClearer->hasPool($id)) {
$pools[$id] = $id;
} else {
} elseif (!$clearAll || $kernel->getContainer()->has($id)) {
$pool = $kernel->getContainer()->get($id);
if ($pool instanceof CacheItemPoolInterface) {
@@ -99,28 +99,28 @@ EOF
} elseif ($pool instanceof Psr6CacheClearer) {
$clearers[$id] = $pool;
} else {
throw new InvalidArgumentException(sprintf('"%s" is not a cache pool nor a cache clearer.', $id));
throw new InvalidArgumentException(\sprintf('"%s" is not a cache pool nor a cache clearer.', $id));
}
}
}
foreach ($clearers as $id => $clearer) {
$io->comment(sprintf('Calling cache clearer: <info>%s</info>', $id));
$io->comment(\sprintf('Calling cache clearer: <info>%s</info>', $id));
$clearer->clear($kernel->getContainer()->getParameter('kernel.cache_dir'));
}
$failure = false;
foreach ($pools as $id => $pool) {
$io->comment(sprintf('Clearing cache pool: <info>%s</info>', $id));
$io->comment(\sprintf('Clearing cache pool: <info>%s</info>', $id));
if ($pool instanceof CacheItemPoolInterface) {
if (!$pool->clear()) {
$io->warning(sprintf('Cache pool "%s" could not be cleared.', $pool));
$io->warning(\sprintf('Cache pool "%s" could not be cleared.', $pool));
$failure = true;
}
} else {
if (false === $this->poolClearer->clearPool($id)) {
$io->warning(sprintf('Cache pool "%s" could not be cleared.', $pool));
$io->warning(\sprintf('Cache pool "%s" could not be cleared.', $pool));
$failure = true;
}
}

View File

@@ -35,7 +35,7 @@ final class CachePoolDeleteCommand extends Command
/**
* @param string[]|null $poolNames
*/
public function __construct(Psr6CacheClearer $poolClearer, array $poolNames = null)
public function __construct(Psr6CacheClearer $poolClearer, ?array $poolNames = null)
{
parent::__construct();
@@ -67,16 +67,16 @@ EOF
$cachePool = $this->poolClearer->getPool($pool);
if (!$cachePool->hasItem($key)) {
$io->note(sprintf('Cache item "%s" does not exist in cache pool "%s".', $key, $pool));
$io->note(\sprintf('Cache item "%s" does not exist in cache pool "%s".', $key, $pool));
return 0;
}
if (!$cachePool->deleteItem($key)) {
throw new \Exception(sprintf('Cache item "%s" could not be deleted.', $key));
throw new \Exception(\sprintf('Cache item "%s" could not be deleted.', $key));
}
$io->success(sprintf('Cache item "%s" was successfully deleted.', $key));
$io->success(\sprintf('Cache item "%s" was successfully deleted.', $key));
return 0;
}

View File

@@ -65,26 +65,26 @@ final class CachePoolInvalidateTagsCommand extends Command
$errors = false;
foreach ($pools as $name) {
$io->comment(sprintf('Invalidating tag(s): <info>%s</info> from pool <comment>%s</comment>.', $tagList, $name));
$io->comment(\sprintf('Invalidating tag(s): <info>%s</info> from pool <comment>%s</comment>.', $tagList, $name));
try {
$pool = $this->pools->get($name);
} catch (ServiceNotFoundException) {
$io->error(sprintf('Pool "%s" not found.', $name));
$io->error(\sprintf('Pool "%s" not found.', $name));
$errors = true;
continue;
}
if (!$pool instanceof TagAwareCacheInterface) {
$io->error(sprintf('Pool "%s" is not taggable.', $name));
$io->error(\sprintf('Pool "%s" is not taggable.', $name));
$errors = true;
continue;
}
if (!$pool->invalidateTags($tags)) {
$io->error(sprintf('Cache tag(s) "%s" could not be invalidated for pool "%s".', $tagList, $name));
$io->error(\sprintf('Cache tag(s) "%s" could not be invalidated for pool "%s".', $tagList, $name));
$errors = true;
}
}

View File

@@ -53,14 +53,21 @@ EOF
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$exitCode = Command::SUCCESS;
foreach ($this->pools as $name => $pool) {
$io->comment(sprintf('Pruning cache pool: <info>%s</info>', $name));
$pool->prune();
$io->comment(\sprintf('Pruning cache pool: <info>%s</info>', $name));
if (!$pool->prune()) {
$io->error(\sprintf('Cache pool "%s" could not be pruned.', $name));
$exitCode = Command::FAILURE;
}
}
$io->success('Successfully pruned cache pool(s).');
if (Command::SUCCESS === $exitCode) {
$io->success('Successfully pruned cache pool(s).');
}
return 0;
return $exitCode;
}
}

View File

@@ -61,7 +61,7 @@ EOF
$io = new SymfonyStyle($input, $output);
$kernel = $this->getApplication()->getKernel();
$io->comment(sprintf('Warming up the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
$io->comment(\sprintf('Warming up the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
if (!$input->getOption('no-optional-warmers')) {
$this->cacheWarmer->enableOptionalWarmers();
@@ -72,14 +72,15 @@ EOF
$kernel->warmUp($cacheDir);
}
$preload = $this->cacheWarmer->warmUp($cacheDir);
$buildDir = $kernel->getContainer()->getParameter('kernel.build_dir');
$preload = $this->cacheWarmer->warmUp($cacheDir, $buildDir);
if ($preload && $cacheDir === $buildDir && file_exists($preloadFile = $buildDir.'/'.$kernel->getContainer()->getParameter('kernel.container_class').'.preload.php')) {
Preloader::append($preloadFile, $preload);
}
$io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully warmed.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
$io->success(\sprintf('Cache for the "%s" environment (debug=%s) was successfully warmed.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
return 0;
}

View File

@@ -41,7 +41,7 @@ class ConfigDebugCommand extends AbstractConfigCommand
{
protected function configure(): void
{
$commentedHelpFormats = array_map(fn ($format) => sprintf('<comment>%s</comment>', $format), $this->getAvailableFormatOptions());
$commentedHelpFormats = array_map(fn ($format) => \sprintf('<comment>%s</comment>', $format), $this->getAvailableFormatOptions());
$helpFormats = implode('", "', $commentedHelpFormats);
$this
@@ -49,7 +49,7 @@ class ConfigDebugCommand extends AbstractConfigCommand
new InputArgument('name', InputArgument::OPTIONAL, 'The bundle name or the extension alias'),
new InputArgument('path', InputArgument::OPTIONAL, 'The configuration option path'),
new InputOption('resolve-env', null, InputOption::VALUE_NONE, 'Display resolved environment variable values instead of placeholders'),
new InputOption('format', null, InputOption::VALUE_REQUIRED, sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())), class_exists(Yaml::class) ? 'txt' : 'json'),
new InputOption('format', null, InputOption::VALUE_REQUIRED, \sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())), class_exists(Yaml::class) ? 'txt' : 'json'),
])
->setHelp(<<<EOF
The <info>%command.name%</info> command dumps the current configuration for an
@@ -106,7 +106,7 @@ EOF
if (null === $path = $input->getArgument('path')) {
if ('txt' === $input->getOption('format')) {
$io->title(
sprintf('Current configuration for %s', $name === $extensionAlias ? sprintf('extension with alias "%s"', $extensionAlias) : sprintf('"%s"', $name))
\sprintf('Current configuration for %s', $name === $extensionAlias ? \sprintf('extension with alias "%s"', $extensionAlias) : \sprintf('"%s"', $name))
);
}
@@ -123,7 +123,7 @@ EOF
return 1;
}
$io->title(sprintf('Current configuration for "%s.%s"', $extensionAlias, $path));
$io->title(\sprintf('Current configuration for "%s.%s"', $extensionAlias, $path));
$io->writeln($this->convertToFormat($config, $format));
@@ -135,7 +135,7 @@ EOF
return match ($format) {
'txt', 'yaml' => Yaml::dump($config, 10),
'json' => json_encode($config, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE),
default => throw new InvalidArgumentException(sprintf('Supported formats are "%s".', implode('", "', $this->getAvailableFormatOptions()))),
default => throw new InvalidArgumentException(\sprintf('Supported formats are "%s".', implode('", "', $this->getAvailableFormatOptions()))),
};
}
@@ -161,8 +161,8 @@ EOF
$steps = explode('.', $path);
foreach ($steps as $step) {
if (!\array_key_exists($step, $config)) {
throw new LogicException(sprintf('Unable to find configuration for "%s.%s".', $alias, $path));
if (!\is_array($config) || !\array_key_exists($step, $config)) {
throw new LogicException(\sprintf('Unable to find configuration for "%s.%s".', $alias, $path));
}
$config = $config[$step];
@@ -190,7 +190,7 @@ EOF
// Fall back to default config if the extension has one
if (!$extension instanceof ConfigurationExtensionInterface && !$extension instanceof ConfigurationInterface) {
throw new \LogicException(sprintf('The extension with alias "%s" does not have configuration.', $extensionAlias));
throw new \LogicException(\sprintf('The extension with alias "%s" does not have configuration.', $extensionAlias));
}
$configs = $container->getExtensionConfig($extensionAlias);

View File

@@ -39,14 +39,14 @@ class ConfigDumpReferenceCommand extends AbstractConfigCommand
{
protected function configure(): void
{
$commentedHelpFormats = array_map(fn ($format) => sprintf('<comment>%s</comment>', $format), $this->getAvailableFormatOptions());
$commentedHelpFormats = array_map(fn ($format) => \sprintf('<comment>%s</comment>', $format), $this->getAvailableFormatOptions());
$helpFormats = implode('", "', $commentedHelpFormats);
$this
->setDefinition([
new InputArgument('name', InputArgument::OPTIONAL, 'The Bundle name or the extension alias'),
new InputArgument('path', InputArgument::OPTIONAL, 'The configuration option path'),
new InputOption('format', null, InputOption::VALUE_REQUIRED, sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())), 'yaml'),
new InputOption('format', null, InputOption::VALUE_REQUIRED, \sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())), 'yaml'),
])
->setHelp(<<<EOF
The <info>%command.name%</info> command dumps the default configuration for an
@@ -118,27 +118,27 @@ EOF
}
if ($name === $extension->getAlias()) {
$message = sprintf('Default configuration for extension with alias: "%s"', $name);
$message = \sprintf('Default configuration for extension with alias: "%s"', $name);
} else {
$message = sprintf('Default configuration for "%s"', $name);
$message = \sprintf('Default configuration for "%s"', $name);
}
if (null !== $path) {
$message .= sprintf(' at path "%s"', $path);
$message .= \sprintf(' at path "%s"', $path);
}
switch ($format) {
case 'yaml':
$io->writeln(sprintf('# %s', $message));
$io->writeln(\sprintf('# %s', $message));
$dumper = new YamlReferenceDumper();
break;
case 'xml':
$io->writeln(sprintf('<!-- %s -->', $message));
$io->writeln(\sprintf('<!-- %s -->', $message));
$dumper = new XmlReferenceDumper();
break;
default:
$io->writeln($message);
throw new InvalidArgumentException(sprintf('Supported formats are "%s".', implode('", "', $this->getAvailableFormatOptions())));
throw new InvalidArgumentException(\sprintf('Supported formats are "%s".', implode('", "', $this->getAvailableFormatOptions())));
}
$io->writeln(null === $path ? $dumper->dump($configuration, $extension->getNamespace()) : $dumper->dumpAtPath($configuration, $path));

View File

@@ -52,7 +52,7 @@ class ContainerDebugCommand extends Command
new InputOption('types', null, InputOption::VALUE_NONE, 'Display types (classes/interfaces) available in the container'),
new InputOption('env-var', null, InputOption::VALUE_REQUIRED, 'Display a specific environment variable used in the container'),
new InputOption('env-vars', null, InputOption::VALUE_NONE, 'Display environment variables used in the container'),
new InputOption('format', null, InputOption::VALUE_REQUIRED, sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())), 'txt'),
new InputOption('format', null, InputOption::VALUE_REQUIRED, \sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())), 'txt'),
new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw description'),
new InputOption('deprecations', null, InputOption::VALUE_NONE, 'Display deprecations generated when compiling and warming up the container'),
])
@@ -171,19 +171,19 @@ EOF
if ($object->hasDefinition($options['id'])) {
$definition = $object->getDefinition($options['id']);
if ($definition->isDeprecated()) {
$errorIo->warning($definition->getDeprecation($options['id'])['message'] ?? sprintf('The "%s" service is deprecated.', $options['id']));
$errorIo->warning($definition->getDeprecation($options['id'])['message'] ?? \sprintf('The "%s" service is deprecated.', $options['id']));
}
}
if ($object->hasAlias($options['id'])) {
$alias = $object->getAlias($options['id']);
if ($alias->isDeprecated()) {
$errorIo->warning($alias->getDeprecation($options['id'])['message'] ?? sprintf('The "%s" alias is deprecated.', $options['id']));
$errorIo->warning($alias->getDeprecation($options['id'])['message'] ?? \sprintf('The "%s" alias is deprecated.', $options['id']));
}
}
}
if (isset($options['id']) && isset($kernel->getContainer()->getRemovedIds()[$options['id']])) {
$errorIo->note(sprintf('The "%s" service or alias has been removed or inlined when the container was compiled.', $options['id']));
$errorIo->note(\sprintf('The "%s" service or alias has been removed or inlined when the container was compiled.', $options['id']));
}
} catch (ServiceNotFoundException $e) {
if ('' !== $e->getId() && '@' === $e->getId()[0]) {
@@ -277,14 +277,16 @@ EOF
$matchingServices = $this->findServiceIdsContaining($container, $name, $showHidden);
if (!$matchingServices) {
throw new InvalidArgumentException(sprintf('No services found that match "%s".', $name));
throw new InvalidArgumentException(\sprintf('No services found that match "%s".', $name));
}
if (1 === \count($matchingServices)) {
return $matchingServices[0];
}
return $io->choice('Select one of the following services to display its information', $matchingServices);
natsort($matchingServices);
return $io->choice('Select one of the following services to display its information', array_values($matchingServices));
}
private function findProperTagName(InputInterface $input, SymfonyStyle $io, ContainerBuilder $container, string $tagName): string
@@ -295,14 +297,16 @@ EOF
$matchingTags = $this->findTagsContaining($container, $tagName);
if (!$matchingTags) {
throw new InvalidArgumentException(sprintf('No tags found that match "%s".', $tagName));
throw new InvalidArgumentException(\sprintf('No tags found that match "%s".', $tagName));
}
if (1 === \count($matchingTags)) {
return $matchingTags[0];
}
return $io->choice('Select one of the following tags to display its information', $matchingTags);
natsort($matchingTags);
return $io->choice('Select one of the following tags to display its information', array_values($matchingTags));
}
private function findServiceIdsContaining(ContainerBuilder $container, string $name, bool $showHidden): array

View File

@@ -80,7 +80,7 @@ final class ContainerLintCommand extends Command
if (!$kernel->isDebug() || !$kernelContainer->getParameter('debug.container.dump') || !(new ConfigCache($kernelContainer->getParameter('debug.container.dump'), true))->isFresh()) {
if (!$kernel instanceof Kernel) {
throw new RuntimeException(sprintf('This command does not support the application kernel: "%s" does not extend "%s".', get_debug_type($kernel), Kernel::class));
throw new RuntimeException(\sprintf('This command does not support the application kernel: "%s" does not extend "%s".', get_debug_type($kernel), Kernel::class));
}
$buildContainer = \Closure::bind(function (): ContainerBuilder {
@@ -91,7 +91,7 @@ final class ContainerLintCommand extends Command
$container = $buildContainer();
} else {
if (!$kernelContainer instanceof Container) {
throw new RuntimeException(sprintf('This command does not support the application container: "%s" does not extend "%s".', get_debug_type($kernelContainer), Container::class));
throw new RuntimeException(\sprintf('This command does not support the application container: "%s" does not extend "%s".', get_debug_type($kernelContainer), Container::class));
}
(new XmlFileLoader($container = new ContainerBuilder($parameterBag = new EnvPlaceholderParameterBag()), new FileLocator()))->load($kernelContainer->getParameter('debug.container.dump'));

View File

@@ -35,7 +35,7 @@ class DebugAutowiringCommand extends ContainerDebugCommand
{
private ?FileLinkFormatter $fileLinkFormatter;
public function __construct(string $name = null, FileLinkFormatter $fileLinkFormatter = null)
public function __construct(?string $name = null, ?FileLinkFormatter $fileLinkFormatter = null)
{
$this->fileLinkFormatter = $fileLinkFormatter;
parent::__construct($name);
@@ -78,7 +78,7 @@ EOF
$serviceIds = array_filter($serviceIds, fn ($serviceId) => false !== stripos(str_replace('\\', '', $serviceId), $searchNormalized) && !str_starts_with($serviceId, '.'));
if (!$serviceIds) {
$errorIo->error(sprintf('No autowirable classes or interfaces found matching "%s"', $search));
$errorIo->error(\sprintf('No autowirable classes or interfaces found matching "%s"', $search));
return 1;
}
@@ -97,7 +97,7 @@ EOF
$io->title('Autowirable Types');
$io->text('The following classes & interfaces can be used as type-hints when autowiring:');
if ($search) {
$io->text(sprintf('(only showing classes/interfaces matching <comment>%s</comment>)', $search));
$io->text(\sprintf('(only showing classes/interfaces matching <comment>%s</comment>)', $search));
}
$hasAlias = [];
$all = $input->getOption('all');
@@ -120,10 +120,10 @@ EOF
}
}
$serviceLine = sprintf('<fg=yellow>%s</>', $serviceId);
$serviceLine = \sprintf('<fg=yellow>%s</>', $serviceId);
if ('' !== $fileLink = $this->getFileLink($previousId)) {
$serviceLine = substr($serviceId, \strlen($previousId));
$serviceLine = sprintf('<fg=yellow;href=%s>%s</>', $fileLink, $previousId).('' !== $serviceLine ? sprintf('<fg=yellow>%s</>', $serviceLine) : '');
$serviceLine = \sprintf('<fg=yellow;href=%s>%s</>', $fileLink, $previousId).('' !== $serviceLine ? \sprintf('<fg=yellow>%s</>', $serviceLine) : '');
}
if ($container->hasAlias($serviceId)) {
@@ -168,7 +168,7 @@ EOF
$io->newLine();
if (0 < $serviceIdsNb) {
$io->text(sprintf('%s more concrete service%s would be displayed when adding the "--all" option.', $serviceIdsNb, $serviceIdsNb > 1 ? 's' : ''));
$io->text(\sprintf('%s more concrete service%s would be displayed when adding the "--all" option.', $serviceIdsNb, $serviceIdsNb > 1 ? 's' : ''));
}
if ($all) {
$io->text('Pro-tip: use interfaces in your type-hints instead of classes to benefit from the dependency inversion principle.');

View File

@@ -52,7 +52,7 @@ class EventDispatcherDebugCommand extends Command
->setDefinition([
new InputArgument('event', InputArgument::OPTIONAL, 'An event name or a part of the event name'),
new InputOption('dispatcher', null, InputOption::VALUE_REQUIRED, 'To view events of a specific event dispatcher', self::DEFAULT_DISPATCHER),
new InputOption('format', null, InputOption::VALUE_REQUIRED, sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())), 'txt'),
new InputOption('format', null, InputOption::VALUE_REQUIRED, \sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())), 'txt'),
new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw description'),
])
->setHelp(<<<'EOF'
@@ -78,7 +78,7 @@ EOF
$options = [];
$dispatcherServiceName = $input->getOption('dispatcher');
if (!$this->dispatchers->has($dispatcherServiceName)) {
$io->getErrorStyle()->error(sprintf('Event dispatcher "%s" is not available.', $dispatcherServiceName));
$io->getErrorStyle()->error(\sprintf('Event dispatcher "%s" is not available.', $dispatcherServiceName));
return 1;
}
@@ -92,7 +92,7 @@ EOF
// if there is no direct match, try find partial matches
$events = $this->searchForEvent($dispatcher, $event);
if (0 === \count($events)) {
$io->getErrorStyle()->warning(sprintf('The event "%s" does not have any registered listeners.', $event));
$io->getErrorStyle()->warning(\sprintf('The event "%s" does not have any registered listeners.', $event));
return 0;
} elseif (1 === \count($events)) {

View File

@@ -42,7 +42,7 @@ class RouterDebugCommand extends Command
private RouterInterface $router;
private ?FileLinkFormatter $fileLinkFormatter;
public function __construct(RouterInterface $router, FileLinkFormatter $fileLinkFormatter = null)
public function __construct(RouterInterface $router, ?FileLinkFormatter $fileLinkFormatter = null)
{
parent::__construct();
@@ -57,7 +57,7 @@ class RouterDebugCommand extends Command
new InputArgument('name', InputArgument::OPTIONAL, 'A route name'),
new InputOption('show-controllers', null, InputOption::VALUE_NONE, 'Show assigned controllers in overview'),
new InputOption('show-aliases', null, InputOption::VALUE_NONE, 'Show aliases in overview'),
new InputOption('format', null, InputOption::VALUE_REQUIRED, sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())), 'txt'),
new InputOption('format', null, InputOption::VALUE_REQUIRED, \sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())), 'txt'),
new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw route(s)'),
])
->setHelp(<<<'EOF'
@@ -107,7 +107,7 @@ EOF
}
if (!$route) {
throw new InvalidArgumentException(sprintf('The route "%s" does not exist.', $name));
throw new InvalidArgumentException(\sprintf('The route "%s" does not exist.', $name));
}
$helper->describe($io, $route, [

View File

@@ -97,21 +97,21 @@ EOF
$matches = false;
foreach ($traces as $trace) {
if (TraceableUrlMatcher::ROUTE_ALMOST_MATCHES == $trace['level']) {
$io->text(sprintf('Route <info>"%s"</> almost matches but %s', $trace['name'], lcfirst($trace['log'])));
$io->text(\sprintf('Route <info>"%s"</> almost matches but %s', $trace['name'], lcfirst($trace['log'])));
} elseif (TraceableUrlMatcher::ROUTE_MATCHES == $trace['level']) {
$io->success(sprintf('Route "%s" matches', $trace['name']));
$io->success(\sprintf('Route "%s" matches', $trace['name']));
$routerDebugCommand = $this->getApplication()->find('debug:router');
$routerDebugCommand->run(new ArrayInput(['name' => $trace['name']]), $output);
$matches = true;
} elseif ($input->getOption('verbose')) {
$io->text(sprintf('Route "%s" does not match: %s', $trace['name'], $trace['log']));
$io->text(\sprintf('Route "%s" does not match: %s', $trace['name'], $trace['log']));
}
}
if (!$matches) {
$io->error(sprintf('None of the routes match the path "%s"', $input->getArgument('path_info')));
$io->error(\sprintf('None of the routes match the path "%s"', $input->getArgument('path_info')));
return 1;
}

View File

@@ -31,7 +31,7 @@ final class SecretsDecryptToLocalCommand extends Command
private AbstractVault $vault;
private ?AbstractVault $localVault;
public function __construct(AbstractVault $vault, AbstractVault $localVault = null)
public function __construct(AbstractVault $vault, ?AbstractVault $localVault = null)
{
$this->vault = $vault;
$this->localVault = $localVault;
@@ -48,7 +48,7 @@ The <info>%command.name%</info> command decrypts all secrets and copies them in
<info>%command.full_name%</info>
When the option <info>--force</info> is provided, secrets that already exist in the local vault are overriden.
When the <info>--force</info> option is provided, secrets that already exist in the local vault are overridden.
<info>%command.full_name% --force</info>
EOF
@@ -68,7 +68,7 @@ EOF
$secrets = $this->vault->list(true);
$io->comment(sprintf('%d secret%s found in the vault.', \count($secrets), 1 !== \count($secrets) ? 's' : ''));
$io->comment(\sprintf('%d secret%s found in the vault.', \count($secrets), 1 !== \count($secrets) ? 's' : ''));
$skipped = 0;
if (!$input->getOption('force')) {
@@ -82,14 +82,14 @@ EOF
if ($skipped > 0) {
$io->warning([
sprintf('%d secret%s already overridden in the local vault and will be skipped.', $skipped, 1 !== $skipped ? 's are' : ' is'),
\sprintf('%d secret%s already overridden in the local vault and will be skipped.', $skipped, 1 !== $skipped ? 's are' : ' is'),
'Use the --force flag to override these.',
]);
}
foreach ($secrets as $k => $v) {
if (null === $v) {
$io->error($this->vault->getLastMessage() ?? sprintf('Secret "%s" has been skipped as there was an error reading it.', $k));
$io->error($this->vault->getLastMessage() ?? \sprintf('Secret "%s" has been skipped as there was an error reading it.', $k));
continue;
}

View File

@@ -30,7 +30,7 @@ final class SecretsEncryptFromLocalCommand extends Command
private AbstractVault $vault;
private ?AbstractVault $localVault;
public function __construct(AbstractVault $vault, AbstractVault $localVault = null)
public function __construct(AbstractVault $vault, ?AbstractVault $localVault = null)
{
$this->vault = $vault;
$this->localVault = $localVault;
@@ -61,14 +61,13 @@ EOF
}
foreach ($this->vault->list(true) as $name => $value) {
$localValue = $this->localVault->reveal($name);
if (null === $localValue = $this->localVault->reveal($name)) {
continue;
}
if (null !== $localValue && $value !== $localValue) {
if ($value !== $localValue) {
$this->vault->seal($name, $localValue);
} elseif (null !== $message = $this->localVault->getLastMessage()) {
$io->error($message);
return 1;
$io->note($this->vault->getLastMessage());
}
}

View File

@@ -33,7 +33,7 @@ final class SecretsGenerateKeysCommand extends Command
private AbstractVault $vault;
private ?AbstractVault $localVault;
public function __construct(AbstractVault $vault, AbstractVault $localVault = null)
public function __construct(AbstractVault $vault, ?AbstractVault $localVault = null)
{
$this->vault = $vault;
$this->localVault = $localVault;
@@ -67,7 +67,7 @@ EOF
$vault = $input->getOption('local') ? $this->localVault : $this->vault;
if (null === $vault) {
$io->success('The local vault is disabled.');
$io->error('The local vault is disabled.');
return 1;
}

View File

@@ -34,7 +34,7 @@ final class SecretsListCommand extends Command
private AbstractVault $vault;
private ?AbstractVault $localVault;
public function __construct(AbstractVault $vault, AbstractVault $localVault = null)
public function __construct(AbstractVault $vault, ?AbstractVault $localVault = null)
{
$this->vault = $vault;
$this->localVault = $localVault;
@@ -66,7 +66,7 @@ EOF
$io->comment('Use <info>"%env(<name>)%"</info> to reference a secret in a config file.');
if (!$reveal = $input->getOption('reveal')) {
$io->comment(sprintf('To reveal the secrets run <info>php %s %s --reveal</info>', $_SERVER['PHP_SELF'], $this->getName()));
$io->comment(\sprintf('To reveal the secrets run <info>php %s %s --reveal</info>', $_SERVER['PHP_SELF'], $this->getName()));
}
$secrets = $this->vault->list($reveal);

View File

@@ -35,7 +35,7 @@ final class SecretsRemoveCommand extends Command
private AbstractVault $vault;
private ?AbstractVault $localVault;
public function __construct(AbstractVault $vault, AbstractVault $localVault = null)
public function __construct(AbstractVault $vault, ?AbstractVault $localVault = null)
{
$this->vault = $vault;
$this->localVault = $localVault;
@@ -63,7 +63,7 @@ EOF
$vault = $input->getOption('local') ? $this->localVault : $this->vault;
if (null === $vault) {
$io->success('The local vault is disabled.');
$io->error('The local vault is disabled.');
return 1;
}

View File

@@ -36,7 +36,7 @@ final class SecretsSetCommand extends Command
private AbstractVault $vault;
private ?AbstractVault $localVault;
public function __construct(AbstractVault $vault, AbstractVault $localVault = null)
public function __construct(AbstractVault $vault, ?AbstractVault $localVault = null)
{
$this->vault = $vault;
$this->localVault = $localVault;
@@ -88,7 +88,7 @@ EOF
}
if ($this->localVault === $vault && !\array_key_exists($name, $this->vault->list())) {
$io->error(sprintf('Secret "%s" does not exist in the vault, you cannot override it locally.', $name));
$io->error(\sprintf('Secret "%s" does not exist in the vault, you cannot override it locally.', $name));
return 1;
}
@@ -107,9 +107,9 @@ EOF
} elseif (is_file($file) && is_readable($file)) {
$value = file_get_contents($file);
} elseif (!is_file($file)) {
throw new \InvalidArgumentException(sprintf('File not found: "%s".', $file));
throw new \InvalidArgumentException(\sprintf('File not found: "%s".', $file));
} elseif (!is_readable($file)) {
throw new \InvalidArgumentException(sprintf('File is not readable: "%s".', $file));
throw new \InvalidArgumentException(\sprintf('File is not readable: "%s".', $file));
}
if ($vault->generateKeys()) {

View File

@@ -59,7 +59,7 @@ class TranslationDebugCommand extends Command
private array $codePaths;
private array $enabledLocales;
public function __construct(TranslatorInterface $translator, TranslationReaderInterface $reader, ExtractorInterface $extractor, string $defaultTransPath = null, string $defaultViewsPath = null, array $transPaths = [], array $codePaths = [], array $enabledLocales = [])
public function __construct(TranslatorInterface $translator, TranslationReaderInterface $reader, ExtractorInterface $extractor, ?string $defaultTransPath = null, ?string $defaultViewsPath = null, array $transPaths = [], array $codePaths = [], array $enabledLocales = [])
{
parent::__construct();
@@ -79,7 +79,7 @@ class TranslationDebugCommand extends Command
->setDefinition([
new InputArgument('locale', InputArgument::REQUIRED, 'The locale'),
new InputArgument('bundle', InputArgument::OPTIONAL, 'The bundle name or directory where to load the messages'),
new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'The messages domain'),
new InputOption('domain', null, InputOption::VALUE_REQUIRED, 'The messages domain'),
new InputOption('only-missing', null, InputOption::VALUE_NONE, 'Display only missing messages'),
new InputOption('only-unused', null, InputOption::VALUE_NONE, 'Display only unused messages'),
new InputOption('all', null, InputOption::VALUE_NONE, 'Load messages from all registered bundles'),
@@ -155,7 +155,7 @@ EOF
$codePaths = [$path.'/templates'];
if (!is_dir($transPaths[0])) {
throw new InvalidArgumentException(sprintf('"%s" is neither an enabled bundle nor a directory.', $transPaths[0]));
throw new InvalidArgumentException(\sprintf('"%s" is neither an enabled bundle nor a directory.', $transPaths[0]));
}
}
} elseif ($input->getOption('all')) {
@@ -181,10 +181,10 @@ EOF
// No defined or extracted messages
if (!$allMessages || null !== $domain && empty($allMessages[$domain])) {
$outputMessage = sprintf('No defined or extracted messages for locale "%s"', $locale);
$outputMessage = \sprintf('No defined or extracted messages for locale "%s"', $locale);
if (null !== $domain) {
$outputMessage .= sprintf(' and domain "%s"', $domain);
$outputMessage .= \sprintf(' and domain "%s"', $domain);
}
$io->getErrorStyle()->warning($outputMessage);
@@ -196,9 +196,9 @@ EOF
$fallbackCatalogues = $this->loadFallbackCatalogues($locale, $transPaths);
// Display header line
$headers = ['State', 'Domain', 'Id', sprintf('Message Preview (%s)', $locale)];
$headers = ['State', 'Domain', 'Id', \sprintf('Message Preview (%s)', $locale)];
foreach ($fallbackCatalogues as $fallbackCatalogue) {
$headers[] = sprintf('Fallback Message Preview (%s)', $fallbackCatalogue->getLocale());
$headers[] = \sprintf('Fallback Message Preview (%s)', $fallbackCatalogue->getLocale());
}
$rows = [];
// Iterate all message ids and determine their state
@@ -320,7 +320,7 @@ EOF
private function formatId(string $id): string
{
return sprintf('<fg=cyan;options=bold>%s</>', $id);
return \sprintf('<fg=cyan;options=bold>%s</>', $id);
}
private function sanitizeString(string $string, int $length = 40): string

View File

@@ -19,7 +19,6 @@ use Symfony\Component\Console\Exception\InvalidArgumentException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\HttpKernel\KernelInterface;
@@ -60,10 +59,14 @@ class TranslationUpdateCommand extends Command
private array $codePaths;
private array $enabledLocales;
public function __construct(TranslationWriterInterface $writer, TranslationReaderInterface $reader, ExtractorInterface $extractor, string $defaultLocale, string $defaultTransPath = null, string $defaultViewsPath = null, array $transPaths = [], array $codePaths = [], array $enabledLocales = [])
public function __construct(TranslationWriterInterface $writer, TranslationReaderInterface $reader, ExtractorInterface $extractor, string $defaultLocale, ?string $defaultTransPath = null, ?string $defaultViewsPath = null, array $transPaths = [], array $codePaths = [], array $enabledLocales = [])
{
parent::__construct();
if (!method_exists($writer, 'getFormats')) {
throw new \InvalidArgumentException(\sprintf('The writer class "%s" does not implement the "getFormats()" method.', $writer::class));
}
$this->writer = $writer;
$this->reader = $reader;
$this->extractor = $extractor;
@@ -81,14 +84,14 @@ class TranslationUpdateCommand extends Command
->setDefinition([
new InputArgument('locale', InputArgument::REQUIRED, 'The locale'),
new InputArgument('bundle', InputArgument::OPTIONAL, 'The bundle name or directory where to load the messages'),
new InputOption('prefix', null, InputOption::VALUE_OPTIONAL, 'Override the default prefix', '__'),
new InputOption('format', null, InputOption::VALUE_OPTIONAL, 'Override the default output format', 'xlf12'),
new InputOption('prefix', null, InputOption::VALUE_REQUIRED, 'Override the default prefix', '__'),
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'Override the default output format', 'xlf12'),
new InputOption('dump-messages', null, InputOption::VALUE_NONE, 'Should the messages be dumped in the console'),
new InputOption('force', null, InputOption::VALUE_NONE, 'Should the extract be done'),
new InputOption('clean', null, InputOption::VALUE_NONE, 'Should clean not found messages'),
new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'Specify the domain to extract'),
new InputOption('domain', null, InputOption::VALUE_REQUIRED, 'Specify the domain to extract'),
new InputOption('sort', null, InputOption::VALUE_OPTIONAL, 'Return list of messages sorted alphabetically (only works with --dump-messages)', 'asc'),
new InputOption('as-tree', null, InputOption::VALUE_OPTIONAL, 'Dump the messages as a tree-like structure: The given value defines the level where to switch to inline YAML'),
new InputOption('as-tree', null, InputOption::VALUE_REQUIRED, 'Dump the messages as a tree-like structure: The given value defines the level where to switch to inline YAML'),
])
->setHelp(<<<'EOF'
The <info>%command.name%</info> command extracts translation strings from templates
@@ -124,13 +127,6 @@ EOF
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io;
if ('translation:update' === $input->getFirstArgument()) {
$errorIo->caution('Command "translation:update" is deprecated since version 5.4 and will be removed in Symfony 6.0. Use "translation:extract" instead.');
}
$io = new SymfonyStyle($input, $output);
$errorIo = $io->getErrorStyle();
@@ -187,13 +183,13 @@ EOF
$codePaths = [$path.'/templates'];
if (!is_dir($transPaths[0])) {
throw new InvalidArgumentException(sprintf('"%s" is neither an enabled bundle nor a directory.', $transPaths[0]));
throw new InvalidArgumentException(\sprintf('"%s" is neither an enabled bundle nor a directory.', $transPaths[0]));
}
}
}
$io->title('Translation Messages Extractor and Dumper');
$io->comment(sprintf('Generating "<info>%s</info>" translation files for "<info>%s</info>"', $input->getArgument('locale'), $currentName));
$io->comment(\sprintf('Generating "<info>%s</info>" translation files for "<info>%s</info>"', $input->getArgument('locale'), $currentName));
$io->comment('Parsing templates...');
$extractedCatalogue = $this->extractMessages($input->getArgument('locale'), $codePaths, $input->getOption('prefix'));
@@ -232,8 +228,8 @@ EOF
$list = array_merge(
array_diff($allKeys, $newKeys),
array_map(fn ($id) => sprintf('<fg=green>%s</>', $id), $newKeys),
array_map(fn ($id) => sprintf('<fg=red>%s</>', $id), array_keys($operation->getObsoleteMessages($domain)))
array_map(fn ($id) => \sprintf('<fg=green>%s</>', $id), $newKeys),
array_map(fn ($id) => \sprintf('<fg=red>%s</>', $id), array_keys($operation->getObsoleteMessages($domain)))
);
$domainMessagesCount = \count($list);
@@ -253,17 +249,17 @@ EOF
}
}
$io->section(sprintf('Messages extracted for domain "<info>%s</info>" (%d message%s)', $domain, $domainMessagesCount, $domainMessagesCount > 1 ? 's' : ''));
$io->section(\sprintf('Messages extracted for domain "<info>%s</info>" (%d message%s)', $domain, $domainMessagesCount, $domainMessagesCount > 1 ? 's' : ''));
$io->listing($list);
$extractedMessagesCount += $domainMessagesCount;
}
if ('xlf' === $format) {
$io->comment(sprintf('Xliff output version is <info>%s</info>', $xliffVersion));
$io->comment(\sprintf('Xliff output version is <info>%s</info>', $xliffVersion));
}
$resultMessage = sprintf('%d message%s successfully extracted', $extractedMessagesCount, $extractedMessagesCount > 1 ? 's were' : ' was');
$resultMessage = \sprintf('%d message%s successfully extracted', $extractedMessagesCount, $extractedMessagesCount > 1 ? 's were' : ' was');
}
// save the files

View File

@@ -62,7 +62,7 @@ class WorkflowDumpCommand extends Command
$this->definitions = $workflows;
trigger_deprecation('symfony/framework-bundle', '6.2', 'Passing an array of definitions in "%s()" is deprecated. Inject a ServiceLocator filled with all workflows instead.', __METHOD__);
} else {
throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be an array or a ServiceLocator, "%s" given.', __METHOD__, \gettype($workflows)));
throw new \TypeError(\sprintf('Argument 1 passed to "%s()" must be an array or a ServiceLocator, "%s" given.', __METHOD__, \gettype($workflows)));
}
}
@@ -94,7 +94,7 @@ EOF
if (isset($this->workflows)) {
if (!$this->workflows->has($workflowName)) {
throw new InvalidArgumentException(sprintf('The workflow named "%s" cannot be found.', $workflowName));
throw new InvalidArgumentException(\sprintf('The workflow named "%s" cannot be found.', $workflowName));
}
$workflow = $this->workflows->get($workflowName);
$type = $workflow instanceof StateMachine ? 'state_machine' : 'workflow';
@@ -108,7 +108,7 @@ EOF
}
if (null === $definition) {
throw new InvalidArgumentException(sprintf('No service found for "workflow.%1$s" nor "state_machine.%1$s".', $workflowName));
throw new InvalidArgumentException(\sprintf('No service found for "workflow.%1$s" nor "state_machine.%1$s".', $workflowName));
}
switch ($input->getOption('dump-format')) {