diff --git a/CHANGELOG.md b/CHANGELOG.md index 2eb2835be..cfb2f8af6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,10 @@ for a given releases. Unreleased, upcoming changes will be updated here periodic # 2.x +## [2.13.2](https://github.com/liip/LiipImagineBundle/tree/2.13.2) + +- Remove deprecated spaceless filter from twig template ([JohJohan](https://github.com/liip/LiipImagineBundle/pull/1609)) + ## [2.13.1](https://github.com/liip/LiipImagineBundle/tree/2.13.1) - Fix Json Manifest handling when manifest file does not exist yet ([AirBair](https://github.com/liip/LiipImagineBundle/pull/1600)) diff --git a/src/Binary/Loader/AbstractDoctrineLoader.php b/src/Binary/Loader/AbstractDoctrineLoader.php index b3158c8e7..9c6382b08 100644 --- a/src/Binary/Loader/AbstractDoctrineLoader.php +++ b/src/Binary/Loader/AbstractDoctrineLoader.php @@ -45,7 +45,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/src/Binary/Loader/ChainLoader.php b/src/Binary/Loader/ChainLoader.php index f37a775c8..0a50def10 100644 --- a/src/Binary/Loader/ChainLoader.php +++ b/src/Binary/Loader/ChainLoader.php @@ -51,12 +51,12 @@ public function find($path) */ private static function getLoaderExceptionMessage(string $path, array $exceptions, array $loaders): string { - $loaderMessages = array_map(static function (string $name, LoaderInterface $loader) { - return sprintf('%s=[%s]', (new \ReflectionObject($loader))->getShortName(), $name); + $loaderMessages = array_map(static function (string $name, LoaderInterface $loader): string { + return \sprintf('%s=[%s]', (new \ReflectionObject($loader))->getShortName(), $name); }, array_keys($loaders), $loaders); - $exceptionMessages = array_map(static function (string $message, LoaderInterface $loader) { - return sprintf('%s=[%s]', (new \ReflectionObject($loader))->getShortName(), $message); + $exceptionMessages = array_map(static function (string $message, LoaderInterface $loader): string { + return \sprintf('%s=[%s]', (new \ReflectionObject($loader))->getShortName(), $message); }, array_keys($exceptions), $exceptions); return vsprintf('Source image not resolvable "%s" using "%s" %d loaders (internal exceptions: %s).', [ diff --git a/src/Binary/Loader/FileSystemLoader.php b/src/Binary/Loader/FileSystemLoader.php index 5fcc2aa5c..ea9f52946 100644 --- a/src/Binary/Loader/FileSystemLoader.php +++ b/src/Binary/Loader/FileSystemLoader.php @@ -27,7 +27,7 @@ class FileSystemLoader implements LoaderInterface public function __construct( MimeTypeGuesserInterface $mimeGuesser, MimeTypesInterface $extensionGuesser, - LocatorInterface $locator + LocatorInterface $locator, ) { $this->mimeTypeGuesser = $mimeGuesser; $this->extensionGuesser = $extensionGuesser; diff --git a/src/Binary/Loader/FlysystemLoader.php b/src/Binary/Loader/FlysystemLoader.php index 0d8bbd63f..c307694f5 100644 --- a/src/Binary/Loader/FlysystemLoader.php +++ b/src/Binary/Loader/FlysystemLoader.php @@ -33,7 +33,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/src/Binary/Loader/FlysystemV2Loader.php b/src/Binary/Loader/FlysystemV2Loader.php index e7dae02d9..e59d47aab 100644 --- a/src/Binary/Loader/FlysystemV2Loader.php +++ b/src/Binary/Loader/FlysystemV2Loader.php @@ -25,7 +25,7 @@ class FlysystemV2Loader implements LoaderInterface public function __construct( MimeTypesInterface $extensionGuesser, - FilesystemOperator $filesystem + FilesystemOperator $filesystem, ) { $this->extensionGuesser = $extensionGuesser; $this->filesystem = $filesystem; @@ -44,7 +44,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/src/Binary/Loader/StreamLoader.php b/src/Binary/Loader/StreamLoader.php index c543e375d..041612ac0 100644 --- a/src/Binary/Loader/StreamLoader.php +++ b/src/Binary/Loader/StreamLoader.php @@ -55,7 +55,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. @@ -64,11 +64,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/src/Binary/Locator/FileSystemLocator.php b/src/Binary/Locator/FileSystemLocator.php index c1a2cd1d8..08e5d9479 100644 --- a/src/Binary/Locator/FileSystemLocator.php +++ b/src/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/src/Binary/SimpleMimeTypeGuesser.php b/src/Binary/SimpleMimeTypeGuesser.php index 12c48fb9c..9727699c6 100644 --- a/src/Binary/SimpleMimeTypeGuesser.php +++ b/src/Binary/SimpleMimeTypeGuesser.php @@ -25,7 +25,7 @@ public function __construct(MimeTypesInterface $mimeTypeGuesser) public function guess(string $binary): ?string { 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/src/Command/CacheCommandTrait.php b/src/Command/CacheCommandTrait.php index a54e4e827..2a5e7e0fe 100644 --- a/src/Command/CacheCommandTrait.php +++ b/src/Command/CacheCommandTrait.php @@ -83,7 +83,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); @@ -91,27 +91,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/src/Command/ResolveCacheCommand.php b/src/Command/ResolveCacheCommand.php index 0deddf0c4..5b346d459 100644 --- a/src/Command/ResolveCacheCommand.php +++ b/src/Command/ResolveCacheCommand.php @@ -113,7 +113,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/src/Component/Console/Style/ImagineStyle.php b/src/Component/Console/Style/ImagineStyle.php index d3b24ebe9..043d62739 100644 --- a/src/Component/Console/Style/ImagineStyle.php +++ b/src/Component/Console/Style/ImagineStyle.php @@ -55,14 +55,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(); @@ -116,7 +116,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; } @@ -146,6 +146,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/src/Config/Controller/ControllerConfig.php b/src/Config/Controller/ControllerConfig.php index cca450530..1de5d5311 100644 --- a/src/Config/Controller/ControllerConfig.php +++ b/src/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/src/Config/Filter/Type/Background.php b/src/Config/Filter/Type/Background.php index 377fd8dde..9c98b6d1d 100644 --- a/src/Config/Filter/Type/Background.php +++ b/src/Config/Filter/Type/Background.php @@ -37,7 +37,7 @@ public function __construct( ?string $color, ?string $transparency, ?string $position, - Size $size + Size $size, ) { $this->color = $color; $this->transparency = $transparency; diff --git a/src/Config/Filter/Type/RelativeResize.php b/src/Config/Filter/Type/RelativeResize.php index 51a7d7b5f..73da46aef 100644 --- a/src/Config/Filter/Type/RelativeResize.php +++ b/src/Config/Filter/Type/RelativeResize.php @@ -30,7 +30,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/src/Config/Filter/Type/Thumbnail.php b/src/Config/Filter/Type/Thumbnail.php index 3c12d68cc..4eeafcc9d 100644 --- a/src/Config/Filter/Type/Thumbnail.php +++ b/src/Config/Filter/Type/Thumbnail.php @@ -32,7 +32,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/src/Config/FilterFactoryCollection.php b/src/Config/FilterFactoryCollection.php index 4a31c9fb2..750021995 100644 --- a/src/Config/FilterFactoryCollection.php +++ b/src/Config/FilterFactoryCollection.php @@ -34,7 +34,7 @@ public function __construct(FilterFactoryInterface ...$filterFactories) public function getFilterFactoryByName(string $name): FilterFactoryInterface { if (!\array_key_exists($name, $this->filterFactories)) { - 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/src/Controller/ImagineController.php b/src/Controller/ImagineController.php index 2e9e5cf32..21b3257e7 100644 --- a/src/Controller/ImagineController.php +++ b/src/Controller/ImagineController.php @@ -38,7 +38,7 @@ public function __construct( FilterService $filterService, DataManager $dataManager, SignerInterface $signer, - ?ControllerConfig $controllerConfig + ControllerConfig $controllerConfig, ) { $this->filterService = $filterService; $this->dataManager = $dataManager; @@ -89,7 +89,7 @@ public function filterRuntimeAction(Request $request, string $hash, string $path $runtimeConfig = $request->query->all('filters'); 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) { @@ -112,11 +112,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/src/DependencyInjection/Compiler/AbstractCompilerPass.php b/src/DependencyInjection/Compiler/AbstractCompilerPass.php index dec901e42..df97d5b77 100644 --- a/src/DependencyInjection/Compiler/AbstractCompilerPass.php +++ b/src/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/src/DependencyInjection/Compiler/DriverCompilerPass.php b/src/DependencyInjection/Compiler/DriverCompilerPass.php index 65739c4c9..5125b47bf 100644 --- a/src/DependencyInjection/Compiler/DriverCompilerPass.php +++ b/src/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/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 64f6f1001..bd4160c10 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -150,8 +150,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/src/DependencyInjection/Factory/Loader/AbstractLoaderFactory.php b/src/DependencyInjection/Factory/Loader/AbstractLoaderFactory.php index 515a0111b..e4c8ae0ae 100644 --- a/src/DependencyInjection/Factory/Loader/AbstractLoaderFactory.php +++ b/src/DependencyInjection/Factory/Loader/AbstractLoaderFactory.php @@ -21,7 +21,7 @@ abstract class AbstractLoaderFactory implements LoaderFactoryInterface final protected function getChildLoaderDefinition(?string $name = null): ChildDefinition { - return new ChildDefinition(sprintf('%s.prototype.%s', static::$namePrefix, $name ?: $this->getName())); + return new ChildDefinition(\sprintf('%s.prototype.%s', static::$namePrefix, $name ?: $this->getName())); } final protected function setTaggedLoaderDefinition(string $name, Definition $definition, ContainerBuilder $container): string @@ -33,7 +33,7 @@ final protected function setTaggedLoaderDefinition(string $name, Definition $def $definition->setPublic(true); $container->setDefinition( - $id = sprintf('%s.%s', static::$namePrefix, $name), + $id = \sprintf('%s.%s', static::$namePrefix, $name), $definition ); diff --git a/src/DependencyInjection/Factory/Loader/ChainLoaderFactory.php b/src/DependencyInjection/Factory/Loader/ChainLoaderFactory.php index 2f03a9f08..d0b958ae3 100644 --- a/src/DependencyInjection/Factory/Loader/ChainLoaderFactory.php +++ b/src/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 (string $name): Reference { - return new Reference(sprintf('liip_imagine.binary.loader.%s', $name)); + return new Reference(\sprintf('liip_imagine.binary.loader.%s', $name)); }, $loaders)); } } diff --git a/src/DependencyInjection/Factory/Loader/FileSystemLoaderFactory.php b/src/DependencyInjection/Factory/Loader/FileSystemLoaderFactory.php index 8b693ffe1..35e5fa54f 100644 --- a/src/DependencyInjection/Factory/Loader/FileSystemLoaderFactory.php +++ b/src/DependencyInjection/Factory/Loader/FileSystemLoaderFactory.php @@ -21,7 +21,7 @@ class FileSystemLoaderFactory extends AbstractLoaderFactory { public function create(ContainerBuilder $container, string $name, array $config): string { - $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']); @@ -148,7 +148,7 @@ private function getBundlePathsUsingNamedObj(array $classes): array 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/src/DependencyInjection/Factory/Resolver/AbstractResolverFactory.php b/src/DependencyInjection/Factory/Resolver/AbstractResolverFactory.php index bb11d114e..5a847a794 100644 --- a/src/DependencyInjection/Factory/Resolver/AbstractResolverFactory.php +++ b/src/DependencyInjection/Factory/Resolver/AbstractResolverFactory.php @@ -19,6 +19,6 @@ abstract class AbstractResolverFactory implements ResolverFactoryInterface final protected function getChildResolverDefinition(?string $name = null): ChildDefinition { - 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/src/Exception/Imagine/Filter/PostProcessor/InvalidOptionException.php b/src/Exception/Imagine/Filter/PostProcessor/InvalidOptionException.php index c372a7062..999a3d5d2 100644 --- a/src/Exception/Imagine/Filter/PostProcessor/InvalidOptionException.php +++ b/src/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(mixed $value): string diff --git a/src/Factory/Config/Filter/Argument/PointFactory.php b/src/Factory/Config/Filter/Argument/PointFactory.php index d4938c173..10439ffbe 100644 --- a/src/Factory/Config/Filter/Argument/PointFactory.php +++ b/src/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/src/Factory/Config/Filter/Argument/SizeFactory.php b/src/Factory/Config/Filter/Argument/SizeFactory.php index aabe9cdca..0d4545cc9 100644 --- a/src/Factory/Config/Filter/Argument/SizeFactory.php +++ b/src/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/src/Imagine/Cache/CacheManager.php b/src/Imagine/Cache/CacheManager.php index 67256c8b9..12c9a8eef 100644 --- a/src/Imagine/Cache/CacheManager.php +++ b/src/Imagine/Cache/CacheManager.php @@ -49,7 +49,7 @@ public function __construct( SignerInterface $signer, EventDispatcherInterface $dispatcher, ?string $defaultResolver = null, - bool $webpGenerate = false + bool $webpGenerate = false, ) { $this->filterConfig = $filterConfig; $this->router = $router; @@ -150,7 +150,7 @@ public function isStored(string $path, string $filter, ?string $resolver = null) public function resolve(string $path, string $filter, ?string $resolver = null): string { 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); @@ -221,7 +221,7 @@ protected function getResolver(string $filter, ?string $resolverName): ResolverI } if (!\array_key_exists($resolverName, $this->resolvers)) { - 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/src/Imagine/Cache/Resolver/AbstractFilesystemResolver.php b/src/Imagine/Cache/Resolver/AbstractFilesystemResolver.php index 52295605b..f682f9d39 100644 --- a/src/Imagine/Cache/Resolver/AbstractFilesystemResolver.php +++ b/src/Imagine/Cache/Resolver/AbstractFilesystemResolver.php @@ -137,7 +137,7 @@ protected function makeFolder(string $dir): void $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/src/Imagine/Cache/Resolver/AwsS3Resolver.php b/src/Imagine/Cache/Resolver/AwsS3Resolver.php index 8db5cb78c..ce8e2ae54 100644 --- a/src/Imagine/Cache/Resolver/AwsS3Resolver.php +++ b/src/Imagine/Cache/Resolver/AwsS3Resolver.php @@ -110,7 +110,7 @@ public function remove(array $paths, array $filters): void if (empty($paths)) { try { - $this->storage->deleteMatchingObjects($this->bucket, '', sprintf( + $this->storage->deleteMatchingObjects($this->bucket, '', \sprintf( '/%s/i', implode('|', $filters) )); @@ -198,8 +198,8 @@ public function setPutOption(string $key, $value): self protected function getObjectPath(string $path, string $filter): string { $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/src/Imagine/Cache/Resolver/FlysystemResolver.php b/src/Imagine/Cache/Resolver/FlysystemResolver.php index decf76455..2e7c83bae 100644 --- a/src/Imagine/Cache/Resolver/FlysystemResolver.php +++ b/src/Imagine/Cache/Resolver/FlysystemResolver.php @@ -44,7 +44,7 @@ public function __construct( RequestContext $requestContext, string $rootUrl, string $cachePrefix = 'media/cache', - string $visibility = AdapterInterface::VISIBILITY_PUBLIC + string $visibility = AdapterInterface::VISIBILITY_PUBLIC, ) { $this->flysystem = $flysystem; $this->requestContext = $requestContext; @@ -75,7 +75,7 @@ public function isStored(string $path, string $filter): bool */ public function resolve(string $path, string $filter): string { - return sprintf( + return \sprintf( '%s/%s', rtrim($this->webRoot, '/'), ltrim($this->getFileUrl($path, $filter), '/') diff --git a/src/Imagine/Cache/Resolver/FlysystemV2Resolver.php b/src/Imagine/Cache/Resolver/FlysystemV2Resolver.php index c764faeaf..ade061073 100644 --- a/src/Imagine/Cache/Resolver/FlysystemV2Resolver.php +++ b/src/Imagine/Cache/Resolver/FlysystemV2Resolver.php @@ -45,7 +45,7 @@ public function __construct( RequestContext $requestContext, string $rootUrl, string $cachePrefix = 'media/cache', - string $visibility = Visibility::PUBLIC + string $visibility = Visibility::PUBLIC, ) { $this->flysystem = $flysystem; $this->requestContext = $requestContext; @@ -76,7 +76,7 @@ public function isStored(string $path, string $filter): bool */ public function resolve(string $path, string $filter): string { - return sprintf( + return \sprintf( '%s/%s', rtrim($this->webRoot, '/'), ltrim($this->getFileUrl($path, $filter), '/') diff --git a/src/Imagine/Cache/Resolver/NoCacheWebPathResolver.php b/src/Imagine/Cache/Resolver/NoCacheWebPathResolver.php index 6bb37d392..ee2eb4670 100644 --- a/src/Imagine/Cache/Resolver/NoCacheWebPathResolver.php +++ b/src/Imagine/Cache/Resolver/NoCacheWebPathResolver.php @@ -39,7 +39,7 @@ public function resolve(string $path, string $filter): string $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/src/Imagine/Cache/Resolver/WebPathResolver.php b/src/Imagine/Cache/Resolver/WebPathResolver.php index 2ffcfb98c..78eaca9e8 100644 --- a/src/Imagine/Cache/Resolver/WebPathResolver.php +++ b/src/Imagine/Cache/Resolver/WebPathResolver.php @@ -32,7 +32,7 @@ public function __construct( Filesystem $filesystem, RequestContext $requestContext, string $webRootDir, - string $cachePrefix = 'media/cache' + string $cachePrefix = 'media/cache', ) { $this->filesystem = $filesystem; $this->requestContext = $requestContext; @@ -44,7 +44,7 @@ public function __construct( public function resolve(string $path, string $filter): string { - return sprintf('%s/%s', + return \sprintf('%s/%s', rtrim($this->getBaseUrl(), '/'), ltrim($this->getFileUrl($path, $filter), '/') ); @@ -114,7 +114,7 @@ protected function getBaseUrl(): string } $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/src/Imagine/Data/DataManager.php b/src/Imagine/Data/DataManager.php index 064b228c8..2c4736b2d 100644 --- a/src/Imagine/Data/DataManager.php +++ b/src/Imagine/Data/DataManager.php @@ -41,7 +41,7 @@ public function __construct( MimeTypesInterface $extensionGuesser, FilterConfiguration $filterConfig, ?string $defaultLoader = null, - ?string $globalDefaultImage = null + ?string $globalDefaultImage = null, ) { $this->mimeTypeGuesser = $mimeTypeGuesser; $this->filterConfig = $filterConfig; @@ -70,7 +70,7 @@ public function getLoader(string $filter): LoaderInterface $loaderName = empty($config['data_loader']) ? $this->defaultLoader : $config['data_loader']; if (!\array_key_exists($loaderName, $this->loaders)) { - 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]; @@ -98,11 +98,11 @@ public function find(string $filter, string $path): BinaryInterface } 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/src/Imagine/Filter/FilterConfiguration.php b/src/Imagine/Filter/FilterConfiguration.php index 810f75956..965a35fb4 100644 --- a/src/Imagine/Filter/FilterConfiguration.php +++ b/src/Imagine/Filter/FilterConfiguration.php @@ -30,7 +30,7 @@ public function __construct(array $filters = []) public function get(string $filter): array { 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/src/Imagine/Filter/FilterManager.php b/src/Imagine/Filter/FilterManager.php index a7a5ac38d..148e53738 100644 --- a/src/Imagine/Filter/FilterManager.php +++ b/src/Imagine/Filter/FilterManager.php @@ -175,7 +175,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; @@ -188,7 +188,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/src/Imagine/Filter/Loader/ResampleFilterLoader.php b/src/Imagine/Filter/Loader/ResampleFilterLoader.php index 17c59a71a..bbbda9a35 100644 --- a/src/Imagine/Filter/Loader/ResampleFilterLoader.php +++ b/src/Imagine/Filter/Loader/ResampleFilterLoader.php @@ -54,7 +54,7 @@ public function load(ImageInterface $image, array $options = []): ImageInterface private function getTemporaryFile(string $path): string { 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; @@ -106,7 +106,7 @@ private function resolveOptions(array $options): array $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); } } @@ -117,7 +117,7 @@ private function resolveOptions(array $options): array 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/src/Imagine/Filter/PostProcessor/AbstractPostProcessor.php b/src/Imagine/Filter/PostProcessor/AbstractPostProcessor.php index 7524dfd7e..ea9598c26 100644 --- a/src/Imagine/Filter/PostProcessor/AbstractPostProcessor.php +++ b/src/Imagine/Filter/PostProcessor/AbstractPostProcessor.php @@ -96,7 +96,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; diff --git a/src/Imagine/Filter/PostProcessor/CwebpPostProcessor.php b/src/Imagine/Filter/PostProcessor/CwebpPostProcessor.php index 86ae48c7f..ee3bc6e97 100644 --- a/src/Imagine/Filter/PostProcessor/CwebpPostProcessor.php +++ b/src/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/src/Imagine/Filter/PostProcessor/JpegOptimPostProcessor.php b/src/Imagine/Filter/PostProcessor/JpegOptimPostProcessor.php index 117f804b9..60e93eaca 100644 --- a/src/Imagine/Filter/PostProcessor/JpegOptimPostProcessor.php +++ b/src/Imagine/Filter/PostProcessor/JpegOptimPostProcessor.php @@ -95,7 +95,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/src/Imagine/Filter/PostProcessor/OptiPngPostProcessor.php b/src/Imagine/Filter/PostProcessor/OptiPngPostProcessor.php index 2cf93bac4..360e54cfb 100644 --- a/src/Imagine/Filter/PostProcessor/OptiPngPostProcessor.php +++ b/src/Imagine/Filter/PostProcessor/OptiPngPostProcessor.php @@ -84,7 +84,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 ($strip = ($options['strip'] ?? $this->strip)) { diff --git a/src/Imagine/Filter/PostProcessor/PngquantPostProcessor.php b/src/Imagine/Filter/PostProcessor/PngquantPostProcessor.php index fa992405a..7c22ad7c7 100644 --- a/src/Imagine/Filter/PostProcessor/PngquantPostProcessor.php +++ b/src/Imagine/Filter/PostProcessor/PngquantPostProcessor.php @@ -91,7 +91,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 (\array_key_exists('speed', $options) && null !== $options['speed']) { diff --git a/src/Imagine/Filter/RelativeResize.php b/src/Imagine/Filter/RelativeResize.php index 48bc74cd0..0256f9331 100644 --- a/src/Imagine/Filter/RelativeResize.php +++ b/src/Imagine/Filter/RelativeResize.php @@ -37,7 +37,7 @@ class RelativeResize implements FilterInterface public function __construct(string $method, mixed $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/src/Resources/views/Form/form_div_layout.html.twig b/src/Resources/views/Form/form_div_layout.html.twig index db4cce224..15c1dab86 100644 --- a/src/Resources/views/Form/form_div_layout.html.twig +++ b/src/Resources/views/Form/form_div_layout.html.twig @@ -1,19 +1,17 @@ {% block liip_imagine_image_widget %} - {% apply spaceless %} - {% if image_path %} -
- {% if link_url %} - - {% endif %} + {% if image_path %} + - {% endif %} + {% if link_url %} + + {% endif %} +
+ {% endif %} - {{ block('form_widget_simple') }} - {% endapply %} + {{ block('form_widget_simple') }} {% endblock %} diff --git a/src/Service/FilterService.php b/src/Service/FilterService.php index c63c4b398..8031d88e5 100644 --- a/src/Service/FilterService.php +++ b/src/Service/FilterService.php @@ -42,7 +42,7 @@ public function __construct( CacheManager $cacheManager, bool $webpGenerate = false, array $webpOptions = [], - ?LoggerInterface $logger = null + ?LoggerInterface $logger = null, ) { $this->dataManager = $dataManager; $this->filterManager = $filterManager; @@ -79,7 +79,7 @@ public function warmUpCache( string $path, string $filter, ?string $resolver = null, - bool $forced = false + bool $forced = false, ): bool { $warmedUp = false; @@ -106,7 +106,7 @@ public function getUrlOfFilteredImageWithRuntimeFilters( string $filter, array $runtimeFilters = [], ?string $resolver = null, - bool $webpSupported = false + bool $webpSupported = false, ): string { $runtimePath = $this->cacheManager->getRuntimePath($path, $runtimeFilters); $runtimeOptions = [ @@ -146,7 +146,7 @@ private function resolveFilterPathContainer( FilterPathContainer $filterPathContainer, string $filter, ?string $resolver = null, - bool $webpSupported = false + bool $webpSupported = false, ): string { $path = $filterPathContainer->getTarget(); @@ -166,7 +166,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( @@ -192,7 +192,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/src/Utility/Framework/SymfonyFramework.php b/src/Utility/Framework/SymfonyFramework.php index dc8301c43..d808622d1 100644 --- a/src/Utility/Framework/SymfonyFramework.php +++ b/src/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((string) Kernel::VERSION_ID, sprintf("%d%'.02d%'.02d", $major, $minor ?: 0, $patch ?: 0), $operator); + return version_compare((string) Kernel::VERSION_ID, \sprintf("%d%'.02d%'.02d", $major, $minor ?: 0, $patch ?: 0), $operator); } } diff --git a/tests/Component/Console/Style/ImagineStyleTest.php b/tests/Component/Console/Style/ImagineStyleTest.php index 651dc0eb0..348b41e24 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 86abfd84a..b78194ec3 100644 --- a/tests/Controller/ImagineControllerTest.php +++ b/tests/Controller/ImagineControllerTest.php @@ -92,13 +92,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->createMock(SignerInterface::class); $signer diff --git a/tests/DependencyInjection/LiipImagineExtensionTest.php b/tests/DependencyInjection/LiipImagineExtensionTest.php index 251354e0e..c85151e59 100644 --- a/tests/DependencyInjection/LiipImagineExtensionTest.php +++ b/tests/DependencyInjection/LiipImagineExtensionTest.php @@ -260,12 +260,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 @@ -285,7 +285,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 cfad2b94e..cc0314376 100644 --- a/tests/Functional/AbstractSetupWebTestCase.php +++ b/tests/Functional/AbstractSetupWebTestCase.php @@ -33,7 +33,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 42dae672d..ada50719b 100644 --- a/tests/Imagine/Filter/Loader/ResampleFilterLoaderTest.php +++ b/tests/Imagine/Filter/Loader/ResampleFilterLoaderTest.php @@ -29,7 +29,7 @@ class ResampleFilterLoaderTest extends AbstractTest public function testResample(string $imgPath, float $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 35bf6102c..a45b9533e 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 9737087de..7ad0b1f98 100644 --- a/tests/Service/FilterServiceTest.php +++ b/tests/Service/FilterServiceTest.php @@ -232,7 +232,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, @@ -330,7 +330,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, @@ -462,7 +462,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,