Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 0 additions & 126 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3708,18 +3708,6 @@ parameters:
count: 1
path: src/bundle/Core/Imagine/Filter/Loader/SwirlFilterLoader.php

-
message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\IORepositoryResolver\:\:remove\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: src/bundle/Core/Imagine/IORepositoryResolver.php

-
message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\IORepositoryResolver\:\:store\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: src/bundle/Core/Imagine/IORepositoryResolver.php

-
message: '#^Parameter \#2 \$data of function fwrite expects string, string\|false given\.$#'
identifier: argument.type
Expand Down Expand Up @@ -27210,120 +27198,6 @@ parameters:
count: 1
path: tests/bundle/Core/Imagine/Filter/UnsupportedFilterTest.php

-
message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\IORepositoryResolverTest\:\:getFilePathProvider\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: tests/bundle/Core/Imagine/IORepositoryResolverTest.php

-
message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\IORepositoryResolverTest\:\:resolveProvider\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: tests/bundle/Core/Imagine/IORepositoryResolverTest.php

-
message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\IORepositoryResolverTest\:\:testGetFilePath\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: tests/bundle/Core/Imagine/IORepositoryResolverTest.php

-
message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\IORepositoryResolverTest\:\:testGetFilePath\(\) has parameter \$expected with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: tests/bundle/Core/Imagine/IORepositoryResolverTest.php

-
message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\IORepositoryResolverTest\:\:testGetFilePath\(\) has parameter \$filter with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: tests/bundle/Core/Imagine/IORepositoryResolverTest.php

-
message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\IORepositoryResolverTest\:\:testGetFilePath\(\) has parameter \$path with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: tests/bundle/Core/Imagine/IORepositoryResolverTest.php

-
message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\IORepositoryResolverTest\:\:testIsStoredImageDoesntExist\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: tests/bundle/Core/Imagine/IORepositoryResolverTest.php

-
message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\IORepositoryResolverTest\:\:testIsStoredImageExists\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: tests/bundle/Core/Imagine/IORepositoryResolverTest.php

-
message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\IORepositoryResolverTest\:\:testRemoveEmptyFilters\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: tests/bundle/Core/Imagine/IORepositoryResolverTest.php

-
message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\IORepositoryResolverTest\:\:testRemoveWithFilters\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: tests/bundle/Core/Imagine/IORepositoryResolverTest.php

-
message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\IORepositoryResolverTest\:\:testResolve\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: tests/bundle/Core/Imagine/IORepositoryResolverTest.php

-
message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\IORepositoryResolverTest\:\:testResolve\(\) has parameter \$expected with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: tests/bundle/Core/Imagine/IORepositoryResolverTest.php

-
message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\IORepositoryResolverTest\:\:testResolve\(\) has parameter \$filter with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: tests/bundle/Core/Imagine/IORepositoryResolverTest.php

-
message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\IORepositoryResolverTest\:\:testResolve\(\) has parameter \$path with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: tests/bundle/Core/Imagine/IORepositoryResolverTest.php

-
message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\IORepositoryResolverTest\:\:testResolve\(\) has parameter \$requestUrl with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: tests/bundle/Core/Imagine/IORepositoryResolverTest.php

-
message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\IORepositoryResolverTest\:\:testResolve\(\) has parameter \$variationPath with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: tests/bundle/Core/Imagine/IORepositoryResolverTest.php

-
message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\IORepositoryResolverTest\:\:testResolveMissing\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: tests/bundle/Core/Imagine/IORepositoryResolverTest.php

-
message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\IORepositoryResolverTest\:\:testResolveNotFound\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: tests/bundle/Core/Imagine/IORepositoryResolverTest.php

-
message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\IORepositoryResolverTest\:\:testStore\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: tests/bundle/Core/Imagine/IORepositoryResolverTest.php

