Skip to content
Open
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
33 changes: 25 additions & 8 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,50 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.1', '7.2', '7.3', '7.4', '8.0']
php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
dependencies: [highest]
symfony: ['*']
stability: ['stable']
include:
# Minimum supported dependencies with the oldest supported PHP version
- php: '7.1'
dependencies: lowest
symfony: '*'
stability: 'stable'

# Minimum supported dependencies with the latest supported PHP version
- php: '8.0'
dependencies: lowest
symfony: '*'
stability: 'stable'

# Test each supported Symfony version with lowest supported PHP version
- php: '7.1'
dependencies: highest
symfony: '3.4.*'
stability: 'stable'

- php: '7.1'
dependencies: highest
symfony: '4.4.*'
stability: 'stable'

- php: '7.2'
dependencies: highest
symfony: '5.1.*'
symfony: '5.3.*'
stability: 'stable'

- php: '7.2'
# Test Symfony 5.4 dev version
- php: '7.4'
dependencies: highest
symfony: '5.4.*'
stability: 'dev'

# Test Symfony 6.0 dev version
- php: '8.0'
dependencies: highest
symfony: '5.2.*'
symfony: '6.0.*'
stability: 'dev'
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -65,10 +79,13 @@ jobs:
composer global require --no-interaction --no-progress symfony/flex:^1.11
composer config extra.symfony.require ${{ matrix.symfony }}

# TODO: remove this step when enqueue supports PHP 8, see https://github.com/php-enqueue/enqueue-dev/issues/1108
- name: Remove EnqueueBundle
if: matrix.php == '8.0'
run: composer remove --dev --no-update enqueue/enqueue-bundle
- name: Remove non-compatible dependencies with Symfony 6
if: matrix.symfony == '6.0.*'
run: |
composer remove enqueue/enqueue-bundle --dev --no-update

- name: Set minimum-stability
run: composer config minimum-stability ${{ matrix.stability }}

# Incompatible with symfony/framework-bundle v3
- name: Remove symfony/messenger
Expand Down
3 changes: 3 additions & 0 deletions Async/ResolveCacheProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public function __construct(
$this->producer = $producer;
}

