From f51040286f60248eef6f3d12102b605afb09f2db Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Fri, 23 Feb 2024 22:05:43 +0100 Subject: [PATCH] adjust to latest codestyle rules --- Async/ResolveCache.php | 2 +- Component/Console/Style/ImagineStyle.php | 12 ++++++------ Config/Filter/Argument/Point.php | 2 +- Config/Filter/Argument/Size.php | 2 +- Config/Filter/Type/Background.php | 6 +++--- Config/Filter/Type/Downscale.php | 2 +- Config/Filter/Type/RelativeResize.php | 8 ++++---- Config/Filter/Type/Scale.php | 2 +- Config/Filter/Type/Thumbnail.php | 6 +++--- Config/Filter/Type/Upscale.php | 2 +- Config/Filter/Type/Watermark.php | 2 +- Config/Stack.php | 2 +- Controller/ImagineController.php | 4 ++-- Factory/Config/Filter/Argument/SizeFactory.php | 2 +- Factory/Config/StackFactory.php | 2 +- Factory/Config/StackFactoryInterface.php | 2 +- .../Cache/Resolver/AbstractFilesystemResolver.php | 2 +- Imagine/Cache/Resolver/CacheResolver.php | 2 +- Imagine/Cache/Resolver/PsrCacheResolver.php | 2 +- Imagine/Cache/Signer.php | 4 ++-- Imagine/Cache/SignerInterface.php | 4 ++-- .../Filter/PostProcessor/AbstractPostProcessor.php | 6 +++--- .../Filter/PostProcessor/CwebpPostProcessor.php | 14 +++++++------- Message/WarmupCache.php | 2 +- Service/FilterService.php | 8 ++++---- Templating/FilterTrait.php | 2 +- Templating/LazyFilterRuntime.php | 6 +++--- Tests/AbstractTest.php | 2 +- Tests/Binary/Loader/ChainLoaderTest.php | 2 +- Tests/Binary/Loader/FileSystemLoaderTest.php | 2 +- Tests/Component/Console/Style/ImagineStyleTest.php | 6 +++--- .../Functional/Command/RemoveCacheCommandTest.php | 2 +- .../Functional/Command/ResolveCacheCommandTest.php | 2 +- .../Filter/Loader/ResampleFilterLoaderTest.php | 2 +- Tests/Templating/AbstractFilterTest.php | 2 +- Tests/Templating/FilterExtensionTest.php | 2 +- Tests/Templating/Helper/FilterHelperTest.php | 2 +- Utility/Framework/SymfonyFramework.php | 6 +++--- 38 files changed, 70 insertions(+), 70 deletions(-) diff --git a/Async/ResolveCache.php b/Async/ResolveCache.php index 3d04f0967..60594e53b 100644 --- a/Async/ResolveCache.php +++ b/Async/ResolveCache.php @@ -37,7 +37,7 @@ class ResolveCache implements \JsonSerializable /** * @param string[]|null $filters */ - 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/Component/Console/Style/ImagineStyle.php b/Component/Console/Style/ImagineStyle.php index 6d3ab9b80..26ba57862 100644 --- a/Component/Console/Style/ImagineStyle.php +++ b/Component/Console/Style/ImagineStyle.php @@ -58,14 +58,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') @@ -74,7 +74,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); @@ -93,7 +93,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); } @@ -103,7 +103,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(); @@ -116,7 +116,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/Config/Filter/Argument/Point.php b/Config/Filter/Argument/Point.php index 33b0d8a6d..19e3450f1 100644 --- a/Config/Filter/Argument/Point.php +++ b/Config/Filter/Argument/Point.php @@ -26,7 +26,7 @@ final class Point */ private $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/Config/Filter/Argument/Size.php b/Config/Filter/Argument/Size.php index e3ec10213..984befc3e 100644 --- a/Config/Filter/Argument/Size.php +++ b/Config/Filter/Argument/Size.php @@ -30,7 +30,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/Config/Filter/Type/Background.php b/Config/Filter/Type/Background.php index a99ca482a..ea9b6a724 100644 --- a/Config/Filter/Type/Background.php +++ b/Config/Filter/Type/Background.php @@ -46,9 +46,9 @@ final class Background extends FilterAbstract * @param string|null $position position of the input image on the newly created background image. Valid values: topleft, top, topright, left, center, right, bottomleft, bottom, and bottomright */ public function __construct( - string $color = null, - string $transparency = null, - string $position = null, + ?string $color, + ?string $transparency, + ?string $position, Size $size ) { $this->color = $color; diff --git a/Config/Filter/Type/Downscale.php b/Config/Filter/Type/Downscale.php index 3afb2f2ac..df15d6d1c 100644 --- a/Config/Filter/Type/Downscale.php +++ b/Config/Filter/Type/Downscale.php @@ -33,7 +33,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/Config/Filter/Type/RelativeResize.php b/Config/Filter/Type/RelativeResize.php index 88ba38bc4..4004137f8 100644 --- a/Config/Filter/Type/RelativeResize.php +++ b/Config/Filter/Type/RelativeResize.php @@ -39,10 +39,10 @@ final class RelativeResize extends FilterAbstract private $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/Config/Filter/Type/Scale.php b/Config/Filter/Type/Scale.php index 26759ba01..1412e5493 100644 --- a/Config/Filter/Type/Scale.php +++ b/Config/Filter/Type/Scale.php @@ -33,7 +33,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/Config/Filter/Type/Thumbnail.php b/Config/Filter/Type/Thumbnail.php index 0ce67f0d6..4ff645f21 100644 --- a/Config/Filter/Type/Thumbnail.php +++ b/Config/Filter/Type/Thumbnail.php @@ -42,9 +42,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/Config/Filter/Type/Upscale.php b/Config/Filter/Type/Upscale.php index a003d7832..e49608298 100644 --- a/Config/Filter/Type/Upscale.php +++ b/Config/Filter/Type/Upscale.php @@ -33,7 +33,7 @@ final class Upscale extends FilterAbstract /** * @param float $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/Config/Filter/Type/Watermark.php b/Config/Filter/Type/Watermark.php index 966d12dd4..c612c8ba1 100644 --- a/Config/Filter/Type/Watermark.php +++ b/Config/Filter/Type/Watermark.php @@ -33,7 +33,7 @@ final class Watermark extends FilterAbstract */ private $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/Config/Stack.php b/Config/Stack.php index 11927a4c7..b96adf92f 100644 --- a/Config/Stack.php +++ b/Config/Stack.php @@ -39,7 +39,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/Controller/ImagineController.php b/Controller/ImagineController.php index ebdf7aca9..da76fd9ec 100644 --- a/Controller/ImagineController.php +++ b/Controller/ImagineController.php @@ -52,7 +52,7 @@ public function __construct( FilterService $filterService, DataManager $dataManager, SignerInterface $signer, - ControllerConfig $controllerConfig = null + ?ControllerConfig $controllerConfig = null ) { $this->filterService = $filterService; $this->dataManager = $dataManager; @@ -156,7 +156,7 @@ private function getFiltersBc(Request $request): array return $runtimeConfig; } - 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/Factory/Config/Filter/Argument/SizeFactory.php b/Factory/Config/Filter/Argument/SizeFactory.php index fd65c793b..deb8663f3 100644 --- a/Factory/Config/Filter/Argument/SizeFactory.php +++ b/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/Factory/Config/StackFactory.php b/Factory/Config/StackFactory.php index 3ae48f01c..e642f2bd1 100644 --- a/Factory/Config/StackFactory.php +++ b/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/Factory/Config/StackFactoryInterface.php b/Factory/Config/StackFactoryInterface.php index 533d39282..5c529296a 100644 --- a/Factory/Config/StackFactoryInterface.php +++ b/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/Imagine/Cache/Resolver/AbstractFilesystemResolver.php b/Imagine/Cache/Resolver/AbstractFilesystemResolver.php index 69c8cecae..a84929dae 100644 --- a/Imagine/Cache/Resolver/AbstractFilesystemResolver.php +++ b/Imagine/Cache/Resolver/AbstractFilesystemResolver.php @@ -52,7 +52,7 @@ public function __construct(Filesystem $filesystem) $this->filesystem = $filesystem; } - public function setRequest(Request $request = null) + public function setRequest(?Request $request = null) { $this->request = $request; } diff --git a/Imagine/Cache/Resolver/CacheResolver.php b/Imagine/Cache/Resolver/CacheResolver.php index d7937c3bd..9b72e271c 100644 --- a/Imagine/Cache/Resolver/CacheResolver.php +++ b/Imagine/Cache/Resolver/CacheResolver.php @@ -44,7 +44,7 @@ class CacheResolver 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(Cache $cache, ResolverInterface $cacheResolver, array $options = [], OptionsResolver $optionsResolver = null) + public function __construct(Cache $cache, ResolverInterface $cacheResolver, array $options = [], ?OptionsResolver $optionsResolver = null) { $this->cache = $cache; $this->resolver = $cacheResolver; diff --git a/Imagine/Cache/Resolver/PsrCacheResolver.php b/Imagine/Cache/Resolver/PsrCacheResolver.php index 971d1b446..392c38179 100644 --- a/Imagine/Cache/Resolver/PsrCacheResolver.php +++ b/Imagine/Cache/Resolver/PsrCacheResolver.php @@ -56,7 +56,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/Imagine/Cache/Signer.php b/Imagine/Cache/Signer.php index 1639d3166..59c25d9bb 100644 --- a/Imagine/Cache/Signer.php +++ b/Imagine/Cache/Signer.php @@ -26,7 +26,7 @@ public function __construct($secret) $this->secret = $secret; } - public function sign($path, array $runtimeConfig = null) + public function sign($path, ?array $runtimeConfig = null) { if ($runtimeConfig) { array_walk_recursive($runtimeConfig, function (&$value) { @@ -37,7 +37,7 @@ public function sign($path, array $runtimeConfig = null) 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($hash, $path, array $runtimeConfig = null) + public function check($hash, $path, ?array $runtimeConfig = null) { return $hash === $this->sign($path, $runtimeConfig); } diff --git a/Imagine/Cache/SignerInterface.php b/Imagine/Cache/SignerInterface.php index d641f22b5..92f7d5cfd 100644 --- a/Imagine/Cache/SignerInterface.php +++ b/Imagine/Cache/SignerInterface.php @@ -20,7 +20,7 @@ interface SignerInterface * * @return string */ - public function sign($path, array $runtimeConfig = null); + public function sign($path, ?array $runtimeConfig = null); /** * Check hash is correct. @@ -30,5 +30,5 @@ public function sign($path, array $runtimeConfig = null); * * @return bool */ - public function check($hash, $path, array $runtimeConfig = null); + public function check($hash, $path, ?array $runtimeConfig = null); } diff --git a/Imagine/Filter/PostProcessor/AbstractPostProcessor.php b/Imagine/Filter/PostProcessor/AbstractPostProcessor.php index 42b8e2497..65383fe0d 100644 --- a/Imagine/Filter/PostProcessor/AbstractPostProcessor.php +++ b/Imagine/Filter/PostProcessor/AbstractPostProcessor.php @@ -34,7 +34,7 @@ abstract class AbstractPostProcessor implements PostProcessorInterface */ private $filesystem; - public function __construct(string $executablePath, string $temporaryRootPath = null) + public function __construct(string $executablePath, ?string $temporaryRootPath = null) { $this->executablePath = $executablePath; $this->temporaryRootPath = $temporaryRootPath; @@ -79,7 +79,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); @@ -92,7 +92,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/Imagine/Filter/PostProcessor/CwebpPostProcessor.php b/Imagine/Filter/PostProcessor/CwebpPostProcessor.php index 3ef82c13b..86ae48c7f 100644 --- a/Imagine/Filter/PostProcessor/CwebpPostProcessor.php +++ b/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/Message/WarmupCache.php b/Message/WarmupCache.php index 040824d28..0c0e2cc77 100644 --- a/Message/WarmupCache.php +++ b/Message/WarmupCache.php @@ -39,7 +39,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/Service/FilterService.php b/Service/FilterService.php index 69dc49140..887d0dec9 100644 --- a/Service/FilterService.php +++ b/Service/FilterService.php @@ -57,7 +57,7 @@ public function __construct( CacheManager $cacheManager, bool $webpGenerate, array $webpOptions, - LoggerInterface $logger = null + ?LoggerInterface $logger = null ) { $this->dataManager = $dataManager; $this->filterManager = $filterManager; @@ -96,7 +96,7 @@ public function bustCache($path, $filter) public function warmUpCache( string $path, string $filter, - string $resolver = null, + ?string $resolver = null, bool $forced = false ): bool { $warmedUp = false; @@ -177,7 +177,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(); @@ -197,7 +197,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/Templating/FilterTrait.php b/Templating/FilterTrait.php index 86f229e4f..7c806dafb 100644 --- a/Templating/FilterTrait.php +++ b/Templating/FilterTrait.php @@ -53,7 +53,7 @@ public function filterCache( string $path, string $filter, array $config = [], - string $resolver = null + ?string $resolver = null ): string { $path = parse_url($path, PHP_URL_PATH); diff --git a/Templating/LazyFilterRuntime.php b/Templating/LazyFilterRuntime.php index 59a300e59..9b23cd12e 100644 --- a/Templating/LazyFilterRuntime.php +++ b/Templating/LazyFilterRuntime.php @@ -29,7 +29,7 @@ final class LazyFilterRuntime implements RuntimeExtensionInterface */ private $assetVersion; - public function __construct(CacheManager $cache, string $assetVersion = null) + public function __construct(CacheManager $cache, ?string $assetVersion = null) { $this->cache = $cache; $this->assetVersion = $assetVersion; @@ -38,7 +38,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); @@ -51,7 +51,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/Tests/AbstractTest.php b/Tests/AbstractTest.php index 9e78d196e..4a981bc6d 100644 --- a/Tests/AbstractTest.php +++ b/Tests/AbstractTest.php @@ -255,7 +255,7 @@ protected function createDataManagerMock() return $this->createObjectMock(DataManager::class, [], false); } - protected function createControllerConfigInstance(int $redirectResponseCode = null): ControllerConfig + protected function createControllerConfigInstance(?int $redirectResponseCode = null): ControllerConfig { return new ControllerConfig($redirectResponseCode ?? 301); } diff --git a/Tests/Binary/Loader/ChainLoaderTest.php b/Tests/Binary/Loader/ChainLoaderTest.php index 06b3c5d2a..a6ec1d08a 100644 --- a/Tests/Binary/Loader/ChainLoaderTest.php +++ b/Tests/Binary/Loader/ChainLoaderTest.php @@ -133,7 +133,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 d0785f7e1..b0139ddb8 100644 --- a/Tests/Binary/Loader/FileSystemLoaderTest.php +++ b/Tests/Binary/Loader/FileSystemLoaderTest.php @@ -216,7 +216,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 { if (interface_exists(MimeTypeGuesserInterface::class)) { $mimeTypes = MimeTypes::getDefault(); diff --git a/Tests/Component/Console/Style/ImagineStyleTest.php b/Tests/Component/Console/Style/ImagineStyleTest.php index 935848071..0a2183a7d 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/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 33334ceae..28329ffcd 100644 --- a/Tests/Imagine/Filter/Loader/ResampleFilterLoaderTest.php +++ b/Tests/Imagine/Filter/Loader/ResampleFilterLoaderTest.php @@ -177,7 +177,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->createImagineInterfaceMock()); } diff --git a/Tests/Templating/AbstractFilterTest.php b/Tests/Templating/AbstractFilterTest.php index f671aa9be..9d9fed55f 100644 --- a/Tests/Templating/AbstractFilterTest.php +++ b/Tests/Templating/AbstractFilterTest.php @@ -104,5 +104,5 @@ public function testInvokeFilterCacheMethodWithRuntimeConfig(): void /** * @return FilterExtension|FilterHelper */ - abstract protected function createTemplatingMock(CacheManager $manager = null); + abstract protected function createTemplatingMock(?CacheManager $manager = null); } diff --git a/Tests/Templating/FilterExtensionTest.php b/Tests/Templating/FilterExtensionTest.php index 958c5099b..e2ecf4d32 100644 --- a/Tests/Templating/FilterExtensionTest.php +++ b/Tests/Templating/FilterExtensionTest.php @@ -33,7 +33,7 @@ public function testInstanceOfTwigFilter(): void $this->assertInstanceOf(AbstractExtension::class, $this->createTemplatingMock()); } - protected function createTemplatingMock(CacheManager $manager = null): FilterExtension + protected function createTemplatingMock(?CacheManager $manager = null): FilterExtension { if (!class_exists(AbstractExtension::class)) { $this->markTestSkipped('Requires the twig/twig package.'); diff --git a/Tests/Templating/Helper/FilterHelperTest.php b/Tests/Templating/Helper/FilterHelperTest.php index 17c6ba664..aeab754e9 100644 --- a/Tests/Templating/Helper/FilterHelperTest.php +++ b/Tests/Templating/Helper/FilterHelperTest.php @@ -29,7 +29,7 @@ public function testInstanceOfSymfonyHelper(): void $this->assertInstanceOf(Helper::class, $this->createTemplatingMock()); } - protected function createTemplatingMock(CacheManager $manager = null): FilterHelper + protected function createTemplatingMock(?CacheManager $manager = null): FilterHelper { $mock = new FilterHelper($manager ?: $this->createCacheManagerMock()); diff --git a/Utility/Framework/SymfonyFramework.php b/Utility/Framework/SymfonyFramework.php index 8c8d45192..8b3a03a9c 100644 --- a/Utility/Framework/SymfonyFramework.php +++ b/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(Kernel::VERSION_ID, sprintf("%d%'.02d%'.02d", $major, $minor ?: 0, $patch ?: 0), $operator); }