diff --git a/CHANGELOG.md b/CHANGELOG.md index dd142c813..bcc45df12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/src/Component/Console/Style/ImagineStyle.php b/src/Component/Console/Style/ImagineStyle.php index 1a3f61c77..d3b24ebe9 100644 --- a/src/Component/Console/Style/ImagineStyle.php +++ b/src/Component/Console/Style/ImagineStyle.php @@ -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('(%1$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('%1$s[%2$s]', $item, $group, $fg ?: 'default') @@ -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); @@ -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); } @@ -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(); @@ -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); diff --git a/src/Config/Filter/Argument/Point.php b/src/Config/Filter/Argument/Point.php index 70dd4c179..ade620b3f 100644 --- a/src/Config/Filter/Argument/Point.php +++ b/src/Config/Filter/Argument/Point.php @@ -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; diff --git a/src/Config/Filter/Argument/Size.php b/src/Config/Filter/Argument/Size.php index 1a93cf599..9f3bea9ac 100644 --- a/src/Config/Filter/Argument/Size.php +++ b/src/Config/Filter/Argument/Size.php @@ -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; diff --git a/src/Config/Filter/Type/Downscale.php b/src/Config/Filter/Type/Downscale.php index 1aafb77de..0b6211dc1 100644 --- a/src/Config/Filter/Type/Downscale.php +++ b/src/Config/Filter/Type/Downscale.php @@ -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; diff --git a/src/Config/Filter/Type/RelativeResize.php b/src/Config/Filter/Type/RelativeResize.php index d295961c0..51a7d7b5f 100644 --- a/src/Config/Filter/Type/RelativeResize.php +++ b/src/Config/Filter/Type/RelativeResize.php @@ -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; diff --git a/src/Config/Filter/Type/Scale.php b/src/Config/Filter/Type/Scale.php index 1d0c7b445..e3d5d5b88 100644 --- a/src/Config/Filter/Type/Scale.php +++ b/src/Config/Filter/Type/Scale.php @@ -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; diff --git a/src/Config/Filter/Type/Thumbnail.php b/src/Config/Filter/Type/Thumbnail.php index 8bc8ed2ec..3c12d68cc 100644 --- a/src/Config/Filter/Type/Thumbnail.php +++ b/src/Config/Filter/Type/Thumbnail.php @@ -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; diff --git a/src/Config/Filter/Type/Upscale.php b/src/Config/Filter/Type/Upscale.php index ba0e2d26d..b95cb0b81 100644 --- a/src/Config/Filter/Type/Upscale.php +++ b/src/Config/Filter/Type/Upscale.php @@ -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; diff --git a/src/Config/Filter/Type/Watermark.php b/src/Config/Filter/Type/Watermark.php index 4bae0e33d..5c41156c1 100644 --- a/src/Config/Filter/Type/Watermark.php +++ b/src/Config/Filter/Type/Watermark.php @@ -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; diff --git a/src/Config/Stack.php b/src/Config/Stack.php index 06e890671..74b594bdb 100644 --- a/src/Config/Stack.php +++ b/src/Config/Stack.php @@ -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; diff --git a/src/Controller/ImagineController.php b/src/Controller/ImagineController.php index 3838c27c5..2e9e5cf32 100644 --- a/src/Controller/ImagineController.php +++ b/src/Controller/ImagineController.php @@ -38,7 +38,7 @@ public function __construct( FilterService $filterService, DataManager $dataManager, SignerInterface $signer, - ControllerConfig $controllerConfig + ?ControllerConfig $controllerConfig ) { $this->filterService = $filterService; $this->dataManager = $dataManager; @@ -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()); diff --git a/src/DependencyInjection/Factory/Loader/AbstractLoaderFactory.php b/src/DependencyInjection/Factory/Loader/AbstractLoaderFactory.php index 3cf0f188c..515a0111b 100644 --- a/src/DependencyInjection/Factory/Loader/AbstractLoaderFactory.php +++ b/src/DependencyInjection/Factory/Loader/AbstractLoaderFactory.php @@ -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())); } diff --git a/src/DependencyInjection/Factory/Resolver/AbstractResolverFactory.php b/src/DependencyInjection/Factory/Resolver/AbstractResolverFactory.php index c3de07770..bb11d114e 100644 --- a/src/DependencyInjection/Factory/Resolver/AbstractResolverFactory.php +++ b/src/DependencyInjection/Factory/Resolver/AbstractResolverFactory.php @@ -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())); } diff --git a/src/DependencyInjection/Factory/Resolver/AwsS3ResolverFactory.php b/src/DependencyInjection/Factory/Resolver/AwsS3ResolverFactory.php index 9d62353a2..8279034b2 100644 --- a/src/DependencyInjection/Factory/Resolver/AwsS3ResolverFactory.php +++ b/src/DependencyInjection/Factory/Resolver/AwsS3ResolverFactory.php @@ -93,7 +93,7 @@ public function addConfiguration(ArrayNodeDefinition $builder): void ->cannotBeEmpty() ->end() ->scalarNode('cache_prefix') - ->defaultValue(null) + ->defaultValue('') ->end() ->arrayNode('client_config') ->isRequired() diff --git a/src/DependencyInjection/Factory/Resolver/FlysystemResolverFactory.php b/src/DependencyInjection/Factory/Resolver/FlysystemResolverFactory.php index 710fd928e..cd3f4c528 100644 --- a/src/DependencyInjection/Factory/Resolver/FlysystemResolverFactory.php +++ b/src/DependencyInjection/Factory/Resolver/FlysystemResolverFactory.php @@ -49,7 +49,7 @@ public function addConfiguration(ArrayNodeDefinition $builder): void ->cannotBeEmpty() ->end() ->scalarNode('cache_prefix') - ->defaultValue(null) + ->defaultValue('') ->end() ->scalarNode('root_url') ->isRequired() diff --git a/src/Events/CacheResolveEvent.php b/src/Events/CacheResolveEvent.php index 46b9a82de..dcec6ef32 100644 --- a/src/Events/CacheResolveEvent.php +++ b/src/Events/CacheResolveEvent.php @@ -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; diff --git a/src/Factory/Config/Filter/Argument/PointFactory.php b/src/Factory/Config/Filter/Argument/PointFactory.php index e412bcc73..d4938c173 100644 --- a/src/Factory/Config/Filter/Argument/PointFactory.php +++ b/src/Factory/Config/Filter/Argument/PointFactory.php @@ -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); } diff --git a/src/Factory/Config/Filter/Argument/SizeFactory.php b/src/Factory/Config/Filter/Argument/SizeFactory.php index 6b2294411..aabe9cdca 100644 --- a/src/Factory/Config/Filter/Argument/SizeFactory.php +++ b/src/Factory/Config/Filter/Argument/SizeFactory.php @@ -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); } diff --git a/src/Factory/Config/StackFactory.php b/src/Factory/Config/StackFactory.php index 29b5333fd..e5993b93a 100644 --- a/src/Factory/Config/StackFactory.php +++ b/src/Factory/Config/StackFactory.php @@ -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); } diff --git a/src/Factory/Config/StackFactoryInterface.php b/src/Factory/Config/StackFactoryInterface.php index a8099cb63..c6f3dd3c7 100644 --- a/src/Factory/Config/StackFactoryInterface.php +++ b/src/Factory/Config/StackFactoryInterface.php @@ -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; } diff --git a/src/Imagine/Cache/CacheManager.php b/src/Imagine/Cache/CacheManager.php index 4a1da10a0..67256c8b9 100644 --- a/src/Imagine/Cache/CacheManager.php +++ b/src/Imagine/Cache/CacheManager.php @@ -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; @@ -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); @@ -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, '/'), @@ -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); } @@ -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)); @@ -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); } diff --git a/src/Imagine/Cache/Resolver/AbstractFilesystemResolver.php b/src/Imagine/Cache/Resolver/AbstractFilesystemResolver.php index 925052b57..52295605b 100644 --- a/src/Imagine/Cache/Resolver/AbstractFilesystemResolver.php +++ b/src/Imagine/Cache/Resolver/AbstractFilesystemResolver.php @@ -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; } diff --git a/src/Imagine/Cache/Resolver/PsrCacheResolver.php b/src/Imagine/Cache/Resolver/PsrCacheResolver.php index 320e2a00b..4eb3f5b9e 100644 --- a/src/Imagine/Cache/Resolver/PsrCacheResolver.php +++ b/src/Imagine/Cache/Resolver/PsrCacheResolver.php @@ -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; diff --git a/src/Imagine/Cache/Signer.php b/src/Imagine/Cache/Signer.php index 5c3dc5f5a..877f80292 100644 --- a/src/Imagine/Cache/Signer.php +++ b/src/Imagine/Cache/Signer.php @@ -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) { @@ -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); } diff --git a/src/Imagine/Cache/SignerInterface.php b/src/Imagine/Cache/SignerInterface.php index 859373524..69ebaea67 100644 --- a/src/Imagine/Cache/SignerInterface.php +++ b/src/Imagine/Cache/SignerInterface.php @@ -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; } diff --git a/src/Imagine/Data/DataManager.php b/src/Imagine/Data/DataManager.php index 39bbd80fc..064b228c8 100644 --- a/src/Imagine/Data/DataManager.php +++ b/src/Imagine/Data/DataManager.php @@ -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; diff --git a/src/Imagine/Filter/PostProcessor/AbstractPostProcessor.php b/src/Imagine/Filter/PostProcessor/AbstractPostProcessor.php index 54bdefe3b..7524dfd7e 100644 --- a/src/Imagine/Filter/PostProcessor/AbstractPostProcessor.php +++ b/src/Imagine/Filter/PostProcessor/AbstractPostProcessor.php @@ -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; @@ -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); @@ -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(); diff --git a/src/Imagine/Filter/PostProcessor/CwebpPostProcessor.php b/src/Imagine/Filter/PostProcessor/CwebpPostProcessor.php index 3ef82c13b..86ae48c7f 100644 --- a/src/Imagine/Filter/PostProcessor/CwebpPostProcessor.php +++ b/src/Imagine/Filter/PostProcessor/CwebpPostProcessor.php @@ -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); diff --git a/src/Imagine/Filter/PostProcessor/JpegOptimPostProcessor.php b/src/Imagine/Filter/PostProcessor/JpegOptimPostProcessor.php index dd8a9ff2b..117f804b9 100644 --- a/src/Imagine/Filter/PostProcessor/JpegOptimPostProcessor.php +++ b/src/Imagine/Filter/PostProcessor/JpegOptimPostProcessor.php @@ -40,7 +40,7 @@ class JpegOptimPostProcessor extends AbstractPostProcessor * @param bool $progressive Force output to be progressive * @param string|null $temporaryRootPath Directory where temporary file will be written */ - public function __construct(string $executablePath = '/usr/bin/jpegoptim', bool $strip = true, int $quality = null, bool $progressive = true, string $temporaryRootPath = null) + public function __construct(string $executablePath = '/usr/bin/jpegoptim', bool $strip = true, ?int $quality = null, bool $progressive = true, ?string $temporaryRootPath = null) { parent::__construct($executablePath, $temporaryRootPath); diff --git a/src/Imagine/Filter/PostProcessor/MozJpegPostProcessor.php b/src/Imagine/Filter/PostProcessor/MozJpegPostProcessor.php index a7f8b225b..ccf7149fe 100644 --- a/src/Imagine/Filter/PostProcessor/MozJpegPostProcessor.php +++ b/src/Imagine/Filter/PostProcessor/MozJpegPostProcessor.php @@ -34,7 +34,7 @@ class MozJpegPostProcessor extends AbstractPostProcessor * @param string $executablePath Path to the mozjpeg cjpeg binary * @param int|null $quality Quality factor */ - public function __construct(string $executablePath = '/opt/mozjpeg/bin/cjpeg', int $quality = null) + public function __construct(string $executablePath = '/opt/mozjpeg/bin/cjpeg', ?int $quality = null) { parent::__construct($executablePath); diff --git a/src/Imagine/Filter/PostProcessor/OptiPngPostProcessor.php b/src/Imagine/Filter/PostProcessor/OptiPngPostProcessor.php index bf3b23c0c..2cf93bac4 100644 --- a/src/Imagine/Filter/PostProcessor/OptiPngPostProcessor.php +++ b/src/Imagine/Filter/PostProcessor/OptiPngPostProcessor.php @@ -34,7 +34,7 @@ class OptiPngPostProcessor extends AbstractPostProcessor * @param bool $strip Strip metadata objects * @param string|null $temporaryRootPath Directory where temporary file will be written */ - public function __construct(string $executablePath = '/usr/bin/optipng', int $level = 7, bool $strip = true, string $temporaryRootPath = null) + public function __construct(string $executablePath = '/usr/bin/optipng', int $level = 7, bool $strip = true, ?string $temporaryRootPath = null) { parent::__construct($executablePath, $temporaryRootPath); diff --git a/src/Message/WarmupCache.php b/src/Message/WarmupCache.php index 5e34ccca0..a9879ee33 100644 --- a/src/Message/WarmupCache.php +++ b/src/Message/WarmupCache.php @@ -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; diff --git a/src/Model/Binary.php b/src/Model/Binary.php index 9cb600659..582d92dcf 100644 --- a/src/Model/Binary.php +++ b/src/Model/Binary.php @@ -21,7 +21,7 @@ class Binary implements BinaryInterface protected ?string $format; - public function __construct(string $content, ?string $mimeType, string $format = null) + public function __construct(string $content, ?string $mimeType, ?string $format = null) { $this->content = $content; $this->mimeType = $mimeType; diff --git a/src/Model/FileBinary.php b/src/Model/FileBinary.php index dc84b946b..3a2e0d71b 100644 --- a/src/Model/FileBinary.php +++ b/src/Model/FileBinary.php @@ -21,7 +21,7 @@ class FileBinary implements FileBinaryInterface protected ?string $format; - public function __construct(string $path, ?string $mimeType, string $format = null) + public function __construct(string $path, ?string $mimeType, ?string $format = null) { $this->path = $path; $this->mimeType = $mimeType; diff --git a/src/Service/FilterService.php b/src/Service/FilterService.php index 515169441..9a0fb1935 100644 --- a/src/Service/FilterService.php +++ b/src/Service/FilterService.php @@ -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; @@ -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; @@ -92,7 +92,7 @@ public function warmUpCache( return $warmedUp; } - public function getUrlOfFilteredImage(string $path, string $filter, string $resolver = null, bool $webpSupported = false): string + public function getUrlOfFilteredImage(string $path, string $filter, ?string $resolver = null, bool $webpSupported = false): string { foreach ($this->buildFilterPathContainers($path) as $filterPathContainer) { $this->warmUpCacheFilterPathContainer($filterPathContainer, $filter, $resolver); @@ -105,7 +105,7 @@ public function getUrlOfFilteredImageWithRuntimeFilters( string $path, string $filter, array $runtimeFilters = [], - string $resolver = null, + ?string $resolver = null, bool $webpSupported = false ): string { $runtimePath = $this->cacheManager->getRuntimePath($path, $runtimeFilters); @@ -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(); @@ -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)) { diff --git a/src/Templating/LazyFilterRuntime.php b/src/Templating/LazyFilterRuntime.php index 794208b40..aec3a1a09 100644 --- a/src/Templating/LazyFilterRuntime.php +++ b/src/Templating/LazyFilterRuntime.php @@ -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; @@ -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); @@ -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)) { diff --git a/src/Utility/Framework/SymfonyFramework.php b/src/Utility/Framework/SymfonyFramework.php index 982bdff66..dc8301c43 100644 --- a/src/Utility/Framework/SymfonyFramework.php +++ b/src/Utility/Framework/SymfonyFramework.php @@ -23,17 +23,17 @@ public static function getContainerResolvableRootWebPath(): string return sprintf('%%kernel.project_dir%%/%s', self::isKernelLessThan(4) ? 'web' : 'public'); } - public static function isKernelGreaterThanOrEqualTo(int $major, int $minor = null, int $patch = null): bool + public static function isKernelGreaterThanOrEqualTo(int $major, ?int $minor = null, ?int $patch = null): bool { return static::kernelVersionCompare('>=', $major, $minor, $patch); } - public static function isKernelLessThan(int $major, int $minor = null, int $patch = null): bool + public static function isKernelLessThan(int $major, ?int $minor = null, ?int $patch = null): bool { return static::kernelVersionCompare('<', $major, $minor, $patch); } - private static function kernelVersionCompare(string $operator, int $major, int $minor = null, int $patch = null): bool + private static function kernelVersionCompare(string $operator, int $major, ?int $minor = null, ?int $patch = null): bool { return version_compare((string) Kernel::VERSION_ID, sprintf("%d%'.02d%'.02d", $major, $minor ?: 0, $patch ?: 0), $operator); } diff --git a/tests/Binary/Loader/ChainLoaderTest.php b/tests/Binary/Loader/ChainLoaderTest.php index 6a727b59f..8ca738cc8 100644 --- a/tests/Binary/Loader/ChainLoaderTest.php +++ b/tests/Binary/Loader/ChainLoaderTest.php @@ -130,7 +130,7 @@ private function getFileSystemLocator(array $paths = []): FileSystemLocator * @param string[] $paths * @param FileSystemLoader[] $loaders */ - private function getChainLoader(array $paths = [], array $loaders = null): ChainLoader + private function getChainLoader(array $paths = [], ?array $loaders = null): ChainLoader { if (null === $loaders) { $loaders = [ diff --git a/tests/Binary/Loader/FileSystemLoaderTest.php b/tests/Binary/Loader/FileSystemLoaderTest.php index 6d5a5cd20..b02badd18 100644 --- a/tests/Binary/Loader/FileSystemLoaderTest.php +++ b/tests/Binary/Loader/FileSystemLoaderTest.php @@ -178,7 +178,7 @@ private function getDefaultDataRoots(): array return [__DIR__]; } - private function getFileSystemLoader(array $roots = [], LocatorInterface $locator = null): FileSystemLoader + private function getFileSystemLoader(array $roots = [], ?LocatorInterface $locator = null): FileSystemLoader { $mimeTypes = MimeTypes::getDefault(); diff --git a/tests/Component/Console/Style/ImagineStyleTest.php b/tests/Component/Console/Style/ImagineStyleTest.php index f9e2dbd8e..651dc0eb0 100644 --- a/tests/Component/Console/Style/ImagineStyleTest.php +++ b/tests/Component/Console/Style/ImagineStyleTest.php @@ -97,7 +97,7 @@ public static function provideNewlineData(): \Generator /** * @dataProvider provideTitleData */ - public function testTitle(string $title, string $type = null, bool $decoration): void + public function testTitle(string $title, ?string $type, bool $decoration): void { $style = $this->createImagineStyle($output = $this->createBufferedOutput(), $decoration); $style->title($title, $type); @@ -174,7 +174,7 @@ public static function provideBlockTypesData(): \Generator /** * @dataProvider provideStatusData */ - public function testStatus(string $status, string $fg = null, string $bg = null): void + public function testStatus(string $status, ?string $fg = null, ?string $bg = null): void { $style = $this->createImagineStyle($output = $this->createBufferedOutput()); $style->status($status, $fg); @@ -198,7 +198,7 @@ public static function provideStatusData(): \Generator /** * @dataProvider provideGroupData */ - public function testGroup(string $item, string $group, string $fg = null, string $bg = null): void + public function testGroup(string $item, string $group, ?string $fg = null, ?string $bg = null): void { $style = $this->createImagineStyle($output = $this->createBufferedOutput()); $style->group($item, $group, $fg, $bg); diff --git a/tests/DependencyInjection/Factory/Resolver/AwsS3ResolverFactoryTest.php b/tests/DependencyInjection/Factory/Resolver/AwsS3ResolverFactoryTest.php index 28110f489..c988a6d07 100644 --- a/tests/DependencyInjection/Factory/Resolver/AwsS3ResolverFactoryTest.php +++ b/tests/DependencyInjection/Factory/Resolver/AwsS3ResolverFactoryTest.php @@ -379,7 +379,7 @@ public function testAddDefaultOptionsIfNotSetOnAddConfiguration(): void $this->assertSame([], $config['get_options']); $this->assertArrayHasKey('cache_prefix', $config); - $this->assertNull($config['cache_prefix']); + $this->assertSame('', $config['cache_prefix']); } public function testSupportAwsV3ClientConfig(): void diff --git a/tests/Functional/Command/RemoveCacheCommandTest.php b/tests/Functional/Command/RemoveCacheCommandTest.php index 8db83d7c4..5aec1d601 100644 --- a/tests/Functional/Command/RemoveCacheCommandTest.php +++ b/tests/Functional/Command/RemoveCacheCommandTest.php @@ -216,7 +216,7 @@ protected function assertOutputNotContainsSummary(string $output, array $images, * @param string[] $filters * @param string[] $additionalOptions */ - private function executeRemoveCacheCommand(array $paths, array $filters = [], array $additionalOptions = [], int &$return = null): string + private function executeRemoveCacheCommand(array $paths, array $filters = [], array $additionalOptions = [], ?int &$return = null): string { $options = array_merge(['paths' => $paths], $additionalOptions); diff --git a/tests/Functional/Command/ResolveCacheCommandTest.php b/tests/Functional/Command/ResolveCacheCommandTest.php index 364100d53..07194b7f9 100644 --- a/tests/Functional/Command/ResolveCacheCommandTest.php +++ b/tests/Functional/Command/ResolveCacheCommandTest.php @@ -219,7 +219,7 @@ protected function assertOutputNotContainsSummary(string $output, array $images, * @param string[] $filters * @param string[] $additionalOptions */ - private function executeResolveCacheCommand(array $paths, array $filters = [], array $additionalOptions = [], int &$return = null): string + private function executeResolveCacheCommand(array $paths, array $filters = [], array $additionalOptions = [], ?int &$return = null): string { $options = array_merge(['paths' => $paths], $additionalOptions); diff --git a/tests/Imagine/Filter/Loader/ResampleFilterLoaderTest.php b/tests/Imagine/Filter/Loader/ResampleFilterLoaderTest.php index 7dfffe1b0..42dae672d 100644 --- a/tests/Imagine/Filter/Loader/ResampleFilterLoaderTest.php +++ b/tests/Imagine/Filter/Loader/ResampleFilterLoaderTest.php @@ -175,7 +175,7 @@ public function testThrowsOnSaveOrOpenError(): void $this->createResampleFilterLoaderInstance()->load($image, ['x' => 120, 'y' => 120, 'unit' => 'ppi']); } - private function createResampleFilterLoaderInstance(ImagineInterface $imagine = null): ResampleFilterLoader + private function createResampleFilterLoaderInstance(?ImagineInterface $imagine = null): ResampleFilterLoader { return new ResampleFilterLoader($imagine ?: $this->createMock(ImagineInterface::class)); }