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 Feb 23, 2024
2 parents 65613e8 + 2ad259d commit cd6aa7e
Show file tree
Hide file tree
Showing 34 changed files with 67 additions and 63 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.12.2](https://github.com/liip/LiipImagineBundle/tree/2.12.2)

- Avoid PHP 8.3 warning with default empty prefix ([simonberger](https://github.com/liip/LiipImagineBundle/pull/1568))

## [2.12.1](https://github.com/liip/LiipImagineBundle/tree/2.12.1)

- Adjustments to install with Symfony 7 ([mbabker](https://github.com/liip/LiipImagineBundle/pull/1535))
Expand Down
12 changes: 6 additions & 6 deletions src/Component/Console/Style/ImagineStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ public function newline(int $count = 1): self
return $this;
}

public function status(string $status, string $fg = null): 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')
);
}

public function group(string $item, string $group, string $fg = null): self
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')
Expand All @@ -68,7 +68,7 @@ public function group(string $item, string $group, string $fg = null): self
return $this->space();
}

public function title(string $title, string $type = null): self
public function title(string $title, ?string $type = null): self
{
if (!$this->decoration) {
return $this->plainTitle($title, $type);
Expand All @@ -87,7 +87,7 @@ public function critBlock(string $string, array $replacements = []): self
return $this->largeBlock($this->compileString(strip_tags($string), $replacements), 'ERROR', 'white', 'red', '#');
}

private function largeBlock(string $string, string $type, string $fg = null, string $bg = null, string $prefix = null): self
private function largeBlock(string $string, string $type, ?string $fg = null, ?string $bg = null, ?string $prefix = null): self
{
return $this->block($string, $type, $fg, $bg, $prefix, true);
}
Expand All @@ -97,7 +97,7 @@ private function space(int $count = 1): self
return $this->text(str_repeat(' ', $count));
}

private function plainTitle(string $title, string $type = null): self
private function plainTitle(string $title, ?string $type = null): self
{
$this->newline();

Expand All @@ -110,7 +110,7 @@ private function plainTitle(string $title, string $type = null): self
return $this->newline();
}

private function block(string $string, string $type = null, string $fg = null, string $bg = null, string $prefix = null, bool $padding = true): self
private function block(string $string, ?string $type = null, ?string $fg = null, ?string $bg = null, ?string $prefix = null, bool $padding = true): self
{
if (!$this->decoration) {
return $this->plainBlock($string, $type);
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Filter/Argument/Point.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class Point

private ?int $y;

public function __construct(int $x = null, int $y = null)
public function __construct(?int $x = null, ?int $y = null)
{
$this->x = $x;
$this->y = $y;
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Filter/Argument/Size.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class Size
* To allow keeping aspect ratio, it is allowed to only specify one of width or height.
* It is however not allowed to specify neither dimension.
*/
public function __construct(int $width = null, int $height = null)
public function __construct(?int $width = null, ?int $height = null)
{
$this->width = $width;
$this->height = $height;
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Filter/Type/Downscale.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class Downscale extends FilterAbstract
/**
* @param float|null $by sets the "ratio multiple" which initiates a proportional scale operation computed by multiplying all image sides by this value
*/
public function __construct(Size $max = null, float $by = null)
public function __construct(?Size $max = null, ?float $by = null)
{
$this->max = $max;
$this->by = $by;
Expand Down
8 changes: 4 additions & 4 deletions src/Config/Filter/Type/RelativeResize.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ final class RelativeResize extends FilterAbstract
private ?float $scale;

public function __construct(
float $heighten = null,
float $widen = null,
float $increase = null,
float $scale = null
?float $heighten = null,
?float $widen = null,
?float $increase = null,
?float $scale = null
) {
$this->heighten = $heighten;
$this->widen = $widen;
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Filter/Type/Scale.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class Scale extends FilterAbstract
/**
* @param float|null $to proportional scale operation computed by multiplying all image sides by this value
*/
public function __construct(Size $dimensions, float $to = null)
public function __construct(Size $dimensions, ?float $to = null)
{
$this->dimensions = $dimensions;
$this->to = $to;
Expand Down
6 changes: 3 additions & 3 deletions src/Config/Filter/Type/Thumbnail.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ final class Thumbnail extends FilterAbstract

public function __construct(
Size $size,
string $mode = null,
bool $allowUpscale = null,
string $filter = null
?string $mode = null,
?bool $allowUpscale = null,
?string $filter = null
) {
$this->size = $size;
$this->mode = $mode;
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Filter/Type/Upscale.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class Upscale extends FilterAbstract
/**
* @param float|null $by sets the "ratio multiple" which initiates a proportional scale operation computed by multiplying all image sides by this value
*/
public function __construct(Size $min, float $by = null)
public function __construct(Size $min, ?float $by = null)
{
$this->min = $min;
$this->by = $by;
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Filter/Type/Watermark.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class Watermark extends FilterAbstract

private ?float $size;

public function __construct(string $image, string $position, float $size = null)
public function __construct(string $image, string $position, ?float $size = null)
{
$this->image = $image;
$this->position = $position;
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Stack.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class Stack implements StackInterface
* @param string|null $dataLoader name of a custom data loader. Default value: filesystem (which means the standard filesystem loader is used).
* @param FilterInterface[] $filters
*/
public function __construct(string $name, string $dataLoader = null, int $quality = null, array $filters = [])
public function __construct(string $name, ?string $dataLoader, ?int $quality, array $filters = [])
{
$this->name = $name;
$this->dataLoader = $dataLoader;
Expand Down
4 changes: 2 additions & 2 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 @@ -103,7 +103,7 @@ public function filterRuntimeAction(Request $request, string $hash, string $path
}, $path, $filter, $hash);
}

private function createRedirectResponse(\Closure $url, string $path, string $filter, string $hash = null): RedirectResponse
private function createRedirectResponse(\Closure $url, string $path, string $filter, ?string $hash = null): RedirectResponse
{
try {
return new RedirectResponse($url(), $this->controllerConfig->getRedirectResponseCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function addConfiguration(ArrayNodeDefinition $builder): void
->cannotBeEmpty()
->end()
->scalarNode('cache_prefix')
->defaultValue(null)
->defaultValue('')
->end()
->arrayNode('client_config')
->isRequired()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function addConfiguration(ArrayNodeDefinition $builder): void
->cannotBeEmpty()
->end()
->scalarNode('cache_prefix')
->defaultValue(null)
->defaultValue('')
->end()
->scalarNode('root_url')
->isRequired()
Expand Down
2 changes: 1 addition & 1 deletion src/Factory/Config/Filter/Argument/SizeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
final class SizeFactory
{
public function create(int $width = null, int $height = null): Size
public function create(?int $width = null, ?int $height = null): Size
{
return new Size($width, $height);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Factory/Config/StackFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
final class StackFactory implements StackFactoryInterface
{
public function create(string $name, string $dataLoader = null, int $quality = null, array $filters = []): StackInterface
public function create(string $name, ?string $dataLoader, ?int $quality, array $filters = []): StackInterface
{
return new Stack($name, $dataLoader, $quality, $filters);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Factory/Config/StackFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ interface StackFactoryInterface
/**
* @param FilterInterface[] $filters
*/
public function create(string $name, string $dataLoader = null, int $quality = null, array $filters = []): StackInterface;
public function create(string $name, ?string $dataLoader, ?int $quality, array $filters = []): StackInterface;
}
2 changes: 1 addition & 1 deletion src/Imagine/Cache/Resolver/AbstractFilesystemResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(Filesystem $filesystem)
$this->filesystem = $filesystem;
}

public function setRequest(Request $request = null): void
public function setRequest(?Request $request = null): void
{
$this->request = $request;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Imagine/Cache/Resolver/PsrCacheResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final class PsrCacheResolver implements ResolverInterface
* * index_key
* The name of the index key being used to save a list of created cache keys regarding one image and filter pairing.
*/
public function __construct(CacheItemPoolInterface $cache, ResolverInterface $cacheResolver, array $options = [], OptionsResolver $optionsResolver = null)
public function __construct(CacheItemPoolInterface $cache, ResolverInterface $cacheResolver, array $options = [], ?OptionsResolver $optionsResolver = null)
{
$this->cache = $cache;
$this->resolver = $cacheResolver;
Expand Down
4 changes: 2 additions & 2 deletions src/Imagine/Cache/Signer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(string $secret)
$this->secret = $secret;
}

public function sign(string $path, array $runtimeConfig = null): string
public function sign(string $path, ?array $runtimeConfig = null): string
{
if ($runtimeConfig) {
array_walk_recursive($runtimeConfig, function (&$value) {
Expand All @@ -31,7 +31,7 @@ public function sign(string $path, array $runtimeConfig = null): string
return mb_substr(preg_replace('/[^a-zA-Z0-9-_]/', '', base64_encode(hash_hmac('sha256', ltrim($path, '/').(null === $runtimeConfig ?: serialize($runtimeConfig)), $this->secret, true))), 0, 8);
}

public function check(string $hash, string $path, array $runtimeConfig = null): bool
public function check(string $hash, string $path, ?array $runtimeConfig = null): bool
{
return $hash === $this->sign($path, $runtimeConfig);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Imagine/Cache/SignerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ interface SignerInterface
/**
* Return the hash for path and runtime config.
*/
public function sign(string $path, array $runtimeConfig = null): string;
public function sign(string $path, ?array $runtimeConfig = null): string;

/**
* Check hash is correct.
*/
public function check(string $hash, string $path, array $runtimeConfig = null): bool;
public function check(string $hash, string $path, ?array $runtimeConfig = null): bool;
}
6 changes: 3 additions & 3 deletions src/Imagine/Filter/PostProcessor/AbstractPostProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ abstract class AbstractPostProcessor implements PostProcessorInterface

private Filesystem $filesystem;

public function __construct(string $executablePath, string $temporaryRootPath = null)
public function __construct(string $executablePath, ?string $temporaryRootPath = null)
{
$this->executablePath = $executablePath;
$this->temporaryRootPath = $temporaryRootPath;
Expand Down Expand Up @@ -70,7 +70,7 @@ protected function isBinaryTypeMatch(BinaryInterface $binary, array $types): boo
return \in_array($binary->getMimeType(), $types, true);
}

protected function writeTemporaryFile(BinaryInterface $binary, array $options = [], string $prefix = null): string
protected function writeTemporaryFile(BinaryInterface $binary, array $options = [], ?string $prefix = null): string
{
$temporary = $this->acquireTemporaryFilePath($options, $prefix);

Expand All @@ -83,7 +83,7 @@ protected function writeTemporaryFile(BinaryInterface $binary, array $options =
return $temporary;
}

protected function acquireTemporaryFilePath(array $options, string $prefix = null): string
protected function acquireTemporaryFilePath(array $options, ?string $prefix = null): string
{
$root = $options['temp_dir'] ?? $this->temporaryRootPath ?: sys_get_temp_dir();

Expand Down
14 changes: 7 additions & 7 deletions src/Imagine/Filter/PostProcessor/CwebpPostProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ class CwebpPostProcessor extends AbstractPostProcessor
*/
public function __construct(
string $executablePath = '/usr/bin/cwebp',
string $temporaryRootPath = null,
int $q = null,
int $alphaQ = null,
int $m = null,
string $alphaFilter = null,
int $alphaMethod = null,
bool $exact = null,
?string $temporaryRootPath = null,
?int $q = null,
?int $alphaQ = null,
?int $m = null,
?string $alphaFilter = null,
?int $alphaMethod = null,
?bool $exact = null,
array $metadata = []
) {
parent::__construct($executablePath, $temporaryRootPath);
Expand Down
2 changes: 1 addition & 1 deletion src/Message/WarmupCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class WarmupCache
* @param string[]|null $filters List of filter set names to warm up. If not set, all available filter sets are warmed up
* @param bool $force Whether to recreate existing cached images or only create them when no cache currently exists
*/
public function __construct(string $path, array $filters = null, bool $force = false)
public function __construct(string $path, ?array $filters = null, bool $force = false)
{
$this->path = $path;
$this->filters = $filters;
Expand Down
8 changes: 4 additions & 4 deletions src/Service/FilterService.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(
CacheManager $cacheManager,
bool $webpGenerate,
array $webpOptions,
LoggerInterface $logger = null
?LoggerInterface $logger = null
) {
$this->dataManager = $dataManager;
$this->filterManager = $filterManager;
Expand Down Expand Up @@ -78,7 +78,7 @@ public function bustCache(string $path, string $filter): bool
public function warmUpCache(
string $path,
string $filter,
string $resolver = null,
?string $resolver = null,
bool $forced = false
): bool {
$warmedUp = false;
Expand Down Expand Up @@ -145,7 +145,7 @@ private function buildFilterPathContainers(string $source, string $target = '',
private function resolveFilterPathContainer(
FilterPathContainer $filterPathContainer,
string $filter,
string $resolver = null,
?string $resolver = null,
bool $webpSupported = false
): string {
$path = $filterPathContainer->getTarget();
Expand All @@ -165,7 +165,7 @@ private function resolveFilterPathContainer(
private function warmUpCacheFilterPathContainer(
FilterPathContainer $filterPathContainer,
string $filter,
string $resolver = null,
?string $resolver = null,
bool $forced = false
): bool {
if ($forced || !$this->cacheManager->isStored($filterPathContainer->getTarget(), $filter, $resolver)) {
Expand Down
6 changes: 3 additions & 3 deletions src/Templating/LazyFilterRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class LazyFilterRuntime implements RuntimeExtensionInterface
*/
private ?string $assetVersion;

public function __construct(CacheManager $cache, string $assetVersion = null)
public function __construct(CacheManager $cache, ?string $assetVersion = null)
{
$this->cache = $cache;
$this->assetVersion = $assetVersion;
Expand All @@ -33,7 +33,7 @@ public function __construct(CacheManager $cache, string $assetVersion = null)
/**
* Gets the browser path for the image and filter to apply.
*/
public function filter(string $path, string $filter, array $config = [], string $resolver = null, int $referenceType = UrlGeneratorInterface::ABSOLUTE_URL): string
public function filter(string $path, string $filter, array $config = [], ?string $resolver = null, int $referenceType = UrlGeneratorInterface::ABSOLUTE_URL): string
{
$path = $this->cleanPath($path);
$path = $this->cache->getBrowserPath($path, $filter, $config, $resolver, $referenceType);
Expand All @@ -46,7 +46,7 @@ public function filter(string $path, string $filter, array $config = [], string
*
* This does not check whether the cached image exists or not.
*/
public function filterCache(string $path, string $filter, array $config = [], string $resolver = null): string
public function filterCache(string $path, string $filter, array $config = [], ?string $resolver = null): string
{
$path = $this->cleanPath($path);
if (\count($config)) {
Expand Down
Loading

0 comments on commit cd6aa7e

Please sign in to comment.