/**
* @return string|object
*/
public function process(Message $psrMessage, Context $psrContext)
{
try {
Expand Down
4 changes: 2 additions & 2 deletions Binary/Loader/StreamLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ public function find($path)
* The error suppression is solely to determine whether the file exists.
* file_exists() is not used as not all wrappers support stat() to actually check for existing resources.
*/
if (($this->context && !$resource = @fopen($name, 'rb', null, $this->context)) || !$resource = @fopen($name, 'rb')) {
if (($this->context && !$resource = @fopen($name, 'rb', false, $this->context)) || !$resource = @fopen($name, 'rb')) {
throw new NotLoadableException(sprintf('Source image %s not found.', $name));
}

// Closing the opened stream to avoid locking of the resource to find.
fclose($resource);

try {
$content = file_get_contents($name, null, $this->context);
$content = file_get_contents($name, false, $this->context);
} catch (\Exception $e) {
throw new NotLoadableException(sprintf('Source image %s could not be loaded.', $name), $e->getCode(), $e);
}
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ This file contains a complete enumeration of all [pull requests](https://github.
for a given releases. Unreleased, upcoming changes will be updated here periodically; reference the next release on our
[milestones](https://github.com/liip/LiipImagineBundle/milestones) page for the latest changes.


## [2.7.2](https://github.com/liip/LiipImagineBundle/tree/2.7.2)

- Address PHP 8.1 deprecations [\#1427](https://github.com/liip/LiipImagineBundle/pull/1427) ([franmomu](https://github.com/franmomu))

## [2.7.1](https://github.com/liip/LiipImagineBundle/tree/2.7.1)

- Bugfix: Don't resolve to webp in the controller if webp generation is disabled [\#1410](https://github.com/liip/LiipImagineBundle/pull/1410) ([mynameisbogdan](https://github.com/mynameisbogdan) / [dbu](https://github.com/dbu))
Expand Down
5 changes: 1 addition & 4 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ public function __construct(array $resolversFactories, array $loadersFactories)
$this->loadersFactories = $loadersFactories;
}

/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('liip_imagine');
$rootNode = method_exists(TreeBuilder::class, 'getRootNode')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private function getBundlePathsUsingNamedObj(array $classes)
try {
$r = new \ReflectionClass($c);
} catch (\ReflectionException $exception) {
throw new InvalidArgumentException(sprintf('Unable to resolve bundle "%s" while auto-registering bundle resource paths.', $c), null, $exception);
throw new InvalidArgumentException(sprintf('Unable to resolve bundle "%s" while auto-registering bundle resource paths.', $c), $exception->getCode(), $exception);
}

$paths[$r->getShortName()] = \dirname($r->getFileName());
Expand Down
6 changes: 2 additions & 4 deletions DependencyInjection/LiipImagineExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Liip\ImagineBundle\Imagine\Cache\CacheManager;
use Liip\ImagineBundle\Imagine\Data\DataManager;
use Liip\ImagineBundle\Imagine\Filter\FilterManager;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Alias;
Expand Down Expand Up @@ -51,10 +52,7 @@ public function addLoaderFactory(LoaderFactoryInterface $loaderFactory)
$this->loadersFactories[$loaderFactory->getName()] = $loaderFactory;
}

/**
* {@inheritdoc}
*/
public function getConfiguration(array $config, ContainerBuilder $container)
public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface
{
return new Configuration($this->resolversFactories, $this->loadersFactories);
}
Expand Down
4 changes: 2 additions & 2 deletions Form/Type/ImageType.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ public function configureOptions(OptionsResolver $resolver)
}

/**
* {@inheritdoc}
* @return string
*/
public function getBlockPrefix()
{
return 'liip_imagine_image';
}

/**
* {@inheritdoc}
* @return string
*/
public function getParent()
{
Expand Down
2 changes: 1 addition & 1 deletion Imagine/Cache/Resolver/AwsS3Resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function store(BinaryInterface $binary, $path, $filter)
'exception' => $e,
]);

throw new NotStorableException('The object could not be created on Amazon S3.', null, $e);
throw new NotStorableException('The object could not be created on Amazon S3.', $e->getCode(), $e);
}
}

Expand Down
4 changes: 4 additions & 0 deletions Imagine/Cache/Resolver/CacheResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ protected function generateIndexKey($cacheKey)
*/
protected function sanitizeCacheKeyPart($cacheKeyPart)
{
if (null === $cacheKeyPart) {
return '';
}

return str_replace('.', '_', $cacheKeyPart);
}

Expand Down
4 changes: 4 additions & 0 deletions Imagine/Cache/Resolver/PsrCacheResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ private function generateIndexKey($cacheKey)
*/
private function sanitizeCacheKeyPart($cacheKeyPart)
{
if (null === $cacheKeyPart) {
return '';
}

return str_replace(self::RESERVED_CHARACTERS, '_', $cacheKeyPart);
}

Expand Down
4 changes: 2 additions & 2 deletions Imagine/Filter/Loader/ResampleFilterLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function load(ImageInterface $image, array $options = [])
$this->delTemporaryFile($tmpFile);
} catch (\Exception $exception) {
$this->delTemporaryFile($tmpFile);
throw new LoadFilterException('Unable to save/open file in resample filter loader.', null, $exception);
throw new LoadFilterException('Unable to save/open file in resample filter loader.', $exception->getCode(), $exception);
}

