Skip to content

Commit

Permalink
update compiler log format, remove legacy code, remove deprecations, …
Browse files Browse the repository at this point in the history
…fix docblocks, general cleanup
  • Loading branch information
robfrawley committed Jan 31, 2018
1 parent c676dee commit f4279cf
Show file tree
Hide file tree
Showing 74 changed files with 358 additions and 343 deletions.
1 change: 0 additions & 1 deletion .coveralls.yml
@@ -1,4 +1,3 @@
service_name: travis-ci
src_dir: .
coverage_clover : var/build/clover.xml
json_path : var/build/coveralls-upload.json
5 changes: 2 additions & 3 deletions .travis.yml
Expand Up @@ -50,14 +50,13 @@ before_install:
- if [[ "$DEPENDENCIES" != "" ]]; then travis_retry composer require ${DEPENDENCIES} --no-update $COMPOSER_FLAGS; fi;
- if [[ "$STABILITY" != "" ]]; then composer config minimum-stability $STABILITY; fi
- if [[ "$ENABLE_CODE_COVERAGE" != "true" && "$TRAVIS_EVENT_TYPE" != "cron" ]]; then phpenv config-rm xdebug.ini || true; fi;
- if [[ "$ENABLE_CODE_COVERAGE" != "true" && "$TRAVIS_EVENT_TYPE" != "cron" ]]; then travis_retry composer require satooshi/php-coveralls:^1.0 --no-update $COMPOSER_FLAGS; fi;
- if [[ "$ENABLE_CODE_COVERAGE" == "true" && "$TRAVIS_EVENT_TYPE" != "cron" ]]; then travis_retry composer require satooshi/php-coveralls:^2.0 --no-update $COMPOSER_FLAGS; fi;

install:
- travis_retry composer update --prefer-dist --no-interaction --no-suggest --no-progress --ansi $COMPOSER_FLAGS $COMPOSER_UPDATE_OPTIONS
- if [[ "$ENABLE_CODE_COVERAGE" == "true" && "$TRAVIS_EVENT_TYPE" == "cron" ]]; then travis_retry composer require --dev satooshi/php-coveralls; fi

script:
- if [[ "$ENABLE_CODE_COVERAGE" == "true" && "$TRAVIS_EVENT_TYPE" == "cron" ]]; then vendor/bin/simple-phpunit --coverage-text --coverage-clover build/logs/clover.xml; else vendor/bin/simple-phpunit -v; fi;

after_success:
- if [[ "$ENABLE_CODE_COVERAGE" == "true" && "$TRAVIS_EVENT_TYPE" == "cron" ]]; then php vendor/bin/coveralls -v --config .coveralls.yml; fi;
- if [[ "$ENABLE_CODE_COVERAGE" == "true" && "$TRAVIS_EVENT_TYPE" == "cron" ]]; then php vendor/bin/php-coveralls -v --config .coveralls.yml; fi;
4 changes: 3 additions & 1 deletion Binary/Loader/LoaderInterface.php
Expand Up @@ -11,6 +11,8 @@

namespace Liip\ImagineBundle\Binary\Loader;

use Liip\ImagineBundle\Binary\BinaryInterface;

interface LoaderInterface
{
/**
Expand All @@ -20,7 +22,7 @@ interface LoaderInterface
*
* @param mixed $path
*
* @return \Liip\ImagineBundle\Binary\BinaryInterface|string An image binary content
* @return BinaryInterface|string An image binary content
*/
public function find($path);
}
16 changes: 3 additions & 13 deletions DependencyInjection/Compiler/AbstractCompilerPass.php
Expand Up @@ -11,7 +11,6 @@

namespace Liip\ImagineBundle\DependencyInjection\Compiler;

use Liip\ImagineBundle\Utility\Framework\SymfonyFramework;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

Expand All @@ -20,19 +19,10 @@ abstract class AbstractCompilerPass implements CompilerPassInterface
/**
* @param ContainerBuilder $container
* @param string $message
* @param mixed[] $replacements
* @param mixed[] ...$replacements
*/
protected function log(ContainerBuilder $container, $message, array $replacements = [])
protected function log(ContainerBuilder $container, string $message, ...$replacements): void
{
if (count($replacements) > 0) {
$message = vsprintf($message, $replacements);
}

if (SymfonyFramework::hasDirectContainerBuilderLogging()) {
$container->log($this, $message);
} else {
$compiler = $container->getCompiler();
$compiler->addLogMessage($compiler->getLoggingFormatter()->format($this, $message));
}
$container->log($this, sprintf('[liip/imagine-bundle] %s', empty($replacements) ? $message : vsprintf($message, $replacements)));
}
}
2 changes: 1 addition & 1 deletion DependencyInjection/Compiler/FiltersCompilerPass.php
Expand Up @@ -28,7 +28,7 @@ public function process(ContainerBuilder $container)

