From 5a00a928a92be590fcabdd07bf4c6efe05397829 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Wed, 4 Sep 2024 13:57:54 +0200 Subject: [PATCH] apply latest cs fixer --- Async/ResolveCacheProcessor.php | 2 +- Binary/Loader/AbstractDoctrineLoader.php | 2 +- Binary/Loader/ChainLoader.php | 4 ++-- Binary/Loader/FileSystemLoader.php | 6 ++--- Binary/Loader/FlysystemLoader.php | 4 ++-- Binary/Loader/FlysystemV2Loader.php | 4 ++-- Binary/Loader/StreamLoader.php | 6 ++--- Binary/Locator/FileSystemLocator.php | 10 ++++---- Binary/SimpleMimeTypeGuesser.php | 4 ++-- Command/CacheCommandTrait.php | 14 +++++------ Command/ResolveCacheCommand.php | 2 +- Component/Console/Style/ImagineStyle.php | 8 +++---- Config/Controller/ControllerConfig.php | 2 +- Config/Filter/Type/Background.php | 2 +- Config/Filter/Type/RelativeResize.php | 2 +- Config/Filter/Type/Thumbnail.php | 2 +- Config/FilterFactoryCollection.php | 2 +- Controller/ImagineController.php | 16 ++++++------- .../Compiler/AbstractCompilerPass.php | 2 +- .../Compiler/DriverCompilerPass.php | 2 +- .../NonFunctionalFilterExceptionPass.php | 2 +- DependencyInjection/Configuration.php | 4 ++-- .../Factory/Loader/AbstractLoaderFactory.php | 4 ++-- .../Factory/Loader/ChainLoaderFactory.php | 2 +- .../Loader/FileSystemLoaderFactory.php | 4 ++-- .../Resolver/AbstractResolverFactory.php | 2 +- .../PostProcessor/InvalidOptionException.php | 6 ++--- .../Config/Filter/Argument/PointFactory.php | 2 +- .../Config/Filter/Argument/SizeFactory.php | 2 +- Imagine/Cache/CacheManager.php | 6 ++--- .../Resolver/AbstractFilesystemResolver.php | 2 +- Imagine/Cache/Resolver/AmazonS3Resolver.php | 2 +- Imagine/Cache/Resolver/AwsS3Resolver.php | 6 ++--- Imagine/Cache/Resolver/FlysystemResolver.php | 4 ++-- .../Cache/Resolver/FlysystemV2Resolver.php | 4 ++-- .../Cache/Resolver/NoCacheWebPathResolver.php | 2 +- Imagine/Cache/Resolver/WebPathResolver.php | 6 ++--- Imagine/Data/DataManager.php | 10 ++++---- Imagine/Filter/FilterConfiguration.php | 2 +- Imagine/Filter/FilterManager.php | 4 ++-- .../Filter/Loader/ResampleFilterLoader.php | 6 ++--- .../PostProcessor/AbstractPostProcessor.php | 4 ++-- .../PostProcessor/CwebpPostProcessor.php | 2 +- .../PostProcessor/JpegOptimPostProcessor.php | 2 +- .../PostProcessor/OptiPngPostProcessor.php | 2 +- .../PostProcessor/PngquantPostProcessor.php | 2 +- Imagine/Filter/RelativeResize.php | 2 +- Service/FilterService.php | 12 +++++----- Templating/FilterTrait.php | 2 +- .../Console/Style/ImagineStyleTest.php | 24 +++++++++---------- .../Controller/ControllerConfigTest.php | 2 +- Tests/Controller/ImagineControllerTest.php | 4 ++-- .../LiipImagineExtensionTest.php | 6 ++--- .../InvalidOptionExceptionTest.php | 4 ++-- Tests/Functional/AbstractSetupWebTestCase.php | 2 +- .../Binary/Loader/ChainLoaderTest.php | 2 +- .../Binary/Loader/FileSystemLoaderTest.php | 2 +- .../Binary/Locator/FileSystemLocatorTest.php | 2 +- .../Command/AbstractCommandTestCase.php | 10 ++++---- .../Command/RemoveCacheCommandTest.php | 20 ++++++++-------- .../Command/ResolveCacheCommandTest.php | 16 ++++++------- .../Loader/ResampleFilterLoaderTest.php | 2 +- .../AbstractPostProcessorTest.php | 8 +++---- Tests/Service/FilterServiceTest.php | 6 ++--- Utility/Framework/SymfonyFramework.php | 4 ++-- 65 files changed, 160 insertions(+), 160 deletions(-) diff --git a/Async/ResolveCacheProcessor.php b/Async/ResolveCacheProcessor.php index 2e600fbfc..935233a06 100644 --- a/Async/ResolveCacheProcessor.php +++ b/Async/ResolveCacheProcessor.php @@ -45,7 +45,7 @@ final class ResolveCacheProcessor implements Processor, CommandSubscriberInterfa public function __construct( FilterManager $filterManager, FilterService $filterService, - ProducerInterface $producer + ProducerInterface $producer, ) { $this->filterManager = $filterManager; $this->filterService = $filterService; diff --git a/Binary/Loader/AbstractDoctrineLoader.php b/Binary/Loader/AbstractDoctrineLoader.php index ffc725284..2da5dd3a3 100644 --- a/Binary/Loader/AbstractDoctrineLoader.php +++ b/Binary/Loader/AbstractDoctrineLoader.php @@ -50,7 +50,7 @@ public function find($path) } if (!$image) { - throw new NotLoadableException(sprintf('Source image was not found with id "%s"', $path)); + throw new NotLoadableException(\sprintf('Source image was not found with id "%s"', $path)); } return stream_get_contents($this->getStreamFromImage($image)); diff --git a/Binary/Loader/ChainLoader.php b/Binary/Loader/ChainLoader.php index 45c23c9f0..ce18fa011 100644 --- a/Binary/Loader/ChainLoader.php +++ b/Binary/Loader/ChainLoader.php @@ -51,11 +51,11 @@ public function find($path) private static function getLoaderExceptionMessage(string $path, array $exceptions, array $loaders): string { array_walk($loaders, function (LoaderInterface &$loader, string $name): void { - $loader = sprintf('%s=[%s]', (new \ReflectionObject($loader))->getShortName(), $name); + $loader = \sprintf('%s=[%s]', (new \ReflectionObject($loader))->getShortName(), $name); }); array_walk($exceptions, function (LoaderInterface &$loader, string $message): void { - $loader = sprintf('%s=[%s]', (new \ReflectionObject($loader))->getShortName(), $message); + $loader = \sprintf('%s=[%s]', (new \ReflectionObject($loader))->getShortName(), $message); }); return vsprintf('Source image not resolvable "%s" using "%s" %d loaders (internal exceptions: %s).', [ diff --git a/Binary/Loader/FileSystemLoader.php b/Binary/Loader/FileSystemLoader.php index 5e8b347ec..6f52ba01b 100644 --- a/Binary/Loader/FileSystemLoader.php +++ b/Binary/Loader/FileSystemLoader.php @@ -43,7 +43,7 @@ class FileSystemLoader implements LoaderInterface public function __construct( $mimeGuesser, $extensionGuesser, - LocatorInterface $locator + LocatorInterface $locator, ) { if (!$mimeGuesser instanceof MimeTypeGuesserInterface && !$mimeGuesser instanceof DeprecatedMimeTypeGuesserInterface) { throw new InvalidArgumentException('$mimeGuesser must be an instance of Symfony\Component\Mime\MimeTypeGuesserInterface or Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface'); @@ -54,11 +54,11 @@ public function __construct( } if (interface_exists(MimeTypeGuesserInterface::class) && $mimeGuesser instanceof DeprecatedMimeTypeGuesserInterface) { - @trigger_error(sprintf('Passing a %s to "%s()" is deprecated since Symfony 4.3, pass a "%s" instead.', DeprecatedMimeTypeGuesserInterface::class, __METHOD__, MimeTypeGuesserInterface::class), E_USER_DEPRECATED); + @trigger_error(\sprintf('Passing a %s to "%s()" is deprecated since Symfony 4.3, pass a "%s" instead.', DeprecatedMimeTypeGuesserInterface::class, __METHOD__, MimeTypeGuesserInterface::class), E_USER_DEPRECATED); } if (interface_exists(MimeTypesInterface::class) && $extensionGuesser instanceof DeprecatedExtensionGuesserInterface) { - @trigger_error(sprintf('Passing a %s to "%s()" is deprecated since Symfony 4.3, pass a "%s" instead.', DeprecatedExtensionGuesserInterface::class, __METHOD__, MimeTypesInterface::class), E_USER_DEPRECATED); + @trigger_error(\sprintf('Passing a %s to "%s()" is deprecated since Symfony 4.3, pass a "%s" instead.', DeprecatedExtensionGuesserInterface::class, __METHOD__, MimeTypesInterface::class), E_USER_DEPRECATED); } $this->mimeTypeGuesser = $mimeGuesser; diff --git a/Binary/Loader/FlysystemLoader.php b/Binary/Loader/FlysystemLoader.php index 497e50bbe..b9631e371 100644 --- a/Binary/Loader/FlysystemLoader.php +++ b/Binary/Loader/FlysystemLoader.php @@ -39,7 +39,7 @@ public function __construct( } if (interface_exists(MimeTypesInterface::class) && $extensionGuesser instanceof DeprecatedExtensionGuesserInterface) { - @trigger_error(sprintf('Passing a %s to "%s()" is deprecated since Symfony 4.3, pass a "%s" instead.', DeprecatedExtensionGuesserInterface::class, __METHOD__, MimeTypesInterface::class), E_USER_DEPRECATED); + @trigger_error(\sprintf('Passing a %s to "%s()" is deprecated since Symfony 4.3, pass a "%s" instead.', DeprecatedExtensionGuesserInterface::class, __METHOD__, MimeTypesInterface::class), E_USER_DEPRECATED); } $this->extensionGuesser = $extensionGuesser; @@ -49,7 +49,7 @@ public function __construct( public function find($path) { if (false === $this->filesystem->has($path)) { - throw new NotLoadableException(sprintf('Source image "%s" not found.', $path)); + throw new NotLoadableException(\sprintf('Source image "%s" not found.', $path)); } $mimeType = $this->filesystem->getMimetype($path); diff --git a/Binary/Loader/FlysystemV2Loader.php b/Binary/Loader/FlysystemV2Loader.php index c03d48a92..6e41136fb 100644 --- a/Binary/Loader/FlysystemV2Loader.php +++ b/Binary/Loader/FlysystemV2Loader.php @@ -31,7 +31,7 @@ class FlysystemV2Loader implements LoaderInterface public function __construct( MimeTypesInterface $extensionGuesser, - FilesystemOperator $filesystem + FilesystemOperator $filesystem, ) { $this->extensionGuesser = $extensionGuesser; $this->filesystem = $filesystem; @@ -50,7 +50,7 @@ public function find($path) $extension ); } catch (FilesystemException $exception) { - throw new NotLoadableException(sprintf('Source image "%s" not found.', $path), 0, $exception); + throw new NotLoadableException(\sprintf('Source image "%s" not found.', $path), 0, $exception); } } diff --git a/Binary/Loader/StreamLoader.php b/Binary/Loader/StreamLoader.php index 015b9cf47..777279da8 100644 --- a/Binary/Loader/StreamLoader.php +++ b/Binary/Loader/StreamLoader.php @@ -58,7 +58,7 @@ public function find($path) * file_exists() is not used as not all wrappers support stat() to actually check for existing resources. */ if (($this->context && !$resource = @fopen($name, 'rb', false, $this->context)) || !$resource = @fopen($name, 'rb')) { - throw new NotLoadableException(sprintf('Source image %s not found.', $name)); + throw new NotLoadableException(\sprintf('Source image %s not found.', $name)); } // Closing the opened stream to avoid locking of the resource to find. @@ -67,11 +67,11 @@ public function find($path) try { $content = file_get_contents($name, false, $this->context); } catch (\Exception $e) { - throw new NotLoadableException(sprintf('Source image %s could not be loaded.', $name), $e->getCode(), $e); + throw new NotLoadableException(\sprintf('Source image %s could not be loaded.', $name), $e->getCode(), $e); } if (false === $content) { - throw new NotLoadableException(sprintf('Source image %s could not be loaded.', $name)); + throw new NotLoadableException(\sprintf('Source image %s could not be loaded.', $name)); } return $content; diff --git a/Binary/Locator/FileSystemLocator.php b/Binary/Locator/FileSystemLocator.php index 563752781..63efbca79 100644 --- a/Binary/Locator/FileSystemLocator.php +++ b/Binary/Locator/FileSystemLocator.php @@ -44,7 +44,7 @@ public function locate(string $path): string return $this->sanitizeAbsolutePath($absolute); } - throw new NotLoadableException(sprintf('Source image not resolvable "%s" in root path(s) "%s"', $path, implode(':', $this->roots))); + throw new NotLoadableException(\sprintf('Source image not resolvable "%s" in root path(s) "%s"', $path, implode(':', $this->roots))); } protected function generateAbsolutePath(string $root, string $path): ?string @@ -77,7 +77,7 @@ private function locateUsingRootPlaceholder(string $path): ?string return $this->generateAbsolutePath($this->roots[$match['name']], $match['path']); } - throw new NotLoadableException(sprintf('Invalid root placeholder "@%s" for path "%s"', $match['name'], $match['path'])); + throw new NotLoadableException(\sprintf('Invalid root placeholder "@%s" for path "%s"', $match['name'], $match['path'])); } /** @@ -93,7 +93,7 @@ private function sanitizeRootPath(string $path, bool $allowUnresolvable): ?strin return null; } - throw new InvalidArgumentException(sprintf('Root image path not resolvable "%s"', $path)); + throw new InvalidArgumentException(\sprintf('Root image path not resolvable "%s"', $path)); } /** @@ -106,11 +106,11 @@ private function sanitizeAbsolutePath(string $path): string }); if (0 === \count($roots)) { - throw new NotLoadableException(sprintf('Source image invalid "%s" as it is outside of the defined root path(s) "%s"', $path, implode(':', $this->roots))); + throw new NotLoadableException(\sprintf('Source image invalid "%s" as it is outside of the defined root path(s) "%s"', $path, implode(':', $this->roots))); } if (!is_readable($path)) { - throw new NotLoadableException(sprintf('Source image invalid "%s" as it is not readable', $path)); + throw new NotLoadableException(\sprintf('Source image invalid "%s" as it is not readable', $path)); } return $path; diff --git a/Binary/SimpleMimeTypeGuesser.php b/Binary/SimpleMimeTypeGuesser.php index 83714c4ec..be4f9206f 100644 --- a/Binary/SimpleMimeTypeGuesser.php +++ b/Binary/SimpleMimeTypeGuesser.php @@ -32,7 +32,7 @@ public function __construct($mimeTypeGuesser) } if (interface_exists((SymfonyMimeTypeGuesserInterface::class) && $mimeTypeGuesser instanceof DeprecatedSymfonyMimeTypeGuesserInterface)) { - @trigger_error(sprintf('Passing a %s to "%s()" is deprecated since Symfony 4.3, pass a "%s" instead.', DeprecatedSymfonyMimeTypeGuesserInterface::class, __METHOD__, SymfonyMimeTypeGuesserInterface::class), E_USER_DEPRECATED); + @trigger_error(\sprintf('Passing a %s to "%s()" is deprecated since Symfony 4.3, pass a "%s" instead.', DeprecatedSymfonyMimeTypeGuesserInterface::class, __METHOD__, SymfonyMimeTypeGuesserInterface::class), E_USER_DEPRECATED); } $this->mimeTypeGuesser = $mimeTypeGuesser; @@ -41,7 +41,7 @@ public function __construct($mimeTypeGuesser) public function guess($binary) { if (false === $tmpFile = tempnam(sys_get_temp_dir(), 'liip-imagine-bundle')) { - throw new \RuntimeException(sprintf('Temp file can not be created in "%s".', sys_get_temp_dir())); + throw new \RuntimeException(\sprintf('Temp file can not be created in "%s".', sys_get_temp_dir())); } try { diff --git a/Command/CacheCommandTrait.php b/Command/CacheCommandTrait.php index fba8363be..e3842310f 100644 --- a/Command/CacheCommandTrait.php +++ b/Command/CacheCommandTrait.php @@ -98,7 +98,7 @@ private function outputCommandResult(array $images, array $filters, string $sing { if (!$this->outputMachineReadable) { $wordPluralizer = function (int $count, string $singular) { - return 1 === $count ? $singular : sprintf('%ss', $singular); + return 1 === $count ? $singular : \sprintf('%ss', $singular); }; $imagePathsSize = \count($images); @@ -106,27 +106,27 @@ private function outputCommandResult(array $images, array $filters, string $sing $allActionsSize = 0 === $imagePathsSize ? $filterSetsSize : ($filterSetsSize * $imagePathsSize) - $this->failures; $allActionsWord = $wordPluralizer($allActionsSize, $singularAction); - $rootTextOutput = sprintf('Completed %d %s', $allActionsSize, $allActionsWord); + $rootTextOutput = \sprintf('Completed %d %s', $allActionsSize, $allActionsWord); $detailTextFormat = '%d %s'; $detailTextsOutput = []; if (0 !== $imagePathsSize) { - $detailTextsOutput[] = sprintf($detailTextFormat, $imagePathsSize, $wordPluralizer($imagePathsSize, 'image')); + $detailTextsOutput[] = \sprintf($detailTextFormat, $imagePathsSize, $wordPluralizer($imagePathsSize, 'image')); } if (0 !== $filterSetsSize) { - $detailTextsOutput[] = sprintf($detailTextFormat, $filterSetsSize, $wordPluralizer($filterSetsSize, 'filter')); + $detailTextsOutput[] = \sprintf($detailTextFormat, $filterSetsSize, $wordPluralizer($filterSetsSize, 'filter')); } if (!empty($detailTextsOutput)) { - $rootTextOutput = sprintf('%s (%s)', $rootTextOutput, implode(', ', $detailTextsOutput)); + $rootTextOutput = \sprintf('%s (%s)', $rootTextOutput, implode(', ', $detailTextsOutput)); } if ($this->failures) { - $this->io->critBlock(sprintf('%s %%s', $rootTextOutput), [ - sprintf('[encountered %d failures]', $this->failures), + $this->io->critBlock(\sprintf('%s %%s', $rootTextOutput), [ + \sprintf('[encountered %d failures]', $this->failures), ]); } else { $this->io->okayBlock($rootTextOutput); diff --git a/Command/ResolveCacheCommand.php b/Command/ResolveCacheCommand.php index 3a2b34923..2ed6e3a6c 100644 --- a/Command/ResolveCacheCommand.php +++ b/Command/ResolveCacheCommand.php @@ -116,7 +116,7 @@ private function runCacheImageResolve(string $image, string $filter, bool $force $this->io->status('cached', 'white'); } - $this->io->line(sprintf(' %s', $this->cacheManager->resolve($image, $filter))); + $this->io->line(\sprintf(' %s', $this->cacheManager->resolve($image, $filter))); } catch (\Exception $e) { ++$this->failures; diff --git a/Component/Console/Style/ImagineStyle.php b/Component/Console/Style/ImagineStyle.php index 26ba57862..81ccd0441 100644 --- a/Component/Console/Style/ImagineStyle.php +++ b/Component/Console/Style/ImagineStyle.php @@ -61,14 +61,14 @@ public function newline(int $count = 1): self public function status(string $status, ?string $fg = null): self { return $this->text( - sprintf('(%1$s)', $status, $fg ?: 'default') + \sprintf('(%1$s)', $status, $fg ?: 'default') ); } public function group(string $item, string $group, ?string $fg = null): self { $this->text( - sprintf('%1$s[%2$s]', $item, $group, $fg ?: 'default') + \sprintf('%1$s[%2$s]', $item, $group, $fg ?: 'default') ); return $this->space(); @@ -122,7 +122,7 @@ private function block(string $string, ?string $type = null, ?string $fg = null, return $this->plainBlock($string, $type); } - $this->io->block($string, $type, sprintf('fg=%s;bg=%s', $fg ?: 'default', $bg ?: 'default'), $prefix ? sprintf(' %s ', $prefix) : ' ', $padding); + $this->io->block($string, $type, \sprintf('fg=%s;bg=%s', $fg ?: 'default', $bg ?: 'default'), $prefix ? \sprintf(' %s ', $prefix) : ' ', $padding); return $this; } @@ -152,6 +152,6 @@ private function compileString(string $format, array $replacements = []): string } catch (\ValueError $error) { } - throw new InvalidArgumentException(sprintf('Invalid string format "%s" or replacements "%s".', $format, implode(', ', array_map(function ($replacement) { return var_export($replacement, true); }, $replacements)))); + throw new InvalidArgumentException(\sprintf('Invalid string format "%s" or replacements "%s".', $format, implode(', ', array_map(function ($replacement) { return var_export($replacement, true); }, $replacements)))); } } diff --git a/Config/Controller/ControllerConfig.php b/Config/Controller/ControllerConfig.php index caa921ffe..6a7073497 100644 --- a/Config/Controller/ControllerConfig.php +++ b/Config/Controller/ControllerConfig.php @@ -22,7 +22,7 @@ final class ControllerConfig public function __construct(int $redirectResponseCode) { if (!\in_array($redirectResponseCode, self::REDIRECT_RESPONSE_CODES, true)) { - throw new InvalidArgumentException(sprintf('Invalid redirect response code "%s" (must be 201, 301, 302, 303, 307, or 308).', $redirectResponseCode)); + throw new InvalidArgumentException(\sprintf('Invalid redirect response code "%s" (must be 201, 301, 302, 303, 307, or 308).', $redirectResponseCode)); } $this->redirectResponseCode = $redirectResponseCode; diff --git a/Config/Filter/Type/Background.php b/Config/Filter/Type/Background.php index ea9b6a724..c540e48b9 100644 --- a/Config/Filter/Type/Background.php +++ b/Config/Filter/Type/Background.php @@ -49,7 +49,7 @@ public function __construct( ?string $color, ?string $transparency, ?string $position, - Size $size + Size $size, ) { $this->color = $color; $this->transparency = $transparency; diff --git a/Config/Filter/Type/RelativeResize.php b/Config/Filter/Type/RelativeResize.php index 4004137f8..aa44e491b 100644 --- a/Config/Filter/Type/RelativeResize.php +++ b/Config/Filter/Type/RelativeResize.php @@ -42,7 +42,7 @@ public function __construct( ?float $heighten = null, ?float $widen = null, ?float $increase = null, - ?float $scale = null + ?float $scale = null, ) { $this->heighten = $heighten; $this->widen = $widen; diff --git a/Config/Filter/Type/Thumbnail.php b/Config/Filter/Type/Thumbnail.php index 4ff645f21..5ed7a0f4a 100644 --- a/Config/Filter/Type/Thumbnail.php +++ b/Config/Filter/Type/Thumbnail.php @@ -44,7 +44,7 @@ public function __construct( Size $size, ?string $mode = null, ?bool $allowUpscale = null, - ?string $filter = null + ?string $filter = null, ) { $this->size = $size; $this->mode = $mode; diff --git a/Config/FilterFactoryCollection.php b/Config/FilterFactoryCollection.php index 56d113c8b..f265fdb5a 100644 --- a/Config/FilterFactoryCollection.php +++ b/Config/FilterFactoryCollection.php @@ -34,7 +34,7 @@ public function __construct(FilterFactoryInterface ...$filterFactories) public function getFilterFactoryByName(string $name): FilterFactoryInterface { if (!isset($this->filterFactories[$name])) { - throw new NotFoundException(sprintf("Filter factory with name '%s' was not found.", $name)); + throw new NotFoundException(\sprintf("Filter factory with name '%s' was not found.", $name)); } return $this->filterFactories[$name]; diff --git a/Controller/ImagineController.php b/Controller/ImagineController.php index da76fd9ec..c796d356b 100644 --- a/Controller/ImagineController.php +++ b/Controller/ImagineController.php @@ -52,14 +52,14 @@ public function __construct( FilterService $filterService, DataManager $dataManager, SignerInterface $signer, - ?ControllerConfig $controllerConfig = null + ?ControllerConfig $controllerConfig = null, ) { $this->filterService = $filterService; $this->dataManager = $dataManager; $this->signer = $signer; if (null === $controllerConfig) { - @trigger_error(sprintf( + @trigger_error(\sprintf( 'Instantiating "%s" without a forth argument of type "%s" is deprecated since 2.2.0 and will be required in 3.0.', self::class, ControllerConfig::class ), E_USER_DEPRECATED); } @@ -121,7 +121,7 @@ public function filterRuntimeAction(Request $request, $hash, $path, $filter) $runtimeConfig = $this->getFiltersBc($request); if (true !== $this->signer->check($hash, $path, $runtimeConfig)) { - throw new BadRequestHttpException(sprintf('Signed url does not pass the sign check for path "%s" and filter "%s" and runtime config %s', $path, $filter, json_encode($runtimeConfig))); + throw new BadRequestHttpException(\sprintf('Signed url does not pass the sign check for path "%s" and filter "%s" and runtime config %s', $path, $filter, json_encode($runtimeConfig))); } return $this->createRedirectResponse(function () use ($path, $filter, $runtimeConfig, $resolver, $request) { @@ -143,14 +143,14 @@ private function getFiltersBc(Request $request): array } catch (BadRequestException $e) { // for strict BC - BadRequestException seems more suited to this situation. // remove the try-catch in version 3 - throw new NotFoundHttpException(sprintf('Filters must be an array. Value was "%s"', $request->query->get('filters'))); + throw new NotFoundHttpException(\sprintf('Filters must be an array. Value was "%s"', $request->query->get('filters'))); } } $runtimeConfig = $request->query->get('filters', []); if (!\is_array($runtimeConfig)) { - throw new NotFoundHttpException(sprintf('Filters must be an array. Value was "%s"', $runtimeConfig)); + throw new NotFoundHttpException(\sprintf('Filters must be an array. Value was "%s"', $runtimeConfig)); } return $runtimeConfig; @@ -165,11 +165,11 @@ private function createRedirectResponse(\Closure $url, string $path, string $fil return new RedirectResponse($this->dataManager->getDefaultImageUrl($filter)); } - throw new NotFoundHttpException(sprintf('Source image for path "%s" could not be found', $path), $exception); + throw new NotFoundHttpException(\sprintf('Source image for path "%s" could not be found', $path), $exception); } catch (NonExistingFilterException $exception) { - throw new NotFoundHttpException(sprintf('Requested non-existing filter "%s"', $filter), $exception); + throw new NotFoundHttpException(\sprintf('Requested non-existing filter "%s"', $filter), $exception); } catch (RuntimeException $exception) { - throw new \RuntimeException(vsprintf('Unable to create image for path "%s" and filter "%s". Message was "%s"', [$hash ? sprintf('%s/%s', $hash, $path) : $path, $filter, $exception->getMessage()]), 0, $exception); + throw new \RuntimeException(vsprintf('Unable to create image for path "%s" and filter "%s". Message was "%s"', [$hash ? \sprintf('%s/%s', $hash, $path) : $path, $filter, $exception->getMessage()]), 0, $exception); } } diff --git a/DependencyInjection/Compiler/AbstractCompilerPass.php b/DependencyInjection/Compiler/AbstractCompilerPass.php index 507a9aa4a..248f4d503 100644 --- a/DependencyInjection/Compiler/AbstractCompilerPass.php +++ b/DependencyInjection/Compiler/AbstractCompilerPass.php @@ -21,7 +21,7 @@ abstract class AbstractCompilerPass implements CompilerPassInterface */ protected function log(ContainerBuilder $container, string $message, ...$replacements): void { - $container->log($this, sprintf( + $container->log($this, \sprintf( '[liip/imagine-bundle] %s', empty($replacements) ? $message : vsprintf($message, $replacements) )); } diff --git a/DependencyInjection/Compiler/DriverCompilerPass.php b/DependencyInjection/Compiler/DriverCompilerPass.php index 65739c4c9..5125b47bf 100644 --- a/DependencyInjection/Compiler/DriverCompilerPass.php +++ b/DependencyInjection/Compiler/DriverCompilerPass.php @@ -26,7 +26,7 @@ public function process(ContainerBuilder $container): void $liipImagineDriver = $container->getParameter('liip_imagine.driver_service'); if (!$container->hasDefinition($liipImagineDriver)) { - throw new InvalidConfigurationException(sprintf("Specified driver '%s' is not defined.", $liipImagineDriver)); + throw new InvalidConfigurationException(\sprintf("Specified driver '%s' is not defined.", $liipImagineDriver)); } } } diff --git a/DependencyInjection/Compiler/NonFunctionalFilterExceptionPass.php b/DependencyInjection/Compiler/NonFunctionalFilterExceptionPass.php index 1a5f0bc77..51edcfd27 100644 --- a/DependencyInjection/Compiler/NonFunctionalFilterExceptionPass.php +++ b/DependencyInjection/Compiler/NonFunctionalFilterExceptionPass.php @@ -24,7 +24,7 @@ public function process(ContainerBuilder $container): void { $canFiltersStillFunction = $container->hasParameter('kernel.root_dir'); $throwWarning = function (string $filterName) use ($canFiltersStillFunction) { - $message = sprintf( + $message = \sprintf( 'The "%s" filter %s in Symfony 5.0. Please use "%s_image" and adapt the "image" option to be relative to the "%%kernel.project_dir%%" instead of "%%kernel.root_dir%%".', $filterName, $canFiltersStillFunction ? 'is deprecated and will not work' : 'no longer works', diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 0c76714d5..8648eea92 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -152,8 +152,8 @@ public function getConfigTreeBuilder(): TreeBuilder ->arrayNode('controller') ->addDefaultsIfNotSet() ->children() - ->scalarNode('filter_action')->defaultValue(sprintf('%s::filterAction', ImagineController::class))->end() - ->scalarNode('filter_runtime_action')->defaultValue(sprintf('%s::filterRuntimeAction', ImagineController::class))->end() + ->scalarNode('filter_action')->defaultValue(\sprintf('%s::filterAction', ImagineController::class))->end() + ->scalarNode('filter_runtime_action')->defaultValue(\sprintf('%s::filterRuntimeAction', ImagineController::class))->end() ->integerNode('redirect_response_code')->defaultValue(302) ->validate() ->ifTrue(function ($redirectResponseCode) { diff --git a/DependencyInjection/Factory/Loader/AbstractLoaderFactory.php b/DependencyInjection/Factory/Loader/AbstractLoaderFactory.php index f11479898..c6314a20b 100644 --- a/DependencyInjection/Factory/Loader/AbstractLoaderFactory.php +++ b/DependencyInjection/Factory/Loader/AbstractLoaderFactory.php @@ -29,7 +29,7 @@ abstract class AbstractLoaderFactory implements LoaderFactoryInterface */ final protected function getChildLoaderDefinition($name = null) { - return new ChildDefinition(sprintf('%s.prototype.%s', static::$namePrefix, $name ?: $this->getName())); + return new ChildDefinition(\sprintf('%s.prototype.%s', static::$namePrefix, $name ?: $this->getName())); } /** @@ -46,7 +46,7 @@ final protected function setTaggedLoaderDefinition($name, Definition $definition $definition->setPublic(true); $container->setDefinition( - $id = sprintf('%s.%s', static::$namePrefix, $name), + $id = \sprintf('%s.%s', static::$namePrefix, $name), $definition ); diff --git a/DependencyInjection/Factory/Loader/ChainLoaderFactory.php b/DependencyInjection/Factory/Loader/ChainLoaderFactory.php index 5affe4e5d..10210cf5a 100644 --- a/DependencyInjection/Factory/Loader/ChainLoaderFactory.php +++ b/DependencyInjection/Factory/Loader/ChainLoaderFactory.php @@ -51,7 +51,7 @@ public function addConfiguration(ArrayNodeDefinition $builder): void private function createLoaderReferences(array $loaders): array { return array_combine($loaders, array_map(function ($name) { - return new Reference(sprintf('liip_imagine.binary.loader.%s', $name)); + return new Reference(\sprintf('liip_imagine.binary.loader.%s', $name)); }, $loaders)); } } diff --git a/DependencyInjection/Factory/Loader/FileSystemLoaderFactory.php b/DependencyInjection/Factory/Loader/FileSystemLoaderFactory.php index e3b3c2d40..ece53910c 100644 --- a/DependencyInjection/Factory/Loader/FileSystemLoaderFactory.php +++ b/DependencyInjection/Factory/Loader/FileSystemLoaderFactory.php @@ -21,7 +21,7 @@ class FileSystemLoaderFactory extends AbstractLoaderFactory { public function create(ContainerBuilder $container, $loaderName, array $config) { - $locatorDefinition = new ChildDefinition(sprintf('liip_imagine.binary.locator.%s', $config['locator'])); + $locatorDefinition = new ChildDefinition(\sprintf('liip_imagine.binary.locator.%s', $config['locator'])); $locatorDefinition->replaceArgument(0, $this->resolveDataRoots($config['data_root'], $config['bundle_resources'], $container)); $locatorDefinition->replaceArgument(1, $config['allow_unresolvable_data_roots']); @@ -156,7 +156,7 @@ private function getBundlePathsUsingNamedObj(array $classes) try { $r = new \ReflectionClass($c); } catch (\ReflectionException $exception) { - throw new InvalidArgumentException(sprintf('Unable to resolve bundle "%s" while auto-registering bundle resource paths.', $c), $exception->getCode(), $exception); + throw new InvalidArgumentException(\sprintf('Unable to resolve bundle "%s" while auto-registering bundle resource paths.', $c), $exception->getCode(), $exception); } $paths[$r->getShortName()] = \dirname($r->getFileName()); diff --git a/DependencyInjection/Factory/Resolver/AbstractResolverFactory.php b/DependencyInjection/Factory/Resolver/AbstractResolverFactory.php index 768c7e8c9..b5cf2142b 100644 --- a/DependencyInjection/Factory/Resolver/AbstractResolverFactory.php +++ b/DependencyInjection/Factory/Resolver/AbstractResolverFactory.php @@ -27,6 +27,6 @@ abstract class AbstractResolverFactory implements ResolverFactoryInterface */ final protected function getChildResolverDefinition($name = null) { - return new ChildDefinition(sprintf('%s.prototype.%s', static::$namePrefix, $name ?: $this->getName())); + return new ChildDefinition(\sprintf('%s.prototype.%s', static::$namePrefix, $name ?: $this->getName())); } } diff --git a/Exception/Imagine/Filter/PostProcessor/InvalidOptionException.php b/Exception/Imagine/Filter/PostProcessor/InvalidOptionException.php index 245c39dae..3a060fa05 100644 --- a/Exception/Imagine/Filter/PostProcessor/InvalidOptionException.php +++ b/Exception/Imagine/Filter/PostProcessor/InvalidOptionException.php @@ -17,7 +17,7 @@ class InvalidOptionException extends \RuntimeException implements ExceptionInter { public function __construct(string $message, array $options = []) { - parent::__construct(sprintf('Invalid post-processor configuration provided (%s) with options %s.', + parent::__construct(\sprintf('Invalid post-processor configuration provided (%s) with options %s.', $message, $this->stringifyOptions($options))); } @@ -30,10 +30,10 @@ private function stringifyOptions(array $options = []): string $options = array_map([$this, 'stringifyOptionValue'], $options); array_walk($options, function (&$o, $name) { - $o = sprintf('%s="%s"', $name, $o); + $o = \sprintf('%s="%s"', $name, $o); }); - return sprintf('[%s]', implode(', ', $options)); + return \sprintf('[%s]', implode(', ', $options)); } private function stringifyOptionValue($value): string diff --git a/Factory/Config/Filter/Argument/PointFactory.php b/Factory/Config/Filter/Argument/PointFactory.php index 34d546a7e..08cf24005 100644 --- a/Factory/Config/Filter/Argument/PointFactory.php +++ b/Factory/Config/Filter/Argument/PointFactory.php @@ -33,7 +33,7 @@ public function createFromOptions(array $options, string $propertyName): Point } if (!\is_array($options[$propertyName])) { - throw new InvalidArgumentException(sprintf('Invalid value for %s provided, array expected.', $propertyName)); + throw new InvalidArgumentException(\sprintf('Invalid value for %s provided, array expected.', $propertyName)); } $x = $options[$propertyName][0] ?? null; diff --git a/Factory/Config/Filter/Argument/SizeFactory.php b/Factory/Config/Filter/Argument/SizeFactory.php index deb8663f3..899c613b6 100644 --- a/Factory/Config/Filter/Argument/SizeFactory.php +++ b/Factory/Config/Filter/Argument/SizeFactory.php @@ -33,7 +33,7 @@ public function createFromOptions(array $options, string $propertyName = 'size') } if (!\is_array($options[$propertyName])) { - throw new InvalidArgumentException(sprintf('Invalid value for %s provided, array expected.', $propertyName)); + throw new InvalidArgumentException(\sprintf('Invalid value for %s provided, array expected.', $propertyName)); } $width = $options[$propertyName][0] ?? null; diff --git a/Imagine/Cache/CacheManager.php b/Imagine/Cache/CacheManager.php index 8894d40b7..c01736c0b 100644 --- a/Imagine/Cache/CacheManager.php +++ b/Imagine/Cache/CacheManager.php @@ -71,7 +71,7 @@ public function __construct( SignerInterface $signer, EventDispatcherInterface $dispatcher, $defaultResolver = null, - $webpGenerate = false + $webpGenerate = false, ) { $this->filterConfig = $filterConfig; $this->router = $router; @@ -196,7 +196,7 @@ public function isStored($path, $filter, $resolver = null) public function resolve($path, $filter, $resolver = null) { if (false !== mb_strpos($path, '/../') || 0 === mb_strpos($path, '../')) { - throw new NotFoundHttpException(sprintf("Source image was searched with '%s' outside of the defined root path", $path)); + throw new NotFoundHttpException(\sprintf("Source image was searched with '%s' outside of the defined root path", $path)); } $preEvent = new CacheResolveEvent($path, $filter); @@ -280,7 +280,7 @@ protected function getResolver($filter, $resolver) } if (!isset($this->resolvers[$resolverName])) { - throw new \OutOfBoundsException(sprintf('Could not find resolver "%s" for "%s" filter type', $resolverName, $filter)); + throw new \OutOfBoundsException(\sprintf('Could not find resolver "%s" for "%s" filter type', $resolverName, $filter)); } return $this->resolvers[$resolverName]; diff --git a/Imagine/Cache/Resolver/AbstractFilesystemResolver.php b/Imagine/Cache/Resolver/AbstractFilesystemResolver.php index a84929dae..b52b04c3d 100644 --- a/Imagine/Cache/Resolver/AbstractFilesystemResolver.php +++ b/Imagine/Cache/Resolver/AbstractFilesystemResolver.php @@ -152,7 +152,7 @@ protected function makeFolder($dir) $this->filesystem->mkdir($dir); $this->filesystem->chmod($dir, $this->folderPermissions); } catch (IOException $e) { - throw new \RuntimeException(sprintf('Could not create directory %s', $dir), 0, $e); + throw new \RuntimeException(\sprintf('Could not create directory %s', $dir), 0, $e); } } } diff --git a/Imagine/Cache/Resolver/AmazonS3Resolver.php b/Imagine/Cache/Resolver/AmazonS3Resolver.php index a28d1b2f7..dec0ea264 100644 --- a/Imagine/Cache/Resolver/AmazonS3Resolver.php +++ b/Imagine/Cache/Resolver/AmazonS3Resolver.php @@ -102,7 +102,7 @@ public function remove(array $paths, array $filters) } if (empty($paths)) { - if (!$this->storage->delete_all_objects($this->bucket, sprintf('/%s/i', implode('|', $filters)))) { + if (!$this->storage->delete_all_objects($this->bucket, \sprintf('/%s/i', implode('|', $filters)))) { $this->logError('The objects could not be deleted from Amazon S3.', [ 'filters' => implode(', ', $filters), 'bucket' => $this->bucket, diff --git a/Imagine/Cache/Resolver/AwsS3Resolver.php b/Imagine/Cache/Resolver/AwsS3Resolver.php index 4ef148d07..75ee2f112 100644 --- a/Imagine/Cache/Resolver/AwsS3Resolver.php +++ b/Imagine/Cache/Resolver/AwsS3Resolver.php @@ -133,7 +133,7 @@ public function remove(array $paths, array $filters) if (empty($paths)) { try { - $this->storage->deleteMatchingObjects($this->bucket, null, sprintf( + $this->storage->deleteMatchingObjects($this->bucket, null, \sprintf( '/%s/i', implode('|', $filters) )); @@ -221,8 +221,8 @@ public function setPutOption($key, $value) protected function getObjectPath($path, $filter) { $path = $this->cachePrefix - ? sprintf('%s/%s/%s', $this->cachePrefix, $filter, $path) - : sprintf('%s/%s', $filter, $path); + ? \sprintf('%s/%s/%s', $this->cachePrefix, $filter, $path) + : \sprintf('%s/%s', $filter, $path); return str_replace('//', '/', $path); } diff --git a/Imagine/Cache/Resolver/FlysystemResolver.php b/Imagine/Cache/Resolver/FlysystemResolver.php index d6ef3c84b..0c0466b00 100644 --- a/Imagine/Cache/Resolver/FlysystemResolver.php +++ b/Imagine/Cache/Resolver/FlysystemResolver.php @@ -65,7 +65,7 @@ public function __construct( RequestContext $requestContext, $rootUrl, $cachePrefix = 'media/cache', - $visibility = AdapterInterface::VISIBILITY_PUBLIC + $visibility = AdapterInterface::VISIBILITY_PUBLIC, ) { $this->flysystem = $flysystem; $this->requestContext = $requestContext; @@ -101,7 +101,7 @@ public function isStored($path, $filter) */ public function resolve($path, $filter) { - return sprintf( + return \sprintf( '%s/%s', rtrim($this->webRoot, '/'), ltrim($this->getFileUrl($path, $filter), '/') diff --git a/Imagine/Cache/Resolver/FlysystemV2Resolver.php b/Imagine/Cache/Resolver/FlysystemV2Resolver.php index 1f0def5f4..a9c23e570 100644 --- a/Imagine/Cache/Resolver/FlysystemV2Resolver.php +++ b/Imagine/Cache/Resolver/FlysystemV2Resolver.php @@ -66,7 +66,7 @@ public function __construct( RequestContext $requestContext, $rootUrl, $cachePrefix = 'media/cache', - $visibility = Visibility::PUBLIC + $visibility = Visibility::PUBLIC, ) { $this->flysystem = $flysystem; $this->requestContext = $requestContext; @@ -102,7 +102,7 @@ public function isStored($path, $filter) */ public function resolve($path, $filter) { - return sprintf( + return \sprintf( '%s/%s', rtrim($this->webRoot, '/'), ltrim($this->getFileUrl($path, $filter), '/') diff --git a/Imagine/Cache/Resolver/NoCacheWebPathResolver.php b/Imagine/Cache/Resolver/NoCacheWebPathResolver.php index c9f0ebba1..48b4c30e6 100644 --- a/Imagine/Cache/Resolver/NoCacheWebPathResolver.php +++ b/Imagine/Cache/Resolver/NoCacheWebPathResolver.php @@ -42,7 +42,7 @@ public function resolve($path, $filter) $port = ":{$this->requestContext->getHttpPort()}"; } - return sprintf('%s://%s%s/%s', + return \sprintf('%s://%s%s/%s', $this->requestContext->getScheme(), $this->requestContext->getHost(), $port, diff --git a/Imagine/Cache/Resolver/WebPathResolver.php b/Imagine/Cache/Resolver/WebPathResolver.php index 6ef744481..b9919776e 100644 --- a/Imagine/Cache/Resolver/WebPathResolver.php +++ b/Imagine/Cache/Resolver/WebPathResolver.php @@ -51,7 +51,7 @@ public function __construct( Filesystem $filesystem, RequestContext $requestContext, $webRootDir, - $cachePrefix = 'media/cache' + $cachePrefix = 'media/cache', ) { $this->filesystem = $filesystem; $this->requestContext = $requestContext; @@ -63,7 +63,7 @@ public function __construct( public function resolve($path, $filter) { - return sprintf('%s/%s', + return \sprintf('%s/%s', rtrim($this->getBaseUrl(), '/'), ltrim($this->getFileUrl($path, $filter), '/') ); @@ -136,7 +136,7 @@ protected function getBaseUrl() } $baseUrl = rtrim($baseUrl, '/\\'); - return sprintf('%s://%s%s%s', + return \sprintf('%s://%s%s%s', $this->requestContext->getScheme(), $this->requestContext->getHost(), $port, diff --git a/Imagine/Data/DataManager.php b/Imagine/Data/DataManager.php index 5f1f316b1..8f9ca6aa8 100644 --- a/Imagine/Data/DataManager.php +++ b/Imagine/Data/DataManager.php @@ -63,14 +63,14 @@ public function __construct( $extensionGuesser, FilterConfiguration $filterConfig, $defaultLoader = null, - $globalDefaultImage = null + $globalDefaultImage = null, ) { if (!$extensionGuesser instanceof MimeTypesInterface && !$extensionGuesser instanceof DeprecatedExtensionGuesserInterface) { throw new InvalidArgumentException('$extensionGuesser must be an instance of Symfony\Component\Mime\MimeTypesInterface or Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesserInterface'); } if (interface_exists(MimeTypesInterface::class) && $extensionGuesser instanceof DeprecatedExtensionGuesserInterface) { - @trigger_error(sprintf('Passing a %s to "%s()" is deprecated since Symfony 4.3, pass a "%s" instead.', DeprecatedExtensionGuesserInterface::class, __METHOD__, MimeTypesInterface::class), E_USER_DEPRECATED); + @trigger_error(\sprintf('Passing a %s to "%s()" is deprecated since Symfony 4.3, pass a "%s" instead.', DeprecatedExtensionGuesserInterface::class, __METHOD__, MimeTypesInterface::class), E_USER_DEPRECATED); } $this->mimeTypeGuesser = $mimeTypeGuesser; @@ -106,7 +106,7 @@ public function getLoader($filter) $loaderName = empty($config['data_loader']) ? $this->defaultLoader : $config['data_loader']; if (!isset($this->loaders[$loaderName])) { - throw new \InvalidArgumentException(sprintf('Could not find data loader "%s" for "%s" filter type', $loaderName, $filter)); + throw new \InvalidArgumentException(\sprintf('Could not find data loader "%s" for "%s" filter type', $loaderName, $filter)); } return $this->loaders[$loaderName]; @@ -139,11 +139,11 @@ public function find($filter, $path) } if (null === $binary->getMimeType()) { - throw new LogicException(sprintf('The mime type of image %s was not guessed.', $path)); + throw new LogicException(\sprintf('The mime type of image %s was not guessed.', $path)); } if (0 !== mb_strpos($binary->getMimeType(), 'image/') && 'application/pdf' !== $binary->getMimeType()) { - throw new LogicException(sprintf('The mime type of file %s must be image/xxx or application/pdf, got %s.', $path, $binary->getMimeType())); + throw new LogicException(\sprintf('The mime type of file %s must be image/xxx or application/pdf, got %s.', $path, $binary->getMimeType())); } return $binary; diff --git a/Imagine/Filter/FilterConfiguration.php b/Imagine/Filter/FilterConfiguration.php index 3921d23b9..6a8f4b576 100644 --- a/Imagine/Filter/FilterConfiguration.php +++ b/Imagine/Filter/FilterConfiguration.php @@ -37,7 +37,7 @@ public function __construct(array $filters = []) public function get($filter) { if (false === \array_key_exists($filter, $this->filters)) { - throw new NonExistingFilterException(sprintf('Could not find configuration for a filter: %s', $filter)); + throw new NonExistingFilterException(\sprintf('Could not find configuration for a filter: %s', $filter)); } return $this->filters[$filter]; diff --git a/Imagine/Filter/FilterManager.php b/Imagine/Filter/FilterManager.php index 892399189..8bd58469b 100644 --- a/Imagine/Filter/FilterManager.php +++ b/Imagine/Filter/FilterManager.php @@ -188,7 +188,7 @@ private function sanitizeFilters(array $filters): array }, ARRAY_FILTER_USE_KEY); if (\count($filters) !== \count($sanitized)) { - throw new \InvalidArgumentException(sprintf('Could not find filter(s): %s', implode(', ', array_map(function (string $name): string { return sprintf('"%s"', $name); }, array_diff(array_keys($filters), array_keys($sanitized)))))); + throw new \InvalidArgumentException(\sprintf('Could not find filter(s): %s', implode(', ', array_map(function (string $name): string { return \sprintf('"%s"', $name); }, array_diff(array_keys($filters), array_keys($sanitized)))))); } return $sanitized; @@ -201,7 +201,7 @@ private function sanitizePostProcessors(array $processors): array }, ARRAY_FILTER_USE_KEY); if (\count($processors) !== \count($sanitized)) { - throw new \InvalidArgumentException(sprintf('Could not find post processor(s): %s', implode(', ', array_map(function (string $name): string { return sprintf('"%s"', $name); }, array_diff(array_keys($processors), array_keys($sanitized)))))); + throw new \InvalidArgumentException(\sprintf('Could not find post processor(s): %s', implode(', ', array_map(function (string $name): string { return \sprintf('"%s"', $name); }, array_diff(array_keys($processors), array_keys($sanitized)))))); } return $sanitized; diff --git a/Imagine/Filter/Loader/ResampleFilterLoader.php b/Imagine/Filter/Loader/ResampleFilterLoader.php index 544d7d2e6..741e8caf3 100644 --- a/Imagine/Filter/Loader/ResampleFilterLoader.php +++ b/Imagine/Filter/Loader/ResampleFilterLoader.php @@ -63,7 +63,7 @@ public function load(ImageInterface $image, array $options = []) private function getTemporaryFile($path) { if (!is_dir($path) || false === $file = tempnam($path, 'liip-imagine-bundle')) { - throw new \RuntimeException(sprintf('Unable to create temporary file in "%s" base path.', $path)); + throw new \RuntimeException(\sprintf('Unable to create temporary file in "%s" base path.', $path)); } return $file; @@ -121,7 +121,7 @@ private function resolveOptions(array $options) $resolver->setNormalizer('filter', function (Options $options, $value) { foreach (['\Imagine\Image\ImageInterface::FILTER_%s', '\Imagine\Image\ImageInterface::%s', '%s'] as $format) { - if (\defined($constant = sprintf($format, mb_strtoupper($value))) || \defined($constant = sprintf($format, $value))) { + if (\defined($constant = \sprintf($format, mb_strtoupper($value))) || \defined($constant = \sprintf($format, $value))) { return \constant($constant); } } @@ -132,7 +132,7 @@ private function resolveOptions(array $options) try { return $resolver->resolve($options); } catch (ExceptionInterface $exception) { - throw new InvalidArgumentException(sprintf('Invalid option(s) passed to %s::load().', __CLASS__), $exception->getCode(), $exception); + throw new InvalidArgumentException(\sprintf('Invalid option(s) passed to %s::load().', __CLASS__), $exception->getCode(), $exception); } } } diff --git a/Imagine/Filter/PostProcessor/AbstractPostProcessor.php b/Imagine/Filter/PostProcessor/AbstractPostProcessor.php index 65383fe0d..26e3b61fd 100644 --- a/Imagine/Filter/PostProcessor/AbstractPostProcessor.php +++ b/Imagine/Filter/PostProcessor/AbstractPostProcessor.php @@ -105,7 +105,7 @@ protected function acquireTemporaryFilePath(array $options, ?string $prefix = nu } if (false === $file = @tempnam($root, $prefix ?: 'post-processor')) { - throw new \RuntimeException(sprintf('Temporary file cannot be created in "%s"', $root)); + throw new \RuntimeException(\sprintf('Temporary file cannot be created in "%s"', $root)); } return $file; @@ -132,7 +132,7 @@ protected function isSuccessfulProcess(Process $process, array $validReturns = [ protected function triggerSetterMethodDeprecation(string $method): void { - @trigger_error(sprintf('The %s() method was deprecated in 2.2 and will be removed in 3.0. You must ' + @trigger_error(\sprintf('The %s() method was deprecated in 2.2 and will be removed in 3.0. You must ' .'setup the class state via its __construct() method. You can still pass filter-specific options to the '. 'process() method to overwrite behavior.', $method), E_USER_DEPRECATED); } diff --git a/Imagine/Filter/PostProcessor/CwebpPostProcessor.php b/Imagine/Filter/PostProcessor/CwebpPostProcessor.php index 86ae48c7f..ee3bc6e97 100644 --- a/Imagine/Filter/PostProcessor/CwebpPostProcessor.php +++ b/Imagine/Filter/PostProcessor/CwebpPostProcessor.php @@ -102,7 +102,7 @@ public function __construct( ?string $alphaFilter = null, ?int $alphaMethod = null, ?bool $exact = null, - array $metadata = [] + array $metadata = [], ) { parent::__construct($executablePath, $temporaryRootPath); diff --git a/Imagine/Filter/PostProcessor/JpegOptimPostProcessor.php b/Imagine/Filter/PostProcessor/JpegOptimPostProcessor.php index 5a66f6d79..d69a57e85 100644 --- a/Imagine/Filter/PostProcessor/JpegOptimPostProcessor.php +++ b/Imagine/Filter/PostProcessor/JpegOptimPostProcessor.php @@ -160,7 +160,7 @@ private function getProcessArguments(array $options = []): array throw new InvalidOptionException('the "quality" option must be an int between 0 and 100', $options); } - $arguments[] = sprintf('--max=%d', $quality); + $arguments[] = \sprintf('--max=%d', $quality); } if ($options['progressive'] ?? $this->progressive) { diff --git a/Imagine/Filter/PostProcessor/OptiPngPostProcessor.php b/Imagine/Filter/PostProcessor/OptiPngPostProcessor.php index b43d8baa3..ef245693e 100644 --- a/Imagine/Filter/PostProcessor/OptiPngPostProcessor.php +++ b/Imagine/Filter/PostProcessor/OptiPngPostProcessor.php @@ -88,7 +88,7 @@ private function getProcessArguments(array $options = []): array throw new InvalidOptionException('the "level" option must be an int between 0 and 7', $options); } - $arguments[] = sprintf('-o%d', $level); + $arguments[] = \sprintf('-o%d', $level); } if (isset($options['strip_all'])) { diff --git a/Imagine/Filter/PostProcessor/PngquantPostProcessor.php b/Imagine/Filter/PostProcessor/PngquantPostProcessor.php index f10b1f6df..739c77d47 100644 --- a/Imagine/Filter/PostProcessor/PngquantPostProcessor.php +++ b/Imagine/Filter/PostProcessor/PngquantPostProcessor.php @@ -118,7 +118,7 @@ private function getProcessArguments(array $options = []): array } $arguments[] = '--quality'; - $arguments[] = sprintf('%d-%d', $quality[0], $quality[1]); + $arguments[] = \sprintf('%d-%d', $quality[0], $quality[1]); } if (isset($options['speed'])) { diff --git a/Imagine/Filter/RelativeResize.php b/Imagine/Filter/RelativeResize.php index e93c17cd0..0631da7db 100644 --- a/Imagine/Filter/RelativeResize.php +++ b/Imagine/Filter/RelativeResize.php @@ -36,7 +36,7 @@ class RelativeResize implements FilterInterface public function __construct($method, $parameter) { if (!\in_array($method, ['heighten', 'increase', 'scale', 'widen'], true)) { - throw new InvalidArgumentException(sprintf('Unsupported method: %s', $method)); + throw new InvalidArgumentException(\sprintf('Unsupported method: %s', $method)); } $this->method = $method; diff --git a/Service/FilterService.php b/Service/FilterService.php index a420bc64f..de74cde54 100644 --- a/Service/FilterService.php +++ b/Service/FilterService.php @@ -57,7 +57,7 @@ public function __construct( CacheManager $cacheManager, bool $webpGenerate = false, array $webpOptions = [], - ?LoggerInterface $logger = null + ?LoggerInterface $logger = null, ) { $this->dataManager = $dataManager; $this->filterManager = $filterManager; @@ -97,7 +97,7 @@ public function warmUpCache( string $path, string $filter, ?string $resolver = null, - bool $forced = false + bool $forced = false, ): bool { $warmedUp = false; @@ -138,7 +138,7 @@ public function getUrlOfFilteredImageWithRuntimeFilters( $filter, array $runtimeFilters = [], $resolver = null, - bool $webpSupported = false + bool $webpSupported = false, ) { $runtimePath = $this->cacheManager->getRuntimePath($path, $runtimeFilters); $runtimeOptions = [ @@ -178,7 +178,7 @@ private function resolveFilterPathContainer( FilterPathContainer $filterPathContainer, string $filter, ?string $resolver = null, - bool $webpSupported = false + bool $webpSupported = false, ): string { $path = $filterPathContainer->getTarget(); @@ -198,7 +198,7 @@ private function warmUpCacheFilterPathContainer( FilterPathContainer $filterPathContainer, string $filter, ?string $resolver = null, - bool $forced = false + bool $forced = false, ): bool { if ($forced || !$this->cacheManager->isStored($filterPathContainer->getTarget(), $filter, $resolver)) { $this->cacheManager->store( @@ -224,7 +224,7 @@ private function createFilteredBinary(FilterPathContainer $filterPathContainer, try { return $this->filterManager->applyFilter($binary, $filter, $filterPathContainer->getOptions()); } catch (NonExistingFilterException $e) { - $this->logger->debug(sprintf( + $this->logger->debug(\sprintf( 'Could not locate filter "%s" for path "%s". Message was "%s"', $filter, $filterPathContainer->getSource(), diff --git a/Templating/FilterTrait.php b/Templating/FilterTrait.php index 7c806dafb..fea2bf1c2 100644 --- a/Templating/FilterTrait.php +++ b/Templating/FilterTrait.php @@ -53,7 +53,7 @@ public function filterCache( string $path, string $filter, array $config = [], - ?string $resolver = null + ?string $resolver = null, ): string { $path = parse_url($path, PHP_URL_PATH); diff --git a/Tests/Component/Console/Style/ImagineStyleTest.php b/Tests/Component/Console/Style/ImagineStyleTest.php index 0a2183a7d..a8f1e46f1 100644 --- a/Tests/Component/Console/Style/ImagineStyleTest.php +++ b/Tests/Component/Console/Style/ImagineStyleTest.php @@ -84,13 +84,13 @@ public function testNewline(int $newlineCount, string $separator): void $style->newline($newlineCount); $style->text($separator); - $this->assertStringContainsString(sprintf('%1$s%2$s%1$s', $separator, str_repeat(PHP_EOL, $newlineCount)), $output->getBuffer()); + $this->assertStringContainsString(\sprintf('%1$s%2$s%1$s', $separator, str_repeat(PHP_EOL, $newlineCount)), $output->getBuffer()); } public static function provideNewlineData(): \Generator { for ($i = 0; $i <= 200; $i += 50) { - yield [$i, sprintf('[abcdef0123-%d]', $i)]; + yield [$i, \sprintf('[abcdef0123-%d]', $i)]; } } @@ -104,15 +104,15 @@ public function testTitle(string $title, ?string $type, bool $decoration): void if ($decoration) { if ($type) { - $expected = sprintf(' [%s] %s', 'white', 'cyan', $type, $title); + $expected = \sprintf(' [%s] %s', 'white', 'cyan', $type, $title); } else { - $expected = sprintf(' %s', 'white', 'cyan', $title); + $expected = \sprintf(' %s', 'white', 'cyan', $title); } } else { if ($type) { - $expected = sprintf('# [%s] %s', $type, $title); + $expected = \sprintf('# [%s] %s', $type, $title); } else { - $expected = sprintf('# %s', $title); + $expected = \sprintf('# %s', $title); } } @@ -137,17 +137,17 @@ public static function provideTitleData(): \Generator */ public function testBlockTypes(string $type, string $expectedFormat, string $format, array $replacements, bool $decoration): void { - $blockMethod = sprintf('%sBlock', $type); + $blockMethod = \sprintf('%sBlock', $type); $style = $this->createImagineStyle($output = $this->createBufferedOutput(), $decoration); if (!\is_callable([$style, $blockMethod])) { - static::fail(sprintf('Required method "%s" for "%s" block type is not callable!', $blockMethod, $type)); + static::fail(\sprintf('Required method "%s" for "%s" block type is not callable!', $blockMethod, $type)); } $style->{$blockMethod}($format, $replacements); $compiled = vsprintf(strip_tags($format), $replacements); - $this->assertStringContainsString(sprintf($expectedFormat, $compiled), $output->getBuffer()); + $this->assertStringContainsString(\sprintf($expectedFormat, $compiled), $output->getBuffer()); } public static function provideBlockTypesData(): \Generator @@ -181,7 +181,7 @@ public function testStatus(string $status, ?string $fg = null, ?string $bg = nul $this->assertStringContainsString($fg ?: 'default', $output->getBuffer()); $this->assertStringContainsString($bg ?: 'default', $output->getBuffer()); - $this->assertStringContainsString(sprintf('(%s)', $status), strip_tags($output->getBuffer())); + $this->assertStringContainsString(\sprintf('(%s)', $status), strip_tags($output->getBuffer())); } public static function provideStatusData(): \Generator @@ -205,7 +205,7 @@ public function testGroup(string $item, string $group, ?string $fg = null, ?stri $this->assertStringContainsString($fg ?: 'default', $output->getBuffer()); $this->assertStringContainsString($bg ?: 'default', $output->getBuffer()); - $this->assertStringContainsString(sprintf('%s[%s]', $item, $group), strip_tags($output->getBuffer())); + $this->assertStringContainsString(\sprintf('%s[%s]', $item, $group), strip_tags($output->getBuffer())); } public static function provideGroupData(): \Generator @@ -213,7 +213,7 @@ public static function provideGroupData(): \Generator foreach (static::getConsoleColors() as $color) { for ($i = 1; $i < 10; $i += 3) { for ($j = 1000; $j < 1004; ++$j) { - yield [sprintf('item-%s', $i), sprintf('group-%s', $j), $color, $color]; + yield [\sprintf('item-%s', $i), \sprintf('group-%s', $j), $color, $color]; } } } diff --git a/Tests/Config/Controller/ControllerConfigTest.php b/Tests/Config/Controller/ControllerConfigTest.php index 17793d702..81deea537 100644 --- a/Tests/Config/Controller/ControllerConfigTest.php +++ b/Tests/Config/Controller/ControllerConfigTest.php @@ -48,7 +48,7 @@ public static function provideInvalidRedirectResponseCodeData(): \Generator public function testInvalidRedirectResponseCode(int $redirectResponseCode): void { $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage(sprintf( + $this->expectExceptionMessage(\sprintf( 'Invalid redirect response code "%s" (must be 201, 301, 302, 303, 307, or 308).', $redirectResponseCode )); $this->assertSame($redirectResponseCode, (new ControllerConfig($redirectResponseCode))->getRedirectResponseCode()); diff --git a/Tests/Controller/ImagineControllerTest.php b/Tests/Controller/ImagineControllerTest.php index 5383f5d6c..ae7ec25f9 100644 --- a/Tests/Controller/ImagineControllerTest.php +++ b/Tests/Controller/ImagineControllerTest.php @@ -105,13 +105,13 @@ private function createControllerInstance(string $path, string $filter, string $ ->expects($expectation ? $this->atLeastOnce() : $this->never()) ->method('getUrlOfFilteredImage') ->with($path, $filter, null) - ->willReturn(sprintf('/resolved/image%s', $path)); + ->willReturn(\sprintf('/resolved/image%s', $path)); $filterService ->expects($expectation ? $this->once() : $this->never()) ->method('getUrlOfFilteredImageWithRuntimeFilters') ->with($path, $filter, [], null) - ->willReturn(sprintf('/resolved/image%s', $path)); + ->willReturn(\sprintf('/resolved/image%s', $path)); $signer = $this->createSignerInterfaceMock(); $signer diff --git a/Tests/DependencyInjection/LiipImagineExtensionTest.php b/Tests/DependencyInjection/LiipImagineExtensionTest.php index 0a092c958..9291859ac 100644 --- a/Tests/DependencyInjection/LiipImagineExtensionTest.php +++ b/Tests/DependencyInjection/LiipImagineExtensionTest.php @@ -304,12 +304,12 @@ protected function getFullConfig() private function assertAlias(string $value, string $key): void { - $this->assertSame($value, (string) $this->containerBuilder->getAlias($key), sprintf('%s alias is correct', $key)); + $this->assertSame($value, (string) $this->containerBuilder->getAlias($key), \sprintf('%s alias is correct', $key)); } private function assertParameter(string $value, string $key): void { - $this->assertSame($value, $this->containerBuilder->getParameter($key), sprintf('%s parameter is correct', $key)); + $this->assertSame($value, $this->containerBuilder->getParameter($key), \sprintf('%s parameter is correct', $key)); } private function assertHasDefinition(string $id): void @@ -329,7 +329,7 @@ private function assertDICConstructorArguments(Definition $definition, array $ar }; $implodeArrayElements = function (array $a): string { - return sprintf('[%s]:%d', implode(',', $a), \count($a)); + return \sprintf('[%s]:%d', implode(',', $a), \count($a)); }; $expectedArguments = $castArrayElementsToString($arguments); diff --git a/Tests/Exception/Imagine/Filter/PostProcessor/InvalidOptionExceptionTest.php b/Tests/Exception/Imagine/Filter/PostProcessor/InvalidOptionExceptionTest.php index ef9f8f512..2db62c156 100644 --- a/Tests/Exception/Imagine/Filter/PostProcessor/InvalidOptionExceptionTest.php +++ b/Tests/Exception/Imagine/Filter/PostProcessor/InvalidOptionExceptionTest.php @@ -38,7 +38,7 @@ public function testExceptionMessage(string $message, array $options, string $op { $exception = new InvalidOptionException($message, $options); - $this->assertStringContainsString(sprintf('(%s)', $message), $exception->getMessage()); - $this->assertStringContainsString(sprintf('[%s]', $optionsText), $exception->getMessage()); + $this->assertStringContainsString(\sprintf('(%s)', $message), $exception->getMessage()); + $this->assertStringContainsString(\sprintf('[%s]', $optionsText), $exception->getMessage()); } } diff --git a/Tests/Functional/AbstractSetupWebTestCase.php b/Tests/Functional/AbstractSetupWebTestCase.php index 717f483f1..699ce706a 100644 --- a/Tests/Functional/AbstractSetupWebTestCase.php +++ b/Tests/Functional/AbstractSetupWebTestCase.php @@ -45,7 +45,7 @@ protected function setUp(): void $this->client = $this->createClient(); $this->client->catchExceptions(false); - $this->webRoot = sprintf('%s/public', self::$kernel->getContainer()->getParameter('kernel.project_dir')); + $this->webRoot = \sprintf('%s/public', self::$kernel->getContainer()->getParameter('kernel.project_dir')); $this->cacheRoot = $this->webRoot.'/media/cache'; $this->filesystem = new Filesystem(); $this->filesystem->remove($this->cacheRoot); diff --git a/Tests/Functional/Binary/Loader/ChainLoaderTest.php b/Tests/Functional/Binary/Loader/ChainLoaderTest.php index 370aacc0d..380a3a65f 100644 --- a/Tests/Functional/Binary/Loader/ChainLoaderTest.php +++ b/Tests/Functional/Binary/Loader/ChainLoaderTest.php @@ -35,6 +35,6 @@ public function testFind(): void */ private function getLoader(string $name): ChainLoader { - return $this->getService(sprintf('liip_imagine.binary.loader.%s', $name)); + return $this->getService(\sprintf('liip_imagine.binary.loader.%s', $name)); } } diff --git a/Tests/Functional/Binary/Loader/FileSystemLoaderTest.php b/Tests/Functional/Binary/Loader/FileSystemLoaderTest.php index e068fb498..972236dce 100644 --- a/Tests/Functional/Binary/Loader/FileSystemLoaderTest.php +++ b/Tests/Functional/Binary/Loader/FileSystemLoaderTest.php @@ -45,6 +45,6 @@ public function testMultipleLoadersHaveDifferentLocatorInstances(): void */ private function getLoader(string $name) { - return $this->getService(sprintf('liip_imagine.binary.loader.%s', $name)); + return $this->getService(\sprintf('liip_imagine.binary.loader.%s', $name)); } } diff --git a/Tests/Functional/Binary/Locator/FileSystemLocatorTest.php b/Tests/Functional/Binary/Locator/FileSystemLocatorTest.php index e411537ca..acadd2308 100644 --- a/Tests/Functional/Binary/Locator/FileSystemLocatorTest.php +++ b/Tests/Functional/Binary/Locator/FileSystemLocatorTest.php @@ -63,7 +63,7 @@ public function testBundleResourcesOnBarLoader(): void private function getFileSystemLoaderLocator(string $name): FileSystemLocator { - return $this->getPrivateProperty($this->getService(sprintf('liip_imagine.binary.loader.%s', $name)), 'locator'); + return $this->getPrivateProperty($this->getService(\sprintf('liip_imagine.binary.loader.%s', $name)), 'locator'); } private function assertFooBundleResourcesExist(LocatorInterface $locator): void diff --git a/Tests/Functional/Command/AbstractCommandTestCase.php b/Tests/Functional/Command/AbstractCommandTestCase.php index 9b6778f77..6833070a6 100644 --- a/Tests/Functional/Command/AbstractCommandTestCase.php +++ b/Tests/Functional/Command/AbstractCommandTestCase.php @@ -42,7 +42,7 @@ protected function assertImagesNotExist(array $images, array $filters): void { foreach ($images as $i) { foreach ($filters as $f) { - $this->assertFileDoesNotExist(sprintf('%s/%s/%s', $this->cacheRoot, $f, $i)); + $this->assertFileDoesNotExist(\sprintf('%s/%s/%s', $this->cacheRoot, $f, $i)); } } } @@ -55,7 +55,7 @@ protected function assertImagesExist($images, $filters): void { foreach ($images as $i) { foreach ($filters as $f) { - $this->assertFileExists(sprintf('%s/%s/%s', $this->cacheRoot, $f, $i)); + $this->assertFileExists(\sprintf('%s/%s/%s', $this->cacheRoot, $f, $i)); } } } @@ -82,7 +82,7 @@ protected function assertOutputContainsFailedImages($output, array $images, arra { foreach ($images as $i) { foreach ($filters as $f) { - $this->assertStringContainsString(sprintf('%s[%s] (failed)', $i, $f), $output); + $this->assertStringContainsString(\sprintf('%s[%s] (failed)', $i, $f), $output); } } } @@ -107,7 +107,7 @@ protected function delResolvedImages(array $images, array $filters): void { foreach ($images as $i) { foreach ($filters as $f) { - if (file_exists($f = sprintf('%s/%s/%s', $this->cacheRoot, $f, $i))) { + if (file_exists($f = \sprintf('%s/%s/%s', $this->cacheRoot, $f, $i))) { @unlink($f); } } @@ -122,7 +122,7 @@ protected function putResolvedImages(array $images, array $filters, string $cont { foreach ($images as $i) { foreach ($filters as $f) { - $this->filesystem->dumpFile(sprintf('%s/%s/%s', $this->cacheRoot, $f, $i), $content); + $this->filesystem->dumpFile(\sprintf('%s/%s/%s', $this->cacheRoot, $f, $i), $content); } } } diff --git a/Tests/Functional/Command/RemoveCacheCommandTest.php b/Tests/Functional/Command/RemoveCacheCommandTest.php index 5aec1d601..8c137ae61 100644 --- a/Tests/Functional/Command/RemoveCacheCommandTest.php +++ b/Tests/Functional/Command/RemoveCacheCommandTest.php @@ -160,7 +160,7 @@ protected function assertOutputContainsSkippedImages($output, array $images, arr { foreach ($images as $i) { foreach ($filters as $f) { - $this->assertStringContainsString(sprintf('%s[%s] (skipped)', $i, $f), $output); + $this->assertStringContainsString(\sprintf('%s[%s] (skipped)', $i, $f), $output); } } } @@ -169,7 +169,7 @@ protected function assertOutputContainsRemovedImages($output, array $images, arr { foreach ($images as $i) { foreach ($filters as $f) { - $this->assertStringContainsString(sprintf('%s[%s] (removed)', $i, $f), $output); + $this->assertStringContainsString(\sprintf('%s[%s] (removed)', $i, $f), $output); } } } @@ -184,16 +184,16 @@ protected function assertOutputContainsSummary(string $output, array $images, ar $filtersSize = \count($filters); $totalSize = 0 === $imagesSize ? $filtersSize : ($imagesSize * $filtersSize) - $failures; - $this->assertStringContainsString(sprintf('Completed %d removal', $totalSize), $output); + $this->assertStringContainsString(\sprintf('Completed %d removal', $totalSize), $output); if (0 !== $imagesSize) { - $this->assertStringContainsString(sprintf('%d image', $imagesSize), $output); + $this->assertStringContainsString(\sprintf('%d image', $imagesSize), $output); } - $this->assertStringContainsString(sprintf('%d filter', $filtersSize), $output); + $this->assertStringContainsString(\sprintf('%d filter', $filtersSize), $output); if (0 !== $failures) { - $this->assertStringContainsString(sprintf('%d failure', $failures), $output); + $this->assertStringContainsString(\sprintf('%d failure', $failures), $output); } } @@ -203,11 +203,11 @@ protected function assertOutputContainsSummary(string $output, array $images, ar */ protected function assertOutputNotContainsSummary(string $output, array $images, array $filters, int $failures = 0): void { - $this->assertStringNotContainsString(sprintf('Completed %d removal', (\count($images) * \count($filters)) - $failures), $output); - $this->assertStringNotContainsString(sprintf('%d image', \count($images)), $output); - $this->assertStringNotContainsString(sprintf('%d filter', \count($filters)), $output); + $this->assertStringNotContainsString(\sprintf('Completed %d removal', (\count($images) * \count($filters)) - $failures), $output); + $this->assertStringNotContainsString(\sprintf('%d image', \count($images)), $output); + $this->assertStringNotContainsString(\sprintf('%d filter', \count($filters)), $output); if (0 !== $failures) { - $this->assertStringNotContainsString(sprintf('%d failure', $failures), $output); + $this->assertStringNotContainsString(\sprintf('%d failure', $failures), $output); } } diff --git a/Tests/Functional/Command/ResolveCacheCommandTest.php b/Tests/Functional/Command/ResolveCacheCommandTest.php index 07194b7f9..b054d6766 100644 --- a/Tests/Functional/Command/ResolveCacheCommandTest.php +++ b/Tests/Functional/Command/ResolveCacheCommandTest.php @@ -192,11 +192,11 @@ public function testScriptReadableOption(): void */ protected function assertOutputContainsSummary(string $output, array $images, array $filters, int $failures = 0): void { - $this->assertStringContainsString(sprintf('Completed %d resolution', (\count($images) * \count($filters)) - $failures), $output); - $this->assertStringContainsString(sprintf('%d image', \count($images)), $output); - $this->assertStringContainsString(sprintf('%d filter', \count($filters)), $output); + $this->assertStringContainsString(\sprintf('Completed %d resolution', (\count($images) * \count($filters)) - $failures), $output); + $this->assertStringContainsString(\sprintf('%d image', \count($images)), $output); + $this->assertStringContainsString(\sprintf('%d filter', \count($filters)), $output); if (0 !== $failures) { - $this->assertStringContainsString(sprintf('%d failure', $failures), $output); + $this->assertStringContainsString(\sprintf('%d failure', $failures), $output); } } @@ -206,11 +206,11 @@ protected function assertOutputContainsSummary(string $output, array $images, ar */ protected function assertOutputNotContainsSummary(string $output, array $images, array $filters, int $failures = 0): void { - $this->assertStringNotContainsString(sprintf('Completed %d resolution', (\count($images) * \count($filters)) - $failures), $output); - $this->assertStringNotContainsString(sprintf('%d image', \count($images)), $output); - $this->assertStringNotContainsString(sprintf('%d filter', \count($filters)), $output); + $this->assertStringNotContainsString(\sprintf('Completed %d resolution', (\count($images) * \count($filters)) - $failures), $output); + $this->assertStringNotContainsString(\sprintf('%d image', \count($images)), $output); + $this->assertStringNotContainsString(\sprintf('%d filter', \count($filters)), $output); if (0 !== $failures) { - $this->assertStringNotContainsString(sprintf('%d failure', $failures), $output); + $this->assertStringNotContainsString(\sprintf('%d failure', $failures), $output); } } diff --git a/Tests/Imagine/Filter/Loader/ResampleFilterLoaderTest.php b/Tests/Imagine/Filter/Loader/ResampleFilterLoaderTest.php index 28329ffcd..5547303ad 100644 --- a/Tests/Imagine/Filter/Loader/ResampleFilterLoaderTest.php +++ b/Tests/Imagine/Filter/Loader/ResampleFilterLoaderTest.php @@ -31,7 +31,7 @@ class ResampleFilterLoaderTest extends AbstractTest public function testResample($imgPath, $resolution): void { $imgType = static::getSupportedDriver(); - $tmpPath = sys_get_temp_dir().DIRECTORY_SEPARATOR.sprintf('liip-imagine-bundle-test-%s-%d.%s', md5($imgPath), time(), pathinfo($imgPath, PATHINFO_EXTENSION)); + $tmpPath = sys_get_temp_dir().DIRECTORY_SEPARATOR.\sprintf('liip-imagine-bundle-test-%s-%d.%s', md5($imgPath), time(), pathinfo($imgPath, PATHINFO_EXTENSION)); $imagine = $this->getImagineInstance($imgType); $image = $imagine->open($imgPath); diff --git a/Tests/Imagine/Filter/PostProcessor/AbstractPostProcessorTest.php b/Tests/Imagine/Filter/PostProcessor/AbstractPostProcessorTest.php index 545c0a6c2..757ca0643 100644 --- a/Tests/Imagine/Filter/PostProcessor/AbstractPostProcessorTest.php +++ b/Tests/Imagine/Filter/PostProcessor/AbstractPostProcessorTest.php @@ -78,7 +78,7 @@ public static function provideWriteTemporaryFileData(): array $data[] = [file_get_contents($f), 'application/x-php', 'php', 'foo-context', []]; $data[] = [file_get_contents($f), 'application/x-php', 'php', 'bar-context', ['temp_dir' => null]]; $data[] = [file_get_contents($f), 'application/x-php', 'php', 'bar-context', ['temp_dir' => sys_get_temp_dir()]]; - $data[] = [file_get_contents($f), 'application/x-php', 'php', 'baz-context', ['temp_dir' => sprintf('%s/foo/bar/baz', sys_get_temp_dir())]]; + $data[] = [file_get_contents($f), 'application/x-php', 'php', 'baz-context', ['temp_dir' => \sprintf('%s/foo/bar/baz', sys_get_temp_dir())]]; } return $data; @@ -100,15 +100,15 @@ public function testWriteTemporaryFile(string $content, string $mimeType, string @unlink($base); @unlink($file); - if (is_dir($dir = sprintf('%s/foo/bar/baz', sys_get_temp_dir()))) { + if (is_dir($dir = \sprintf('%s/foo/bar/baz', sys_get_temp_dir()))) { @rmdir($dir); } - if (is_dir($dir = sprintf('%s/foo/bar', sys_get_temp_dir()))) { + if (is_dir($dir = \sprintf('%s/foo/bar', sys_get_temp_dir()))) { @rmdir($dir); } - if (is_dir($dir = sprintf('%s/foo', sys_get_temp_dir()))) { + if (is_dir($dir = \sprintf('%s/foo', sys_get_temp_dir()))) { @rmdir($dir); } } diff --git a/Tests/Service/FilterServiceTest.php b/Tests/Service/FilterServiceTest.php index 1b3b8fd6a..25ac546a6 100644 --- a/Tests/Service/FilterServiceTest.php +++ b/Tests/Service/FilterServiceTest.php @@ -254,7 +254,7 @@ public function testWarmsUpCacheNonExistingFilter(bool $webpGenerate): void $this->logger ->expects($this->once()) ->method('debug') - ->with(sprintf( + ->with(\sprintf( 'Could not locate filter "%s" for path "%s". Message was "%s"', self::FILTER, self::SOURCE_IMAGE, @@ -356,7 +356,7 @@ public function testGetUrlOfFilteredImageNotExistingFilter(bool $webpGenerate): $this->logger ->expects($this->once()) ->method('debug') - ->with(sprintf( + ->with(\sprintf( 'Could not locate filter "%s" for path "%s". Message was "%s"', self::FILTER, self::SOURCE_IMAGE, @@ -492,7 +492,7 @@ public function testGetUrlOfFilteredImageWithRuntimeFiltersNotExistingFilter(boo $this->logger ->expects($this->once()) ->method('debug') - ->with(sprintf( + ->with(\sprintf( 'Could not locate filter "%s" for path "%s". Message was "%s"', self::FILTER, self::SOURCE_IMAGE, diff --git a/Utility/Framework/SymfonyFramework.php b/Utility/Framework/SymfonyFramework.php index 8b3a03a9c..b1a61f5dc 100644 --- a/Utility/Framework/SymfonyFramework.php +++ b/Utility/Framework/SymfonyFramework.php @@ -20,7 +20,7 @@ final class SymfonyFramework { public static function getContainerResolvableRootWebPath(): string { - return sprintf('%%kernel.project_dir%%/%s', self::isKernelLessThan(4) ? 'web' : 'public'); + return \sprintf('%%kernel.project_dir%%/%s', self::isKernelLessThan(4) ? 'web' : 'public'); } public static function isKernelGreaterThanOrEqualTo(int $major, ?int $minor = null, ?int $patch = null): bool @@ -35,6 +35,6 @@ public static function isKernelLessThan(int $major, ?int $minor = null, ?int $pa private static function kernelVersionCompare(string $operator, int $major, ?int $minor = null, ?int $patch = null): bool { - return version_compare(Kernel::VERSION_ID, sprintf("%d%'.02d%'.02d", $major, $minor ?: 0, $patch ?: 0), $operator); + return version_compare(Kernel::VERSION_ID, \sprintf("%d%'.02d%'.02d", $major, $minor ?: 0, $patch ?: 0), $operator); } }