return $image;
Expand Down Expand Up @@ -134,7 +134,7 @@ private function resolveOptions(array $options)
try {
return $resolver->resolve($options);
} catch (ExceptionInterface $exception) {
throw new InvalidArgumentException(sprintf('Invalid option(s) passed to %s::load().', __CLASS__), null, $exception);
throw new InvalidArgumentException(sprintf('Invalid option(s) passed to %s::load().', __CLASS__), $exception->getCode(), $exception);
}
}
}
2 changes: 2 additions & 0 deletions Templating/FilterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public function filterCache(

/**
* {@inheritdoc}
*
* @return string
*/
public function getName()
{
Expand Down
4 changes: 2 additions & 2 deletions Templating/LazyFilterExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
final class LazyFilterExtension extends AbstractExtension
{
/**
* {@inheritdoc}
* @return TwigFilter[]
*/
public function getFilters()
public function getFilters(): array
{
return [
new TwigFilter('imagine_filter', [LazyFilterRuntime::class, 'filter']),
Expand Down
5 changes: 1 addition & 4 deletions Tests/Functional/AbstractWebTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@

abstract class AbstractWebTestCase extends WebTestCase
{
/**
* @return string
*/
public static function getKernelClass()
public static function getKernelClass(): string
{
require_once __DIR__.'/app/AppKernel.php';

Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/Controller/ImagineControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function setUp(): void
// supported by the current PHP build or not. Enabling WebP in configurations will drop all tests if WebP is
// not supported.
if ($this->webp_generate) {
$filterService = self::getService('liip_imagine.service.filter');
$filterService = self::getService('test.liip_imagine.service.filter');
$webpGenerate = new \ReflectionProperty($filterService, 'webpGenerate');
$webpGenerate->setAccessible(true);
$webpGenerate->setValue($filterService, true);
Expand Down
42 changes: 22 additions & 20 deletions Tests/Functional/app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@
namespace Liip\ImagineBundle\Tests\Functional\app;

use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;

class AppKernel extends Kernel
{
/**
* @return array
*/
public function registerBundles()
public function registerBundles(): iterable
{
$bundles = [
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
Expand All @@ -31,37 +29,41 @@ public function registerBundles()
return $bundles;
}

/**
* @return string
*/
public function getCacheDir()
public function getCacheDir(): string
{
return sys_get_temp_dir().'/liip_imagine_test/cache';
}

/**
* @return string
*/
public function getLogDir()
public function getLogDir(): string
{
return sys_get_temp_dir().'/liip_imagine_test/cache/logs';
}

public function getProjectDir()
public function getProjectDir(): string
{
return __DIR__;
}

/**
* @throws \Exception
*/
public function registerContainerConfiguration(LoaderInterface $loader)
public function registerContainerConfiguration(LoaderInterface $loader): void
{
if (version_compare(self::VERSION, '5.3', '>=')) {
$loader->load(__DIR__.'/config/symfony_5-3.yaml');
} else {
$loader->load(__DIR__.'/config/symfony_legacy.yaml');
}
$loader->load(__DIR__.'/config/config.yml');
$loader->load(function (ContainerBuilder $container) use ($loader) {
if (version_compare(self::VERSION, '5.3', '>=')) {
$loader->load($this->getProjectDir().'/config/symfony_5-3.yaml');
} else {
$loader->load($this->getProjectDir().'/config/symfony_legacy.yaml');
}

$loader->load($this->getProjectDir().'/config/config.yml');

$container
->setAlias('test.liip_imagine.service.filter', 'liip_imagine.service.filter')
->setPublic(true);
$container
->setAlias('test.liip_imagine.filter.manager', 'liip_imagine.filter.manager')
->setPublic(true);
});
}
}
4 changes: 2 additions & 2 deletions Tests/Message/Handler/WarmupCacheHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ public function testThrowIfMessageMissingPath(): void
*/
private function createFilterManagerMock()
{
return $this->getService('liip_imagine.filter.manager');
return $this->getService('test.liip_imagine.filter.manager');
}

/**
* @return object|FilterService
*/
private function createFilterServiceMock()
{
return $this->getService('liip_imagine.service.filter');
return $this->getService('test.liip_imagine.service.filter');
}
}
4 changes: 2 additions & 2 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

This file contains a descriptive enumeration of *important* changes that may require *manual intervention* in your
application code or are otherwise particularly noteworthy. Reference our full
[changelog](https://github.com/liip/LiipImagineBundle/blob/2.0/CHANGELOG.md) for a complete list of all changes for a
[changelog](https://github.com/liip/LiipImagineBundle/blob/2.x/CHANGELOG.md) for a complete list of all changes for a
given release.

## [Unreleased](https://github.com/liip/LiipImagineBundle/tree/HEAD)
## 2.3.0 - 2.7.0

- __[Deprecated]__ As `doctrine/cache` has been deprecated, the `Liip\ImagineBundle\Imagine\Resolver\CacheResolver`
class and the corresponding service prototype - `liip_imagine.cache.resolver.prototype.cache` have been deprecated.
Expand Down
Loading