foreach ($tags as $id => $tag) {
$manager->addMethodCall('addLoader', [$tag[0]['loader'], new Reference($id)]);
$this->log($container, 'Registered imagine-bimdle filter loader: %s', [$id]);
$this->log($container, 'Registered filter loader: %s', $id);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Compiler/LoadersCompilerPass.php
Expand Up @@ -28,7 +28,7 @@ public function process(ContainerBuilder $container)

foreach ($tags as $id => $tag) {
$manager->addMethodCall('addLoader', [$tag[0]['loader'], new Reference($id)]);
$this->log($container, 'Registered imagine-bimdle binary loader: %s', [$id]);
$this->log($container, 'Registered binary loader: %s', $id);
}
}
}
Expand Down
21 changes: 8 additions & 13 deletions DependencyInjection/Compiler/MetadataReaderCompilerPass.php
Expand Up @@ -15,8 +15,7 @@
use Symfony\Component\DependencyInjection\Definition;

/**
* Be default, a metadata reader that requires the "exif" PHP extension is used. This compiler pass checks if the
* extension is loaded or not, and switches to a metadata reader (that does not rely on "exif") if not.
* Replaces the default exif-extension-based metadata reader with a degraded one if the exif extensions is not loaded.
*/
class MetadataReaderCompilerPass extends AbstractCompilerPass
{
Expand All @@ -38,18 +37,14 @@ class MetadataReaderCompilerPass extends AbstractCompilerPass
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (!$this->isExifExtensionLoaded() && $this->isExifMetadataReaderSet($container)) {
$container->setDefinition(self::$metadataReaderServiceId, new Definition(self::$metadataReaderDefaultClass));
$message = 'Overwrote "%s" service to use "%s" instead of "%s" due to missing "exif" extension '
.'(installing the "exif" extension is highly recommended; you may experience degraded '
.'metadata handling without it)';
$this->log($container, $message, array(
self::$metadataReaderServiceId,
self::$metadataReaderDefaultClass,
self::$metadataReaderExifClass,
));
$message = 'Replaced the "%s" metadata reader service with "%s" from "%s" due to missing "exif" extension '.
'(as you may experience degraded metadata handling without the exif extension, installation is '.
'highly recommended)';
$this->log($container, $message, self::$metadataReaderServiceId, self::$metadataReaderDefaultClass, self::$metadataReaderExifClass);
}
}

Expand All @@ -58,15 +53,15 @@ public function process(ContainerBuilder $container)
*
* @return bool
*/
private function isExifMetadataReaderSet(ContainerBuilder $container)
private function isExifMetadataReaderSet(ContainerBuilder $container): bool
{
return $container->getDefinition(self::$metadataReaderServiceId)->getClass() === self::$metadataReaderExifClass;
}

/**
* @return bool
*/
protected function isExifExtensionLoaded()
protected function isExifExtensionLoaded(): bool
{
return extension_loaded('exif');
}
Expand Down
Expand Up @@ -33,7 +33,7 @@ public function process(ContainerBuilder $container)

foreach ($tags as $id => $tag) {
$manager->addMethodCall('addPostProcessor', [$tag[0]['post_processor'], new Reference($id)]);
$this->log($container, 'Registered imagine-bimdle filter post-processor: %s', [$id]);
$this->log($container, 'Registered filter post-processor: %s', $id);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Compiler/ResolversCompilerPass.php
Expand Up @@ -28,7 +28,7 @@ public function process(ContainerBuilder $container)

foreach ($tags as $id => $tag) {
$manager->addMethodCall('addResolver', [$tag[0]['resolver'], new Reference($id)]);
$this->log($container, 'Registered imagine-bimdle cache resolver: %s', [$id]);
$this->log($container, 'Registered cache resolver: %s', $id);
}
}
}
Expand Down
25 changes: 0 additions & 25 deletions DependencyInjection/Factory/ChildDefinitionTrait.php

This file was deleted.

8 changes: 2 additions & 6 deletions DependencyInjection/Factory/Loader/AbstractLoaderFactory.php
Expand Up @@ -11,27 +11,23 @@

namespace Liip\ImagineBundle\DependencyInjection\Factory\Loader;

use Liip\ImagineBundle\DependencyInjection\Factory\ChildDefinitionTrait;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\DefinitionDecorator;

abstract class AbstractLoaderFactory implements LoaderFactoryInterface
{
use ChildDefinitionTrait;

/**
* @var string
*/
protected static $namePrefix = 'liip_imagine.binary.loader';

/**
* @return ChildDefinition|DefinitionDecorator
* @return ChildDefinition
*/
final protected function getChildLoaderDefinition()
{
return $this->getChildDefinition(sprintf('%s.prototype.%s', static::$namePrefix, $this->getName()));
return new ChildDefinition(sprintf('%s.prototype.%s', static::$namePrefix, $this->getName()));
}

/**
Expand Down
Expand Up @@ -11,14 +11,10 @@

namespace Liip\ImagineBundle\DependencyInjection\Factory\Resolver;

use Liip\ImagineBundle\DependencyInjection\Factory\ChildDefinitionTrait;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\DefinitionDecorator;

abstract class AbstractResolverFactory implements ResolverFactoryInterface
{
use ChildDefinitionTrait;

/**
* @var string
*/
Expand All @@ -27,10 +23,10 @@ abstract class AbstractResolverFactory implements ResolverFactoryInterface
/**
* @param string|null $name
*
* @return ChildDefinition|DefinitionDecorator
* @return ChildDefinition
*/
final protected function getChildResolverDefinition($name = null)
{
return $this->getChildDefinition(sprintf('%s.prototype.%s', static::$namePrefix, $name ?: $this->getName()));
return new ChildDefinition(sprintf('%s.prototype.%s', static::$namePrefix, $name ?: $this->getName()));
}
}
3 changes: 3 additions & 0 deletions DependencyInjection/LiipImagineExtension.php
Expand Up @@ -59,6 +59,9 @@ public function getConfiguration(array $config, ContainerBuilder $container)

