Skip to content

Commit

Permalink
apply latest cs fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Sep 4, 2024
1 parent 8a2c9fc commit 5a00a92
Show file tree
Hide file tree
Showing 65 changed files with 160 additions and 160 deletions.
2 changes: 1 addition & 1 deletion Async/ResolveCacheProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Binary/Loader/AbstractDoctrineLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions 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
{
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).', [
Expand Down
6 changes: 3 additions & 3 deletions Binary/Loader/FileSystemLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Binary/Loader/FlysystemLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions Binary/Loader/FlysystemV2Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class FlysystemV2Loader implements LoaderInterface

public function __construct(
MimeTypesInterface $extensionGuesser,
FilesystemOperator $filesystem
FilesystemOperator $filesystem,
) {
$this->extensionGuesser = $extensionGuesser;
$this->filesystem = $filesystem;
Expand All @@ -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);
}
}

Expand Down
6 changes: 3 additions & 3 deletions Binary/Loader/StreamLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions 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
4 changes: 2 additions & 2 deletions Binary/SimpleMimeTypeGuesser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
14 changes: 7 additions & 7 deletions Command/CacheCommandTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,35 +98,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 Command/ResolveCacheCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 4 additions & 4 deletions Component/Console/Style/ImagineStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,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 @@ -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;
}
Expand Down Expand Up @@ -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))));
}
}
2 changes: 1 addition & 1 deletion 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 Config/Filter/Type/Background.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct(
?string $color,
?string $transparency,
?string $position,
Size $size
Size $size,
) {
$this->color = $color;
$this->transparency = $transparency;
Expand Down
2 changes: 1 addition & 1 deletion Config/Filter/Type/RelativeResize.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Config/Filter/Type/Thumbnail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion 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 (!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];
Expand Down
16 changes: 8 additions & 8 deletions Controller/ImagineController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand All @@ -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);
}
}

Expand Down
Loading

0 comments on commit 5a00a92

Please sign in to comment.