From c38e95b8ae7597bb173b596d3f36ac3f57ac6b5a Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 16 Jul 2025 15:35:29 +0200 Subject: [PATCH 01/18] Added missing type hints to classes in `Imagine\Cache` namespace --- .../Imagine/Cache/AliasGeneratorDecorator.php | 68 ++++++++----------- .../Imagine/Cache/Resolver/ProxyResolver.php | 9 +-- .../Cache/Resolver/RelativeResolver.php | 8 +-- .../Core/Imagine/Cache/ResolverFactory.php | 36 ++++------ src/bundle/Core/Resources/config/image.yml | 9 ++- 5 files changed, 55 insertions(+), 75 deletions(-) diff --git a/src/bundle/Core/Imagine/Cache/AliasGeneratorDecorator.php b/src/bundle/Core/Imagine/Cache/AliasGeneratorDecorator.php index a149702054..6f71bd40e1 100644 --- a/src/bundle/Core/Imagine/Cache/AliasGeneratorDecorator.php +++ b/src/bundle/Core/Imagine/Cache/AliasGeneratorDecorator.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\Cache; @@ -22,35 +23,24 @@ */ class AliasGeneratorDecorator implements VariationHandler, SiteAccessAware { - private const IMAGE_VARIATION_IDENTIFIER = 'image_variation'; - private const IMAGE_VARIATION_SITEACCESS_IDENTIFIER = 'image_variation_siteaccess'; - private const IMAGE_VARIATION_CONTENT_IDENTIFIER = 'image_variation_content'; - private const IMAGE_VARIATION_FIELD_IDENTIFIER = 'image_variation_field'; - private const IMAGE_VARIATION_NAME_IDENTIFIER = 'image_variation_name'; - private const CONTENT_IDENTIFIER = 'content'; - private const CONTENT_VERSION_IDENTIFIER = 'content_version'; + private const string IMAGE_VARIATION_IDENTIFIER = 'image_variation'; + private const string IMAGE_VARIATION_SITEACCESS_IDENTIFIER = 'image_variation_siteaccess'; + private const string IMAGE_VARIATION_CONTENT_IDENTIFIER = 'image_variation_content'; + private const string IMAGE_VARIATION_FIELD_IDENTIFIER = 'image_variation_field'; + private const string IMAGE_VARIATION_NAME_IDENTIFIER = 'image_variation_name'; + private const string CONTENT_IDENTIFIER = 'content'; + private const string CONTENT_VERSION_IDENTIFIER = 'content_version'; - /** @var \Ibexa\Contracts\Core\Variation\VariationHandler */ - private $aliasGenerator; + private VariationHandler $aliasGenerator; - /** @var \Symfony\Component\Cache\Adapter\TagAwareAdapterInterface */ - private $cache; + private TagAwareAdapterInterface $cache; - /** @var \Ibexa\Core\MVC\Symfony\SiteAccess */ - private $siteAccess; + private ?SiteAccess $siteAccess = null; - /** @var \Symfony\Component\Routing\RequestContext */ - private $requestContext; + private RequestContext $requestContext; - /** @var \Ibexa\Core\Persistence\Cache\Identifier\CacheIdentifierGeneratorInterface */ - private $cacheIdentifierGenerator; + private CacheIdentifierGeneratorInterface $cacheIdentifierGenerator; - /** - * @param \Ibexa\Contracts\Core\Variation\VariationHandler $aliasGenerator - * @param \Symfony\Component\Cache\Adapter\TagAwareAdapterInterface $cache - * @param \Symfony\Component\Routing\RequestContext $requestContext - * @param \Ibexa\Core\Persistence\Cache\Identifier\CacheIdentifierGeneratorInterface $cacheIdentifierGenerator - */ public function __construct( VariationHandler $aliasGenerator, TagAwareAdapterInterface $cache, @@ -64,17 +54,16 @@ public function __construct( } /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Field $field - * @param \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo $versionInfo - * @param string $variationName - * @param array $parameters - * - * @return \Ibexa\Contracts\Core\Variation\Values\Variation - * + * @throws \Psr\Cache\CacheException * @throws \Psr\Cache\InvalidArgumentException + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ - public function getVariation(Field $field, VersionInfo $versionInfo, string $variationName, array $parameters = []): Variation - { + public function getVariation( + Field $field, + VersionInfo $versionInfo, + string $variationName, + array $parameters = [] + ): Variation { $item = $this->cache->getItem($this->getCacheKey($field, $versionInfo, $variationName)); $image = $item->get(); if (!$item->isHit()) { @@ -90,19 +79,15 @@ public function getVariation(Field $field, VersionInfo $versionInfo, string $var /** * @param \Ibexa\Core\MVC\Symfony\SiteAccess|null $siteAccess */ - public function setSiteAccess(SiteAccess $siteAccess = null) + public function setSiteAccess(?SiteAccess $siteAccess = null): void { $this->siteAccess = $siteAccess; } /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Field $field - * @param \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo $versionInfo - * @param string $variationName - * - * @return string + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ - private function getCacheKey(Field $field, VersionInfo $versionInfo, $variationName): string + private function getCacheKey(Field $field, VersionInfo $versionInfo, string $variationName): string { return sprintf( $this->cacheIdentifierGenerator->generateKey(self::IMAGE_VARIATION_IDENTIFIER, [], true) . '-%s-%s-%s-%d-%d-%d-%s-%s', @@ -117,6 +102,11 @@ private function getCacheKey(Field $field, VersionInfo $versionInfo, $variationN ); } + /** + * @return string[] + * + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException + */ private function getTagsForVariation(Field $field, VersionInfo $versionInfo, string $variationName): array { $contentId = $versionInfo->getContentInfo()->id; diff --git a/src/bundle/Core/Imagine/Cache/Resolver/ProxyResolver.php b/src/bundle/Core/Imagine/Cache/Resolver/ProxyResolver.php index b2eeee613f..e231bb24d8 100644 --- a/src/bundle/Core/Imagine/Cache/Resolver/ProxyResolver.php +++ b/src/bundle/Core/Imagine/Cache/Resolver/ProxyResolver.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\Cache\Resolver; @@ -14,14 +15,14 @@ class ProxyResolver extends ImagineProxyResolver /** * Replaces host with given proxy host. * - * The original method from Liip\ImagineBundle\Imagine\Cache\Resolver\ProxyResolver:rewriteUrl() + * The original method from `\Liip\ImagineBundle\Imagine\Cache\Resolver\ProxyResolver::rewriteUrl()` * doesn't behave correctly when working with domain and port or with host which contains trailing slash. * - * @param string $url + * @see \Liip\ImagineBundle\Imagine\Cache\Resolver\ProxyResolver::rewriteUrl * - * @return string + * @param string $url */ - protected function rewriteUrl($url) + protected function rewriteUrl($url): string { if (empty($this->hosts)) { return $url; diff --git a/src/bundle/Core/Imagine/Cache/Resolver/RelativeResolver.php b/src/bundle/Core/Imagine/Cache/Resolver/RelativeResolver.php index bfb59d333e..4afb915c57 100644 --- a/src/bundle/Core/Imagine/Cache/Resolver/RelativeResolver.php +++ b/src/bundle/Core/Imagine/Cache/Resolver/RelativeResolver.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\Cache\Resolver; @@ -15,9 +16,6 @@ */ class RelativeResolver extends ImagineProxyResolver { - /** - * @param \Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface $resolver - */ public function __construct(ResolverInterface $resolver) { parent::__construct($resolver, []); @@ -27,10 +25,8 @@ public function __construct(ResolverInterface $resolver) * Returns relative image path. * * @param $url string - * - * @return string */ - protected function rewriteUrl($url) + protected function rewriteUrl($url): string { return parse_url($url, PHP_URL_PATH); } diff --git a/src/bundle/Core/Imagine/Cache/ResolverFactory.php b/src/bundle/Core/Imagine/Cache/ResolverFactory.php index d6666ffa4e..ad2150f56a 100644 --- a/src/bundle/Core/Imagine/Cache/ResolverFactory.php +++ b/src/bundle/Core/Imagine/Cache/ResolverFactory.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\Cache; @@ -12,32 +13,25 @@ class ResolverFactory { - /** @var \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface */ - private $configResolver; + private ConfigResolverInterface $configResolver; - /** @var \Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface */ - private $resolver; + private ResolverInterface $resolver; - /** @var string|null */ - private $resolverDecoratorClass; + /** @phpstan-var class-string<\Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface> */ + private string $proxyResolverClass; - /** @var string */ - private $proxyResolverClass; - - /** @var string */ - private $relativeResolverClass; + /** @phpstan-var class-string<\Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface> */ + private string $relativeResolverClass; /** - * @param \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface $configResolver - * @param \Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface $resolver - * @param string $proxyResolverClass - * @param string $relativeResolverClass + * @phpstan-param class-string<\Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface> $proxyResolverClass + * @phpstan-param class-string<\Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface> $relativeResolverClass */ public function __construct( ConfigResolverInterface $configResolver, ResolverInterface $resolver, - $proxyResolverClass, - $relativeResolverClass + string $proxyResolverClass, + string $relativeResolverClass ) { $this->configResolver = $configResolver; $this->resolver = $resolver; @@ -48,7 +42,7 @@ public function __construct( /** * @return \Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface */ - public function createCacheResolver() + public function createCacheResolver(): ResolverInterface { $imageHost = $this->configResolver->hasParameter('image_host') ? $this->configResolver->getParameter('image_host') : @@ -59,11 +53,11 @@ public function createCacheResolver() } if ($imageHost === '/') { - $this->resolverDecoratorClass = $this->relativeResolverClass; + $resolverDecoratorClass = $this->relativeResolverClass; } else { - $this->resolverDecoratorClass = $this->proxyResolverClass; + $resolverDecoratorClass = $this->proxyResolverClass; } - return new $this->resolverDecoratorClass($this->resolver, [$imageHost]); + return new $resolverDecoratorClass($this->resolver, [$imageHost]); } } diff --git a/src/bundle/Core/Resources/config/image.yml b/src/bundle/Core/Resources/config/image.yml index d3a1f4fe91..af9850bc05 100644 --- a/src/bundle/Core/Resources/config/image.yml +++ b/src/bundle/Core/Resources/config/image.yml @@ -47,12 +47,11 @@ services: - { name: liip_imagine.cache.resolver, resolver: ibexa } Ibexa\Bundle\Core\Imagine\Cache\ResolverFactory: - class: Ibexa\Bundle\Core\Imagine\Cache\ResolverFactory arguments: - - '@ibexa.config.resolver' - - '@ibexa.image_alias.imagine.cache_resolver_decorator.inner' - - 'Ibexa\Bundle\Core\Imagine\Cache\Resolver\ProxyResolver' - - 'Ibexa\Bundle\Core\Imagine\Cache\Resolver\RelativeResolver' + $configResolver: '@ibexa.config.resolver' + $resolver: '@ibexa.image_alias.imagine.cache_resolver_decorator.inner' + $proxyResolverClass: 'Ibexa\Bundle\Core\Imagine\Cache\Resolver\ProxyResolver' + $relativeResolverClass: 'Ibexa\Bundle\Core\Imagine\Cache\Resolver\RelativeResolver' lazy: true ibexa.image_alias.imagine.cache_resolver_decorator: From 85cad420cd05dd203a40df881156632e0b63bfde Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 16 Jul 2025 15:45:15 +0200 Subject: [PATCH 02/18] Added missing type hints to `Imagine\Filter\FilterInterface` and its implementations --- .../Core/Imagine/Filter/AbstractFilter.php | 21 +++++++-------- .../Imagine/Filter/FilterConfiguration.php | 1 + .../Core/Imagine/Filter/FilterInterface.php | 27 ++++++------------- .../Filter/Gmagick/ReduceNoiseFilter.php | 15 ++++++----- .../Imagine/Filter/Gmagick/SwirlFilter.php | 15 ++++++----- .../Filter/Imagick/ReduceNoiseFilter.php | 15 ++++++----- .../Imagine/Filter/Imagick/SwirlFilter.php | 15 ++++++----- .../Core/Imagine/Filter/UnsupportedFilter.php | 3 ++- 8 files changed, 53 insertions(+), 59 deletions(-) diff --git a/src/bundle/Core/Imagine/Filter/AbstractFilter.php b/src/bundle/Core/Imagine/Filter/AbstractFilter.php index 2a0956a27f..dffd7179cd 100644 --- a/src/bundle/Core/Imagine/Filter/AbstractFilter.php +++ b/src/bundle/Core/Imagine/Filter/AbstractFilter.php @@ -12,35 +12,34 @@ */ abstract class AbstractFilter implements FilterInterface { - /** @var array */ - private $options; - - public function __construct(array $options = []) + /** + * @phpstan-param array $options + */ + public function __construct(private array $options = []) { - $this->options = $options; } - public function setOption($optionName, $value) + public function setOption(string $optionName, mixed $value): void { $this->options[$optionName] = $value; } - public function getOption($optionName, $defaultValue = null) + public function getOption(string $optionName, mixed $defaultValue = null): mixed { - return isset($this->options[$optionName]) ? $this->options[$optionName] : $defaultValue; + return $this->options[$optionName] ?? $defaultValue; } - public function hasOption($optionName) + public function hasOption(string $optionName): bool { return isset($this->options[$optionName]); } - public function setOptions(array $options) + public function setOptions(array $options): void { $this->options = $options; } - public function getOptions() + public function getOptions(): array { return $this->options; } diff --git a/src/bundle/Core/Imagine/Filter/FilterConfiguration.php b/src/bundle/Core/Imagine/Filter/FilterConfiguration.php index 68f21c3368..8d930627b3 100644 --- a/src/bundle/Core/Imagine/Filter/FilterConfiguration.php +++ b/src/bundle/Core/Imagine/Filter/FilterConfiguration.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\Filter; diff --git a/src/bundle/Core/Imagine/Filter/FilterInterface.php b/src/bundle/Core/Imagine/Filter/FilterInterface.php index 0396468396..b8928edb31 100644 --- a/src/bundle/Core/Imagine/Filter/FilterInterface.php +++ b/src/bundle/Core/Imagine/Filter/FilterInterface.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\Filter; @@ -13,43 +14,31 @@ interface FilterInterface extends BaseFilterInterface { /** * Sets $value for $optionName. - * - * @param string $optionName - * @param mixed $value */ - public function setOption($optionName, $value); + public function setOption(string $optionName, mixed $value): void; /** * Returns value for $optionName. * Defaults to $defaultValue if $optionName doesn't exist. - * - * @param string $optionName - * @param mixed|null $defaultValue - * - * @return mixed */ - public function getOption($optionName, $defaultValue = null); + public function getOption(string $optionName, mixed $defaultValue = null): mixed; /** * Checks if $optionName exists and has a value. - * - * @param string $optionName - * - * @return bool */ - public function hasOption($optionName); + public function hasOption(string $optionName): bool; /** * Replaces inner options by $options. * - * @param array $options + * @phpstan-param array $options */ - public function setOptions(array $options); + public function setOptions(array $options): void; /** * Returns all options. * - * @return array + * @return array */ - public function getOptions(); + public function getOptions(): array; } diff --git a/src/bundle/Core/Imagine/Filter/Gmagick/ReduceNoiseFilter.php b/src/bundle/Core/Imagine/Filter/Gmagick/ReduceNoiseFilter.php index c57da06e43..68d9738b88 100644 --- a/src/bundle/Core/Imagine/Filter/Gmagick/ReduceNoiseFilter.php +++ b/src/bundle/Core/Imagine/Filter/Gmagick/ReduceNoiseFilter.php @@ -4,24 +4,25 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\Filter\Gmagick; use Ibexa\Bundle\Core\Imagine\Filter\AbstractFilter; +use Imagine\Gmagick\Image; use Imagine\Image\ImageInterface; class ReduceNoiseFilter extends AbstractFilter { /** - * @param \Imagine\Image\ImageInterface|\Imagine\Gmagick\Image $image - * - * @return \Imagine\Image\ImageInterface + * @throws \GmagickException */ - public function apply(ImageInterface $image) + public function apply(ImageInterface $image): ImageInterface { - /** @var \Gmagick $gmagick */ - $gmagick = $image->getGmagick(); - $gmagick->reduceNoiseImage((float)$this->getOption('radius', 0)); + if ($image instanceof Image) { + $gmagick = $image->getGmagick(); + $gmagick->reduceNoiseImage((float)$this->getOption('radius', 0)); + } return $image; } diff --git a/src/bundle/Core/Imagine/Filter/Gmagick/SwirlFilter.php b/src/bundle/Core/Imagine/Filter/Gmagick/SwirlFilter.php index 39290e0f10..3ac31aa52c 100644 --- a/src/bundle/Core/Imagine/Filter/Gmagick/SwirlFilter.php +++ b/src/bundle/Core/Imagine/Filter/Gmagick/SwirlFilter.php @@ -4,24 +4,25 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\Filter\Gmagick; use Ibexa\Bundle\Core\Imagine\Filter\AbstractFilter; +use Imagine\Gmagick\Image; use Imagine\Image\ImageInterface; class SwirlFilter extends AbstractFilter { /** - * @param \Imagine\Image\ImageInterface|\Imagine\Gmagick\Image $image - * - * @return \Imagine\Image\ImageInterface + * @throws \GmagickException */ - public function apply(ImageInterface $image) + public function apply(ImageInterface $image): ImageInterface { - /** @var \Gmagick $gmagick */ - $gmagick = $image->getGmagick(); - $gmagick->swirlimage((float)$this->getOption('degrees', 60)); + if ($image instanceof Image) { + $gmagick = $image->getGmagick(); + $gmagick->swirlimage((float)$this->getOption('degrees', 60)); + } return $image; } diff --git a/src/bundle/Core/Imagine/Filter/Imagick/ReduceNoiseFilter.php b/src/bundle/Core/Imagine/Filter/Imagick/ReduceNoiseFilter.php index b0858347c9..2d150ba1d5 100644 --- a/src/bundle/Core/Imagine/Filter/Imagick/ReduceNoiseFilter.php +++ b/src/bundle/Core/Imagine/Filter/Imagick/ReduceNoiseFilter.php @@ -4,24 +4,25 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\Filter\Imagick; use Ibexa\Bundle\Core\Imagine\Filter\AbstractFilter; use Imagine\Image\ImageInterface; +use Imagine\Imagick\Image; class ReduceNoiseFilter extends AbstractFilter { /** - * @param \Imagine\Image\ImageInterface|\Imagine\Imagick\Image $image - * - * @return \Imagine\Image\ImageInterface + * @throws \ImagickException */ - public function apply(ImageInterface $image) + public function apply(ImageInterface $image): ImageInterface { - /** @var \Imagick $imagick */ - $imagick = $image->getImagick(); - $imagick->reduceNoiseImage((float)$this->getOption('radius', 0)); + if ($image instanceof Image) { + $imagick = $image->getImagick(); + $imagick->reduceNoiseImage((float)$this->getOption('radius', 0)); + } return $image; } diff --git a/src/bundle/Core/Imagine/Filter/Imagick/SwirlFilter.php b/src/bundle/Core/Imagine/Filter/Imagick/SwirlFilter.php index 4c75ea173e..d78a59b527 100644 --- a/src/bundle/Core/Imagine/Filter/Imagick/SwirlFilter.php +++ b/src/bundle/Core/Imagine/Filter/Imagick/SwirlFilter.php @@ -4,24 +4,25 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\Filter\Imagick; use Ibexa\Bundle\Core\Imagine\Filter\AbstractFilter; use Imagine\Image\ImageInterface; +use Imagine\Imagick\Image; class SwirlFilter extends AbstractFilter { /** - * @param \Imagine\Image\ImageInterface|\Imagine\Imagick\Image $image - * - * @return \Imagine\Image\ImageInterface + * @throws \ImagickException */ - public function apply(ImageInterface $image) + public function apply(ImageInterface $image): Image|ImageInterface { - /** @var \Imagick $imagick */ - $imagick = $image->getImagick(); - $imagick->swirlImage((float)$this->getOption('degrees', 60)); + if ($image instanceof Image) { + $imagick = $image->getImagick(); + $imagick->swirlImage((float)$this->getOption('degrees', 60)); + } return $image; } diff --git a/src/bundle/Core/Imagine/Filter/UnsupportedFilter.php b/src/bundle/Core/Imagine/Filter/UnsupportedFilter.php index 2b6cfd1f48..6914ffa119 100644 --- a/src/bundle/Core/Imagine/Filter/UnsupportedFilter.php +++ b/src/bundle/Core/Imagine/Filter/UnsupportedFilter.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\Filter; @@ -15,7 +16,7 @@ class UnsupportedFilter extends AbstractFilter /** * @throws \Imagine\Exception\NotSupportedException */ - public function apply(ImageInterface $image) + public function apply(ImageInterface $image): never { throw new NotSupportedException('The filter is not supported by your current configuration.'); } From b58bb98901337796200445b98915419ecc7a9d3b Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 16 Jul 2025 15:53:38 +0200 Subject: [PATCH 03/18] Added missing type hints Imagine Filter Loaders --- .../Filter/Loader/BorderFilterLoader.php | 21 ++++++++++--------- .../Filter/Loader/CropFilterLoader.php | 6 +++++- .../Filter/Loader/FilterLoaderWrapped.php | 9 +++----- .../Filter/Loader/GrayscaleFilterLoader.php | 6 +++++- .../Filter/Loader/ReduceNoiseFilterLoader.php | 9 +++++--- .../Loader/ScaleDownOnlyFilterLoader.php | 8 +++---- .../Filter/Loader/ScaleExactFilterLoader.php | 6 +++++- .../Filter/Loader/ScaleFilterLoader.php | 8 +++++-- .../ScaleHeightDownOnlyFilterLoader.php | 6 +++++- .../Filter/Loader/ScaleHeightFilterLoader.php | 8 +++++-- .../Loader/ScalePercentFilterLoader.php | 8 +++++-- .../Loader/ScaleWidthDownOnlyFilterLoader.php | 6 +++++- .../Filter/Loader/ScaleWidthFilterLoader.php | 6 +++++- .../Filter/Loader/SwirlFilterLoader.php | 9 +++++--- 14 files changed, 77 insertions(+), 39 deletions(-) diff --git a/src/bundle/Core/Imagine/Filter/Loader/BorderFilterLoader.php b/src/bundle/Core/Imagine/Filter/Loader/BorderFilterLoader.php index 6baf9cf2cb..8324daa8a9 100644 --- a/src/bundle/Core/Imagine/Filter/Loader/BorderFilterLoader.php +++ b/src/bundle/Core/Imagine/Filter/Loader/BorderFilterLoader.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\Filter\Loader; @@ -20,26 +21,26 @@ */ class BorderFilterLoader implements LoaderInterface { - public const IDENTIFIER = 'border'; + public const string IDENTIFIER = 'border'; - public const DEFAULT_BORDER_COLOR = '#000'; + public const string DEFAULT_BORDER_COLOR = '#000'; + /** + * @phpstan-param array{0?: int, 1?: int, 2?: string} $options + */ public function load(ImageInterface $image, array $options = []): ImageInterface { - $optionsCount = count($options); - if ($optionsCount < 2) { + if (!isset($options[0], $options[1])) { throw new InvalidArgumentException('Invalid options for border filter. You must provide array(width, height)'); } $color = static::DEFAULT_BORDER_COLOR; - if ($optionsCount > 2) { - list($width, $height, $color) = $options; + if (isset($options[2])) { + [$width, $height, $color] = $options; } else { - list($width, $height) = $options; + [$width, $height] = $options; } - $border = new Border($image->palette()->color($color), $width, $height); - - return $border->apply($image); + return (new Border($image->palette()->color($color), $width, $height))->apply($image); } } diff --git a/src/bundle/Core/Imagine/Filter/Loader/CropFilterLoader.php b/src/bundle/Core/Imagine/Filter/Loader/CropFilterLoader.php index 8819f32884..8f6c674405 100644 --- a/src/bundle/Core/Imagine/Filter/Loader/CropFilterLoader.php +++ b/src/bundle/Core/Imagine/Filter/Loader/CropFilterLoader.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\Filter\Loader; @@ -16,8 +17,11 @@ */ class CropFilterLoader extends FilterLoaderWrapped { - public const IDENTIFIER = 'geometry/crop'; + public const string IDENTIFIER = 'geometry/crop'; + /** + * @phpstan-param array{0?: int, 1?: int, 2?: int, 3?: int} $options + */ public function load(ImageInterface $image, array $options = []): ImageInterface { if (count($options) < 4) { diff --git a/src/bundle/Core/Imagine/Filter/Loader/FilterLoaderWrapped.php b/src/bundle/Core/Imagine/Filter/Loader/FilterLoaderWrapped.php index 5aa4c68170..046eca4014 100644 --- a/src/bundle/Core/Imagine/Filter/Loader/FilterLoaderWrapped.php +++ b/src/bundle/Core/Imagine/Filter/Loader/FilterLoaderWrapped.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\Filter\Loader; @@ -11,13 +12,9 @@ abstract class FilterLoaderWrapped implements LoaderInterface { - /** @var \Liip\ImagineBundle\Imagine\Filter\Loader\LoaderInterface */ - protected $innerLoader; + protected LoaderInterface $innerLoader; - /** - * @param \Liip\ImagineBundle\Imagine\Filter\Loader\LoaderInterface $innerLoader - */ - public function setInnerLoader(LoaderInterface $innerLoader) + public function setInnerLoader(LoaderInterface $innerLoader): void { $this->innerLoader = $innerLoader; } diff --git a/src/bundle/Core/Imagine/Filter/Loader/GrayscaleFilterLoader.php b/src/bundle/Core/Imagine/Filter/Loader/GrayscaleFilterLoader.php index 39ee09b4e9..a9a3418824 100644 --- a/src/bundle/Core/Imagine/Filter/Loader/GrayscaleFilterLoader.php +++ b/src/bundle/Core/Imagine/Filter/Loader/GrayscaleFilterLoader.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\Filter\Loader; @@ -16,8 +17,11 @@ */ class GrayscaleFilterLoader implements LoaderInterface { - public const IDENTIFIER = 'colorspace/gray'; + public const string IDENTIFIER = 'colorspace/gray'; + /** + * @param array{} $options + */ public function load(ImageInterface $image, array $options = []): ImageInterface { $image->effects()->grayscale(); diff --git a/src/bundle/Core/Imagine/Filter/Loader/ReduceNoiseFilterLoader.php b/src/bundle/Core/Imagine/Filter/Loader/ReduceNoiseFilterLoader.php index b4e2af766c..9db0609f97 100644 --- a/src/bundle/Core/Imagine/Filter/Loader/ReduceNoiseFilterLoader.php +++ b/src/bundle/Core/Imagine/Filter/Loader/ReduceNoiseFilterLoader.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\Filter\Loader; @@ -20,16 +21,18 @@ */ class ReduceNoiseFilterLoader implements LoaderInterface { - public const IDENTIFIER = 'filter/noise'; + public const string IDENTIFIER = 'filter/noise'; - /** @var \Ibexa\Bundle\Core\Imagine\Filter\FilterInterface */ - private $filter; + private FilterInterface $filter; public function __construct(FilterInterface $filter) { $this->filter = $filter; } + /** + * @phpstan-param array{0?: int} $options radius + */ public function load(ImageInterface $image, array $options = []): ImageInterface { if (!$image instanceof ImagickImage && !$image instanceof GmagickImage) { diff --git a/src/bundle/Core/Imagine/Filter/Loader/ScaleDownOnlyFilterLoader.php b/src/bundle/Core/Imagine/Filter/Loader/ScaleDownOnlyFilterLoader.php index 294045dcf9..6ae55fb009 100644 --- a/src/bundle/Core/Imagine/Filter/Loader/ScaleDownOnlyFilterLoader.php +++ b/src/bundle/Core/Imagine/Filter/Loader/ScaleDownOnlyFilterLoader.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\Filter\Loader; @@ -16,17 +17,14 @@ */ class ScaleDownOnlyFilterLoader extends FilterLoaderWrapped { - public const IDENTIFIER = 'geometry/scaledownonly'; + public const string IDENTIFIER = 'geometry/scaledownonly'; /** * Loads and applies a filter on the given image. * - * @param \Imagine\Image\ImageInterface $image - * @param array $options Numerically indexed array. First entry is width, second is height. + * @param array{0?: int, 1?: int} $options Numerically indexed array. The First entry is width, the second is height. * * @throws \Imagine\Exception\InvalidArgumentException - * - * @return \Imagine\Image\ImageInterface */ public function load(ImageInterface $image, array $options = []): ImageInterface { diff --git a/src/bundle/Core/Imagine/Filter/Loader/ScaleExactFilterLoader.php b/src/bundle/Core/Imagine/Filter/Loader/ScaleExactFilterLoader.php index cf2657d9bd..39bdf15f7b 100644 --- a/src/bundle/Core/Imagine/Filter/Loader/ScaleExactFilterLoader.php +++ b/src/bundle/Core/Imagine/Filter/Loader/ScaleExactFilterLoader.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\Filter\Loader; @@ -16,8 +17,11 @@ */ class ScaleExactFilterLoader extends FilterLoaderWrapped { - public const IDENTIFIER = 'geometry/scaleexact'; + public const string IDENTIFIER = 'geometry/scaleexact'; + /** + * @phpstan-param array{0?: int, 1?: int} $options width, height + */ public function load(ImageInterface $image, array $options = []): ImageInterface { if (count($options) < 2) { diff --git a/src/bundle/Core/Imagine/Filter/Loader/ScaleFilterLoader.php b/src/bundle/Core/Imagine/Filter/Loader/ScaleFilterLoader.php index 81796692a2..db4d6ed382 100644 --- a/src/bundle/Core/Imagine/Filter/Loader/ScaleFilterLoader.php +++ b/src/bundle/Core/Imagine/Filter/Loader/ScaleFilterLoader.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\Filter\Loader; @@ -16,15 +17,18 @@ */ class ScaleFilterLoader extends FilterLoaderWrapped { - public const IDENTIFIER = 'geometry/scale'; + public const string IDENTIFIER = 'geometry/scale'; + /** + * @phpstan-param array{0?: int, 1?: int} $options width, height + */ public function load(ImageInterface $image, array $options = []): ImageInterface { if (count($options) < 2) { throw new InvalidArgumentException('Missing width and/or height options'); } - list($width, $height) = $options; + [$width, $height] = $options; $size = $image->getSize(); $ratioWidth = $width / $size->getWidth(); $ratioHeight = $height / $size->getHeight(); diff --git a/src/bundle/Core/Imagine/Filter/Loader/ScaleHeightDownOnlyFilterLoader.php b/src/bundle/Core/Imagine/Filter/Loader/ScaleHeightDownOnlyFilterLoader.php index 5d3f127de9..aacbc16b87 100644 --- a/src/bundle/Core/Imagine/Filter/Loader/ScaleHeightDownOnlyFilterLoader.php +++ b/src/bundle/Core/Imagine/Filter/Loader/ScaleHeightDownOnlyFilterLoader.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\Filter\Loader; @@ -16,8 +17,11 @@ */ class ScaleHeightDownOnlyFilterLoader extends FilterLoaderWrapped { - public const IDENTIFIER = 'geometry/scaleheightdownonly'; + public const string IDENTIFIER = 'geometry/scaleheightdownonly'; + /** + * @phpstan-param array{0?: int} $options height + */ public function load(ImageInterface $image, array $options = []): ImageInterface { if (empty($options)) { diff --git a/src/bundle/Core/Imagine/Filter/Loader/ScaleHeightFilterLoader.php b/src/bundle/Core/Imagine/Filter/Loader/ScaleHeightFilterLoader.php index 01a8badb23..5482d2b209 100644 --- a/src/bundle/Core/Imagine/Filter/Loader/ScaleHeightFilterLoader.php +++ b/src/bundle/Core/Imagine/Filter/Loader/ScaleHeightFilterLoader.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\Filter\Loader; @@ -16,12 +17,15 @@ */ class ScaleHeightFilterLoader extends FilterLoaderWrapped { - public const IDENTIFIER = 'geometry/scaleheight'; + public const string IDENTIFIER = 'geometry/scaleheight'; + /** + * @phpstan-param array{0?: int} $options height + */ public function load(ImageInterface $image, array $options = []): ImageInterface { if (empty($options)) { - throw new InvalidArgumentException('Missing width option'); + throw new InvalidArgumentException('Missing height option'); } return $this->innerLoader->load($image, ['heighten' => $options[0]]); diff --git a/src/bundle/Core/Imagine/Filter/Loader/ScalePercentFilterLoader.php b/src/bundle/Core/Imagine/Filter/Loader/ScalePercentFilterLoader.php index b9c6c2419e..63dea55c69 100644 --- a/src/bundle/Core/Imagine/Filter/Loader/ScalePercentFilterLoader.php +++ b/src/bundle/Core/Imagine/Filter/Loader/ScalePercentFilterLoader.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\Filter\Loader; @@ -16,8 +17,11 @@ */ class ScalePercentFilterLoader extends FilterLoaderWrapped { - public const IDENTIFIER = 'geometry/scalepercent'; + public const string IDENTIFIER = 'geometry/scalepercent'; + /** + * @phpstan-param array{0?: int, 1?: int} $options width, height + */ public function load(ImageInterface $image, array $options = []): ImageInterface { if (count($options) < 2) { @@ -27,7 +31,7 @@ public function load(ImageInterface $image, array $options = []): ImageInterface $size = $image->getSize(); $origWidth = $size->getWidth(); $origHeight = $size->getHeight(); - list($widthPercent, $heightPercent) = $options; + [$widthPercent, $heightPercent] = $options; $targetWidth = ($origWidth * $widthPercent) / 100; $targetHeight = ($origHeight * $heightPercent) / 100; diff --git a/src/bundle/Core/Imagine/Filter/Loader/ScaleWidthDownOnlyFilterLoader.php b/src/bundle/Core/Imagine/Filter/Loader/ScaleWidthDownOnlyFilterLoader.php index 5b2777561b..69698680b8 100644 --- a/src/bundle/Core/Imagine/Filter/Loader/ScaleWidthDownOnlyFilterLoader.php +++ b/src/bundle/Core/Imagine/Filter/Loader/ScaleWidthDownOnlyFilterLoader.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\Filter\Loader; @@ -16,8 +17,11 @@ */ class ScaleWidthDownOnlyFilterLoader extends FilterLoaderWrapped { - public const IDENTIFIER = 'geometry/scalewidthdownonly'; + public const string IDENTIFIER = 'geometry/scalewidthdownonly'; + /** + * @phpstan-param array{0?: int} $options width + */ public function load(ImageInterface $image, array $options = []): ImageInterface { if (empty($options)) { diff --git a/src/bundle/Core/Imagine/Filter/Loader/ScaleWidthFilterLoader.php b/src/bundle/Core/Imagine/Filter/Loader/ScaleWidthFilterLoader.php index b15d374e4e..4da242d47b 100644 --- a/src/bundle/Core/Imagine/Filter/Loader/ScaleWidthFilterLoader.php +++ b/src/bundle/Core/Imagine/Filter/Loader/ScaleWidthFilterLoader.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\Filter\Loader; @@ -16,8 +17,11 @@ */ class ScaleWidthFilterLoader extends FilterLoaderWrapped { - public const IDENTIFIER = 'geometry/scalewidth'; + public const string IDENTIFIER = 'geometry/scalewidth'; + /** + * @phpstan-param array{0?: int} $options width + */ public function load(ImageInterface $image, array $options = []): ImageInterface { if (empty($options)) { diff --git a/src/bundle/Core/Imagine/Filter/Loader/SwirlFilterLoader.php b/src/bundle/Core/Imagine/Filter/Loader/SwirlFilterLoader.php index 603a9d78d1..85e64b43d3 100644 --- a/src/bundle/Core/Imagine/Filter/Loader/SwirlFilterLoader.php +++ b/src/bundle/Core/Imagine/Filter/Loader/SwirlFilterLoader.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\Filter\Loader; @@ -13,16 +14,18 @@ class SwirlFilterLoader implements LoaderInterface { - public const IDENTIFIER = 'filter/swirl'; + public const string IDENTIFIER = 'filter/swirl'; - /** @var \Ibexa\Bundle\Core\Imagine\Filter\FilterInterface */ - private $filter; + private FilterInterface $filter; public function __construct(FilterInterface $filter) { $this->filter = $filter; } + /** + * @phpstan-param array{0?: int|float} $options degrees + */ public function load(ImageInterface $image, array $options = []): ImageInterface { if (!empty($options)) { From f26b7a67c23807b8f2b33f0917bfb34e1fe02faa Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 16 Jul 2025 17:26:37 +0200 Subject: [PATCH 04/18] Added missing type hints to VariationHandler contract and its implementations --- src/bundle/Core/Imagine/AliasGenerator.php | 53 +++++++++---------- .../Imagine/Cache/AliasGeneratorDecorator.php | 4 +- .../Imagine/ImageAsset/AliasGenerator.php | 19 ++----- .../Imagine/PlaceholderAliasGenerator.php | 53 ++++++++++--------- .../Variation/ImagineAwareAliasGenerator.php | 35 ++++-------- .../Variation/VariationHandlerResolver.php | 1 + src/contracts/Variation/VariationHandler.php | 4 ++ 7 files changed, 76 insertions(+), 93 deletions(-) diff --git a/src/bundle/Core/Imagine/AliasGenerator.php b/src/bundle/Core/Imagine/AliasGenerator.php index 97679a5049..d2ed16a37a 100644 --- a/src/bundle/Core/Imagine/AliasGenerator.php +++ b/src/bundle/Core/Imagine/AliasGenerator.php @@ -4,9 +4,11 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine; +use Ibexa\Contracts\Core\Exception\InvalidArgumentException; use Ibexa\Contracts\Core\FieldType\Value; use Ibexa\Contracts\Core\Repository\Exceptions\InvalidVariationException; use Ibexa\Contracts\Core\Repository\Values\Content\Field; @@ -17,7 +19,6 @@ use Ibexa\Core\FieldType\Image\Value as ImageValue; use Ibexa\Core\MVC\Exception\SourceImageNotFoundException; use Imagine\Exception\RuntimeException; -use InvalidArgumentException; use Liip\ImagineBundle\Binary\BinaryInterface; use Liip\ImagineBundle\Binary\Loader\LoaderInterface; use Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException; @@ -35,27 +36,21 @@ */ class AliasGenerator implements VariationHandler { - public const ALIAS_ORIGINAL = 'original'; + public const string ALIAS_ORIGINAL = 'original'; - /** @var \Psr\Log\LoggerInterface */ - private $logger; + private LoggerInterface $logger; /** * Loader used to retrieve the original image. * DataManager is not used to remain independent from ImagineBundle configuration. - * - * @var \Liip\ImagineBundle\Binary\Loader\LoaderInterface */ - private $dataLoader; + private LoaderInterface $dataLoader; - /** @var \Liip\ImagineBundle\Imagine\Filter\FilterManager */ - private $filterManager; + private FilterManager $filterManager; - /** @var \Liip\ImagineBundle\Imagine\Filter\FilterConfiguration */ - private $filterConfiguration; + private FilterConfiguration $filterConfiguration; - /** @var \Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface */ - private $ioResolver; + private ResolverInterface $ioResolver; public function __construct( LoaderInterface $dataLoader, @@ -68,16 +63,9 @@ public function __construct( $this->filterManager = $filterManager; $this->ioResolver = $ioResolver; $this->filterConfiguration = $filterConfiguration; - $this->logger = null !== $logger ? $logger : new NullLogger(); + $this->logger = $logger ?? new NullLogger(); } - /** - * {@inheritdoc} - * - * @throws \InvalidArgumentException If field value is not an instance of {@see \Ibexa\Core\FieldType\Image\Value}. - * @throws \Ibexa\Core\MVC\Exception\SourceImageNotFoundException If source image cannot be found. - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidVariationException If a problem occurs with generated variation. - */ public function getVariation(Field $field, VersionInfo $versionInfo, string $variationName, array $parameters = []): Variation { /** @var \Ibexa\Core\FieldType\Image\Value $imageValue */ @@ -85,7 +73,10 @@ public function getVariation(Field $field, VersionInfo $versionInfo, string $var $fieldId = $field->id; $fieldDefIdentifier = $field->fieldDefIdentifier; if (!$this->supportsValue($imageValue)) { - throw new InvalidArgumentException("Value of Field with ID $fieldId ($fieldDefIdentifier) cannot be used for generating an image variation."); + throw new InvalidArgumentException( + '$field', + "Value of Field with ID $fieldId ($fieldDefIdentifier) cannot be used for generating an image variation." + ); } $originalPath = $imageValue->id; @@ -98,6 +89,17 @@ public function getVariation(Field $field, VersionInfo $versionInfo, string $var } catch (NotLoadableException $e) { throw new SourceImageNotFoundException((string)$originalPath, 0, $e); } + if (!$originalBinary instanceof BinaryInterface) { + throw new InvalidArgumentException( + '$field', + sprintf( + 'Data loader for \'%s\' path loaded %s instead of %s', + $originalPath, + get_debug_type($originalBinary), + BinaryInterface::class + ) + ); + } $this->logger->debug("Generating '$variationName' variation on $originalPath, field #$fieldId ($fieldDefIdentifier)"); @@ -145,13 +147,8 @@ public function getVariation(Field $field, VersionInfo $versionInfo, string $var * An Ibexa variation may have a "reference". * In that case, reference's filters are applied first, recursively (a reference may also have another reference). * Reference must be a valid variation name, configured in Ibexa or in LiipImagineBundle. - * - * @param \Liip\ImagineBundle\Binary\BinaryInterface $image - * @param string $variationName - * - * @return \Liip\ImagineBundle\Binary\BinaryInterface */ - private function applyFilter(BinaryInterface $image, $variationName) + private function applyFilter(BinaryInterface $image, string $variationName): BinaryInterface { $filterConfig = $this->filterConfiguration->get($variationName); // If the variation has a reference, we recursively call this method to apply reference's filters. diff --git a/src/bundle/Core/Imagine/Cache/AliasGeneratorDecorator.php b/src/bundle/Core/Imagine/Cache/AliasGeneratorDecorator.php index 6f71bd40e1..b54c152e0f 100644 --- a/src/bundle/Core/Imagine/Cache/AliasGeneratorDecorator.php +++ b/src/bundle/Core/Imagine/Cache/AliasGeneratorDecorator.php @@ -54,9 +54,11 @@ public function __construct( } /** + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException * @throws \Psr\Cache\CacheException * @throws \Psr\Cache\InvalidArgumentException - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ public function getVariation( Field $field, diff --git a/src/bundle/Core/Imagine/ImageAsset/AliasGenerator.php b/src/bundle/Core/Imagine/ImageAsset/AliasGenerator.php index d021cf689a..c5df234f6e 100644 --- a/src/bundle/Core/Imagine/ImageAsset/AliasGenerator.php +++ b/src/bundle/Core/Imagine/ImageAsset/AliasGenerator.php @@ -18,24 +18,16 @@ use Ibexa\Core\FieldType\ImageAsset\Value as ImageAssetValue; /** - * Alias Generator Decorator allowing generate variations based on passed ImageAsset\Value. + * Alias Generator Decorator allowing to generate variations based on passed ImageAsset\Value. */ class AliasGenerator implements VariationHandler { - /** @var \Ibexa\Contracts\Core\Variation\VariationHandler */ - private $innerAliasGenerator; + private VariationHandler $innerAliasGenerator; - /** @var \Ibexa\Contracts\Core\Repository\ContentService */ - private $contentService; + private ContentService $contentService; - /** @var \Ibexa\Core\FieldType\ImageAsset\AssetMapper */ - private $assetMapper; + private AssetMapper $assetMapper; - /** - * @param \Ibexa\Contracts\Core\Variation\VariationHandler $innerAliasGenerator - * @param \Ibexa\Contracts\Core\Repository\ContentService $contentService - * @param \Ibexa\Core\FieldType\ImageAsset\AssetMapper $assetMapper - */ public function __construct( VariationHandler $innerAliasGenerator, ContentService $contentService, @@ -46,9 +38,6 @@ public function __construct( $this->assetMapper = $assetMapper; } - /** - * {@inheritdoc} - */ public function getVariation(Field $field, VersionInfo $versionInfo, string $variationName, array $parameters = []): Variation { if ($this->supportsValue($field->value)) { diff --git a/src/bundle/Core/Imagine/PlaceholderAliasGenerator.php b/src/bundle/Core/Imagine/PlaceholderAliasGenerator.php index b76111f32e..f3ad72209a 100644 --- a/src/bundle/Core/Imagine/PlaceholderAliasGenerator.php +++ b/src/bundle/Core/Imagine/PlaceholderAliasGenerator.php @@ -4,11 +4,12 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine; use Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException as APIInvalidArgumentException; -use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException; +use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException as APINotFoundException; use Ibexa\Contracts\Core\Repository\Values\Content\Field; use Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo; use Ibexa\Contracts\Core\Variation\Values\Variation; @@ -22,23 +23,18 @@ class PlaceholderAliasGenerator implements VariationHandler { - /** @var \Ibexa\Contracts\Core\Variation\VariationHandler */ - private $aliasGenerator; + private VariationHandler $aliasGenerator; - /** @var \Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface */ - private $ioResolver; + private ResolverInterface $ioResolver; - /** @var \Ibexa\Core\IO\IOServiceInterface */ - private $ioService; + private IOServiceInterface $ioService; - /** @var \Ibexa\Bundle\Core\Imagine\PlaceholderProvider|null */ - private $placeholderProvider; + private ?PlaceholderProvider $placeholderProvider = null; - /** @var array */ - private $placeholderOptions = []; + /** @var array */ + private array $placeholderOptions = []; - /** @var bool */ - private $verifyBinaryDataAvailability = false; + private bool $verifyBinaryDataAvailability = false; public function __construct( VariationHandler $aliasGenerator, @@ -51,15 +47,23 @@ public function __construct( } /** - * {@inheritdoc} + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException */ - public function getVariation(Field $field, VersionInfo $versionInfo, string $variationName, array $parameters = []): Variation - { + public function getVariation( + Field $field, + VersionInfo $versionInfo, + string $variationName, + array $parameters = [] + ): Variation { if ($this->placeholderProvider !== null) { /** @var \Ibexa\Core\FieldType\Image\Value $imageValue */ $imageValue = $field->value; if (!$this->supportsValue($imageValue)) { - throw new InvalidArgumentException("Value of Field with ID {$field->id} ($field->fieldDefIdentifier) cannot be used for generating an image placeholder."); + throw new InvalidArgumentException( + "Value of Field with ID {$field->id} ($field->fieldDefIdentifier) cannot be used for generating an image placeholder." + ); } if (!$this->isOriginalImageAvailable($imageValue)) { @@ -75,7 +79,10 @@ public function getVariation(Field $field, VersionInfo $versionInfo, string $var return $this->aliasGenerator->getVariation($field, $versionInfo, $variationName, $parameters); } - public function setPlaceholderProvider(PlaceholderProvider $provider, array $options = []) + /** + * @param array $options + */ + public function setPlaceholderProvider(PlaceholderProvider $provider, array $options = []): void { $this->placeholderProvider = $provider; $this->placeholderOptions = $options; @@ -84,9 +91,7 @@ public function setPlaceholderProvider(PlaceholderProvider $provider, array $opt /** * Enable/disable binary data availability verification. * - * If enabled then binary data storage will be used to check if original file exists. Required for DFS setup. - * - * @param bool $verifyBinaryDataAvailability + * If enabled, then binary data storage will be used to check if original file exists. Required for DFS setup. */ public function setVerifyBinaryDataAvailability(bool $verifyBinaryDataAvailability): void { @@ -102,15 +107,15 @@ private function isOriginalImageAvailable(ImageValue $imageValue): bool { try { $this->ioResolver->resolve($imageValue->id, IORepositoryResolver::VARIATION_ORIGINAL); - } catch (NotResolvableException $e) { + } catch (NotResolvableException) { return false; } if ($this->verifyBinaryDataAvailability) { try { - // Try to open input stream to original file + // Try to open input stream to an original file $this->ioService->getFileInputStream($this->ioService->loadBinaryFile($imageValue->id)); - } catch (NotFoundException | APIInvalidArgumentException $e) { + } catch (APINotFoundException | APIInvalidArgumentException) { return false; } } diff --git a/src/bundle/Core/Imagine/Variation/ImagineAwareAliasGenerator.php b/src/bundle/Core/Imagine/Variation/ImagineAwareAliasGenerator.php index 05cb472a90..b0464e1eff 100644 --- a/src/bundle/Core/Imagine/Variation/ImagineAwareAliasGenerator.php +++ b/src/bundle/Core/Imagine/Variation/ImagineAwareAliasGenerator.php @@ -4,17 +4,20 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\Variation; use Ibexa\Bundle\Core\Imagine\IORepositoryResolver; use Ibexa\Contracts\Core\Repository\Values\Content\Field; use Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo; +use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface; use Ibexa\Contracts\Core\Variation\Values\ImageVariation; use Ibexa\Contracts\Core\Variation\Values\Variation; use Ibexa\Contracts\Core\Variation\VariationHandler; use Ibexa\Contracts\Core\Variation\VariationPathGenerator; use Ibexa\Core\IO\IOServiceInterface; +use Ibexa\Core\IO\Values\BinaryFile; use Imagine\Image\ImagineInterface; /** @@ -23,20 +26,15 @@ */ class ImagineAwareAliasGenerator implements VariationHandler { - /** @var \Ibexa\Contracts\Core\Variation\VariationHandler */ - private $aliasGenerator; + private VariationHandler $aliasGenerator; - /** @var \Ibexa\Contracts\Core\Variation\VariationPathGenerator */ - private $variationPathGenerator; + private VariationPathGenerator $variationPathGenerator; - /** @var \Ibexa\Core\IO\IOServiceInterface */ - private $ioService; + private IOServiceInterface $ioService; - /** @var \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface */ - private $configResolver; + private ConfigResolverInterface $configResolver; - /** @var \Imagine\Image\ImagineInterface */ - private $imagine; + private ImagineInterface $imagine; public function __construct( VariationHandler $aliasGenerator, @@ -50,14 +48,6 @@ public function __construct( $this->imagine = $imagine; } - /** - * Returns a Variation object, ensuring proper image dimensions. - * - * {@inheritdoc} - * - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException - */ public function getVariation( Field $field, VersionInfo $versionInfo, @@ -97,17 +87,12 @@ public function getVariation( } /** - * Get image variation filesystem path. - * - * @param string $originalPath - * @param string $variationName - * - * @return \Ibexa\Core\IO\Values\BinaryFile + * Get an image variation filesystem path. * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException */ - private function getVariationBinaryFile($originalPath, $variationName) + private function getVariationBinaryFile(string $originalPath, string $variationName): BinaryFile { if ($variationName !== IORepositoryResolver::VARIATION_ORIGINAL) { $variationPath = $this->variationPathGenerator->getVariationPath( diff --git a/src/bundle/Core/Variation/VariationHandlerResolver.php b/src/bundle/Core/Variation/VariationHandlerResolver.php index 0e42561fb6..01b45a9e3c 100644 --- a/src/bundle/Core/Variation/VariationHandlerResolver.php +++ b/src/bundle/Core/Variation/VariationHandlerResolver.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Variation; diff --git a/src/contracts/Variation/VariationHandler.php b/src/contracts/Variation/VariationHandler.php index e60273cb39..156f241b52 100644 --- a/src/contracts/Variation/VariationHandler.php +++ b/src/contracts/Variation/VariationHandler.php @@ -25,6 +25,10 @@ interface VariationHandler * Variations might be applicable for images (aliases), documents... * * @param array $parameters Hash of arbitrary parameters useful to generate the variation + * + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException */ public function getVariation( Field $field, From 39aef6e7b848d44bcd776a0a16c38dbb7ed7562a Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 16 Jul 2025 17:46:28 +0200 Subject: [PATCH 05/18] Added missing type hints to PlaceholderProvider implementation --- .../PlaceholderAliasGeneratorConfigurator.php | 30 ++++++++----------- .../Core/Imagine/PlaceholderProvider.php | 4 +-- .../PlaceholderProvider/GenericProvider.php | 29 ++++++++---------- .../PlaceholderProvider/RemoteProvider.php | 7 +++-- .../Imagine/PlaceholderProviderRegistry.php | 13 +++----- 5 files changed, 36 insertions(+), 47 deletions(-) diff --git a/src/bundle/Core/Imagine/PlaceholderAliasGeneratorConfigurator.php b/src/bundle/Core/Imagine/PlaceholderAliasGeneratorConfigurator.php index a8a3b6d894..ac52b733b9 100644 --- a/src/bundle/Core/Imagine/PlaceholderAliasGeneratorConfigurator.php +++ b/src/bundle/Core/Imagine/PlaceholderAliasGeneratorConfigurator.php @@ -4,33 +4,29 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine; use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface; -class PlaceholderAliasGeneratorConfigurator +final readonly class PlaceholderAliasGeneratorConfigurator { - /** @var \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface */ - private $configResolver; - - /** @var \Ibexa\Bundle\Core\Imagine\PlaceholderProviderRegistry */ - private $providerRegistry; - - /** @var array */ - private $providersConfig; - + /** + * @phpstan-param array, + * verify_binary_data_availability?: bool + * }> $providersConfig + */ public function __construct( - ConfigResolverInterface $configResolver, - PlaceholderProviderRegistry $providerRegistry, - array $providersConfig + private ConfigResolverInterface $configResolver, + private PlaceholderProviderRegistry $providerRegistry, + private array $providersConfig ) { - $this->configResolver = $configResolver; - $this->providerRegistry = $providerRegistry; - $this->providersConfig = $providersConfig; } - public function configure(PlaceholderAliasGenerator $generator) + public function configure(PlaceholderAliasGenerator $generator): void { $binaryHandlerName = $this->configResolver->getParameter('io.binarydata_handler'); diff --git a/src/bundle/Core/Imagine/PlaceholderProvider.php b/src/bundle/Core/Imagine/PlaceholderProvider.php index 8a78a6ea24..9671ed32f5 100644 --- a/src/bundle/Core/Imagine/PlaceholderProvider.php +++ b/src/bundle/Core/Imagine/PlaceholderProvider.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine; @@ -14,8 +15,7 @@ interface PlaceholderProvider /** * Provides a placeholder image path for a given Image FieldType value. * - * @param \Ibexa\Core\FieldType\Image\Value $value - * @param array $options + * @param array $options * * @return string Path to placeholder */ diff --git a/src/bundle/Core/Imagine/PlaceholderProvider/GenericProvider.php b/src/bundle/Core/Imagine/PlaceholderProvider/GenericProvider.php index ca397bcd99..78e9effe60 100644 --- a/src/bundle/Core/Imagine/PlaceholderProvider/GenericProvider.php +++ b/src/bundle/Core/Imagine/PlaceholderProvider/GenericProvider.php @@ -4,33 +4,26 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\PlaceholderProvider; use Ibexa\Bundle\Core\Imagine\PlaceholderProvider; use Ibexa\Core\FieldType\Image\Value as ImageValue; -use Imagine\Image as Image; +use Imagine\Image; +use Imagine\Image\AbstractFont; use Imagine\Image\ImagineInterface; use Symfony\Component\OptionsResolver\OptionsResolver; class GenericProvider implements PlaceholderProvider { - /** @var \Imagine\Image\ImagineInterface */ - private $imagine; - - /** - * GenericProvider constructor. - * - * @param \Imagine\Image\ImagineInterface $imagine - */ + private ImagineInterface $imagine; + public function __construct(ImagineInterface $imagine) { $this->imagine = $imagine; } - /** - * {@inheritdoc} - */ public function getPlaceholder(ImageValue $value, array $options = []): string { $options = $this->resolveOptions($options); @@ -40,8 +33,12 @@ public function getPlaceholder(ImageValue $value, array $options = []): string $foreground = $palette->color($options['foreground']); $secondary = $palette->color($options['secondary']); - $size = new Image\Box($value->width, $value->height); + $size = new Image\Box($value->width ?? 0, $value->height ?? 0); $font = $this->imagine->font($options['fontpath'], $options['fontsize'], $foreground); + if (!$font instanceof AbstractFont) { + throw new \LogicException("Font {$options['fontpath']} is not an instance of AbstractFont"); + } + $text = $this->getPlaceholderText($options['text'], $value); $center = new Image\Point\Center($size); @@ -54,13 +51,13 @@ public function getPlaceholder(ImageValue $value, array $options = []): string $image = $this->imagine->create($size, $background); $image->draw()->line( new Image\Point(0, 0), - new Image\Point($value->width, $value->height), + new Image\Point($value->width ?? 0, $value->height ?? 0), $secondary ); $image->draw()->line( - new Image\Point($value->width, 0), - new Image\Point(0, $value->height), + new Image\Point($value->width ?? 0, 0), + new Image\Point(0, $value->height ?? 0), $secondary ); diff --git a/src/bundle/Core/Imagine/PlaceholderProvider/RemoteProvider.php b/src/bundle/Core/Imagine/PlaceholderProvider/RemoteProvider.php index 9ec16b2c5d..653f0fb03e 100644 --- a/src/bundle/Core/Imagine/PlaceholderProvider/RemoteProvider.php +++ b/src/bundle/Core/Imagine/PlaceholderProvider/RemoteProvider.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine\PlaceholderProvider; @@ -17,9 +18,6 @@ */ class RemoteProvider implements PlaceholderProvider { - /** - * {@inheritdoc} - */ public function getPlaceholder(ImageValue $value, array $options = []): string { $options = $this->resolveOptions($options); @@ -61,6 +59,9 @@ private function getTemporaryPath(): string return stream_get_meta_data(tmpfile())['uri']; } + /** + * @param array $options + */ private function resolveOptions(array $options): array { $resolver = new OptionsResolver(); diff --git a/src/bundle/Core/Imagine/PlaceholderProviderRegistry.php b/src/bundle/Core/Imagine/PlaceholderProviderRegistry.php index 3ef89d4ff8..be2a8d5e63 100644 --- a/src/bundle/Core/Imagine/PlaceholderProviderRegistry.php +++ b/src/bundle/Core/Imagine/PlaceholderProviderRegistry.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine; @@ -11,20 +12,14 @@ class PlaceholderProviderRegistry { - /** @var \Ibexa\Bundle\Core\Imagine\PlaceholderProvider */ - private $providers; - /** - * PlaceholderProviderRegistry constructor. - * - * @param array $providers + * @param array $providers */ - public function __construct(array $providers = []) + public function __construct(private array $providers = []) { - $this->providers = $providers; } - public function addProvider(string $type, PlaceholderProvider $provider) + public function addProvider(string $type, PlaceholderProvider $provider): void { $this->providers[$type] = $provider; } From 67ae896926a755d4828763a27b16ba609677ea65 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 16 Jul 2025 17:50:58 +0200 Subject: [PATCH 06/18] Added missing type hints to Image alias cleaners --- src/bundle/Core/Imagine/AliasCleaner.php | 6 +++--- src/bundle/Core/Imagine/BinaryLoader.php | 16 +++++++--------- .../FieldType/Image/AliasCleanerInterface.php | 7 +++++-- src/lib/FieldType/Image/NullAliasCleaner.php | 2 +- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/bundle/Core/Imagine/AliasCleaner.php b/src/bundle/Core/Imagine/AliasCleaner.php index 78ff42b9cf..369cfa09b6 100644 --- a/src/bundle/Core/Imagine/AliasCleaner.php +++ b/src/bundle/Core/Imagine/AliasCleaner.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine; @@ -12,15 +13,14 @@ class AliasCleaner implements AliasCleanerInterface { - /** @var \Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface */ - private $aliasResolver; + private ResolverInterface $aliasResolver; public function __construct(ResolverInterface $aliasResolver) { $this->aliasResolver = $aliasResolver; } - public function removeAliases($originalPath) + public function removeAliases(string $originalPath): void { $this->aliasResolver->remove([$originalPath], []); } diff --git a/src/bundle/Core/Imagine/BinaryLoader.php b/src/bundle/Core/Imagine/BinaryLoader.php index 48d7cf755a..b05ad190a6 100644 --- a/src/bundle/Core/Imagine/BinaryLoader.php +++ b/src/bundle/Core/Imagine/BinaryLoader.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\Core\Imagine; @@ -11,6 +12,7 @@ use Ibexa\Core\IO\Exception\InvalidBinaryFileIdException; use Ibexa\Core\IO\IOServiceInterface; use Ibexa\Core\IO\Values\MissingBinaryFile; +use Liip\ImagineBundle\Binary\BinaryInterface; use Liip\ImagineBundle\Binary\Loader\LoaderInterface; use Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException; use Liip\ImagineBundle\Model\Binary; @@ -22,11 +24,9 @@ */ class BinaryLoader implements LoaderInterface { - /** @var \Ibexa\Core\IO\IOServiceInterface */ - private $ioService; + private IOServiceInterface $ioService; - /** @var \Symfony\Component\Mime\MimeTypesInterface */ - private $mimeTypes; + private MimeTypesInterface $mimeTypes; public function __construct(IOServiceInterface $ioService, MimeTypesInterface $mimeTypes) { @@ -36,10 +36,8 @@ public function __construct(IOServiceInterface $ioService, MimeTypesInterface $m /** * @param string $path - * - * @return \Liip\ImagineBundle\Binary\BinaryInterface */ - public function find($path) + public function find($path): BinaryInterface { try { $binaryFile = $this->ioService->loadBinaryFile($path); @@ -52,8 +50,8 @@ public function find($path) return new Binary( $this->ioService->getFileContents($binaryFile), - $mimeType, - $this->mimeTypes->getExtensions($mimeType)[0] ?? null + $mimeType ?? '', + $this->mimeTypes->getExtensions($mimeType ?? '')[0] ?? null ); } catch (InvalidBinaryFileIdException $e) { $message = diff --git a/src/lib/FieldType/Image/AliasCleanerInterface.php b/src/lib/FieldType/Image/AliasCleanerInterface.php index 6a41c6c01d..693e4296ef 100644 --- a/src/lib/FieldType/Image/AliasCleanerInterface.php +++ b/src/lib/FieldType/Image/AliasCleanerInterface.php @@ -16,6 +16,9 @@ interface AliasCleanerInterface * Removes all aliases corresponding to original image. * * @param string $originalPath Path to original image which aliases have been created from. - */ - public function removeAliases($originalPath); + * + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException + * */ + public function removeAliases(string $originalPath): void; } diff --git a/src/lib/FieldType/Image/NullAliasCleaner.php b/src/lib/FieldType/Image/NullAliasCleaner.php index f3ffb523b3..dfcb6d5d76 100644 --- a/src/lib/FieldType/Image/NullAliasCleaner.php +++ b/src/lib/FieldType/Image/NullAliasCleaner.php @@ -18,7 +18,7 @@ */ final class NullAliasCleaner implements AliasCleanerInterface { - public function removeAliases($originalPath): void + public function removeAliases(string $originalPath): void { // Nothing to do } From 51bef0c71d1ed8e699af0e03514e73da42278d40 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 16 Jul 2025 18:38:43 +0200 Subject: [PATCH 07/18] Added missing type hints to MVC\Symfony\Templating\Twig\Extension\ImageExtension --- .../Twig/Extension/ImageExtension.php | 28 ++++++++----------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/lib/MVC/Symfony/Templating/Twig/Extension/ImageExtension.php b/src/lib/MVC/Symfony/Templating/Twig/Extension/ImageExtension.php index 21abc9ac49..866560c7d1 100644 --- a/src/lib/MVC/Symfony/Templating/Twig/Extension/ImageExtension.php +++ b/src/lib/MVC/Symfony/Templating/Twig/Extension/ImageExtension.php @@ -4,26 +4,26 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Core\MVC\Symfony\Templating\Twig\Extension; +use Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException; use Ibexa\Contracts\Core\Repository\Exceptions\InvalidVariationException; use Ibexa\Contracts\Core\Repository\Values\Content\Field; use Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo; +use Ibexa\Contracts\Core\Variation\Values\Variation; use Ibexa\Contracts\Core\Variation\VariationHandler; use Ibexa\Core\FieldType\ImageAsset\AssetMapper; use Ibexa\Core\MVC\Exception\SourceImageNotFoundException; -use InvalidArgumentException; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; class ImageExtension extends AbstractExtension { - /** @var \Ibexa\Contracts\Core\Variation\VariationHandler */ - private $imageVariationService; + private VariationHandler $imageVariationService; - /** @var \Ibexa\Core\FieldType\ImageAsset\AssetMapper */ - protected $assetMapper; + protected AssetMapper $assetMapper; public function __construct(VariationHandler $imageVariationService, AssetMapper $assetMapper) { @@ -49,42 +49,36 @@ public function getFunctions(): array /** * Returns the image variation object for $field/$versionInfo. - * - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Field $field - * @param \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo $versionInfo - * @param string $variationName - * - * @return \Ibexa\Contracts\Core\Variation\Values\Variation|null */ - public function getImageVariation(Field $field, VersionInfo $versionInfo, $variationName) + public function getImageVariation(Field $field, VersionInfo $versionInfo, string $variationName): ?Variation { try { return $this->imageVariationService->getVariation($field, $versionInfo, $variationName); - } catch (InvalidVariationException $e) { + } catch (InvalidVariationException) { if (isset($this->logger)) { $this->logger->error("Couldn't get variation '{$variationName}' for image with id {$field->value->id}"); } - } catch (SourceImageNotFoundException $e) { + } catch (SourceImageNotFoundException) { if (isset($this->logger)) { $this->logger->error( "Couldn't create variation '{$variationName}' for image with id {$field->value->id} because source image can't be found" ); } - } catch (InvalidArgumentException $e) { + } catch (InvalidArgumentException) { if (isset($this->logger)) { $this->logger->error( "Couldn't create variation '{$variationName}' for image with id {$field->value->id} because an image could not be created from the given input" ); } } + + return null; } /** * Return identifier of the field used to store Image Asset value. * * Typically used to create generic view of the Image Asset field. - * - * @return string */ public function getImageAssetContentFieldIdentifier(): string { From 175354564e3643f17ba864ccea07135f57819cca Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 16 Jul 2025 15:56:29 +0200 Subject: [PATCH 08/18] [Tests] Refactored Imagine\Cache ProxyResolverTest to use data provider --- .../Cache/Resolver/ProxyResolverTest.php | 82 ++++++++----------- 1 file changed, 36 insertions(+), 46 deletions(-) diff --git a/tests/bundle/Core/Imagine/Cache/Resolver/ProxyResolverTest.php b/tests/bundle/Core/Imagine/Cache/Resolver/ProxyResolverTest.php index 0f53eea8d3..008b22e370 100644 --- a/tests/bundle/Core/Imagine/Cache/Resolver/ProxyResolverTest.php +++ b/tests/bundle/Core/Imagine/Cache/Resolver/ProxyResolverTest.php @@ -4,23 +4,25 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine\Cache\Resolver; use Ibexa\Bundle\Core\Imagine\Cache\Resolver\ProxyResolver; use Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class ProxyResolverTest extends TestCase +/** + * @covers \Ibexa\Bundle\Core\Imagine\Cache\Resolver\ProxyResolver + */ +final class ProxyResolverTest extends TestCase { - /** @var \PHPUnit\Framework\MockObject\MockObject|\Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface */ - private $resolver; + private ResolverInterface & MockObject $resolver; - /** @var string */ - private $path; + private string $path; - /** @var string */ - private $filter; + private string $filter; protected function setUp(): void { @@ -30,57 +32,45 @@ protected function setUp(): void $this->filter = 'medium'; } - public function testResolveUsingProxyHostWithTrailingSlash() + /** + * @dataProvider getDataForTestResolve + * + * @param string[] $hosts + */ + public function testResolve(array $hosts, string $resolvedPath, string $expected): void { - $hosts = ['http://ezplatform.com/']; $proxyResolver = new ProxyResolver($this->resolver, $hosts); - $resolvedPath = 'http://ibexa.co/var/site/storage/images/_aliases/medium/7/4/2/0/247-1-eng-GB/img_0885.jpg'; - $this->resolver ->expects(self::once()) ->method('resolve') ->with($this->path, $this->filter) ->willReturn($resolvedPath); - $expected = 'http://ezplatform.com/var/site/storage/images/_aliases/medium/7/4/2/0/247-1-eng-GB/img_0885.jpg'; - self::assertEquals($expected, $proxyResolver->resolve($this->path, $this->filter)); } - public function testResolveAndRemovePortUsingProxyHost() + /** + * @return iterable + */ + public static function getDataForTestResolve(): iterable { - $hosts = ['http://ibexa.co']; - $proxyResolver = new ProxyResolver($this->resolver, $hosts); - - $resolvedPath = 'http://ibexa.co:8060/var/site/storage/images/_aliases/medium/7/4/2/0/247-1-eng-GB/img_0885.jpg'; - - $this->resolver - ->expects(self::once()) - ->method('resolve') - ->with($this->path, $this->filter) - ->willReturn($resolvedPath); - - $expected = 'http://ibexa.co/var/site/storage/images/_aliases/medium/7/4/2/0/247-1-eng-GB/img_0885.jpg'; - - self::assertEquals($expected, $proxyResolver->resolve($this->path, $this->filter)); - } - - public function testResolveAndRemovePortUsingProxyHostWithTrailingSlash() - { - $hosts = ['http://ibexa.co']; - $proxyResolver = new ProxyResolver($this->resolver, $hosts); - - $resolvedPath = 'http://ezplatform.com:8080/var/site/storage/images/_aliases/medium/7/4/2/0/247-1-eng-GB/img_0885.jpg'; - - $this->resolver - ->expects(self::once()) - ->method('resolve') - ->with($this->path, $this->filter) - ->willReturn($resolvedPath); - - $expected = 'http://ibexa.co/var/site/storage/images/_aliases/medium/7/4/2/0/247-1-eng-GB/img_0885.jpg'; - - self::assertEquals($expected, $proxyResolver->resolve($this->path, $this->filter)); + yield 'proxy host with trailing slash' => [ + ['https://qntmgroup.com/'], + 'https://ibexa.co/var/site/storage/images/_aliases/medium/7/4/2/0/247-1-eng-GB/img_0885.jpg', + 'https://qntmgroup.com/var/site/storage/images/_aliases/medium/7/4/2/0/247-1-eng-GB/img_0885.jpg', + ]; + + yield 'remove port using proxy host' => [ + ['https://ibexa.co'], + 'https://ibexa.co:8060/var/site/storage/images/_aliases/medium/7/4/2/0/247-1-eng-GB/img_0885.jpg', + 'https://ibexa.co/var/site/storage/images/_aliases/medium/7/4/2/0/247-1-eng-GB/img_0885.jpg', + ]; + + yield 'remove port using proxy host with trailing slash' => [ + ['https://ibexa.co'], + 'https://qntmgroup.com:8080/var/site/storage/images/_aliases/medium/7/4/2/0/247-1-eng-GB/img_0885.jpg', + 'https://ibexa.co/var/site/storage/images/_aliases/medium/7/4/2/0/247-1-eng-GB/img_0885.jpg', + ]; } } From 3ff8d77fc61fa0a7e69de29b3e3d1309b41f10ad Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 16 Jul 2025 15:57:06 +0200 Subject: [PATCH 09/18] [Tests] Added missing type hints to `Imagine\Cache` Resolver tests --- .../Cache/Resolver/RelativeResolverTest.php | 14 +++++---- .../Imagine/Cache/ResolverFactoryTest.php | 30 ++++++++++--------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/tests/bundle/Core/Imagine/Cache/Resolver/RelativeResolverTest.php b/tests/bundle/Core/Imagine/Cache/Resolver/RelativeResolverTest.php index 1d41a4f323..4aead0c298 100644 --- a/tests/bundle/Core/Imagine/Cache/Resolver/RelativeResolverTest.php +++ b/tests/bundle/Core/Imagine/Cache/Resolver/RelativeResolverTest.php @@ -4,17 +4,21 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine\Cache\Resolver; use Ibexa\Bundle\Core\Imagine\Cache\Resolver\RelativeResolver; use Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class RelativeResolverTest extends TestCase +/** + * @covers \Ibexa\Bundle\Core\Imagine\Cache\Resolver\RelativeResolver + */ +final class RelativeResolverTest extends TestCase { - /** @var \PHPUnit\Framework\MockObject\MockObject|\Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface */ - private $liipResolver; + private ResolverInterface & MockObject $liipResolver; protected function setUp(): void { @@ -22,14 +26,14 @@ protected function setUp(): void $this->liipResolver = $this->getMockBuilder(ResolverInterface::class)->getMock(); } - public function testResolve() + public function testResolve(): void { $resolver = new RelativeResolver($this->liipResolver); $path = '7/4/2/0/247-1-eng-GB/test.png'; $filter = 'big'; - $absolute = 'http://ibexa.co/var/site/storage/images/_aliases/big/7/4/2/0/247-1-eng-GB/test.png'; + $absolute = 'https://ibexa.co/var/site/storage/images/_aliases/big/7/4/2/0/247-1-eng-GB/test.png'; $expected = '/var/site/storage/images/_aliases/big/7/4/2/0/247-1-eng-GB/test.png'; $this->liipResolver diff --git a/tests/bundle/Core/Imagine/Cache/ResolverFactoryTest.php b/tests/bundle/Core/Imagine/Cache/ResolverFactoryTest.php index 32c17cf66c..b3125e4b12 100644 --- a/tests/bundle/Core/Imagine/Cache/ResolverFactoryTest.php +++ b/tests/bundle/Core/Imagine/Cache/ResolverFactoryTest.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine\Cache; @@ -12,18 +13,19 @@ use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface; use Liip\ImagineBundle\Imagine\Cache\Resolver\ProxyResolver; use Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class ResolverFactoryTest extends TestCase +/** + * @covers \Ibexa\Bundle\Core\Imagine\Cache\ResolverFactory + */ +final class ResolverFactoryTest extends TestCase { - /** @var \PHPUnit\Framework\MockObject\MockObject|\Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface */ - private $configResolver; + private ConfigResolverInterface&MockObject $configResolver; - /** @var \PHPUnit\Framework\MockObject\MockObject|\Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface */ - private $resolver; + private ResolverInterface & MockObject $resolver; - /** @var \Ibexa\Bundle\Core\Imagine\Cache\ResolverFactory */ - private $factory; + private ResolverFactory $factory; protected function setUp(): void { @@ -38,18 +40,18 @@ protected function setUp(): void ); } - public function testCreateProxyCacheResolver() + public function testCreateProxyCacheResolver(): void { $this->configResolver - ->expects(self::at(0)) + ->expects(self::once()) ->method('hasParameter') ->with('image_host') ->willReturn(true); - $host = 'http://ibexa.co'; + $host = 'https://ibexa.co'; $this->configResolver - ->expects(self::at(1)) + ->expects(self::once()) ->method('getParameter') ->with('image_host') ->willReturn($host); @@ -59,10 +61,10 @@ public function testCreateProxyCacheResolver() self::assertEquals($expected, $this->factory->createCacheResolver()); } - public function testCreateRelativeCacheResolver() + public function testCreateRelativeCacheResolver(): void { $this->configResolver - ->expects(self::at(0)) + ->expects(self::once()) ->method('hasParameter') ->with('image_host') ->willReturn(true); @@ -70,7 +72,7 @@ public function testCreateRelativeCacheResolver() $host = '/'; $this->configResolver - ->expects(self::at(1)) + ->expects(self::once()) ->method('getParameter') ->with('image_host') ->willReturn($host); From 122d372b5fc6387f20d38e494cabc7bff7014759 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 16 Jul 2025 16:59:58 +0200 Subject: [PATCH 10/18] [Tests] Added missing type hints and refactored Filter Loader tests --- .../Imagine/Filter/AbstractFilterTest.php | 23 ++++--- .../Filter/FilterConfigurationTest.php | 50 +++++++------- .../Filter/Loader/BorderFilterLoaderTest.php | 66 +++++++++++-------- .../Filter/Loader/CropFilterLoaderTest.php | 26 +++++--- .../Loader/GrayscaleFilterLoaderTest.php | 12 ++-- .../Loader/ReduceNoiseFilterLoaderTest.php | 19 +++--- .../Loader/ScaleDownOnlyFilterLoaderTest.php | 26 +++++--- .../Loader/ScaleExactFilterLoaderTest.php | 26 +++++--- .../Filter/Loader/ScaleFilterLoaderTest.php | 34 ++++++---- .../ScaleHeightDownOnlyFilterLoaderTest.php | 19 +++--- .../Loader/ScaleHeightFilterLoaderTest.php | 20 +++--- .../Loader/ScalePercentFilterLoaderTest.php | 28 +++++--- .../ScaleWidthDownOnlyFilterLoaderTest.php | 19 +++--- .../Loader/ScaleWidthFilterLoaderTest.php | 21 +++--- .../Filter/Loader/SwirlFilterLoaderTest.php | 26 +++++--- .../Imagine/Filter/UnsupportedFilterTest.php | 12 ++-- 16 files changed, 257 insertions(+), 170 deletions(-) diff --git a/tests/bundle/Core/Imagine/Filter/AbstractFilterTest.php b/tests/bundle/Core/Imagine/Filter/AbstractFilterTest.php index 4f4ef7ca3f..57d1c3241d 100644 --- a/tests/bundle/Core/Imagine/Filter/AbstractFilterTest.php +++ b/tests/bundle/Core/Imagine/Filter/AbstractFilterTest.php @@ -4,16 +4,17 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine\Filter; use Ibexa\Bundle\Core\Imagine\Filter\AbstractFilter; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class AbstractFilterTest extends TestCase { - /** @var \Ibexa\Bundle\Core\Imagine\Filter\AbstractFilter */ - protected $filter; + protected AbstractFilter & MockObject $filter; protected function setUp(): void { @@ -21,12 +22,12 @@ protected function setUp(): void $this->filter = $this->getFilter(); } - protected function getFilter() + protected function getFilter(): AbstractFilter & MockObject { return $this->getMockForAbstractClass(AbstractFilter::class); } - public function testGetSetOptions() + public function testGetSetOptions(): void { self::assertSame([], $this->filter->getOptions()); $options = ['foo' => 'bar', 'some' => ['thing']]; @@ -37,7 +38,7 @@ public function testGetSetOptions() /** * @dataProvider getSetOptionNoDefaulValueProvider */ - public function testGetSetOptionNoDefaultValue($optionName, $value) + public function testGetSetOptionNoDefaultValue(string $optionName, mixed $value): void { self::assertFalse($this->filter->hasOption($optionName)); self::assertNull($this->filter->getOption($optionName)); @@ -46,7 +47,10 @@ public function testGetSetOptionNoDefaultValue($optionName, $value) self::assertSame($value, $this->filter->getOption($optionName)); } - public function getSetOptionNoDefaulValueProvider() + /** + * @return array + */ + public static function getSetOptionNoDefaulValueProvider(): array { return [ ['foo', 'bar'], @@ -61,7 +65,7 @@ public function getSetOptionNoDefaulValueProvider() /** * @dataProvider getSetOptionWithDefaulValueProvider */ - public function testGetSetOptionWithDefaultValue($optionName, $value, $defaultValue) + public function testGetSetOptionWithDefaultValue(string $optionName, mixed $value, mixed $defaultValue): void { self::assertFalse($this->filter->hasOption($optionName)); self::assertSame($defaultValue, $this->filter->getOption($optionName, $defaultValue)); @@ -70,7 +74,10 @@ public function testGetSetOptionWithDefaultValue($optionName, $value, $defaultVa self::assertSame($value, $this->filter->getOption($optionName)); } - public function getSetOptionWithDefaulValueProvider() + /** + * @return array + */ + public static function getSetOptionWithDefaulValueProvider(): array { return [ ['foo', 'bar', 'default'], diff --git a/tests/bundle/Core/Imagine/Filter/FilterConfigurationTest.php b/tests/bundle/Core/Imagine/Filter/FilterConfigurationTest.php index fe9cf8af97..d9bffece15 100644 --- a/tests/bundle/Core/Imagine/Filter/FilterConfigurationTest.php +++ b/tests/bundle/Core/Imagine/Filter/FilterConfigurationTest.php @@ -4,20 +4,24 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine\Filter; use Ibexa\Bundle\Core\Imagine\Filter\FilterConfiguration; use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +use RuntimeException; -class FilterConfigurationTest extends TestCase +/** + * @covers \Ibexa\Bundle\Core\Imagine\Filter\FilterConfiguration + */ +final class FilterConfigurationTest extends TestCase { - /** @var \PHPUnit\Framework\MockObject\MockObject */ - private $configResolver; + private ConfigResolverInterface & MockObject $configResolver; - /** @var \Ibexa\Bundle\Core\Imagine\Filter\FilterConfiguration */ - private $filterConfiguration; + private FilterConfiguration $filterConfiguration; protected function setUp(): void { @@ -27,7 +31,7 @@ protected function setUp(): void $this->filterConfiguration->setConfigResolver($this->configResolver); } - public function testGetOnlyImagineFilters() + public function testGetOnlyImagineFilters(): void { $fooConfig = ['fooconfig']; $barConfig = ['barconfig']; @@ -38,16 +42,14 @@ public function testGetOnlyImagineFilters() ->expects(self::exactly(2)) ->method('getParameter') ->with('image_variations') - ->will(self::returnValue([])); + ->willReturn([]); self::assertSame($fooConfig, $this->filterConfiguration->get('foo')); self::assertSame($barConfig, $this->filterConfiguration->get('bar')); } - public function testGetNoEzVariationInvalidImagineFilter() + public function testGetNoVariationInvalidImagineFilter(): void { - $this->expectException(\RuntimeException::class); - $fooConfig = ['fooconfig']; $barConfig = ['barconfig']; $this->filterConfiguration->set('foo', $fooConfig); @@ -57,12 +59,14 @@ public function testGetNoEzVariationInvalidImagineFilter() ->expects(self::once()) ->method('getParameter') ->with('image_variations') - ->will(self::returnValue([])); + ->willReturn([]); + + $this->expectException(RuntimeException::class); $this->filterConfiguration->get('foobar'); } - public function testGetWithEzVariationNullConfiguration(): void + public function testGetWithVariationNullConfiguration(): void { $fooConfig = ['fooconfig']; $barConfig = ['barconfig']; @@ -76,7 +80,7 @@ public function testGetWithEzVariationNullConfiguration(): void ->expects(self::once()) ->method('getParameter') ->with('image_variations') - ->will(self::returnValue($variations)); + ->willReturn($variations); self::assertSame( [ @@ -90,7 +94,7 @@ public function testGetWithEzVariationNullConfiguration(): void ); } - public function testGetEzVariationNoReference() + public function testGetVariationNoReference(): void { $fooConfig = ['fooconfig']; $barConfig = ['barconfig']; @@ -105,7 +109,7 @@ public function testGetEzVariationNoReference() ->expects(self::once()) ->method('getParameter') ->with('image_variations') - ->will(self::returnValue($variations)); + ->willReturn($variations); self::assertSame( [ @@ -119,7 +123,7 @@ public function testGetEzVariationNoReference() ); } - public function testGetEzVariationWithReference() + public function testGetVariationWithReference(): void { $fooConfig = ['fooconfig']; $barConfig = ['barconfig']; @@ -135,7 +139,7 @@ public function testGetEzVariationWithReference() ->expects(self::once()) ->method('getParameter') ->with('image_variations') - ->will(self::returnValue($variations)); + ->willReturn($variations); self::assertSame( [ @@ -149,7 +153,7 @@ public function testGetEzVariationWithReference() ); } - public function testGetEzVariationImagineFilters() + public function testGetVariationImagineFilters(): void { $filters = ['some_filter' => []]; $imagineConfig = ['filters' => $filters]; @@ -163,7 +167,7 @@ public function testGetEzVariationImagineFilters() ->expects(self::once()) ->method('getParameter') ->with('image_variations') - ->will(self::returnValue($variations)); + ->willReturn($variations); self::assertSame( [ @@ -177,7 +181,7 @@ public function testGetEzVariationImagineFilters() ); } - public function testGetEzVariationImagineOptions() + public function testGetVariationImagineOptions(): void { $imagineConfig = [ 'foo_option' => 'foo', @@ -194,7 +198,7 @@ public function testGetEzVariationImagineOptions() ->expects(self::once()) ->method('getParameter') ->with('image_variations') - ->will(self::returnValue($variations)); + ->willReturn($variations); self::assertSame( [ @@ -210,7 +214,7 @@ public function testGetEzVariationImagineOptions() ); } - public function testAll() + public function testAll(): void { $fooConfig = ['fooconfig']; $barConfig = ['barconfig']; @@ -226,7 +230,7 @@ public function testAll() ->expects(self::once()) ->method('getParameter') ->with('image_variations') - ->will(self::returnValue($variations)); + ->willReturn($variations); self::assertEquals( [ diff --git a/tests/bundle/Core/Imagine/Filter/Loader/BorderFilterLoaderTest.php b/tests/bundle/Core/Imagine/Filter/Loader/BorderFilterLoaderTest.php index 3dc1640763..3bfbbc40c7 100644 --- a/tests/bundle/Core/Imagine/Filter/Loader/BorderFilterLoaderTest.php +++ b/tests/bundle/Core/Imagine/Filter/Loader/BorderFilterLoaderTest.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine\Filter\Loader; @@ -16,20 +17,28 @@ use Imagine\Image\Palette\PaletteInterface; use PHPUnit\Framework\TestCase; -class BorderFilterLoaderTest extends TestCase +/** + * @covers \Ibexa\Bundle\Core\Imagine\Filter\Loader\BorderFilterLoader + */ +final class BorderFilterLoaderTest extends TestCase { /** * @dataProvider loadInvalidProvider + * + * @param array $options */ - public function testLoadInvalidOptions(array $options) + public function testLoadInvalidOptions(array $options): void { - $this->expectException(InvalidArgumentException::class); - $loader = new BorderFilterLoader(); + + $this->expectException(InvalidArgumentException::class); $loader->load($this->createMock(ImageInterface::class), $options); } - public function loadInvalidProvider() + /** + * @return array}> + */ + public static function loadInvalidProvider(): array { return [ [[]], @@ -38,7 +47,7 @@ public function loadInvalidProvider() ]; } - public function testLoadDefaultColor() + public function testLoadDefaultColor(): void { $image = $this->createMock(ImageInterface::class); $options = [10, 10]; @@ -47,36 +56,36 @@ public function testLoadDefaultColor() $image ->expects(self::once()) ->method('palette') - ->will(self::returnValue($palette)); + ->willReturn($palette); $palette ->expects(self::once()) ->method('color') ->with(BorderFilterLoader::DEFAULT_BORDER_COLOR) - ->will(self::returnValue($this->createMock(ColorInterface::class))); + ->willReturn($this->createMock(ColorInterface::class)); $box = $this->createMock(BoxInterface::class); $image ->expects(self::once()) ->method('getSize') - ->will(self::returnValue($box)); + ->willReturn($box); $box - ->expects(self::any()) + ->expects(self::atLeastOnce()) ->method('getWidth') - ->will(self::returnValue(100)); + ->willReturn(100); $box ->expects(self::any()) ->method('getHeight') - ->will(self::returnValue(100)); + ->willReturn(100); $drawer = $this->createMock(DrawerInterface::class); $image ->expects(self::once()) ->method('draw') - ->will(self::returnValue($drawer)); + ->willReturn($drawer); $drawer - ->expects(self::any()) + ->expects(self::atLeastOnce()) ->method('line') - ->will(self::returnValue($drawer)); + ->willReturn($drawer); $loader = new BorderFilterLoader(); self::assertSame($image, $loader->load($image, $options)); @@ -85,7 +94,7 @@ public function testLoadDefaultColor() /** * @dataProvider loadProvider */ - public function testLoad($thickX, $thickY, $color) + public function testLoad(int $thickX, int $thickY, string $color): void { $image = $this->createMock(ImageInterface::class); $options = [$thickX, $thickY, $color]; @@ -94,42 +103,45 @@ public function testLoad($thickX, $thickY, $color) $image ->expects(self::once()) ->method('palette') - ->will(self::returnValue($palette)); + ->willReturn($palette); $palette ->expects(self::once()) ->method('color') ->with($color) - ->will(self::returnValue($this->createMock(ColorInterface::class))); + ->willReturn($this->createMock(ColorInterface::class)); $box = $this->createMock(BoxInterface::class); $image ->expects(self::once()) ->method('getSize') - ->will(self::returnValue($box)); + ->willReturn($box); $box - ->expects(self::any()) + ->expects(self::atLeastOnce()) ->method('getWidth') - ->will(self::returnValue(1000)); + ->willReturn(1000); $box - ->expects(self::any()) + ->expects(self::atLeastOnce()) ->method('getHeight') - ->will(self::returnValue(1000)); + ->willReturn(1000); $drawer = $this->createMock(DrawerInterface::class); $image ->expects(self::once()) ->method('draw') - ->will(self::returnValue($drawer)); + ->willReturn($drawer); $drawer - ->expects(self::any()) + ->expects(self::atLeastOnce()) ->method('line') - ->will(self::returnValue($drawer)); + ->willReturn($drawer); $loader = new BorderFilterLoader(); self::assertSame($image, $loader->load($image, $options)); } - public function loadProvider() + /** + * @return array + */ + public static function loadProvider(): array { return [ [10, 10, '#fff'], diff --git a/tests/bundle/Core/Imagine/Filter/Loader/CropFilterLoaderTest.php b/tests/bundle/Core/Imagine/Filter/Loader/CropFilterLoaderTest.php index e937182c95..220a16c61e 100644 --- a/tests/bundle/Core/Imagine/Filter/Loader/CropFilterLoaderTest.php +++ b/tests/bundle/Core/Imagine/Filter/Loader/CropFilterLoaderTest.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine\Filter\Loader; @@ -11,15 +12,17 @@ use Imagine\Exception\InvalidArgumentException; use Imagine\Image\ImageInterface; use Liip\ImagineBundle\Imagine\Filter\Loader\LoaderInterface; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class CropFilterLoaderTest extends TestCase +/** + * @covers \Ibexa\Bundle\Core\Imagine\Filter\Loader\CropFilterLoader + */ +final class CropFilterLoaderTest extends TestCase { - /** @var \PHPUnit\Framework\MockObject\MockObject */ - private $innerLoader; + private LoaderInterface & MockObject $innerLoader; - /** @var \Ibexa\Bundle\Core\Imagine\Filter\Loader\CropFilterLoader */ - private $loader; + private CropFilterLoader $loader; protected function setUp(): void { @@ -31,15 +34,20 @@ protected function setUp(): void /** * @dataProvider loadInvalidProvider + * + * @param array $options */ - public function testLoadInvalidOptions(array $options) + public function testLoadInvalidOptions(array $options): void { $this->expectException(InvalidArgumentException::class); $this->loader->load($this->createMock(ImageInterface::class), $options); } - public function loadInvalidProvider() + /** + * @return array}> + */ + public static function loadInvalidProvider(): array { return [ [[]], @@ -50,7 +58,7 @@ public function loadInvalidProvider() ]; } - public function testLoad() + public function testLoad(): void { $width = 123; $height = 789; @@ -62,7 +70,7 @@ public function testLoad() ->expects(self::once()) ->method('load') ->with($image, ['size' => [$width, $height], 'start' => [$offsetX, $offsetY]]) - ->will(self::returnValue($image)); + ->willReturn($image); self::assertSame($image, $this->loader->load($image, [$width, $height, $offsetX, $offsetY])); } diff --git a/tests/bundle/Core/Imagine/Filter/Loader/GrayscaleFilterLoaderTest.php b/tests/bundle/Core/Imagine/Filter/Loader/GrayscaleFilterLoaderTest.php index eaa18287ba..e64e8e0292 100644 --- a/tests/bundle/Core/Imagine/Filter/Loader/GrayscaleFilterLoaderTest.php +++ b/tests/bundle/Core/Imagine/Filter/Loader/GrayscaleFilterLoaderTest.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine\Filter\Loader; @@ -12,20 +13,23 @@ use Imagine\Image\ImageInterface; use PHPUnit\Framework\TestCase; -class GrayscaleFilterLoaderTest extends TestCase +/** + * @covers \Ibexa\Bundle\Core\Imagine\Filter\Loader\GrayscaleFilterLoader + */ +final class GrayscaleFilterLoaderTest extends TestCase { - public function testLoad() + public function testLoad(): void { $image = $this->createMock(ImageInterface::class); $effects = $this->createMock(EffectsInterface::class); $image ->expects(self::once()) ->method('effects') - ->will(self::returnValue($effects)); + ->willReturn($effects); $effects ->expects(self::once()) ->method('grayscale') - ->will(self::returnValue($effects)); + ->willReturn($effects); $loader = new GrayscaleFilterLoader(); self::assertSame($image, $loader->load($image)); diff --git a/tests/bundle/Core/Imagine/Filter/Loader/ReduceNoiseFilterLoaderTest.php b/tests/bundle/Core/Imagine/Filter/Loader/ReduceNoiseFilterLoaderTest.php index b4a6eb2942..3a71c78a14 100644 --- a/tests/bundle/Core/Imagine/Filter/Loader/ReduceNoiseFilterLoaderTest.php +++ b/tests/bundle/Core/Imagine/Filter/Loader/ReduceNoiseFilterLoaderTest.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine\Filter\Loader; @@ -13,22 +14,20 @@ use Imagine\Image\ImageInterface; use PHPUnit\Framework\TestCase; -class ReduceNoiseFilterLoaderTest extends TestCase +/** + * @covers \Ibexa\Bundle\Core\Imagine\Filter\Loader\ReduceNoiseFilterLoader + */ +final class ReduceNoiseFilterLoaderTest extends TestCase { - /** @var \PHPUnit\Framework\MockObject\MockObject */ - private $filter; - - /** @var \Ibexa\Bundle\Core\Imagine\Filter\Loader\ReduceNoiseFilterLoader */ - private $loader; + private ReduceNoiseFilterLoader $loader; protected function setUp(): void { - parent::setUp(); - $this->filter = $this->createMock(FilterInterface::class); - $this->loader = new ReduceNoiseFilterLoader($this->filter); + $filter = $this->createMock(FilterInterface::class); + $this->loader = new ReduceNoiseFilterLoader($filter); } - public function testLoadInvalidDriver() + public function testLoadInvalidDriver(): void { $this->expectException(NotSupportedException::class); diff --git a/tests/bundle/Core/Imagine/Filter/Loader/ScaleDownOnlyFilterLoaderTest.php b/tests/bundle/Core/Imagine/Filter/Loader/ScaleDownOnlyFilterLoaderTest.php index c120b142ab..4329041df7 100644 --- a/tests/bundle/Core/Imagine/Filter/Loader/ScaleDownOnlyFilterLoaderTest.php +++ b/tests/bundle/Core/Imagine/Filter/Loader/ScaleDownOnlyFilterLoaderTest.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine\Filter\Loader; @@ -11,15 +12,17 @@ use Imagine\Exception\InvalidArgumentException; use Imagine\Image\ImageInterface; use Liip\ImagineBundle\Imagine\Filter\Loader\LoaderInterface; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class ScaleDownOnlyFilterLoaderTest extends TestCase +/** + * @covers \Ibexa\Bundle\Core\Imagine\Filter\Loader\ScaleDownOnlyFilterLoader + */ +final class ScaleDownOnlyFilterLoaderTest extends TestCase { - /** @var \PHPUnit\Framework\MockObject\MockObject */ - private $innerLoader; + private LoaderInterface & MockObject $innerLoader; - /** @var \Ibexa\Bundle\Core\Imagine\Filter\Loader\ScaleDownOnlyFilterLoader */ - private $loader; + private ScaleDownOnlyFilterLoader $loader; protected function setUp(): void { @@ -31,15 +34,20 @@ protected function setUp(): void /** * @dataProvider loadInvalidProvider + * + * @param array $options */ - public function testLoadInvalidOptions(array $options) + public function testLoadInvalidOptions(array $options): void { $this->expectException(InvalidArgumentException::class); $this->loader->load($this->createMock(ImageInterface::class), $options); } - public function loadInvalidProvider() + /** + * @return array}> + */ + public static function loadInvalidProvider(): array { return [ [[]], @@ -48,7 +56,7 @@ public function loadInvalidProvider() ]; } - public function testLoad() + public function testLoad(): void { $options = [123, 456]; $image = $this->createMock(ImageInterface::class); @@ -56,7 +64,7 @@ public function testLoad() ->expects(self::once()) ->method('load') ->with($image, self::equalTo(['size' => $options, 'mode' => 'inset'])) - ->will(self::returnValue($image)); + ->willReturn($image); self::assertSame($image, $this->loader->load($image, $options)); } diff --git a/tests/bundle/Core/Imagine/Filter/Loader/ScaleExactFilterLoaderTest.php b/tests/bundle/Core/Imagine/Filter/Loader/ScaleExactFilterLoaderTest.php index 273b6dd972..369cf0ae65 100644 --- a/tests/bundle/Core/Imagine/Filter/Loader/ScaleExactFilterLoaderTest.php +++ b/tests/bundle/Core/Imagine/Filter/Loader/ScaleExactFilterLoaderTest.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine\Filter\Loader; @@ -11,15 +12,17 @@ use Imagine\Exception\InvalidArgumentException; use Imagine\Image\ImageInterface; use Liip\ImagineBundle\Imagine\Filter\Loader\LoaderInterface; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class ScaleExactFilterLoaderTest extends TestCase +/** + * @covers \Ibexa\Bundle\Core\Imagine\Filter\Loader\ScaleExactFilterLoader + */ +final class ScaleExactFilterLoaderTest extends TestCase { - /** @var \PHPUnit\Framework\MockObject\MockObject */ - private $innerLoader; + private LoaderInterface & MockObject $innerLoader; - /** @var \Ibexa\Bundle\Core\Imagine\Filter\Loader\ScaleExactFilterLoader */ - private $loader; + private ScaleExactFilterLoader $loader; protected function setUp(): void { @@ -31,15 +34,20 @@ protected function setUp(): void /** * @dataProvider loadInvalidProvider + * + * @param array $options */ - public function testLoadInvalidOptions(array $options) + public function testLoadInvalidOptions(array $options): void { $this->expectException(InvalidArgumentException::class); $this->loader->load($this->createMock(ImageInterface::class), $options); } - public function loadInvalidProvider() + /** + * @return array}> + */ + public static function loadInvalidProvider(): array { return [ [[]], @@ -48,7 +56,7 @@ public function loadInvalidProvider() ]; } - public function testLoad() + public function testLoad(): void { $options = [123, 456]; $image = $this->createMock(ImageInterface::class); @@ -56,7 +64,7 @@ public function testLoad() ->expects(self::once()) ->method('load') ->with($image, ['size' => $options]) - ->will(self::returnValue($image)); + ->willReturn($image); self::assertSame($image, $this->loader->load($image, $options)); } diff --git a/tests/bundle/Core/Imagine/Filter/Loader/ScaleFilterLoaderTest.php b/tests/bundle/Core/Imagine/Filter/Loader/ScaleFilterLoaderTest.php index 873eb0d0fc..22c85587f3 100644 --- a/tests/bundle/Core/Imagine/Filter/Loader/ScaleFilterLoaderTest.php +++ b/tests/bundle/Core/Imagine/Filter/Loader/ScaleFilterLoaderTest.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine\Filter\Loader; @@ -12,15 +13,17 @@ use Imagine\Image\Box; use Imagine\Image\ImageInterface; use Liip\ImagineBundle\Imagine\Filter\Loader\LoaderInterface; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class ScaleFilterLoaderTest extends TestCase +/** + * @covers \Ibexa\Bundle\Core\Imagine\Filter\Loader\ScaleFilterLoader + */ +final class ScaleFilterLoaderTest extends TestCase { - /** @var \PHPUnit\Framework\MockObject\MockObject */ - private $innerLoader; + private LoaderInterface & MockObject $innerLoader; - /** @var \Ibexa\Bundle\Core\Imagine\Filter\Loader\ScaleFilterLoader */ - private $loader; + private ScaleFilterLoader $loader; protected function setUp(): void { @@ -32,15 +35,20 @@ protected function setUp(): void /** * @dataProvider loadInvalidProvider + * + * @param array $options */ - public function testLoadInvalidOptions(array $options) + public function testLoadInvalidOptions(array $options): void { $this->expectException(InvalidArgumentException::class); $this->loader->load($this->createMock(ImageInterface::class), $options); } - public function loadInvalidProvider() + /** + * @return array}> + */ + public static function loadInvalidProvider(): array { return [ [[]], @@ -49,7 +57,7 @@ public function loadInvalidProvider() ]; } - public function testLoadHeighten() + public function testLoadHeighten(): void { $width = 900; $height = 400; @@ -61,18 +69,18 @@ public function testLoadHeighten() $image ->expects(self::once()) ->method('getSize') - ->will(self::returnValue($box)); + ->willReturn($box); $this->innerLoader ->expects(self::once()) ->method('load') ->with($image, self::equalTo(['heighten' => $height])) - ->will(self::returnValue($image)); + ->willReturn($image); self::assertSame($image, $this->loader->load($image, [$width, $height])); } - public function testLoadWiden() + public function testLoadWiden(): void { $width = 900; $height = 600; @@ -84,13 +92,13 @@ public function testLoadWiden() $image ->expects(self::once()) ->method('getSize') - ->will(self::returnValue($box)); + ->willReturn($box); $this->innerLoader ->expects(self::once()) ->method('load') ->with($image, self::equalTo(['widen' => $width])) - ->will(self::returnValue($image)); + ->willReturn($image); self::assertSame($image, $this->loader->load($image, [$width, $height])); } diff --git a/tests/bundle/Core/Imagine/Filter/Loader/ScaleHeightDownOnlyFilterLoaderTest.php b/tests/bundle/Core/Imagine/Filter/Loader/ScaleHeightDownOnlyFilterLoaderTest.php index 840cca4006..0fec8b000d 100644 --- a/tests/bundle/Core/Imagine/Filter/Loader/ScaleHeightDownOnlyFilterLoaderTest.php +++ b/tests/bundle/Core/Imagine/Filter/Loader/ScaleHeightDownOnlyFilterLoaderTest.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine\Filter\Loader; @@ -11,15 +12,17 @@ use Imagine\Exception\InvalidArgumentException; use Imagine\Image\ImageInterface; use Liip\ImagineBundle\Imagine\Filter\Loader\LoaderInterface; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class ScaleHeightDownOnlyFilterLoaderTest extends TestCase +/** + * @covers \Ibexa\Bundle\Core\Imagine\Filter\Loader\ScaleHeightDownOnlyFilterLoader + */ +final class ScaleHeightDownOnlyFilterLoaderTest extends TestCase { - /** @var \PHPUnit\Framework\MockObject\MockObject */ - private $innerLoader; + private LoaderInterface & MockObject $innerLoader; - /** @var \Ibexa\Bundle\Core\Imagine\Filter\Loader\ScaleHeightDownOnlyFilterLoader */ - private $loader; + private ScaleHeightDownOnlyFilterLoader $loader; protected function setUp(): void { @@ -29,14 +32,14 @@ protected function setUp(): void $this->loader->setInnerLoader($this->innerLoader); } - public function testLoadInvalid() + public function testLoadInvalid(): void { $this->expectException(InvalidArgumentException::class); $this->loader->load($this->createMock(ImageInterface::class), []); } - public function testLoad() + public function testLoad(): void { $height = 123; $image = $this->createMock(ImageInterface::class); @@ -44,7 +47,7 @@ public function testLoad() ->expects(self::once()) ->method('load') ->with($image, self::equalTo(['size' => [null, $height], 'mode' => 'inset'])) - ->will(self::returnValue($image)); + ->willReturn($image); self::assertSame($image, $this->loader->load($image, [$height])); } diff --git a/tests/bundle/Core/Imagine/Filter/Loader/ScaleHeightFilterLoaderTest.php b/tests/bundle/Core/Imagine/Filter/Loader/ScaleHeightFilterLoaderTest.php index 9b36149c03..f4ffcbcb73 100644 --- a/tests/bundle/Core/Imagine/Filter/Loader/ScaleHeightFilterLoaderTest.php +++ b/tests/bundle/Core/Imagine/Filter/Loader/ScaleHeightFilterLoaderTest.php @@ -11,15 +11,17 @@ use Imagine\Exception\InvalidArgumentException; use Imagine\Image\ImageInterface; use Liip\ImagineBundle\Imagine\Filter\Loader\LoaderInterface; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class ScaleHeightFilterLoaderTest extends TestCase +/** + * @covers \Ibexa\Bundle\Core\Imagine\Filter\Loader\ScaleHeightFilterLoader + */ +final class ScaleHeightFilterLoaderTest extends TestCase { - /** @var \PHPUnit\Framework\MockObject\MockObject */ - private $innerLoader; + private LoaderInterface & MockObject $innerLoader; - /** @var \Ibexa\Bundle\Core\Imagine\Filter\Loader\ScaleHeightFilterLoader */ - private $loader; + private ScaleHeightFilterLoader $loader; protected function setUp(): void { @@ -29,14 +31,14 @@ protected function setUp(): void $this->loader->setInnerLoader($this->innerLoader); } - public function testLoadFail() + public function testLoadFail(): void { $this->expectException(InvalidArgumentException::class); - $this->loader->load($this->createMock(ImageInterface::class, [])); + $this->loader->load($this->createMock(ImageInterface::class)); } - public function testLoad() + public function testLoad(): void { $height = 123; $image = $this->createMock(ImageInterface::class); @@ -44,7 +46,7 @@ public function testLoad() ->expects(self::once()) ->method('load') ->with($image, self::equalTo(['heighten' => $height])) - ->will(self::returnValue($image)); + ->willReturn($image); self::assertSame($image, $this->loader->load($image, [$height])); } diff --git a/tests/bundle/Core/Imagine/Filter/Loader/ScalePercentFilterLoaderTest.php b/tests/bundle/Core/Imagine/Filter/Loader/ScalePercentFilterLoaderTest.php index 762ec807e8..c5ec9b177d 100644 --- a/tests/bundle/Core/Imagine/Filter/Loader/ScalePercentFilterLoaderTest.php +++ b/tests/bundle/Core/Imagine/Filter/Loader/ScalePercentFilterLoaderTest.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine\Filter\Loader; @@ -12,15 +13,17 @@ use Imagine\Image\Box; use Imagine\Image\ImageInterface; use Liip\ImagineBundle\Imagine\Filter\Loader\LoaderInterface; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class ScalePercentFilterLoaderTest extends TestCase +/** + * @covers \Ibexa\Bundle\Core\Imagine\Filter\Loader\ScalePercentFilterLoader + */ +final class ScalePercentFilterLoaderTest extends TestCase { - /** @var \PHPUnit\Framework\MockObject\MockObject */ - private $innerLoader; + private LoaderInterface & MockObject $innerLoader; - /** @var \Ibexa\Bundle\Core\Imagine\Filter\Loader\ScalePercentFilterLoader */ - private $loader; + private ScalePercentFilterLoader $loader; protected function setUp(): void { @@ -32,15 +35,20 @@ protected function setUp(): void /** * @dataProvider loadInvalidProvider + * + * @param array $options */ - public function testLoadInvalidOptions(array $options) + public function testLoadInvalidOptions(array $options): void { $this->expectException(InvalidArgumentException::class); $this->loader->load($this->createMock(ImageInterface::class), $options); } - public function loadInvalidProvider() + /** + * @return array}> + */ + public static function loadInvalidProvider(): array { return [ [[]], @@ -49,7 +57,7 @@ public function loadInvalidProvider() ]; } - public function testLoad() + public function testLoad(): void { $widthPercent = 40; $heightPercent = 125; @@ -63,13 +71,13 @@ public function testLoad() $image ->expects(self::once()) ->method('getSize') - ->will(self::returnValue($box)); + ->willReturn($box); $this->innerLoader ->expects(self::once()) ->method('load') ->with($image, self::equalTo(['size' => [$expectedWidth, $expectedHeight]])) - ->will(self::returnValue($image)); + ->willReturn($image); self::assertSame($image, $this->loader->load($image, [$widthPercent, $heightPercent])); } diff --git a/tests/bundle/Core/Imagine/Filter/Loader/ScaleWidthDownOnlyFilterLoaderTest.php b/tests/bundle/Core/Imagine/Filter/Loader/ScaleWidthDownOnlyFilterLoaderTest.php index 4ad49d493d..dbe207eaa8 100644 --- a/tests/bundle/Core/Imagine/Filter/Loader/ScaleWidthDownOnlyFilterLoaderTest.php +++ b/tests/bundle/Core/Imagine/Filter/Loader/ScaleWidthDownOnlyFilterLoaderTest.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine\Filter\Loader; @@ -11,15 +12,17 @@ use Imagine\Exception\InvalidArgumentException; use Imagine\Image\ImageInterface; use Liip\ImagineBundle\Imagine\Filter\Loader\LoaderInterface; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class ScaleWidthDownOnlyFilterLoaderTest extends TestCase +/** + * @covers \Ibexa\Bundle\Core\Imagine\Filter\Loader\ScaleWidthDownOnlyFilterLoader + */ +final class ScaleWidthDownOnlyFilterLoaderTest extends TestCase { - /** @var \PHPUnit\Framework\MockObject\MockObject */ - private $innerLoader; + private LoaderInterface & MockObject $innerLoader; - /** @var \Ibexa\Bundle\Core\Imagine\Filter\Loader\ScaleWidthDownOnlyFilterLoader */ - private $loader; + private ScaleWidthDownOnlyFilterLoader $loader; protected function setUp(): void { @@ -29,14 +32,14 @@ protected function setUp(): void $this->loader->setInnerLoader($this->innerLoader); } - public function testLoadInvalid() + public function testLoadInvalid(): void { $this->expectException(InvalidArgumentException::class); $this->loader->load($this->createMock(ImageInterface::class), []); } - public function testLoad() + public function testLoad(): void { $width = 123; $image = $this->createMock(ImageInterface::class); @@ -44,7 +47,7 @@ public function testLoad() ->expects(self::once()) ->method('load') ->with($image, self::equalTo(['size' => [$width, null], 'mode' => 'inset'])) - ->will(self::returnValue($image)); + ->willReturn($image); self::assertSame($image, $this->loader->load($image, [$width])); } diff --git a/tests/bundle/Core/Imagine/Filter/Loader/ScaleWidthFilterLoaderTest.php b/tests/bundle/Core/Imagine/Filter/Loader/ScaleWidthFilterLoaderTest.php index 78fb82b9e0..6132642764 100644 --- a/tests/bundle/Core/Imagine/Filter/Loader/ScaleWidthFilterLoaderTest.php +++ b/tests/bundle/Core/Imagine/Filter/Loader/ScaleWidthFilterLoaderTest.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine\Filter\Loader; @@ -11,15 +12,17 @@ use Imagine\Exception\InvalidArgumentException; use Imagine\Image\ImageInterface; use Liip\ImagineBundle\Imagine\Filter\Loader\LoaderInterface; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class ScaleWidthFilterLoaderTest extends TestCase +/** + * @covers \Ibexa\Bundle\Core\Imagine\Filter\Loader\ScaleWidthFilterLoader + */ +final class ScaleWidthFilterLoaderTest extends TestCase { - /** @var \PHPUnit\Framework\MockObject\MockObject */ - private $innerLoader; + private LoaderInterface & MockObject $innerLoader; - /** @var \Ibexa\Bundle\Core\Imagine\Filter\Loader\ScaleWidthFilterLoader */ - private $loader; + private ScaleWidthFilterLoader $loader; protected function setUp(): void { @@ -29,14 +32,14 @@ protected function setUp(): void $this->loader->setInnerLoader($this->innerLoader); } - public function testLoadFail() + public function testLoadFail(): void { $this->expectException(InvalidArgumentException::class); - $this->loader->load($this->createMock(ImageInterface::class, [])); + $this->loader->load($this->createMock(ImageInterface::class)); } - public function testLoad() + public function testLoad(): void { $width = 123; $image = $this->createMock(ImageInterface::class); @@ -44,7 +47,7 @@ public function testLoad() ->expects(self::once()) ->method('load') ->with($image, self::equalTo(['widen' => $width])) - ->will(self::returnValue($image)); + ->willReturn($image); self::assertSame($image, $this->loader->load($image, [$width])); } diff --git a/tests/bundle/Core/Imagine/Filter/Loader/SwirlFilterLoaderTest.php b/tests/bundle/Core/Imagine/Filter/Loader/SwirlFilterLoaderTest.php index 4af693b48b..1881baad01 100644 --- a/tests/bundle/Core/Imagine/Filter/Loader/SwirlFilterLoaderTest.php +++ b/tests/bundle/Core/Imagine/Filter/Loader/SwirlFilterLoaderTest.php @@ -4,21 +4,24 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine\Filter\Loader; use Ibexa\Bundle\Core\Imagine\Filter\FilterInterface; use Ibexa\Bundle\Core\Imagine\Filter\Loader\SwirlFilterLoader; use Imagine\Image\ImageInterface; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class SwirlFilterLoaderTest extends TestCase +/** + * @covers \Ibexa\Bundle\Core\Imagine\Filter\Loader\SwirlFilterLoader + */ +final class SwirlFilterLoaderTest extends TestCase { - /** @var \PHPUnit\Framework\MockObject\MockObject */ - private $filter; + private FilterInterface & MockObject $filter; - /** @var \Ibexa\Bundle\Core\Imagine\Filter\Loader\SwirlFilterLoader */ - private $loader; + private SwirlFilterLoader $loader; protected function setUp(): void { @@ -27,7 +30,7 @@ protected function setUp(): void $this->loader = new SwirlFilterLoader($this->filter); } - public function testLoadNoOption() + public function testLoadNoOption(): void { $image = $this->createMock(ImageInterface::class); $this->filter @@ -38,7 +41,7 @@ public function testLoadNoOption() ->expects(self::once()) ->method('apply') ->with($image) - ->will(self::returnValue($image)); + ->willReturn($image); self::assertSame($image, $this->loader->load($image)); } @@ -46,7 +49,7 @@ public function testLoadNoOption() /** * @dataProvider loadWithOptionProvider */ - public function testLoadWithOption($degrees) + public function testLoadWithOption(float $degrees): void { $image = $this->createMock(ImageInterface::class); $this->filter @@ -58,12 +61,15 @@ public function testLoadWithOption($degrees) ->expects(self::once()) ->method('apply') ->with($image) - ->will(self::returnValue($image)); + ->willReturn($image); self::assertSame($image, $this->loader->load($image, [$degrees])); } - public function loadWithOptionProvider() + /** + * @return array + */ + public static function loadWithOptionProvider(): array { return [ [10], diff --git a/tests/bundle/Core/Imagine/Filter/UnsupportedFilterTest.php b/tests/bundle/Core/Imagine/Filter/UnsupportedFilterTest.php index 6076a2a83b..e4955a067b 100644 --- a/tests/bundle/Core/Imagine/Filter/UnsupportedFilterTest.php +++ b/tests/bundle/Core/Imagine/Filter/UnsupportedFilterTest.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine\Filter; @@ -11,13 +12,16 @@ use Imagine\Exception\NotSupportedException; use Imagine\Image\ImageInterface; -class UnsupportedFilterTest extends AbstractFilterTest +/** + * @covers \Ibexa\Bundle\Core\Imagine\Filter\UnsupportedFilter + */ +final class UnsupportedFilterTest extends AbstractFilterTest { - public function testLoad() + public function testLoad(): void { - $this->expectException(NotSupportedException::class); - $filter = new UnsupportedFilter(); + + $this->expectException(NotSupportedException::class); $filter->apply($this->createMock(ImageInterface::class)); } } From 2157c06e42b5075f7ba323c10422bfc366717a81 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 16 Jul 2025 17:52:50 +0200 Subject: [PATCH 11/18] [Tests] Added missing type hints to Imagine AliasCleanerTest --- tests/bundle/Core/Imagine/AliasCleanerTest.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/bundle/Core/Imagine/AliasCleanerTest.php b/tests/bundle/Core/Imagine/AliasCleanerTest.php index 596e2381f2..9f0770546d 100644 --- a/tests/bundle/Core/Imagine/AliasCleanerTest.php +++ b/tests/bundle/Core/Imagine/AliasCleanerTest.php @@ -4,20 +4,20 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine; use Ibexa\Bundle\Core\Imagine\AliasCleaner; use Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class AliasCleanerTest extends TestCase { - /** @var \Ibexa\Bundle\Core\Imagine\AliasCleaner */ - private $aliasCleaner; + private AliasCleaner $aliasCleaner; - /** @var \PHPUnit\Framework\MockObject\MockObject */ - private $resolver; + private ResolverInterface & MockObject $resolver; protected function setUp(): void { @@ -26,7 +26,10 @@ protected function setUp(): void $this->aliasCleaner = new AliasCleaner($this->resolver); } - public function testRemoveAliases() + /** + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\Exception + */ + public function testRemoveAliases(): void { $originalPath = 'foo/bar/test.jpg'; $this->resolver From d56c9a27ce7967a18d8dab4150de0c4bf51c9b89 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 16 Jul 2025 17:53:16 +0200 Subject: [PATCH 12/18] [Tests] Added missing type hints to PlaceholderAlias tests --- .../PlaceholderAliasGeneratorConfiguratorTest.php | 14 +++++++++----- .../Imagine/PlaceholderProviderRegistryTest.php | 13 +++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/tests/bundle/Core/Imagine/PlaceholderAliasGeneratorConfiguratorTest.php b/tests/bundle/Core/Imagine/PlaceholderAliasGeneratorConfiguratorTest.php index d1e84f2a66..8d75f26a3d 100644 --- a/tests/bundle/Core/Imagine/PlaceholderAliasGeneratorConfiguratorTest.php +++ b/tests/bundle/Core/Imagine/PlaceholderAliasGeneratorConfiguratorTest.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine; @@ -14,17 +15,20 @@ use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface; use PHPUnit\Framework\TestCase; -class PlaceholderAliasGeneratorConfiguratorTest extends TestCase +/** + * @covers \Ibexa\Bundle\Core\Imagine\PlaceholderAliasGeneratorConfigurator + */ +final class PlaceholderAliasGeneratorConfiguratorTest extends TestCase { - public const BINARY_HANDLER_NAME = 'default'; - public const PROVIDER_TYPE = 'generic'; - public const PROVIDER_OPTIONS = [ + public const string BINARY_HANDLER_NAME = 'default'; + public const string PROVIDER_TYPE = 'generic'; + public const array PROVIDER_OPTIONS = [ 'a' => 'A', 'b' => 'B', 'c' => 'C', ]; - public function testConfigure() + public function testConfigure(): void { $configResolver = $this->createMock(ConfigResolverInterface::class); $configResolver diff --git a/tests/bundle/Core/Imagine/PlaceholderProviderRegistryTest.php b/tests/bundle/Core/Imagine/PlaceholderProviderRegistryTest.php index c5b421f6a3..54474d238e 100644 --- a/tests/bundle/Core/Imagine/PlaceholderProviderRegistryTest.php +++ b/tests/bundle/Core/Imagine/PlaceholderProviderRegistryTest.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine; @@ -16,13 +17,13 @@ */ class PlaceholderProviderRegistryTest extends TestCase { - private const FOO = 'foo'; - private const BAR = 'bar'; + private const string FOO = 'foo'; + private const string BAR = 'bar'; /** * @depends testGetProviderKnown */ - public function testConstructor() + public function testConstructor(): void { $providers = [ self::FOO => $this->getPlaceholderProviderMock(), @@ -48,7 +49,7 @@ public function testAddProvider(): void self::assertSame($provider, $registry->getProvider(self::FOO)); } - public function testSupports() + public function testSupports(): void { $registry = new PlaceholderProviderRegistry([ 'supported' => $this->getPlaceholderProviderMock(), @@ -58,7 +59,7 @@ public function testSupports() self::assertFalse($registry->supports('unsupported')); } - public function testGetProviderKnown() + public function testGetProviderKnown(): void { $provider = $this->getPlaceholderProviderMock(); @@ -69,7 +70,7 @@ public function testGetProviderKnown() self::assertEquals($provider, $registry->getProvider(self::FOO)); } - public function testGetProviderUnknown() + public function testGetProviderUnknown(): void { $this->expectException(\InvalidArgumentException::class); From a7d14be8eacb003c40ff8c15a88afd4bd2ebdddf Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 16 Jul 2025 18:41:52 +0200 Subject: [PATCH 13/18] [Tests] Added missing type hints & refactored Placeholder provider tests --- .../Imagine/PlaceholderAliasGeneratorTest.php | 215 +++++++++++------- .../GenericProviderTest.php | 28 ++- 2 files changed, 152 insertions(+), 91 deletions(-) diff --git a/tests/bundle/Core/Imagine/PlaceholderAliasGeneratorTest.php b/tests/bundle/Core/Imagine/PlaceholderAliasGeneratorTest.php index 92a097e089..564ad7b2c2 100644 --- a/tests/bundle/Core/Imagine/PlaceholderAliasGeneratorTest.php +++ b/tests/bundle/Core/Imagine/PlaceholderAliasGeneratorTest.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine; @@ -23,28 +24,28 @@ use Ibexa\Core\IO\Values\BinaryFile; use Ibexa\Core\IO\Values\BinaryFileCreateStruct; use Ibexa\Core\Repository\Values\Content\VersionInfo; +use InvalidArgumentException; use Liip\ImagineBundle\Exception\Imagine\Cache\Resolver\NotResolvableException; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class PlaceholderAliasGeneratorTest extends TestCase +/** + * @covers \Ibexa\Bundle\Core\Imagine\PlaceholderAliasGenerator + */ +final class PlaceholderAliasGeneratorTest extends TestCase { - /** @var \Ibexa\Bundle\Core\Imagine\PlaceholderAliasGenerator */ - private $aliasGenerator; + private PlaceholderAliasGenerator $aliasGenerator; - /** @var \Ibexa\Contracts\Core\Variation\VariationHandler|\PHPUnit\Framework\MockObject\MockObject */ - private $innerAliasGenerator; + private VariationHandler & MockObject $innerAliasGenerator; - /** @var \Ibexa\Core\IO\IOServiceInterface|\PHPUnit\Framework\MockObject\MockObject */ - private $ioService; + private IOServiceInterface & MockObject $ioService; - /** @var \Ibexa\Bundle\Core\Imagine\IORepositoryResolver|\PHPUnit\Framework\MockObject\MockObject */ - private $ioResolver; + private IORepositoryResolver & MockObject $ioResolver; - /** @var \Ibexa\Bundle\Core\Imagine\PlaceholderProvider|\PHPUnit\Framework\MockObject\MockObject */ - private $placeholderProvider; + private PlaceholderProvider & MockObject $placeholderProvider; - /** @var array */ - private $placeholderOptions; + /** @var array */ + private array $placeholderOptions; protected function setUp(): void { @@ -64,14 +65,19 @@ protected function setUp(): void ); } - public function testGetVariationWrongValue() + /** + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\Exception + */ + public function testGetVariationWrongValue(): void { - $this->expectException(\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); - $field = new Field([ - 'value' => $this->createMock(FieldTypeValue::class), - 'fieldDefIdentifier' => 'image', - ]); + $field = new Field( + [ + 'value' => $this->createMock(FieldTypeValue::class), + 'fieldDefIdentifier' => 'image', + ] + ); $this->aliasGenerator->setPlaceholderProvider( $this->placeholderProvider, @@ -82,9 +88,17 @@ public function testGetVariationWrongValue() /** * @dataProvider getVariationProvider + * + * @param array $parameters + * + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\Exception */ - public function testGetVariationSkipsPlaceholderGeneration(Field $field, APIVersionInfo $versionInfo, string $variationName, array $parameters) - { + public function testGetVariationSkipsPlaceholderGeneration( + Field $field, + APIVersionInfo $versionInfo, + string $variationName, + array $parameters + ): void { $expectedVariation = $this->createMock(ImageVariation::class); $this->ioResolver @@ -115,9 +129,17 @@ public function testGetVariationSkipsPlaceholderGeneration(Field $field, APIVers /** * @dataProvider getVariationProvider + * + * @param array $parameters + * + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\Exception */ - public function testGetVariationOriginalFound(Field $field, APIVersionInfo $versionInfo, string $variationName, array $parameters) - { + public function testGetVariationOriginalFound( + Field $field, + APIVersionInfo $versionInfo, + string $variationName, + array $parameters + ): void { $expectedVariation = $this->createMock(ImageVariation::class); $this->ioResolver @@ -148,9 +170,17 @@ public function testGetVariationOriginalFound(Field $field, APIVersionInfo $vers /** * @dataProvider getVariationProvider + * + * @param array $parameters + * + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\Exception */ - public function testGetVariationOriginalNotFound(Field $field, APIVersionInfo $versionInfo, string $variationName, array $parameters) - { + public function testGetVariationOriginalNotFound( + Field $field, + APIVersionInfo $versionInfo, + string $variationName, + array $parameters + ): void { $placeholderPath = '/tmp/placeholder.jpg'; $binaryCreateStruct = new BinaryFileCreateStruct(); $expectedVariation = $this->createMock(ImageVariation::class); @@ -161,34 +191,16 @@ public function testGetVariationOriginalNotFound(Field $field, APIVersionInfo $v ->with($field->value->id, IORepositoryResolver::VARIATION_ORIGINAL) ->willThrowException($this->createMock(NotResolvableException::class)); - $this->placeholderProvider - ->expects(self::once()) - ->method('getPlaceholder') - ->with($field->value, $this->placeholderOptions) - ->willReturn($placeholderPath); - - $this->ioService - ->expects(self::once()) - ->method('newBinaryCreateStructFromLocalFile') - ->with($placeholderPath) - ->willReturn($binaryCreateStruct); - - $this->ioService - ->expects(self::once()) - ->method('createBinaryFile') - ->with($binaryCreateStruct); - - $this->aliasGenerator->setPlaceholderProvider( - $this->placeholderProvider, - $this->placeholderOptions + $this->configurePlaceholderProvider( + $field, + $placeholderPath, + $binaryCreateStruct, + $versionInfo, + $variationName, + $parameters, + $expectedVariation ); - $this->innerAliasGenerator - ->expects(self::once()) - ->method('getVariation') - ->with($field, $versionInfo, $variationName, $parameters) - ->willReturn($expectedVariation); - $actualVariation = $this->aliasGenerator->getVariation( $field, $versionInfo, @@ -202,6 +214,10 @@ public function testGetVariationOriginalNotFound(Field $field, APIVersionInfo $v /** * @dataProvider getVariationProvider + * + * @param array $parameters + * + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\Exception */ public function testGetVariationReturnsPlaceholderIfBinaryDataIsNotAvailable( Field $field, @@ -232,34 +248,16 @@ public function testGetVariationReturnsPlaceholderIfBinaryDataIsNotAvailable( ->with($binaryFile) ->willThrowException($this->createMock(NotFoundException::class)); - $this->placeholderProvider - ->expects(self::once()) - ->method('getPlaceholder') - ->with($field->value, $this->placeholderOptions) - ->willReturn($placeholderPath); - - $this->ioService - ->expects(self::once()) - ->method('newBinaryCreateStructFromLocalFile') - ->with($placeholderPath) - ->willReturn($binaryCreateStruct); - - $this->ioService - ->expects(self::once()) - ->method('createBinaryFile') - ->with($binaryCreateStruct); - - $this->aliasGenerator->setPlaceholderProvider( - $this->placeholderProvider, - $this->placeholderOptions + $this->configurePlaceholderProvider( + $field, + $placeholderPath, + $binaryCreateStruct, + $versionInfo, + $variationName, + $parameters, + $expectedVariation ); - $this->innerAliasGenerator - ->expects(self::once()) - ->method('getVariation') - ->with($field, $versionInfo, $variationName, $parameters) - ->willReturn($expectedVariation); - $actualVariation = $this->aliasGenerator->getVariation( $field, $versionInfo, @@ -274,12 +272,15 @@ public function testGetVariationReturnsPlaceholderIfBinaryDataIsNotAvailable( /** * @dataProvider supportsValueProvider */ - public function testSupportsValue(Value $value, bool $isSupported) + public function testSupportsValue(Value $value, bool $isSupported): void { self::assertSame($isSupported, $this->aliasGenerator->supportsValue($value)); } - public function supportsValueProvider(): array + /** + * @return array + */ + public static function supportsValueProvider(): array { return [ [new NullValue(), false], @@ -287,16 +288,62 @@ public function supportsValueProvider(): array ]; } - public function getVariationProvider(): array + /** + * @return array}> + * + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException + */ + public static function getVariationProvider(): array { $field = new Field([ - 'value' => new ImageValue([ - 'id' => 'images/6/8/4/0/486-10-eng-GB/photo.jpg', - ]), - ]); + 'value' => new ImageValue([ + 'id' => 'images/6/8/4/0/486-10-eng-GB/photo.jpg', + ]), + ]); return [ [$field, new VersionInfo(), 'thumbnail', []], ]; } + + /** + * @param array $parameters + */ + private function configurePlaceholderProvider( + Field $field, + string $placeholderPath, + BinaryFileCreateStruct $binaryCreateStruct, + APIVersionInfo $versionInfo, + string $variationName, + array $parameters, + ImageVariation & MockObject $expectedVariation + ): void { + $this->placeholderProvider + ->expects(self::once()) + ->method('getPlaceholder') + ->with($field->value, $this->placeholderOptions) + ->willReturn($placeholderPath); + + $this->ioService + ->expects(self::once()) + ->method('newBinaryCreateStructFromLocalFile') + ->with($placeholderPath) + ->willReturn($binaryCreateStruct); + + $this->ioService + ->expects(self::once()) + ->method('createBinaryFile') + ->with($binaryCreateStruct); + + $this->aliasGenerator->setPlaceholderProvider( + $this->placeholderProvider, + $this->placeholderOptions + ); + + $this->innerAliasGenerator + ->expects(self::once()) + ->method('getVariation') + ->with($field, $versionInfo, $variationName, $parameters) + ->willReturn($expectedVariation); + } } diff --git a/tests/bundle/Core/Imagine/PlaceholderProvider/GenericProviderTest.php b/tests/bundle/Core/Imagine/PlaceholderProvider/GenericProviderTest.php index def720c8ad..350343f6e1 100644 --- a/tests/bundle/Core/Imagine/PlaceholderProvider/GenericProviderTest.php +++ b/tests/bundle/Core/Imagine/PlaceholderProvider/GenericProviderTest.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine\PlaceholderProvider; @@ -17,12 +18,17 @@ use Imagine\Image\Palette\Color\ColorInterface; use PHPUnit\Framework\TestCase; -class GenericProviderTest extends TestCase +/** + * @covers \Ibexa\Bundle\Core\Imagine\PlaceholderProvider\GenericProvider + */ +final class GenericProviderTest extends TestCase { /** * @dataProvider getPlaceholderDataProvider + * + * @param array $options */ - public function testGetPlaceholder(ImageValue $value, $expectedText, array $options = []) + public function testGetPlaceholder(ImageValue $value, string $expectedText, array $options = []): void { $font = $this->createMock(AbstractFont::class); @@ -39,7 +45,7 @@ public function testGetPlaceholder(ImageValue $value, $expectedText, array $opti }); $font - ->expects(self::any()) + ->expects(self::atLeastOnce()) ->method('box') ->willReturn($this->createMock(BoxInterface::class)); @@ -57,7 +63,7 @@ public function testGetPlaceholder(ImageValue $value, $expectedText, array $opti $drawer = $this->createMock(DrawerInterface::class); $image - ->expects(self::any()) + ->expects(self::atLeastOnce()) ->method('draw') ->willReturn($drawer); @@ -70,7 +76,12 @@ public function testGetPlaceholder(ImageValue $value, $expectedText, array $opti $provider->getPlaceholder($value, $options); } - public function getPlaceholderDataProvider() + /** + * @return array}> + * + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException + */ + public static function getPlaceholderDataProvider(): array { return [ [ @@ -91,13 +102,16 @@ public function getPlaceholderDataProvider() ]; } - private function assertSizeEquals(array $expected, BoxInterface $actual) + /** + * @param array{int|null, int|null} $expected width, height + */ + private function assertSizeEquals(array $expected, BoxInterface $actual): void { self::assertEquals($expected[0], $actual->getWidth()); self::assertEquals($expected[1], $actual->getHeight()); } - private function assertColorEquals($expected, ColorInterface $actual) + private function assertColorEquals(string $expected, ColorInterface $actual): void { self::assertEquals(strtolower($expected), strtolower((string)$actual)); } From 0b5d9bce40dafc25bf3a847348936ca55794aef1 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 16 Jul 2025 18:42:06 +0200 Subject: [PATCH 14/18] [Tests] Added missing type hints to ImageAsset AliasGeneratorTest --- .../Imagine/ImageAsset/AliasGeneratorTest.php | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/tests/bundle/Core/Imagine/ImageAsset/AliasGeneratorTest.php b/tests/bundle/Core/Imagine/ImageAsset/AliasGeneratorTest.php index dac3ff147d..386f674a87 100644 --- a/tests/bundle/Core/Imagine/ImageAsset/AliasGeneratorTest.php +++ b/tests/bundle/Core/Imagine/ImageAsset/AliasGeneratorTest.php @@ -15,29 +15,30 @@ use Ibexa\Contracts\Core\Variation\VariationHandler; use Ibexa\Core\FieldType\Image; use Ibexa\Core\FieldType\ImageAsset; +use Ibexa\Core\FieldType\ImageAsset\AssetMapper; use Ibexa\Core\Repository\Values\Content\Content; use Ibexa\Core\Repository\Values\Content\VersionInfo; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class AliasGeneratorTest extends TestCase +/** + * @covers \Ibexa\Bundle\Core\Imagine\ImageAsset\AliasGenerator + */ +final class AliasGeneratorTest extends TestCase { - /** @var \Ibexa\Bundle\Core\Imagine\ImageAsset\AliasGenerator */ - private $aliasGenerator; + private AliasGenerator $aliasGenerator; - /** @var \Ibexa\Contracts\Core\Variation\VariationHandler|\PHPUnit\Framework\MockObject\MockObject */ - private $innerAliasGenerator; + private VariationHandler & MockObject $innerAliasGenerator; - /** @var \Ibexa\Contracts\Core\Repository\ContentService|\PHPUnit\Framework\MockObject\MockObject */ - private $contentService; + private ContentService & MockObject $contentService; - /** @var \Ibexa\Core\FieldType\ImageAsset\AssetMapper|\PHPUnit\Framework\MockObject\MockObject */ - private $assetMapper; + private AssetMapper & MockObject $assetMapper; protected function setUp(): void { $this->innerAliasGenerator = $this->createMock(VariationHandler::class); $this->contentService = $this->createMock(ContentService::class); - $this->assetMapper = $this->createMock(ImageAsset\AssetMapper::class); + $this->assetMapper = $this->createMock(AssetMapper::class); $this->aliasGenerator = new AliasGenerator( $this->innerAliasGenerator, @@ -46,7 +47,10 @@ protected function setUp(): void ); } - public function testGetVariationOfImageAsset() + /** + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\Exception + */ + public function testGetVariationOfImageAsset(): void { $assetField = new Field([ 'value' => new ImageAsset\Value(486), @@ -96,7 +100,7 @@ public function testGetVariationOfImageAsset() self::assertEquals($expectedVariation, $actualVariation); } - public function testGetVariationOfNonImageAsset() + public function testGetVariationOfNonImageAsset(): void { $imageField = new Field([ 'value' => new Image\Value([ @@ -134,7 +138,7 @@ public function testGetVariationOfNonImageAsset() self::assertEquals($expectedVariation, $actualVariation); } - public function testSupport() + public function testSupport(): void { self::assertTrue($this->aliasGenerator->supportsValue(new ImageAsset\Value())); self::assertFalse($this->aliasGenerator->supportsValue(new Image\Value())); From 01b4c1debff09b0e3b7bef6b54c1d434cb1067a2 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 16 Jul 2025 20:28:20 +0200 Subject: [PATCH 15/18] [Tests] Added missing type hints to VariationPathGenerator tests --- .../AliasDirectoryVariationPathGeneratorTest.php | 8 ++++++-- .../OriginalDirectoryVariationPathGeneratorTest.php | 8 ++++++-- .../WebpFormatVariationPathGeneratorTest.php | 3 +-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/bundle/Core/Imagine/VariationPathGenerator/AliasDirectoryVariationPathGeneratorTest.php b/tests/bundle/Core/Imagine/VariationPathGenerator/AliasDirectoryVariationPathGeneratorTest.php index fa6ecbec97..265459a431 100644 --- a/tests/bundle/Core/Imagine/VariationPathGenerator/AliasDirectoryVariationPathGeneratorTest.php +++ b/tests/bundle/Core/Imagine/VariationPathGenerator/AliasDirectoryVariationPathGeneratorTest.php @@ -4,15 +4,19 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine\VariationPathGenerator; use Ibexa\Bundle\Core\Imagine\VariationPathGenerator\AliasDirectoryVariationPathGenerator; use PHPUnit\Framework\TestCase; -class AliasDirectoryVariationPathGeneratorTest extends TestCase +/** + * @covers \Ibexa\Bundle\Core\Imagine\VariationPathGenerator\AliasDirectoryVariationPathGenerator + */ +final class AliasDirectoryVariationPathGeneratorTest extends TestCase { - public function testGetVariationPath() + public function testGetVariationPath(): void { $generator = new AliasDirectoryVariationPathGenerator(); diff --git a/tests/bundle/Core/Imagine/VariationPathGenerator/OriginalDirectoryVariationPathGeneratorTest.php b/tests/bundle/Core/Imagine/VariationPathGenerator/OriginalDirectoryVariationPathGeneratorTest.php index 88edae38c2..0386ec4a59 100644 --- a/tests/bundle/Core/Imagine/VariationPathGenerator/OriginalDirectoryVariationPathGeneratorTest.php +++ b/tests/bundle/Core/Imagine/VariationPathGenerator/OriginalDirectoryVariationPathGeneratorTest.php @@ -4,15 +4,19 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine\VariationPathGenerator; use Ibexa\Bundle\Core\Imagine\VariationPathGenerator\OriginalDirectoryVariationPathGenerator; use PHPUnit\Framework\TestCase; -class OriginalDirectoryVariationPathGeneratorTest extends TestCase +/** + * @covers \Ibexa\Bundle\Core\Imagine\VariationPathGenerator\OriginalDirectoryVariationPathGenerator + */ +final class OriginalDirectoryVariationPathGeneratorTest extends TestCase { - public function testGetVariationPath() + public function testGetVariationPath(): void { $generator = new OriginalDirectoryVariationPathGenerator(); self::assertEquals( diff --git a/tests/bundle/Core/Imagine/VariationPathGenerator/WebpFormatVariationPathGeneratorTest.php b/tests/bundle/Core/Imagine/VariationPathGenerator/WebpFormatVariationPathGeneratorTest.php index d12c11c382..a8df87f645 100644 --- a/tests/bundle/Core/Imagine/VariationPathGenerator/WebpFormatVariationPathGeneratorTest.php +++ b/tests/bundle/Core/Imagine/VariationPathGenerator/WebpFormatVariationPathGeneratorTest.php @@ -18,8 +18,7 @@ final class WebpFormatVariationPathGeneratorTest extends TestCase { private VariationPathGenerator&MockObject $innerVariationPathGenerator; - /** @var \Ibexa\Bundle\Core\Imagine\Filter\FilterConfiguration|\PHPUnit\Framework\MockObject\MockObject */ - private FilterConfiguration $filterConfiguration; + private FilterConfiguration & MockObject $filterConfiguration; protected function setUp(): void { From c2dbad93d751b457319ec82d538de926d7e8ca42 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 16 Jul 2025 20:28:42 +0200 Subject: [PATCH 16/18] [Tests] Added missing type hints and refactored AliasGeneratorTest --- .../Core/Imagine/AliasGeneratorTest.php | 274 ++++++++---------- 1 file changed, 128 insertions(+), 146 deletions(-) diff --git a/tests/bundle/Core/Imagine/AliasGeneratorTest.php b/tests/bundle/Core/Imagine/AliasGeneratorTest.php index a50dfafd07..4af07afe46 100644 --- a/tests/bundle/Core/Imagine/AliasGeneratorTest.php +++ b/tests/bundle/Core/Imagine/AliasGeneratorTest.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine; @@ -11,9 +12,11 @@ use Ibexa\Bundle\Core\Imagine\AliasGenerator; use Ibexa\Bundle\Core\Imagine\Variation\ImagineAwareAliasGenerator; use Ibexa\Contracts\Core\FieldType\Value as FieldTypeValue; +use Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException; use Ibexa\Contracts\Core\Repository\Exceptions\InvalidVariationException; use Ibexa\Contracts\Core\Repository\Values\Content\Field; use Ibexa\Contracts\Core\Variation\Values\ImageVariation; +use Ibexa\Contracts\Core\Variation\VariationHandler; use Ibexa\Contracts\Core\Variation\VariationPathGenerator; use Ibexa\Core\FieldType\Image\Value as ImageValue; use Ibexa\Core\FieldType\TextLine\Value as TextLineValue; @@ -31,46 +34,38 @@ use Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface; use Liip\ImagineBundle\Imagine\Filter\FilterConfiguration; use Liip\ImagineBundle\Imagine\Filter\FilterManager; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; -class AliasGeneratorTest extends TestCase +/** + * @covers \Ibexa\Bundle\Core\Imagine\AliasGenerator + */ +final class AliasGeneratorTest extends TestCase { - /** @var \PHPUnit\Framework\MockObject\MockObject|\Liip\ImagineBundle\Binary\Loader\LoaderInterface */ - private $dataLoader; + private LoaderInterface & MockObject $dataLoader; - /** @var \PHPUnit\Framework\MockObject\MockObject|\Liip\ImagineBundle\Imagine\Filter\FilterManager */ - private $filterManager; + private FilterManager & MockObject $filterManager; - /** @var \PHPUnit\Framework\MockObject\MockObject|\Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface */ - private $ioResolver; + private ResolverInterface & MockObject $ioResolver; - /** @var \Liip\ImagineBundle\Imagine\Filter\FilterConfiguration */ - private $filterConfiguration; + private FilterConfiguration $filterConfiguration; - /** @var \PHPUnit\Framework\MockObject\MockObject|\Psr\Log\LoggerInterface */ - private $logger; + private LoggerInterface & MockObject $logger; - /** @var \PHPUnit\Framework\MockObject\MockObject|\Imagine\Image\ImagineInterface */ - private $imagine; + private ImagineInterface & MockObject $imagine; - /** @var \Ibexa\Bundle\Core\Imagine\AliasGenerator */ - private $aliasGenerator; + private AliasGenerator $aliasGenerator; - /** @var \Ibexa\Contracts\Core\Variation\VariationHandler */ - private $decoratedAliasGenerator; + private VariationHandler $decoratedAliasGenerator; - /** @var \PHPUnit\Framework\MockObject\MockObject|\Imagine\Image\BoxInterface */ - private $box; + private BoxInterface & MockObject $box; - /** @var \PHPUnit\Framework\MockObject\MockObject|\Imagine\Image\ImageInterface */ - private $image; + private ImageInterface & MockObject $image; - /** @var \PHPUnit\Framework\MockObject\MockObject|\Ibexa\Core\IO\IOServiceInterface */ - private $ioService; + private IOServiceInterface & MockObject $ioService; - /** @var \PHPUnit\Framework\MockObject\MockObject|\Ibexa\Contracts\Core\Variation\VariationPathGenerator */ - private $variationPathGenerator; + private VariationPathGenerator & MockObject $variationPathGenerator; protected function setUp(): void { @@ -105,11 +100,8 @@ protected function setUp(): void /** * @dataProvider supportsValueProvider - * - * @param \Ibexa\Contracts\Core\FieldType\Value $value - * @param bool $isSupported */ - public function testSupportsValue($value, $isSupported) + public function testSupportsValue(FieldTypeValue $value, bool $isSupported): void { self::assertSame($isSupported, $this->aliasGenerator->supportsValue($value)); } @@ -117,13 +109,11 @@ public function testSupportsValue($value, $isSupported) /** * Data provider for testSupportsValue. * - * @see testSupportsValue - * - * @return array + * @return array * - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException + * @see testSupportsValue */ - public function supportsValueProvider() + public function supportsValueProvider(): array { return [ [$this->createMock(FieldTypeValue::class), false], @@ -133,23 +123,26 @@ public function supportsValueProvider() ]; } - public function testGetVariationWrongValue() + /** + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\Exception + */ + public function testGetVariationWrongValue(): void { - $this->expectException(\InvalidArgumentException::class); - $field = new Field([ - 'value' => $this->createMock(FieldTypeValue::class), - 'fieldDefIdentifier' => 'image_field', - ]); + 'value' => $this->createMock(FieldTypeValue::class), + 'fieldDefIdentifier' => 'image_field', + ]); + + $this->expectException(InvalidArgumentException::class); $this->aliasGenerator->getVariation($field, new VersionInfo(), 'foo'); } /** * Test obtaining Image Variation that hasn't been stored yet. * - * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentType + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\Exception */ - public function testGetVariationNotStored() + public function testGetVariationNotStored(): void { $originalPath = 'foo/bar/image.jpg'; $variationName = 'my_variation'; @@ -159,27 +152,12 @@ public function testGetVariationNotStored() $imageHeight = 300; $expectedUrl = "http://localhost/foo/bar/image_$variationName.jpg"; - $this->ioResolver - ->expects(self::once()) - ->method('isStored') - ->with($originalPath, $variationName) - ->will(self::returnValue(false)); - - $this->logger - ->expects(self::once()) - ->method('debug'); - - $binary = $this->createMock(BinaryInterface::class); - $this->dataLoader - ->expects(self::once()) - ->method('find') - ->with($originalPath) - ->will(self::returnValue($binary)); + $binary = $this->configureMocksForNotStoredVariation($originalPath, $variationName); $this->filterManager ->expects(self::once()) ->method('applyFilter') ->with($binary, $variationName) - ->will(self::returnValue($binary)); + ->willReturn($binary); $this->ioResolver ->expects(self::once()) ->method('store') @@ -195,7 +173,10 @@ public function testGetVariationNotStored() ); } - public function testGetVariationOriginal() + /** + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\Exception + */ + public function testGetVariationOriginal(): void { $originalPath = 'foo/bar/image.jpg'; $variationName = 'original'; @@ -212,16 +193,16 @@ public function testGetVariationOriginal() ] ); $field = new Field([ - 'value' => $imageValue, - 'fieldDefIdentifier' => 'image_field', - ]); + 'value' => $imageValue, + 'fieldDefIdentifier' => 'image_field', + ]); $expectedUrl = 'http://localhost/foo/bar/image.jpg'; $this->ioResolver ->expects(self::never()) ->method('isStored') ->with($originalPath, $variationName) - ->will(self::returnValue(false)); + ->willReturn(false); $this->logger ->expects(self::once()) @@ -231,7 +212,7 @@ public function testGetVariationOriginal() ->expects(self::once()) ->method('resolve') ->with($originalPath, $variationName) - ->will(self::returnValue($expectedUrl)); + ->willReturn($expectedUrl); $expected = new ImageVariation( [ @@ -244,15 +225,18 @@ public function testGetVariationOriginal() 'width' => $imageWidth, ] ); - self::assertEquals($expected, $this->decoratedAliasGenerator->getVariation($field, new VersionInfo(), $variationName)); + self::assertEquals( + $expected, + $this->decoratedAliasGenerator->getVariation($field, new VersionInfo(), $variationName) + ); } /** * Test obtaining Image Variation that hasn't been stored yet and has multiple references. * - * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentType + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\Exception */ - public function testGetVariationNotStoredHavingReferences() + public function testGetVariationNotStoredHavingReferences(): void { $originalPath = 'foo/bar/image.jpg'; $variationName = 'my_variation'; @@ -269,39 +253,19 @@ public function testGetVariationNotStoredHavingReferences() $imageHeight = 300; $expectedUrl = "http://localhost/foo/bar/image_$variationName.jpg"; - $this->ioResolver - ->expects(self::once()) - ->method('isStored') - ->with($originalPath, $variationName) - ->will(self::returnValue(false)); - - $this->logger - ->expects(self::once()) - ->method('debug'); - - $binary = $this->createMock(BinaryInterface::class); - $this->dataLoader - ->expects(self::once()) - ->method('find') - ->with($originalPath) - ->will(self::returnValue($binary)); + $binary = $this->configureMocksForNotStoredVariation($originalPath, $variationName); // Filter manager is supposed to be called 3 times to generate references, and then passed variation. $this->filterManager - ->expects(self::at(0)) - ->method('applyFilter') - ->with($binary, $reference2) - ->will(self::returnValue($binary)); - $this->filterManager - ->expects(self::at(1)) - ->method('applyFilter') - ->with($binary, $reference1) - ->will(self::returnValue($binary)); - $this->filterManager - ->expects(self::at(2)) + ->expects(self::exactly(3)) ->method('applyFilter') - ->with($binary, $variationName) - ->will(self::returnValue($binary)); + ->willReturnMap( + [ + [$binary, $reference2, [], $binary], + [$binary, $reference1, [], $binary], + [$binary, $variationName, [], $binary], + ] + ); $this->ioResolver ->expects(self::once()) @@ -321,9 +285,9 @@ public function testGetVariationNotStoredHavingReferences() /** * Test obtaining Image Variation that has been stored already. * - * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentType + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\Exception */ - public function testGetVariationAlreadyStored() + public function testGetVariationAlreadyStored(): void { $originalPath = 'foo/bar/image.jpg'; $variationName = 'my_variation'; @@ -332,25 +296,7 @@ public function testGetVariationAlreadyStored() $imageHeight = 300; $expectedUrl = "http://localhost/foo/bar/image_$variationName.jpg"; - $this->ioResolver - ->expects(self::once()) - ->method('isStored') - ->with($originalPath, $variationName) - ->will(self::returnValue(true)); - - $this->logger - ->expects(self::once()) - ->method('debug'); - - $this->dataLoader - ->expects(self::never()) - ->method('find'); - $this->filterManager - ->expects(self::never()) - ->method('applyFilter'); - $this->ioResolver - ->expects(self::never()) - ->method('store'); + $this->configureMocksForAlreadyStoredVariation($originalPath, $variationName); $this->assertImageVariationIsCorrect( $expectedUrl, @@ -362,7 +308,10 @@ public function testGetVariationAlreadyStored() ); } - public function testGetVariationOriginalNotFound() + /** + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\Exception + */ + public function testGetVariationOriginalNotFound(): void { $this->expectException(SourceImageNotFoundException::class); @@ -372,13 +321,16 @@ public function testGetVariationOriginalNotFound() ->will(self::throwException(new NotLoadableException())); $field = new Field([ - 'value' => new ImageValue(), - 'fieldDefIdentifier' => 'image_field', - ]); + 'value' => new ImageValue(), + 'fieldDefIdentifier' => 'image_field', + ]); $this->aliasGenerator->getVariation($field, new VersionInfo(), 'foo'); } - public function testGetVariationInvalidVariation() + /** + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\Exception + */ + public function testGetVariationInvalidVariation(): void { $this->expectException(InvalidVariationException::class); @@ -388,25 +340,7 @@ public function testGetVariationInvalidVariation() $imageValue = new ImageValue(['id' => $originalPath, 'imageId' => $imageId]); $field = new Field(['value' => $imageValue, 'fieldDefIdentifier' => 'image_field']); - $this->ioResolver - ->expects(self::once()) - ->method('isStored') - ->with($originalPath, $variationName) - ->will(self::returnValue(true)); - - $this->logger - ->expects(self::once()) - ->method('debug'); - - $this->dataLoader - ->expects(self::never()) - ->method('find'); - $this->filterManager - ->expects(self::never()) - ->method('applyFilter'); - $this->ioResolver - ->expects(self::never()) - ->method('store'); + $this->configureMocksForAlreadyStoredVariation($originalPath, $variationName); $this->ioResolver ->expects(self::once()) @@ -422,6 +356,7 @@ public function testGetVariationInvalidVariation() * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException */ protected function assertImageVariationIsCorrect( string $expectedUrl, @@ -433,14 +368,14 @@ protected function assertImageVariationIsCorrect( ): void { $imageValue = new ImageValue(['id' => $originalPath, 'imageId' => $imageId]); $field = new Field([ - 'value' => $imageValue, - 'fieldDefIdentifier' => 'image_field', - ]); + 'value' => $imageValue, + 'fieldDefIdentifier' => 'image_field', + ]); $binaryFile = new BinaryFile( [ 'id' => 'foo/bar/image.jpg', - 'uri' => "_aliases/{$variationName}/foo/bar/image.jpg", + 'uri' => "_aliases/$variationName/foo/bar/image.jpg", 'mtime' => new DateTime('2020-01-01 00:00:00'), 'size' => 123, ] @@ -514,4 +449,51 @@ protected function assertImageVariationIsCorrect( $this->decoratedAliasGenerator->getVariation($field, new VersionInfo(), $variationName) ); } + + private function configureMocksForAlreadyStoredVariation(string $originalPath, string $variationName): void + { + $this->ioResolver + ->expects(self::once()) + ->method('isStored') + ->with($originalPath, $variationName) + ->willReturn(true); + + $this->logger + ->expects(self::once()) + ->method('debug'); + + $this->dataLoader + ->expects(self::never()) + ->method('find'); + $this->filterManager + ->expects(self::never()) + ->method('applyFilter'); + $this->ioResolver + ->expects(self::never()) + ->method('store'); + } + + private function configureMocksForNotStoredVariation( + string $originalPath, + string $variationName + ): BinaryInterface&MockObject { + $this->ioResolver + ->expects(self::once()) + ->method('isStored') + ->with($originalPath, $variationName) + ->willReturn(false); + + $this->logger + ->expects(self::once()) + ->method('debug'); + + $binary = $this->createMock(BinaryInterface::class); + $this->dataLoader + ->expects(self::once()) + ->method('find') + ->with($originalPath) + ->willReturn($binary); + + return $binary; + } } From 41eeb1743b86e31bb6a859a8e594062cbd292240 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 16 Jul 2025 20:29:13 +0200 Subject: [PATCH 17/18] [Tests] Added missing type hints to BinaryLoaderTest --- .../bundle/Core/Imagine/BinaryLoaderTest.php | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/tests/bundle/Core/Imagine/BinaryLoaderTest.php b/tests/bundle/Core/Imagine/BinaryLoaderTest.php index feddb12766..0fdab5dc7c 100644 --- a/tests/bundle/Core/Imagine/BinaryLoaderTest.php +++ b/tests/bundle/Core/Imagine/BinaryLoaderTest.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\Bundle\Core\Imagine; @@ -15,16 +16,18 @@ use Ibexa\Core\IO\Values\MissingBinaryFile; use Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException; use Liip\ImagineBundle\Model\Binary; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Mime\MimeTypes; -class BinaryLoaderTest extends TestCase +/** + * @covers \Ibexa\Bundle\Core\Imagine\BinaryLoader + */ +final class BinaryLoaderTest extends TestCase { - /** @var \PHPUnit\Framework\MockObject\MockObject */ - private $ioService; + private IOServiceInterface & MockObject $ioService; - /** @var \Ibexa\Bundle\Core\Imagine\BinaryLoader */ - private $binaryLoader; + private BinaryLoader $binaryLoader; protected function setUp(): void { @@ -33,10 +36,8 @@ protected function setUp(): void $this->binaryLoader = new BinaryLoader($this->ioService, new MimeTypes()); } - public function testFindNotFound() + public function testFindNotFound(): void { - $this->expectException(\Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException::class); - $path = 'something.jpg'; $this->ioService ->expects(self::once()) @@ -44,24 +45,25 @@ public function testFindNotFound() ->with($path) ->will(self::throwException(new NotFoundException('foo', 'bar'))); + $this->expectException(NotLoadableException::class); $this->binaryLoader->find($path); } - public function testFindMissing() + public function testFindMissing(): void { - $this->expectException(\Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException::class); + $this->expectException(NotLoadableException::class); $path = 'something.jpg'; $this->ioService ->expects(self::once()) ->method('loadBinaryFile') ->with($path) - ->will(self::returnValue(new MissingBinaryFile())); + ->willReturn(new MissingBinaryFile()); $this->binaryLoader->find($path); } - public function testFindBadPathRoot() + public function testFindBadPathRoot(): void { $path = 'var/site/storage/images/1/2/3/123-name/name.png'; $this->ioService From 5a1342f3d464185bf7498fc42e69cb10adbebcfd Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 16 Jul 2025 18:42:43 +0200 Subject: [PATCH 18/18] [PHPStan] Removed resolved issues from the baseline --- phpstan-baseline.neon | 1038 ----------------------------------------- 1 file changed, 1038 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 6daf2b3e32..820edeaf03 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -3408,60 +3408,6 @@ parameters: count: 1 path: src/bundle/Core/IbexaCoreBundle.php - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\AliasCleaner\:\:removeAliases\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: src/bundle/Core/Imagine/AliasCleaner.php - - - - message: '#^Parameter \#1 \$image of method Ibexa\\Bundle\\Core\\Imagine\\AliasGenerator\:\:applyFilter\(\) expects Liip\\ImagineBundle\\Binary\\BinaryInterface, Liip\\ImagineBundle\\Binary\\BinaryInterface\|string given\.$#' - identifier: argument.type - count: 1 - path: src/bundle/Core/Imagine/AliasGenerator.php - - - - message: '#^Parameter \#1 \$mimeType of method Symfony\\Component\\Mime\\MimeTypesInterface\:\:getExtensions\(\) expects string, string\|null given\.$#' - identifier: argument.type - count: 1 - path: src/bundle/Core/Imagine/BinaryLoader.php - - - - message: '#^Parameter \#2 \$mimeType of class Liip\\ImagineBundle\\Model\\Binary constructor expects string, string\|null given\.$#' - identifier: argument.type - count: 1 - path: src/bundle/Core/Imagine/BinaryLoader.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Cache\\AliasGeneratorDecorator\:\:getTagsForVariation\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/Cache/AliasGeneratorDecorator.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Cache\\AliasGeneratorDecorator\:\:getVariation\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/Cache/AliasGeneratorDecorator.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Cache\\AliasGeneratorDecorator\:\:setSiteAccess\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: src/bundle/Core/Imagine/Cache/AliasGeneratorDecorator.php - - - - message: '#^Property Ibexa\\Bundle\\Core\\Imagine\\Cache\\AliasGeneratorDecorator\:\:\$siteAccess \(Ibexa\\Core\\MVC\\Symfony\\SiteAccess\) does not accept Ibexa\\Core\\MVC\\Symfony\\SiteAccess\|null\.$#' - identifier: assign.propertyType - count: 1 - path: src/bundle/Core/Imagine/Cache/AliasGeneratorDecorator.php - - - - message: '#^Property Ibexa\\Core\\MVC\\Symfony\\SiteAccess\:\:\$name \(string\) on left side of \?\? is not nullable\.$#' - identifier: nullCoalesce.property - count: 2 - path: src/bundle/Core/Imagine/Cache/AliasGeneratorDecorator.php - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Cache\\Resolver\\RelativeResolver\:\:rewriteUrl\(\) has parameter \$url with no type specified\.$#' identifier: missingType.parameter @@ -3474,234 +3420,12 @@ parameters: count: 1 path: src/bundle/Core/Imagine/Cache/Resolver/RelativeResolver.php - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Cache\\ResolverFactory\:\:createCacheResolver\(\) should return Liip\\ImagineBundle\\Imagine\\Cache\\Resolver\\ResolverInterface but returns object\.$#' - identifier: return.type - count: 1 - path: src/bundle/Core/Imagine/Cache/ResolverFactory.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Filter\\AbstractFilter\:\:__construct\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/Filter/AbstractFilter.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Filter\\AbstractFilter\:\:getOptions\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/Filter/AbstractFilter.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Filter\\AbstractFilter\:\:setOption\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: src/bundle/Core/Imagine/Filter/AbstractFilter.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Filter\\AbstractFilter\:\:setOptions\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: src/bundle/Core/Imagine/Filter/AbstractFilter.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Filter\\AbstractFilter\:\:setOptions\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/Filter/AbstractFilter.php - - - - message: '#^Property Ibexa\\Bundle\\Core\\Imagine\\Filter\\AbstractFilter\:\:\$options type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/Filter/AbstractFilter.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Filter\\FilterInterface\:\:getOptions\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/Filter/FilterInterface.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Filter\\FilterInterface\:\:setOption\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: src/bundle/Core/Imagine/Filter/FilterInterface.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Filter\\FilterInterface\:\:setOptions\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: src/bundle/Core/Imagine/Filter/FilterInterface.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Filter\\FilterInterface\:\:setOptions\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/Filter/FilterInterface.php - - - - message: '#^Call to an undefined method Imagine\\Image\\ImageInterface\:\:getGmagick\(\)\.$#' - identifier: method.notFound - count: 1 - path: src/bundle/Core/Imagine/Filter/Gmagick/ReduceNoiseFilter.php - - - - message: '#^Call to an undefined method Imagine\\Image\\ImageInterface\:\:getGmagick\(\)\.$#' - identifier: method.notFound - count: 1 - path: src/bundle/Core/Imagine/Filter/Gmagick/SwirlFilter.php - - - - message: '#^Call to an undefined method Imagine\\Image\\ImageInterface\:\:getImagick\(\)\.$#' - identifier: method.notFound - count: 1 - path: src/bundle/Core/Imagine/Filter/Imagick/ReduceNoiseFilter.php - - - - message: '#^Call to an undefined method Imagine\\Image\\ImageInterface\:\:getImagick\(\)\.$#' - identifier: method.notFound - count: 1 - path: src/bundle/Core/Imagine/Filter/Imagick/SwirlFilter.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Filter\\Loader\\BorderFilterLoader\:\:load\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/Filter/Loader/BorderFilterLoader.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Filter\\Loader\\CropFilterLoader\:\:load\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/Filter/Loader/CropFilterLoader.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Filter\\Loader\\FilterLoaderWrapped\:\:setInnerLoader\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: src/bundle/Core/Imagine/Filter/Loader/FilterLoaderWrapped.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Filter\\Loader\\GrayscaleFilterLoader\:\:load\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/Filter/Loader/GrayscaleFilterLoader.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Filter\\Loader\\ReduceNoiseFilterLoader\:\:load\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/Filter/Loader/ReduceNoiseFilterLoader.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleDownOnlyFilterLoader\:\:load\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/Filter/Loader/ScaleDownOnlyFilterLoader.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleExactFilterLoader\:\:load\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/Filter/Loader/ScaleExactFilterLoader.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleFilterLoader\:\:load\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/Filter/Loader/ScaleFilterLoader.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleHeightDownOnlyFilterLoader\:\:load\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/Filter/Loader/ScaleHeightDownOnlyFilterLoader.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleHeightFilterLoader\:\:load\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/Filter/Loader/ScaleHeightFilterLoader.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScalePercentFilterLoader\:\:load\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/Filter/Loader/ScalePercentFilterLoader.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleWidthDownOnlyFilterLoader\:\:load\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/Filter/Loader/ScaleWidthDownOnlyFilterLoader.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleWidthFilterLoader\:\:load\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/Filter/Loader/ScaleWidthFilterLoader.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Filter\\Loader\\SwirlFilterLoader\:\:load\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/Filter/Loader/SwirlFilterLoader.php - - message: '#^Parameter \#2 \$data of function fwrite expects string, string\|false given\.$#' identifier: argument.type count: 1 path: src/bundle/Core/Imagine/IORepositoryResolver.php - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\PlaceholderAliasGenerator\:\:setPlaceholderProvider\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: src/bundle/Core/Imagine/PlaceholderAliasGenerator.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\PlaceholderAliasGenerator\:\:setPlaceholderProvider\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/PlaceholderAliasGenerator.php - - - - message: '#^Property Ibexa\\Bundle\\Core\\Imagine\\PlaceholderAliasGenerator\:\:\$placeholderOptions type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/PlaceholderAliasGenerator.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\PlaceholderAliasGeneratorConfigurator\:\:__construct\(\) has parameter \$providersConfig with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/PlaceholderAliasGeneratorConfigurator.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\PlaceholderAliasGeneratorConfigurator\:\:configure\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: src/bundle/Core/Imagine/PlaceholderAliasGeneratorConfigurator.php - - - - message: '#^Property Ibexa\\Bundle\\Core\\Imagine\\PlaceholderAliasGeneratorConfigurator\:\:\$providersConfig type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/PlaceholderAliasGeneratorConfigurator.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\PlaceholderProvider\:\:getPlaceholder\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/PlaceholderProvider.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\PlaceholderProvider\\GenericProvider\:\:getPlaceholder\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/PlaceholderProvider/GenericProvider.php - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\PlaceholderProvider\\GenericProvider\:\:resolveOptions\(\) has parameter \$options with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -3714,78 +3438,12 @@ parameters: count: 1 path: src/bundle/Core/Imagine/PlaceholderProvider/GenericProvider.php - - - message: '#^Parameter \#1 \$width of class Imagine\\Image\\Box constructor expects int, int\|null given\.$#' - identifier: argument.type - count: 1 - path: src/bundle/Core/Imagine/PlaceholderProvider/GenericProvider.php - - - - message: '#^Parameter \#1 \$x of class Imagine\\Image\\Point constructor expects int, int\|null given\.$#' - identifier: argument.type - count: 2 - path: src/bundle/Core/Imagine/PlaceholderProvider/GenericProvider.php - - - - message: '#^Parameter \#2 \$font of method Imagine\\Draw\\DrawerInterface\:\:text\(\) expects Imagine\\Image\\AbstractFont, Imagine\\Image\\FontInterface given\.$#' - identifier: argument.type - count: 1 - path: src/bundle/Core/Imagine/PlaceholderProvider/GenericProvider.php - - - - message: '#^Parameter \#2 \$height of class Imagine\\Image\\Box constructor expects int, int\|null given\.$#' - identifier: argument.type - count: 1 - path: src/bundle/Core/Imagine/PlaceholderProvider/GenericProvider.php - - - - message: '#^Parameter \#2 \$y of class Imagine\\Image\\Point constructor expects int, int\|null given\.$#' - identifier: argument.type - count: 2 - path: src/bundle/Core/Imagine/PlaceholderProvider/GenericProvider.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\PlaceholderProvider\\RemoteProvider\:\:getPlaceholder\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/PlaceholderProvider/RemoteProvider.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\PlaceholderProvider\\RemoteProvider\:\:resolveOptions\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/PlaceholderProvider/RemoteProvider.php - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\PlaceholderProvider\\RemoteProvider\:\:resolveOptions\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 path: src/bundle/Core/Imagine/PlaceholderProvider/RemoteProvider.php - - - message: '#^Cannot access offset string on Ibexa\\Bundle\\Core\\Imagine\\PlaceholderProvider\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 3 - path: src/bundle/Core/Imagine/PlaceholderProviderRegistry.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\PlaceholderProviderRegistry\:\:__construct\(\) has parameter \$providers with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Core/Imagine/PlaceholderProviderRegistry.php - - - - message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\PlaceholderProviderRegistry\:\:addProvider\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: src/bundle/Core/Imagine/PlaceholderProviderRegistry.php - - - - message: '#^Property Ibexa\\Bundle\\Core\\Imagine\\PlaceholderProviderRegistry\:\:\$providers \(Ibexa\\Bundle\\Core\\Imagine\\PlaceholderProvider\) does not accept array\.$#' - identifier: assign.propertyType - count: 1 - path: src/bundle/Core/Imagine/PlaceholderProviderRegistry.php - - message: '#^Property Ibexa\\Bundle\\Core\\Imagine\\Variation\\ImagineAwareAliasGenerator\:\:\$configResolver is unused\.$#' identifier: property.unused @@ -6606,12 +6264,6 @@ parameters: count: 2 path: src/lib/FieldType/ISBN/Type.php - - - message: '#^Method Ibexa\\Core\\FieldType\\Image\\AliasCleanerInterface\:\:removeAliases\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: src/lib/FieldType/Image/AliasCleanerInterface.php - - message: '#^Cannot access offset ''id'' on array\|bool\|float\|int\|string\.$#' identifier: offsetAccess.nonOffsetAccessible @@ -9318,12 +8970,6 @@ parameters: count: 1 path: src/lib/MVC/Symfony/Templating/Twig/Extension/FileSizeExtension.php - - - message: '#^Method Ibexa\\Core\\MVC\\Symfony\\Templating\\Twig\\Extension\\ImageExtension\:\:getImageVariation\(\) should return Ibexa\\Contracts\\Core\\Variation\\Values\\Variation\|null but return statement is missing\.$#' - identifier: return.missing - count: 1 - path: src/lib/MVC/Symfony/Templating/Twig/Extension/ImageExtension.php - - message: '#^Method Ibexa\\Core\\MVC\\Symfony\\Templating\\Twig\\Extension\\QueryRenderingExtension\:\:createControllerReference\(\) has parameter \$options with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -22758,690 +22404,6 @@ parameters: count: 1 path: tests/bundle/Core/Fragment/FragmentListenerFactoryTest.php - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\AliasCleanerTest\:\:testRemoveAliases\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/AliasCleanerTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\AliasGeneratorTest\:\:supportsValueProvider\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/bundle/Core/Imagine/AliasGeneratorTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\AliasGeneratorTest\:\:testGetVariationAlreadyStored\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/AliasGeneratorTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\AliasGeneratorTest\:\:testGetVariationInvalidVariation\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/AliasGeneratorTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\AliasGeneratorTest\:\:testGetVariationNotStored\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/AliasGeneratorTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\AliasGeneratorTest\:\:testGetVariationNotStoredHavingReferences\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/AliasGeneratorTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\AliasGeneratorTest\:\:testGetVariationOriginal\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/AliasGeneratorTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\AliasGeneratorTest\:\:testGetVariationOriginalNotFound\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/AliasGeneratorTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\AliasGeneratorTest\:\:testGetVariationWrongValue\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/AliasGeneratorTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\AliasGeneratorTest\:\:testSupportsValue\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/AliasGeneratorTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\BinaryLoaderTest\:\:testFindBadPathRoot\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/BinaryLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\BinaryLoaderTest\:\:testFindMissing\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/BinaryLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\BinaryLoaderTest\:\:testFindNotFound\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/BinaryLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Cache\\Resolver\\ProxyResolverTest\:\:testResolveAndRemovePortUsingProxyHost\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Cache/Resolver/ProxyResolverTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Cache\\Resolver\\ProxyResolverTest\:\:testResolveAndRemovePortUsingProxyHostWithTrailingSlash\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Cache/Resolver/ProxyResolverTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Cache\\Resolver\\ProxyResolverTest\:\:testResolveUsingProxyHostWithTrailingSlash\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Cache/Resolver/ProxyResolverTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Cache\\Resolver\\RelativeResolverTest\:\:testResolve\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Cache/Resolver/RelativeResolverTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Cache\\ResolverFactoryTest\:\:testCreateProxyCacheResolver\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Cache/ResolverFactoryTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Cache\\ResolverFactoryTest\:\:testCreateRelativeCacheResolver\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Cache/ResolverFactoryTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\AbstractFilterTest\:\:getFilter\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/AbstractFilterTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\AbstractFilterTest\:\:getSetOptionNoDefaulValueProvider\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/AbstractFilterTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\AbstractFilterTest\:\:getSetOptionWithDefaulValueProvider\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/AbstractFilterTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\AbstractFilterTest\:\:testGetSetOptionNoDefaultValue\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/AbstractFilterTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\AbstractFilterTest\:\:testGetSetOptionNoDefaultValue\(\) has parameter \$optionName with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: tests/bundle/Core/Imagine/Filter/AbstractFilterTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\AbstractFilterTest\:\:testGetSetOptionNoDefaultValue\(\) has parameter \$value with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: tests/bundle/Core/Imagine/Filter/AbstractFilterTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\AbstractFilterTest\:\:testGetSetOptionWithDefaultValue\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/AbstractFilterTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\AbstractFilterTest\:\:testGetSetOptionWithDefaultValue\(\) has parameter \$defaultValue with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: tests/bundle/Core/Imagine/Filter/AbstractFilterTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\AbstractFilterTest\:\:testGetSetOptionWithDefaultValue\(\) has parameter \$optionName with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: tests/bundle/Core/Imagine/Filter/AbstractFilterTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\AbstractFilterTest\:\:testGetSetOptionWithDefaultValue\(\) has parameter \$value with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: tests/bundle/Core/Imagine/Filter/AbstractFilterTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\AbstractFilterTest\:\:testGetSetOptions\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/AbstractFilterTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\FilterConfigurationTest\:\:testAll\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/FilterConfigurationTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\FilterConfigurationTest\:\:testGetEzVariationImagineFilters\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/FilterConfigurationTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\FilterConfigurationTest\:\:testGetEzVariationImagineOptions\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/FilterConfigurationTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\FilterConfigurationTest\:\:testGetEzVariationNoReference\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/FilterConfigurationTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\FilterConfigurationTest\:\:testGetEzVariationWithReference\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/FilterConfigurationTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\FilterConfigurationTest\:\:testGetNoEzVariationInvalidImagineFilter\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/FilterConfigurationTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\FilterConfigurationTest\:\:testGetOnlyImagineFilters\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/FilterConfigurationTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\BorderFilterLoaderTest\:\:loadInvalidProvider\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/BorderFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\BorderFilterLoaderTest\:\:loadProvider\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/BorderFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\BorderFilterLoaderTest\:\:testLoad\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/BorderFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\BorderFilterLoaderTest\:\:testLoad\(\) has parameter \$color with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/BorderFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\BorderFilterLoaderTest\:\:testLoad\(\) has parameter \$thickX with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/BorderFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\BorderFilterLoaderTest\:\:testLoad\(\) has parameter \$thickY with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/BorderFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\BorderFilterLoaderTest\:\:testLoadDefaultColor\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/BorderFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\BorderFilterLoaderTest\:\:testLoadInvalidOptions\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/BorderFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\BorderFilterLoaderTest\:\:testLoadInvalidOptions\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/BorderFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\CropFilterLoaderTest\:\:loadInvalidProvider\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/CropFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\CropFilterLoaderTest\:\:testLoad\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/CropFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\CropFilterLoaderTest\:\:testLoadInvalidOptions\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/CropFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\CropFilterLoaderTest\:\:testLoadInvalidOptions\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/CropFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\GrayscaleFilterLoaderTest\:\:testLoad\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/GrayscaleFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\ReduceNoiseFilterLoaderTest\:\:testLoadInvalidDriver\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ReduceNoiseFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleDownOnlyFilterLoaderTest\:\:loadInvalidProvider\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScaleDownOnlyFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleDownOnlyFilterLoaderTest\:\:testLoad\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScaleDownOnlyFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleDownOnlyFilterLoaderTest\:\:testLoadInvalidOptions\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScaleDownOnlyFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleDownOnlyFilterLoaderTest\:\:testLoadInvalidOptions\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScaleDownOnlyFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleExactFilterLoaderTest\:\:loadInvalidProvider\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScaleExactFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleExactFilterLoaderTest\:\:testLoad\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScaleExactFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleExactFilterLoaderTest\:\:testLoadInvalidOptions\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScaleExactFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleExactFilterLoaderTest\:\:testLoadInvalidOptions\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScaleExactFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleFilterLoaderTest\:\:loadInvalidProvider\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScaleFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleFilterLoaderTest\:\:testLoadHeighten\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScaleFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleFilterLoaderTest\:\:testLoadInvalidOptions\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScaleFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleFilterLoaderTest\:\:testLoadInvalidOptions\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScaleFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleFilterLoaderTest\:\:testLoadWiden\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScaleFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleHeightDownOnlyFilterLoaderTest\:\:testLoad\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScaleHeightDownOnlyFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleHeightDownOnlyFilterLoaderTest\:\:testLoadInvalid\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScaleHeightDownOnlyFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleHeightFilterLoaderTest\:\:testLoad\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScaleHeightFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleHeightFilterLoaderTest\:\:testLoadFail\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScaleHeightFilterLoaderTest.php - - - - message: '#^Method PHPUnit\\Framework\\TestCase\:\:createMock\(\) invoked with 2 parameters, 1 required\.$#' - identifier: arguments.count - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScaleHeightFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScalePercentFilterLoaderTest\:\:loadInvalidProvider\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScalePercentFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScalePercentFilterLoaderTest\:\:testLoad\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScalePercentFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScalePercentFilterLoaderTest\:\:testLoadInvalidOptions\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScalePercentFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScalePercentFilterLoaderTest\:\:testLoadInvalidOptions\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScalePercentFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleWidthDownOnlyFilterLoaderTest\:\:testLoad\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScaleWidthDownOnlyFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleWidthDownOnlyFilterLoaderTest\:\:testLoadInvalid\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScaleWidthDownOnlyFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleWidthFilterLoaderTest\:\:testLoad\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScaleWidthFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\ScaleWidthFilterLoaderTest\:\:testLoadFail\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScaleWidthFilterLoaderTest.php - - - - message: '#^Method PHPUnit\\Framework\\TestCase\:\:createMock\(\) invoked with 2 parameters, 1 required\.$#' - identifier: arguments.count - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/ScaleWidthFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\SwirlFilterLoaderTest\:\:loadWithOptionProvider\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/SwirlFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\SwirlFilterLoaderTest\:\:testLoadNoOption\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/SwirlFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\SwirlFilterLoaderTest\:\:testLoadWithOption\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/SwirlFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\Loader\\SwirlFilterLoaderTest\:\:testLoadWithOption\(\) has parameter \$degrees with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: tests/bundle/Core/Imagine/Filter/Loader/SwirlFilterLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\Filter\\UnsupportedFilterTest\:\:testLoad\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/Filter/UnsupportedFilterTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\ImageAsset\\AliasGeneratorTest\:\:testGetVariationOfImageAsset\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/ImageAsset/AliasGeneratorTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\ImageAsset\\AliasGeneratorTest\:\:testGetVariationOfNonImageAsset\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/ImageAsset/AliasGeneratorTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\ImageAsset\\AliasGeneratorTest\:\:testSupport\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/ImageAsset/AliasGeneratorTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\PlaceholderAliasGeneratorConfiguratorTest\:\:testConfigure\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/PlaceholderAliasGeneratorConfiguratorTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\PlaceholderAliasGeneratorTest\:\:getVariationProvider\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/bundle/Core/Imagine/PlaceholderAliasGeneratorTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\PlaceholderAliasGeneratorTest\:\:supportsValueProvider\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/bundle/Core/Imagine/PlaceholderAliasGeneratorTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\PlaceholderAliasGeneratorTest\:\:testGetVariationOriginalFound\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/PlaceholderAliasGeneratorTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\PlaceholderAliasGeneratorTest\:\:testGetVariationOriginalFound\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/bundle/Core/Imagine/PlaceholderAliasGeneratorTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\PlaceholderAliasGeneratorTest\:\:testGetVariationOriginalNotFound\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/PlaceholderAliasGeneratorTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\PlaceholderAliasGeneratorTest\:\:testGetVariationOriginalNotFound\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/bundle/Core/Imagine/PlaceholderAliasGeneratorTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\PlaceholderAliasGeneratorTest\:\:testGetVariationReturnsPlaceholderIfBinaryDataIsNotAvailable\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/bundle/Core/Imagine/PlaceholderAliasGeneratorTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\PlaceholderAliasGeneratorTest\:\:testGetVariationSkipsPlaceholderGeneration\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/PlaceholderAliasGeneratorTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\PlaceholderAliasGeneratorTest\:\:testGetVariationSkipsPlaceholderGeneration\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/bundle/Core/Imagine/PlaceholderAliasGeneratorTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\PlaceholderAliasGeneratorTest\:\:testGetVariationWrongValue\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/PlaceholderAliasGeneratorTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\PlaceholderAliasGeneratorTest\:\:testSupportsValue\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/PlaceholderAliasGeneratorTest.php - - - - message: '#^Property Ibexa\\Tests\\Bundle\\Core\\Imagine\\PlaceholderAliasGeneratorTest\:\:\$placeholderOptions type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/bundle/Core/Imagine/PlaceholderAliasGeneratorTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\PlaceholderProvider\\GenericProviderTest\:\:assertColorEquals\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/PlaceholderProvider/GenericProviderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\PlaceholderProvider\\GenericProviderTest\:\:assertColorEquals\(\) has parameter \$expected with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: tests/bundle/Core/Imagine/PlaceholderProvider/GenericProviderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\PlaceholderProvider\\GenericProviderTest\:\:assertSizeEquals\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/PlaceholderProvider/GenericProviderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\PlaceholderProvider\\GenericProviderTest\:\:assertSizeEquals\(\) has parameter \$expected with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/bundle/Core/Imagine/PlaceholderProvider/GenericProviderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\PlaceholderProvider\\GenericProviderTest\:\:getPlaceholderDataProvider\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/PlaceholderProvider/GenericProviderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\PlaceholderProvider\\GenericProviderTest\:\:testGetPlaceholder\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/PlaceholderProvider/GenericProviderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\PlaceholderProvider\\GenericProviderTest\:\:testGetPlaceholder\(\) has parameter \$expectedText with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: tests/bundle/Core/Imagine/PlaceholderProvider/GenericProviderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\PlaceholderProvider\\GenericProviderTest\:\:testGetPlaceholder\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/bundle/Core/Imagine/PlaceholderProvider/GenericProviderTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\PlaceholderProviderRegistryTest\:\:testConstructor\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/PlaceholderProviderRegistryTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\PlaceholderProviderRegistryTest\:\:testGetProviderKnown\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/PlaceholderProviderRegistryTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\PlaceholderProviderRegistryTest\:\:testGetProviderUnknown\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/PlaceholderProviderRegistryTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\PlaceholderProviderRegistryTest\:\:testSupports\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/PlaceholderProviderRegistryTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\VariationPathGenerator\\AliasDirectoryVariationPathGeneratorTest\:\:testGetVariationPath\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/VariationPathGenerator/AliasDirectoryVariationPathGeneratorTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\VariationPathGenerator\\OriginalDirectoryVariationPathGeneratorTest\:\:testGetVariationPath\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: tests/bundle/Core/Imagine/VariationPathGenerator/OriginalDirectoryVariationPathGeneratorTest.php - - message: '#^Cannot access offset ''path'' on array\{scheme\?\: string, host\?\: string, port\?\: int\<0, 65535\>, user\?\: string, pass\?\: string, path\?\: string, query\?\: string, fragment\?\: string\}\|false\.$#' identifier: offsetAccess.nonOffsetAccessible