Skip to content

Commit

Permalink
increase requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
garak committed Dec 25, 2017
1 parent e463904 commit 2a39e12
Show file tree
Hide file tree
Showing 109 changed files with 601 additions and 914 deletions.
5 changes: 5 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ $finder = PhpCsFixer\Finder::create()
;

return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'@PHP71Migration:risky' => true,
'@PHPUnit60Migration:risky' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => true,
'declare_strict_types' => false,
])
->setFinder($finder)
;
13 changes: 4 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: php

php:
- 7.0
- 7.1
- 7.2
- nightly
Expand All @@ -13,21 +12,17 @@ cache:
- $HOME/.composer/cache

env:
- SYMFONY_VERSION="~2.8.0"
- SYMFONY_VERSION="~3.4.0"
- COMPOSER_FLAGS="--prefer-dist"

matrix:
include:
- php: 7.1
env: VALIDATE_DOCS=true
- php: 7.0
env: COMPOSER_FLAGS="--prefer-lowest"
- php: 7.1
env: SYMFONY_VERSION="~3.3.0"
env: SYMFONY_VERSION="~3.4.0" WITH_LIIP_IMAGINE=true
- php: 7.2
env: SYMFONY_VERSION="~3.4.0"
- php: 7.1
env: SYMFONY_VERSION="~2.8.0" WITH_LIIP_IMAGINE=true
- php: 7.1
env: SYMFONY_VERSION="~4.0.0" WITH_LIIP_IMAGINE=true
allow_failures:
- php: nightly
Expand All @@ -40,7 +35,7 @@ before_install:
- if [ "$WITH_LIIP_IMAGINE" = true ] ; then composer require --no-update liip/imagine-bundle:"^1.7|^2.0@dev"; fi;
- if [ "$VALIDATE_DOCS" = true ]; then composer require --dev --no-update kphoen/rusty dev-master; fi

install: php -d memory_limit=-1 $(phpenv which composer) update $COMPOSER_FLAGS --no-suggest --prefer-dist
install: php -d memory_limit=-1 $(phpenv which composer) update $COMPOSER_FLAGS --no-suggest

script:
- if [ "$VALIDATE_DOCS" != true ]; then ./vendor/bin/phpunit; fi
Expand Down
2 changes: 1 addition & 1 deletion Adapter/ODM/MongoDB/MongoDBAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function getObjectFromArgs($event)
/**
* {@inheritdoc}
*/
public function recomputeChangeSet($event)
public function recomputeChangeSet($event): void
{
$object = $this->getObjectFromArgs($event);

Expand Down
2 changes: 1 addition & 1 deletion Adapter/ORM/DoctrineORMAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function getObjectFromArgs($event)
/**
* {@inheritdoc}
*/
public function recomputeChangeSet($event)
public function recomputeChangeSet($event): void
{
$object = $this->getObjectFromArgs($event);

Expand Down
2 changes: 1 addition & 1 deletion Adapter/PHPCR/PHPCRAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function getObjectFromArgs($event)
/**
* {@inheritdoc}
*/
public function recomputeChangeSet($event)
public function recomputeChangeSet($event): void
{
$object = $this->getObjectFromArgs($event);

Expand Down
2 changes: 1 addition & 1 deletion Adapter/Propel/PropelORMAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function getObjectFromArgs($event)
/**
* {@inheritdoc}
*/
public function recomputeChangeSet($event)
public function recomputeChangeSet($event): void
{
}
}
3 changes: 2 additions & 1 deletion Command/MappingDebugClassCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Vich\UploaderBundle\Metadata\MetadataReader;

class MappingDebugClassCommand extends Command
{
Expand All @@ -19,7 +20,7 @@ public function __construct(MetadataReader $metadataReader)
$this->metadataReader = $metadataReader;
}

protected function configure()
protected function configure(): void
{
$this
->setName('vich:mapping:debug-class')
Expand Down
4 changes: 2 additions & 2 deletions Command/MappingDebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(array $mappings)
$this->mappings = $mappings;
}

protected function configure()
protected function configure(): void
{
$this
->setName('vich:mapping:debug')
Expand All @@ -29,7 +29,7 @@ protected function configure()
;
}

protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): void
{
$mapping = $input->getArgument('mapping');

Expand Down
4 changes: 2 additions & 2 deletions Command/MappingListClassesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ public function __construct(MetadataReader $metadataReader)
$this->metadataReader = $metadataReader;
}

protected function configure()
protected function configure(): void
{
$this
->setName('vich:mapping:list-classes')
->setDescription('Searches for uploadable classes.')
;
}

protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): void
{
$output->writeln('Looking for uploadable classes.');

Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Compiler/RegisterPropelModelsPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class RegisterPropelModelsPass implements CompilerPassInterface
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (!$container->hasParameter('vich_uploader.mappings')) {
return;
Expand Down
11 changes: 4 additions & 7 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ class Configuration implements ConfigurationInterface

protected $supportedStorages = ['gaufrette', 'flysystem', 'file_system'];

/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$tb = new TreeBuilder();
$root = $tb->root('vich_uploader');
Expand All @@ -32,7 +29,7 @@ public function getConfigTreeBuilder()
return $tb;
}

protected function addGeneralSection(ArrayNodeDefinition $node)
protected function addGeneralSection(ArrayNodeDefinition $node): void
{
$node
->children()
Expand Down Expand Up @@ -74,7 +71,7 @@ protected function addGeneralSection(ArrayNodeDefinition $node)
;
}

protected function addMetadataSection(ArrayNodeDefinition $node)
protected function addMetadataSection(ArrayNodeDefinition $node): void
{
$node
->children()
Expand Down Expand Up @@ -103,7 +100,7 @@ protected function addMetadataSection(ArrayNodeDefinition $node)
->end();
}

protected function addMappingsSection(ArrayNodeDefinition $node)
protected function addMappingsSection(ArrayNodeDefinition $node): void
{
$node
->children()
Expand Down
42 changes: 14 additions & 28 deletions DependencyInjection/VichUploaderExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\DefinitionDecorator;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Vich\UploaderBundle\Templating\Helper\UploaderHelper;

/**
Expand All @@ -26,13 +25,7 @@ class VichUploaderExtension extends Extension
'phpcr' => 'doctrine_phpcr.event_subscriber',
];

/**
* Loads the extension.
*
* @param array $configs The configuration
* @param ContainerBuilder $container The container builder
*/
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
Expand All @@ -59,7 +52,7 @@ public function load(array $configs, ContainerBuilder $container)
$this->registerFormTheme($container);
}

protected function loadServicesFiles(ContainerBuilder $container, array $config)
protected function loadServicesFiles(ContainerBuilder $container, array $config): void
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));

