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 1adcca2
Show file tree
Hide file tree
Showing 59 changed files with 145 additions and 145 deletions.
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
4 changes: 2 additions & 2 deletions Binary/Loader/FileSystemLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Binary/Loader/FlysystemV2Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/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
14 changes: 7 additions & 7 deletions Controller/ImagineController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function __construct(
$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
2 changes: 1 addition & 1 deletion 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 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));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function process(ContainerBuilder $container): void
{
$canFiltersStillFunction = $container->hasParameter('kernel.root_dir');
$throwWarning = function (string $filterName) use ($canFiltersStillFunction) {
$message = sprintf(
$message = \sprintf(
'The "%s" filter %s in Symfony 5.0. Please use "%s_image" and adapt the "image" option to be relative to the "%%kernel.project_dir%%" instead of "%%kernel.root_dir%%".',
$filterName,
$canFiltersStillFunction ? 'is deprecated and will not work' : 'no longer works',
Expand Down
4 changes: 2 additions & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ public function getConfigTreeBuilder(): TreeBuilder
->arrayNode('controller')
->addDefaultsIfNotSet()
->children()
->scalarNode('filter_action')->defaultValue(sprintf('%s::filterAction', ImagineController::class))->end()
->scalarNode('filter_runtime_action')->defaultValue(sprintf('%s::filterRuntimeAction', ImagineController::class))->end()
->scalarNode('filter_action')->defaultValue(\sprintf('%s::filterAction', ImagineController::class))->end()
->scalarNode('filter_runtime_action')->defaultValue(\sprintf('%s::filterRuntimeAction', ImagineController::class))->end()
->integerNode('redirect_response_code')->defaultValue(302)
->validate()
->ifTrue(function ($redirectResponseCode) {
Expand Down
Loading

0 comments on commit 1adcca2

Please sign in to comment.