Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.x' into 2-to-3
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Sep 4, 2024
2 parents 342bbf2 + 98e0318 commit 1493e2b
Show file tree
Hide file tree
Showing 57 changed files with 146 additions and 144 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion src/Binary/Loader/AbstractDoctrineLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions src/Binary/Loader/ChainLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ public function find($path)
*/
private static function getLoaderExceptionMessage(string $path, array $exceptions, array $loaders): string
{
$loaderMessages = array_map(static function (string $name, LoaderInterface $loader) {
$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) {
$exceptionMessages = array_map(static function (string $message, LoaderInterface $loader): string {
return sprintf('%s=[%s]', (new \ReflectionObject($loader))->getShortName(), $message);
}, array_keys($exceptions), $exceptions);

Expand Down
2 changes: 1 addition & 1 deletion src/Binary/Loader/FlysystemLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Binary/Loader/FlysystemV2Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/Binary/Loader/StreamLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions src/Binary/Locator/FileSystemLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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']));
}

/**
Expand All @@ -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));
}

/**
Expand All @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions src/Command/CacheCommandTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,35 +83,35 @@ 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);
$filterSetsSize = \count($filters);
$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);
Expand Down
2 changes: 1 addition & 1 deletion src/Command/ResolveCacheCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 4 additions & 4 deletions src/Component/Console/Style/ImagineStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ public function newline(int $count = 1): self
public function status(string $status, ?string $fg = null): self
{
return $this->text(
sprintf('<fg=%2$s>(</><fg=%2$s;options=bold>%1$s</><fg=%2$s>)</>', $status, $fg ?: 'default')
\sprintf('<fg=%2$s>(</><fg=%2$s;options=bold>%1$s</><fg=%2$s>)</>', $status, $fg ?: 'default')
);
}

public function group(string $item, string $group, ?string $fg = null): self
{
$this->text(
sprintf('<fg=%3$s;options=bold>%1$s[</><fg=%3$s>%2$s</><fg=%3$s;options=bold>]</>', $item, $group, $fg ?: 'default')
\sprintf('<fg=%3$s;options=bold>%1$s[</><fg=%3$s>%2$s</><fg=%3$s;options=bold>]</>', $item, $group, $fg ?: 'default')
);

return $this->space();
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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))));
}
}
2 changes: 1 addition & 1 deletion src/Config/Controller/ControllerConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Config/FilterFactoryCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
10 changes: 5 additions & 5 deletions src/Controller/ImagineController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(
FilterService $filterService,
DataManager $dataManager,
SignerInterface $signer,
?ControllerConfig $controllerConfig
ControllerConfig $controllerConfig
) {
$this->filterService = $filterService;
$this->dataManager = $dataManager;
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Compiler/AbstractCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
));
}
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Compiler/DriverCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
4 changes: 2 additions & 2 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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']);

Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}

Expand All @@ -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
Expand Down
Loading

0 comments on commit 1493e2b

Please sign in to comment.