Skip to content
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

[CS] [Dependencies] [Dependency Injection] [Form] [General] Update compiler log format, remove legacy code, remove deprecated, fix docblocks/style, general Travis config, upgrade coveralls, and general fixes #1047

Merged
merged 2 commits into from Feb 15, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions .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
service_name : travis-ci
coverage_clover: var/build/clover.xml
json_path : var/build/upload.json
55 changes: 43 additions & 12 deletions .travis.yml
@@ -1,19 +1,27 @@
sudo: false

language: php

sudo: false

cache:

directories:
- $HOME/.composer/cache


env:

global:
- SYMFONY_DEPRECATIONS_HELPER="weak_vendors"
- ENABLE_CODE_COVERAGE="false"
- SIMPLE_PHPUNIT_FLAGS="-v"


matrix:

fast_finish: true

include:

- php: 7.1
- php: 7.1
env:
Expand All @@ -28,10 +36,11 @@ matrix:
- php: 7.2
env:
- DEPENDENCIES="symfony/phpunit-bridge:^4"
- COMPOSER_UPDATE_OPTIONS="--no-dev"
- COMPOSER_UPDATE_FLAGS="--no-dev"
- php: 7.2
env:
- ENABLE_CODE_COVERAGE="true"
- SIMPLE_PHPUNIT_FLAGS="-v --coverage-text --coverage-clover var/build/clover.xml"
- php: 7.2
env:
- SYMFONY_VERSION=dev-master
Expand All @@ -40,28 +49,50 @@ matrix:
env:
- SYMFONY_VERSION=4.0.*
- COMPOSER_FLAGS="--ignore-platform-reqs"

allow_failures:

- env:
- ENABLE_CODE_COVERAGE="true"
- SIMPLE_PHPUNIT_FLAGS="-v --coverage-text --coverage-clover var/build/clover.xml"
- env:
- SYMFONY_VERSION=dev-master
- STABILITY=dev
- php: nightly


before_install:
- if [[ "$SYMFONY_VERSION" != "" ]]; then travis_retry composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update $COMPOSER_FLAGS; fi;
- 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 [[ "$SYMFONY_VERSION" != "" ]]; then
travis_retry composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update $COMPOSER_FLAGS;
fi
- if [[ "$DEPENDENCIES" != "" ]]; then
travis_retry composer require $DEPENDENCIES --no-update $COMPOSER_FLAGS;
fi
- if [[ "$STABILITY" != "" ]]; then
travis_retry composer config minimum-stability $STABILITY;
fi
- if [[ "$ENABLE_CODE_COVERAGE" != "true" ]]; then
phpenv config-rm xdebug.ini || true;
fi
- if [[ "$ENABLE_CODE_COVERAGE" == "true" ]]; then
travis_retry composer require --dev satooshi/php-coveralls:^2.0@dev --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

- travis_retry composer update --prefer-dist --no-interaction --no-suggest --no-progress --ansi $COMPOSER_FLAGS $COMPOSER_UPDATE_FLAGS
- ./vendor/bin/simple-phpunit install


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;

- ./vendor/bin/simple-phpunit $SIMPLE_PHPUNIT_FLAGS


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" ]]; then
./vendor/bin/php-coveralls -vvv --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);
}
18 changes: 5 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,12 @@ 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