Skip to content

[WiP] IBX-9727: Fixed strict types of SPI field type layer #626

New issue

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

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

Already on GitHub? Sign in to your account

Draft
wants to merge 78 commits into
base: ibx-9727-strict-types-core-imagine
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
ae34093
Defined strict types for IO contracts
alongosz Jul 8, 2025
33141ad
Defined template type for IO HandlerRegistry
alongosz Jul 8, 2025
fca78f4
Fixed type hints for IOBinarydataHandler implementations
alongosz Jul 8, 2025
197a83f
Fixed type hints for IOMetadataHandler implementations
alongosz Jul 8, 2025
6fe46b0
Added missing type hints to IO UrlDecorator
alongosz Jul 8, 2025
0780c41
Aligned NotFoundException `$previous` arg type with `\Exception` sign…
alongosz Jul 8, 2025
ef1fdb9
Added missing type hints to IO\MimeTypeDetector\FileInfo
alongosz Jul 8, 2025
c52ee66
Fixed strict types in \Ibexa\Bundle\IO\Migration namespace
alongosz Jul 8, 2025
cb366b5
Added missing type hints and improved code of Imagine VariationPurger
alongosz Jul 9, 2025
4a8c0ad
Added missing type hints to IOServiceInterface and aligned related code
alongosz Jul 14, 2025
87b1d73
Added missing type hints to \Ibexa\Bundle\Core\Imagine\Filter\FilterC…
alongosz Jul 14, 2025
145c2d2
Added missing type hints to \Ibexa\Core\IO\FilePathNormalizer\Flysystem
alongosz Jul 14, 2025
448038f
Fixed strict types of MigrateFilesCommand and improved its code
alongosz Jul 15, 2025
ff35baa
[DI] Added missing type hints to IO Bundle Configuration
alongosz Jul 15, 2025
e48c8d3
Fixed strict types and improved IO Handler Configuration Factories
alongosz Jul 15, 2025
1bc06ee
Added missing type hints to StreamFileListener
alongosz Jul 15, 2025
a63c315
Declared strict types and fixed IbexaIOBundle
alongosz Jul 15, 2025
4bd7a10
Declared strict types for MigrationFileListerPass
alongosz Jul 15, 2025
a3289ff
Declared strict types for FileMigratorInterface
alongosz Jul 15, 2025
5ce54c4
Declared strict types for BinaryStreamResponse
alongosz Jul 15, 2025
9d27c23
Simplified LegacyStorageImageFileRowReader::getRow implementation
alongosz Jul 21, 2025
85e2453
[Tests] Dropped obsolete test replaced by strict types
alongosz Jul 8, 2025
9323ee5
[Tests] Aligned tests with the changes
alongosz Jul 8, 2025
20bca2b
[Tests] Aligned VariationPurger unit tests with the changes
alongosz Jul 9, 2025
bfc1e7e
[Tests] Aligned IO\Migration tests with the changes
alongosz Jul 9, 2025
fc85762
[Tests] Aligned IOServiceTest with the changes
alongosz Jul 9, 2025
a4c101b
[Tests] Fixed & refactored IORepositoryResolverTest
alongosz Jul 14, 2025
232ce94
[Tests] Fixed & refactored LegacyTest after BinaryFile strict types c…
alongosz Jul 14, 2025
ce3000b
[Tests] Fixed strict types of IOConfigurationPassTest
alongosz Jul 15, 2025
fa02b3d
[Tests] Improved quality of LegacyDFSClusterTest
alongosz Jul 15, 2025
b7e47e2
[Tests] Fixed ConfigurationFactory test cases
alongosz Jul 15, 2025
8472d7e
[Tests] Improved \Ibexa\Tests\Bundle\IO\DependencyInjection\Configura…
alongosz Jul 15, 2025
193bee5
[PHPStan] Removed resolved issues from the baseline
alongosz Jul 9, 2025
3e40afc
Added missing type hints to classes in `Imagine\Cache` namespace
alongosz Jul 16, 2025
2a5bd58
Added missing type hints to `Imagine\Filter\FilterInterface` and its …
alongosz Jul 16, 2025
dcf28d6
Added missing type hints Imagine Filter Loaders
alongosz Jul 16, 2025
6d3a5f0
Added missing type hints to VariationHandler contract and its impleme…
alongosz Jul 16, 2025
8cecd20
Added missing type hints to PlaceholderProvider implementation
alongosz Jul 16, 2025
6da0be7
Added missing type hints to Image alias cleaners
alongosz Jul 16, 2025
d9d6189
Added missing type hints to MVC\Symfony\Templating\Twig\Extension\Ima…
alongosz Jul 16, 2025
f62f076
[Tests] Refactored Imagine\Cache ProxyResolverTest to use data provider
alongosz Jul 16, 2025
a97b96e
[Tests] Added missing type hints to `Imagine\Cache` Resolver tests
alongosz Jul 16, 2025
27ede04
[Tests] Added missing type hints and refactored Filter Loader tests
alongosz Jul 16, 2025
0af3270
[Tests] Added missing type hints to Imagine AliasCleanerTest
alongosz Jul 16, 2025
b0e2da8
[Tests] Added missing type hints to PlaceholderAlias tests
alongosz Jul 16, 2025
ca9b954
[Tests] Added missing type hints & refactored Placeholder provider tests
alongosz Jul 16, 2025
5e72f02
[Tests] Added missing type hints to ImageAsset AliasGeneratorTest
alongosz Jul 16, 2025
3b7b464
[Tests] Added missing type hints to VariationPathGenerator tests
alongosz Jul 16, 2025
fca9da4
[Tests] Added missing type hints and refactored AliasGeneratorTest
alongosz Jul 16, 2025
9b3a67a
[Tests] Added missing type hints to BinaryLoaderTest
alongosz Jul 16, 2025
dd6f888
[PHPStan] Removed resolved issues from the baseline
alongosz Jul 16, 2025
7284c8e
Added missing type hints to \Ibexa\Contracts\Core\FieldType\Value
alongosz Jul 24, 2025
c6dca22
Added and fixed strict types to the abstract FieldType base implement…
alongosz Jul 24, 2025
6d7a333
Added missing type hints to \Ibexa\Contracts\Core\FieldType\Generic\Type
alongosz Jul 24, 2025
57372c9
[WiP] Added missing type hints to \Ibexa\Contracts\Core\Repository\Fi…
alongosz Jul 24, 2025
1dcc502
Added missing type hints to \Ibexa\Contracts\Core\Persistence\Content…
alongosz Jul 24, 2025
a0bd7ba
Aligned Author field type implementation with contracts changes
alongosz Jul 24, 2025
3ca91f4
Aligned Binary-based field type implementations with contracts changes
alongosz Jul 24, 2025
6408e87
Added missing type hints to abstract \Ibexa\Core\FieldType\Value
alongosz Jul 24, 2025
053f0b8
[WiP] Added missing type hints to abstract \Ibexa\Core\FieldType\Fiel…
alongosz Jul 24, 2025
b410c78
Aligned Text-based field type implementations with contracts changes
alongosz Jul 24, 2025
45c50cf
Aligned date/time-related field type implementations with contracts c…
alongosz Jul 24, 2025
cee5397
Aligned numeric-based field type implementations with contracts changes
alongosz Jul 24, 2025
7aee0c9
Aligned Checkbox field type implementation with contracts changes
alongosz Jul 24, 2025
c46f221
Aligned Country field type implementation with contracts changes
alongosz Jul 24, 2025
09fa379
Aligned Email field type implementation with contracts changes
alongosz Jul 24, 2025
c2706e9
Aligned ImageAsset field type implementation with contracts changes
alongosz Jul 24, 2025
52e5162
Aligned ISBN field type implementation with contracts changes
alongosz Jul 24, 2025
e6f4f34
Aligned Keyword field type implementation with contracts changes
alongosz Jul 24, 2025
720edb7
Aligned MapLocation field type implementation with contracts changes
alongosz Jul 24, 2025
53e7beb
Aligned Null field type implementation with contracts changes
alongosz Jul 24, 2025
17983bf
Aligned Relation field types implementations with contracts changes
alongosz Jul 24, 2025
9ee8d41
Aligned Selection field type implementation with contracts changes
alongosz Jul 24, 2025
0008a75
Aligned Url field type implementation with contracts changes
alongosz Jul 24, 2025
1daec34
Aligned User field type implementation with contracts changes
alongosz Jul 24, 2025
1461348
[WiP] Added missing type hints to \Ibexa\Core\Repository\Values\Conte…
alongosz Jul 24, 2025
0f47f22
[Tests] Aligned unit tests with the changes
alongosz Jul 24, 2025
3bf40f6
[Tests] Aligned integration tests with the changes
alongosz Jul 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,080 changes: 379 additions & 2,701 deletions phpstan-baseline.neon

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/bundle/Core/Imagine/AliasCleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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], []);
}
Expand Down
53 changes: 25 additions & 28 deletions src/bundle/Core/Imagine/AliasGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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,
Expand All @@ -68,42 +63,49 @@
$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 */
$imageValue = $field->value;
$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;