/**
* @see \Symfony\Component\DependencyInjection\Extension.ExtensionInterface::load()
*
* @param array $configs
* @param ContainerBuilder $container
*/
public function load(array $configs, ContainerBuilder $container)
{
Expand Down
17 changes: 0 additions & 17 deletions Form/Type/ImageType.php
Expand Up @@ -16,7 +16,6 @@
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

/**
* ImageType.
Expand Down Expand Up @@ -56,27 +55,11 @@ public function configureOptions(OptionsResolver $resolver)
]);
}

/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$this->configureOptions($resolver);
}

/**
* {@inheritdoc}
*/
public function getParent()
{
return FileType::class;
}

/**
* {@inheritdoc}
*/
public function getName()
{
return 'liip_imagine_image';
}
}
3 changes: 3 additions & 0 deletions Imagine/Cache/CacheManagerAwareTrait.php
Expand Up @@ -18,6 +18,9 @@ trait CacheManagerAwareTrait
*/
protected $cacheManager;

/**
* @param CacheManager $cacheManager
*/
public function setCacheManager(CacheManager $cacheManager)
{
$this->cacheManager = $cacheManager;
Expand Down
2 changes: 2 additions & 0 deletions Imagine/Cache/Resolver/AmazonS3Resolver.php
Expand Up @@ -194,6 +194,8 @@ protected function getObjectUrl($path)
*
* @param string $objectPath
*
* @throws \S3_Exception
*
* @return bool
*/
protected function objectExists($objectPath)
Expand Down
8 changes: 4 additions & 4 deletions Imagine/Cache/Resolver/AwsS3Resolver.php
Expand Up @@ -192,12 +192,12 @@ public function remove(array $paths, array $filters)
*
* If the option is already set, it will be overwritten.
*
* @see Aws\S3\S3Client::getObjectUrl() for available options
* @see \Aws\S3\S3Client::getObjectUrl() for available options
*
* @param string $key The name of the option
* @param mixed $value The value to be set
*
* @return AmazonS3Resolver $this
* @return $this
*/
public function setGetOption($key, $value)
{
Expand All @@ -211,12 +211,12 @@ public function setGetOption($key, $value)
*
* If the option is already set, it will be overwritten.
*
* @see Aws\S3\S3Client::putObject() for available options
* @see \Aws\S3\S3Client::putObject() for available options
*
* @param string $key The name of the option
* @param mixed $value The value to be set
*
* @return AmazonS3Resolver $this
* @return $this
*/
public function setPutOption($key, $value)
{
Expand Down
5 changes: 5 additions & 0 deletions Imagine/Cache/Resolver/NoCacheWebPathResolver.php
Expand Up @@ -16,6 +16,11 @@

class NoCacheWebPathResolver implements ResolverInterface
{
/**
* @var RequestContext
*/
private $requestContext;

/**
* @param RequestContext $requestContext
*/
Expand Down
2 changes: 1 addition & 1 deletion Imagine/Data/DataManager.php
Expand Up @@ -116,7 +116,7 @@ public function getLoader($filter)
*
* @throws \LogicException
*
* @return \Liip\ImagineBundle\Binary\BinaryInterface
* @return BinaryInterface
*/
public function find($filter, $path)
{
Expand Down
2 changes: 0 additions & 2 deletions Imagine/Filter/FilterConfiguration.php
Expand Up @@ -51,8 +51,6 @@ public function get($filter)
*
* @param string $filter
* @param array $config
*
* @return array
*/
public function set($filter, array $config)
{
Expand Down
15 changes: 6 additions & 9 deletions Imagine/Filter/FilterManager.php
Expand Up @@ -98,18 +98,15 @@ public function getFilterConfiguration()
*
* @throws \InvalidArgumentException
*
* @return Binary
* @return BinaryInterface
*/
public function apply(BinaryInterface $binary, array $config)
{
$config = array_replace(
[
'filters' => [],
'quality' => 100,
'animated' => false,
],
$config
);
$config = array_replace([
'filters' => [],
'quality' => 100,
'animated' => false,
], $config);

if ($binary instanceof FileBinaryInterface) {
$image = $this->imagine->open($binary->getPath());
Expand Down

0 comments on commit f4279cf

Please sign in to comment.