Expand All @@ -71,7 +64,7 @@ protected function loadServicesFiles(ContainerBuilder $container, array $config)
$loader->load($file);
}

if (in_array($config['storage'], ['gaufrette', 'flysystem'])) {
if (in_array($config['storage'], ['gaufrette', 'flysystem'], true)) {
$loader->load($config['storage'].'.xml');
}

Expand All @@ -87,7 +80,7 @@ protected function loadServicesFiles(ContainerBuilder $container, array $config)
}
}

protected function registerMetadataDirectories(ContainerBuilder $container, array $config)
protected function registerMetadataDirectories(ContainerBuilder $container, array $config): void
{
$bundles = $container->getParameter('kernel.bundles');

Expand Down Expand Up @@ -129,7 +122,7 @@ protected function registerMetadataDirectories(ContainerBuilder $container, arra
;
}

protected function registerCacheStrategy(ContainerBuilder $container, array $config)
protected function registerCacheStrategy(ContainerBuilder $container, array $config): void
{
if ('none' === $config['metadata']['cache']) {
$container->removeAlias('vich_uploader.metadata.cache');
Expand All @@ -148,7 +141,7 @@ protected function registerCacheStrategy(ContainerBuilder $container, array $con
}
}

protected function fixDbDriverConfig(array $config)
protected function fixDbDriverConfig(array $config): array
{
// mapping with no declared db_driver use the top-level one
foreach ($config['mappings'] as &$mapping) {
Expand All @@ -158,7 +151,7 @@ protected function fixDbDriverConfig(array $config)
return $config;
}

protected function registerListeners(ContainerBuilder $container, array $config)
protected function registerListeners(ContainerBuilder $container, array $config): void
{
$servicesMap = [
'inject_on_load' => ['name' => 'inject', 'priority' => 0],
Expand All @@ -183,7 +176,7 @@ protected function registerListeners(ContainerBuilder $container, array $config)
}
}

protected function createNamerServices(ContainerBuilder $container, array $config)
protected function createNamerServices(ContainerBuilder $container, array $config): array
{
foreach ($config['mappings'] as $name => $mapping) {
if (!empty($mapping['namer']['service'])) {
Expand All @@ -194,24 +187,22 @@ protected function createNamerServices(ContainerBuilder $container, array $confi
return $config;
}

protected function createNamerService(ContainerBuilder $container, $mappingName, array $mapping)
protected function createNamerService(ContainerBuilder $container, $mappingName, array $mapping): array
{
$definitionClassname = $this->getDefinitionClassname();
$serviceId = sprintf('%s.%s', $mapping['namer']['service'], $mappingName);
$container->setDefinition(
$serviceId, new $definitionClassname($mapping['namer']['service'])
$serviceId, new ChildDefinition($mapping['namer']['service'])
);

$mapping['namer']['service'] = $serviceId;

return $mapping;
}

protected function createListener(ContainerBuilder $container, $name, $type, $driver, $priority = 0)
protected function createListener(ContainerBuilder $container, $name, $type, $driver, $priority = 0): void
{
$definitionClassname = $this->getDefinitionClassname();
$definition = $container
->setDefinition(sprintf('vich_uploader.listener.%s.%s', $type, $name), new $definitionClassname(sprintf('vich_uploader.listener.%s.%s', $type, $driver)))
->setDefinition(sprintf('vich_uploader.listener.%s.%s', $type, $name), new ChildDefinition(sprintf('vich_uploader.listener.%s.%s', $type, $driver)))
->replaceArgument(0, $name)
->replaceArgument(1, new Reference('vich_uploader.adapter.'.$driver));

Expand All @@ -221,17 +212,12 @@ protected function createListener(ContainerBuilder $container, $name, $type, $dr
}
}

private function registerFormTheme(ContainerBuilder $container)
private function registerFormTheme(ContainerBuilder $container): void
{
$resources = $container->hasParameter('twig.form.resources') ?
$container->getParameter('twig.form.resources') : [];

array_unshift($resources, '@VichUploader/Form/fields.html.twig');
$container->setParameter('twig.form.resources', $resources);
}

private function getDefinitionClassname(): string
{
return class_exists(ChildDefinition::class) ? ChildDefinition::class : DefinitionDecorator::class;
}
}
Loading

0 comments on commit 2a39e12

Please sign in to comment.