Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 to 3 #1570

Merged
merged 7 commits into from
Feb 26, 2024
Merged

2 to 3 #1570

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -19,7 +19,7 @@ abstract class AbstractLoaderFactory implements LoaderFactoryInterface
{
protected static string $namePrefix = 'liip_imagine.binary.loader';

final protected function getChildLoaderDefinition(string $name = null): ChildDefinition
final protected function getChildLoaderDefinition(?string $name = null): ChildDefinition
{
return new ChildDefinition(sprintf('%s.prototype.%s', static::$namePrefix, $name ?: $this->getName()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ abstract class AbstractResolverFactory implements ResolverFactoryInterface
{
protected static string $namePrefix = 'liip_imagine.cache.resolver';

final protected function getChildResolverDefinition(string $name = null): ChildDefinition
final protected function getChildResolverDefinition(?string $name = null): ChildDefinition
{
return new ChildDefinition(sprintf('%s.prototype.%s', static::$namePrefix, $name ?: $this->getName()));
}
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/Events/CacheResolveEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class CacheResolveEvent extends Event
/**
* Init default event state.
*/
public function __construct(string $path, string $filter, string $url = null)
public function __construct(string $path, string $filter, ?string $url = null)
{
$this->path = $path;
$this->filter = $filter;
Expand Down
2 changes: 1 addition & 1 deletion src/Factory/Config/Filter/Argument/PointFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
final class PointFactory
{
public function create(int $x = null, int $y = null): Point
public function create(?int $x = null, ?int $y = null): Point
{
return new Point($x, $y);
}
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;
}
12 changes: 6 additions & 6 deletions src/Imagine/Cache/CacheManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function __construct(
RouterInterface $router,
SignerInterface $signer,
EventDispatcherInterface $dispatcher,
string $defaultResolver = null,
?string $defaultResolver = null,
bool $webpGenerate = false
) {
$this->filterConfig = $filterConfig;
Expand Down Expand Up @@ -77,7 +77,7 @@ public function addResolver(string $filter, ResolverInterface $resolver): void
*
* @param string $path The path where the resolved file is expected
*/
public function getBrowserPath(string $path, string $filter, array $runtimeConfig = [], string $resolver = null, int $referenceType = UrlGeneratorInterface::ABSOLUTE_URL): string
public function getBrowserPath(string $path, string $filter, array $runtimeConfig = [], ?string $resolver = null, int $referenceType = UrlGeneratorInterface::ABSOLUTE_URL): string
{
if (!empty($runtimeConfig)) {
$rcPath = $this->getRuntimePath($path, $runtimeConfig);
Expand Down Expand Up @@ -109,7 +109,7 @@ public function getRuntimePath(string $path, array $runtimeConfig): string
* @param string $filter The name of the imagine filter in effect
* @param int $referenceType The type of reference to be generated (one of the UrlGenerator constants)
*/
public function generateUrl(string $path, string $filter, array $runtimeConfig = [], string $resolver = null, int $referenceType = UrlGeneratorInterface::ABSOLUTE_URL): string
public function generateUrl(string $path, string $filter, array $runtimeConfig = [], ?string $resolver = null, int $referenceType = UrlGeneratorInterface::ABSOLUTE_URL): string
{
$params = [
'path' => ltrim($path, '/'),
Expand All @@ -135,7 +135,7 @@ public function generateUrl(string $path, string $filter, array $runtimeConfig =
/**
* Checks whether the path is already stored within the respective Resolver.
*/
public function isStored(string $path, string $filter, string $resolver = null): bool
public function isStored(string $path, string $filter, ?string $resolver = null): bool
{
return $this->getResolver($filter, $resolver)->isStored($path, $filter);
}
Expand All @@ -147,7 +147,7 @@ public function isStored(string $path, string $filter, string $resolver = null):
*
* @return string The url of resolved image
*/
public function resolve(string $path, string $filter, string $resolver = null): string
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));
Expand All @@ -167,7 +167,7 @@ public function resolve(string $path, string $filter, string $resolver = null):
/**
* @see ResolverInterface::store
*/
public function store(BinaryInterface $binary, string $path, string $filter, string $resolver = null): void
public function store(BinaryInterface $binary, string $path, string $filter, ?string $resolver = null): void
{
$this->getResolver($filter, $resolver)->store($binary, $path, $filter);
}
Expand Down
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;
}
4 changes: 2 additions & 2 deletions src/Imagine/Data/DataManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public function __construct(
MimeTypeGuesserInterface $mimeTypeGuesser,
MimeTypesInterface $extensionGuesser,
FilterConfiguration $filterConfig,
string $defaultLoader = null,
string $globalDefaultImage = null
?string $defaultLoader = null,
?string $globalDefaultImage = null
) {
$this->mimeTypeGuesser = $mimeTypeGuesser;
$this->filterConfig = $filterConfig;
Expand Down
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
Loading
Loading