-
message: '#^Method Ibexa\\Tests\\Bundle\\Core\\Imagine\\ImageAsset\\AliasGeneratorTest\:\:testGetVariationOfImageAsset\(\) has no return type specified\.$#'
identifier: missingType.return
Expand Down
29 changes: 7 additions & 22 deletions src/bundle/Core/Imagine/IORepositoryResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,19 @@
*/
class IORepositoryResolver extends PathResolver implements ResolverInterface
{
public const VARIATION_ORIGINAL = 'original';

/** @var \Ibexa\Core\IO\IOServiceInterface */
private $ioService;

/** @var \Liip\ImagineBundle\Imagine\Filter\FilterConfiguration */
private $filterConfiguration;

/** @var \Ibexa\Contracts\Core\Variation\VariationPurger */
private $variationPurger;
public const string VARIATION_ORIGINAL = 'original';

public function __construct(
IOServiceInterface $ioService,
private readonly IOServiceInterface $ioService,
RequestContext $requestContext,
FilterConfiguration $filterConfiguration,
VariationPurger $variationPurger,
private readonly FilterConfiguration $filterConfiguration,
private readonly VariationPurger $variationPurger,
VariationPathGenerator $variationPathGenerator
) {
parent::__construct($requestContext, $variationPathGenerator);

$this->ioService = $ioService;
$this->filterConfiguration = $filterConfiguration;
$this->variationPurger = $variationPurger;
}

public function isStored($path, $filter)
public function isStored($path, $filter): bool
{
return $this->ioService->exists($this->getFilePath($path, $filter));
}
Expand Down Expand Up @@ -85,10 +72,8 @@ public function resolve($path, $filter): string
/**
* Stores image alias in the IO Repository.
* A temporary file is created to dump the filtered image and is used as basis for creation in the IO Repository.
*
* {@inheritdoc}
*/
public function store(BinaryInterface $binary, $path, $filter)
public function store(BinaryInterface $binary, $path, $filter): void
{
$tmpFile = tmpfile();
fwrite($tmpFile, $binary->getContent());
Expand All @@ -105,7 +90,7 @@ public function store(BinaryInterface $binary, $path, $filter)
* @param string[] $paths The paths where the original files are expected to be.
* @param string[] $filters The imagine filters in effect.
*/
public function remove(array $paths, array $filters)
public function remove(array $paths, array $filters): void
{
if (empty($filters)) {
$filters = array_keys($this->filterConfiguration->all());
Expand Down
28 changes: 17 additions & 11 deletions tests/bundle/Core/Imagine/IORepositoryResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected function setUp(): void
/**
* @dataProvider getFilePathProvider
*/
public function testGetFilePath($path, $filter, $expected)
public function testGetFilePath(string $path, string $filter, string $expected): void
{
$this->variationPathGenerator
->expects(self::once())
Expand All @@ -78,7 +78,10 @@ public function testGetFilePath($path, $filter, $expected)
self::assertSame($expected, $this->imageResolver->getFilePath($path, $filter));
}

public function getFilePathProvider()
/**
* @return array<array{string, string, string}>
*/
public function getFilePathProvider(): array
{
return [
['Tardis/bigger/in-the-inside/RiverSong.jpg', 'thumbnail', 'Tardis/bigger/in-the-inside/RiverSong_thumbnail.jpg'],
Expand All @@ -88,7 +91,7 @@ public function getFilePathProvider()
];
}

public function testIsStoredImageExists()
public function testIsStoredImageExists(): void
{
$filter = 'thumbnail';
$path = 'Tardis/bigger/in-the-inside/RiverSong.jpg';
Expand All @@ -109,7 +112,7 @@ public function testIsStoredImageExists()
self::assertTrue($this->imageResolver->isStored($path, $filter));
}

public function testIsStoredImageDoesntExist()
public function testIsStoredImageDoesntExist(): void
{
$filter = 'thumbnail';
$path = 'Tardis/bigger/in-the-inside/RiverSong.jpg';
Expand All @@ -133,7 +136,7 @@ public function testIsStoredImageDoesntExist()
/**
* @dataProvider resolveProvider
*/
public function testResolve($path, $filter, $variationPath, $requestUrl, $expected)
public function testResolve(string $path, string $filter, string $variationPath, ?string $requestUrl, mixed $expected): void
{
if ($requestUrl) {
$this->requestContext->fromRequest(Request::create($requestUrl));
Expand All @@ -153,7 +156,7 @@ public function testResolve($path, $filter, $variationPath, $requestUrl, $expect
self::assertSame($expected, $result);
}

public function testResolveMissing()
public function testResolveMissing(): void
{
$this->expectException(NotResolvableException::class);

Expand All @@ -167,7 +170,7 @@ public function testResolveMissing()
$this->imageResolver->resolve($path, 'some_filter');
}

public function testResolveNotFound()
public function testResolveNotFound(): void
{
$this->expectException(NotResolvableException::class);

Expand All @@ -181,7 +184,10 @@ public function testResolveNotFound()
$this->imageResolver->resolve($path, 'some_filter');
}

public function resolveProvider()
/**
* @return array<int, array{string, string, string, string|null, string}>
*/
public function resolveProvider(): array
{
return [
[
Expand Down Expand Up @@ -236,7 +242,7 @@ public function resolveProvider()
];
}

public function testStore()
public function testStore(): void
{
$filter = 'thumbnail';
$path = 'Tardis/bigger/in-the-inside/RiverSong.jpg';
Expand All @@ -256,7 +262,7 @@ public function testStore()
$this->imageResolver->store($binary, $path, $filter);
}

public function testRemoveEmptyFilters()
public function testRemoveEmptyFilters(): void
{
$originalPath = 'foo/bar/test.jpg';
$filters = ['filter1' => true, 'filter2' => true, 'chaud_cacao' => true];
Expand Down Expand Up @@ -309,7 +315,7 @@ public function testRemoveEmptyFilters()
$this->imageResolver->remove([$originalPath], []);
}

public function testRemoveWithFilters()
public function testRemoveWithFilters(): void
{
$originalPath = 'foo/bar/test.jpg';
$filters = ['filter1', 'filter2', 'chaud_cacao'];
Expand Down
Loading