$variationWidth = $variationHeight = null;
// Create the image alias only if it does not already exist.
if ($variationName !== IORepositoryResolver::VARIATION_ORIGINAL && !$this->ioResolver->isStored($originalPath, $variationName)) {

Check failure on line 86 in src/bundle/Core/Imagine/AliasGenerator.php

View workflow job for this annotation

GitHub Actions / Unit tests & SQLite integration tests (8.3)

Parameter #1 $path of method Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface::isStored() expects string, string|null given.
try {
$originalBinary = $this->dataLoader->find($originalPath);
} 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)");

$this->ioResolver->store(
$this->applyFilter($originalBinary, $variationName),
$originalPath,

Check failure on line 108 in src/bundle/Core/Imagine/AliasGenerator.php

View workflow job for this annotation

GitHub Actions / Unit tests & SQLite integration tests (8.3)

Parameter #2 $path of method Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface::store() expects string, string|null given.
$variationName
);
} else {
Expand All @@ -116,7 +118,7 @@

try {
$aliasInfo = new SplFileInfo(
$this->ioResolver->resolve($originalPath, $variationName)

Check failure on line 121 in src/bundle/Core/Imagine/AliasGenerator.php

View workflow job for this annotation

GitHub Actions / Unit tests & SQLite integration tests (8.3)

Parameter #1 $path of method Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface::resolve() expects string, string|null given.
);
} catch (NotResolvableException $e) {
// If for some reason image alias cannot be resolved, throw the appropriate exception.
Expand Down Expand Up @@ -145,13 +147,8 @@
* 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.
Expand Down
16 changes: 7 additions & 9 deletions src/bundle/Core/Imagine/BinaryLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
* @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 Exception;
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;
Expand All @@ -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)
{
Expand All @@ -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);
Expand All @@ -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 =
Expand Down
70 changes: 31 additions & 39 deletions src/bundle/Core/Imagine/Cache/AliasGeneratorDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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,
Expand All @@ -64,17 +54,18 @@ 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 \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
*/
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()) {
Expand All @@ -90,19 +81,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',
Expand All @@ -117,6 +104,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;
Expand Down
9 changes: 5 additions & 4 deletions src/bundle/Core/Imagine/Cache/Resolver/ProxyResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
8 changes: 2 additions & 6 deletions src/bundle/Core/Imagine/Cache/Resolver/RelativeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -15,9 +16,6 @@
*/
class RelativeResolver extends ImagineProxyResolver
{
/**
* @param \Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface $resolver
*/
public function __construct(ResolverInterface $resolver)
{
parent::__construct($resolver, []);
Expand All @@ -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);
}
Expand Down
Loading
Loading