Skip to content

Commit

Permalink
big coding standard fix
Browse files Browse the repository at this point in the history
  • Loading branch information
garak committed Jan 9, 2017
1 parent d3c6f7f commit 5e3d634
Show file tree
Hide file tree
Showing 100 changed files with 884 additions and 890 deletions.
7 changes: 4 additions & 3 deletions Adapter/AdapterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ interface AdapterInterface
/**
* Gets the mapped object from an event.
*
* @param object $event The event.
* @return object The mapped object.
* @param object $event The event
*
* @return object The mapped object
*/
public function getObjectFromArgs($event);

/**
* Recomputes the change set for the object.
*
* @param object $event The event.
* @param object $event The event
*/
public function recomputeChangeSet($event);
}
4 changes: 2 additions & 2 deletions Adapter/ODM/MongoDB/MongoDBAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
class MongoDBAdapter implements AdapterInterface
{
/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function getObjectFromArgs($event)
{
return $event->getDocument();
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function recomputeChangeSet($event)
{
Expand Down
4 changes: 2 additions & 2 deletions Adapter/ORM/DoctrineORMAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
class DoctrineORMAdapter implements AdapterInterface
{
/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function getObjectFromArgs($event)
{
return $event->getEntity();
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function recomputeChangeSet($event)
{
Expand Down
4 changes: 2 additions & 2 deletions Adapter/PHPCR/PHPCRAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
class PHPCRAdapter implements AdapterInterface
{
/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function getObjectFromArgs($event)
{
return $event->getEntity();
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function recomputeChangeSet($event)
{
Expand Down
4 changes: 2 additions & 2 deletions Adapter/Propel/PropelORMAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
class PropelORMAdapter implements AdapterInterface
{
/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function getObjectFromArgs($event)
{
return $event->getSubject();
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function recomputeChangeSet($event)
{
Expand Down
3 changes: 2 additions & 1 deletion Command/MappingDebugClassCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$metadataReader = $this->getContainer()->get('vich_uploader.metadata_reader');
$fqcn = $input->getArgument('fqcn');
$fqcn = $input->getArgument('fqcn');

if (!$metadataReader->isUploadable($fqcn)) {
$output->writeln(sprintf('<error>"%s" is not uploadable.</error>', $fqcn));

return 1;
}

Expand Down
5 changes: 2 additions & 3 deletions Command/MappingDebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

use Vich\UploaderBundle\Exception\MappingNotFoundException;

class MappingDebugCommand extends ContainerAwareCommand
Expand All @@ -23,15 +22,15 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$mappings = $this->getContainer()->getParameter('vich_uploader.mappings');
$mapping = $input->getArgument('mapping');
$mapping = $input->getArgument('mapping');

if (!isset($mappings[$mapping])) {
throw new MappingNotFoundException(sprintf('Mapping "%s" does not exist.', $mapping));
}

$output->writeln(sprintf('Debug information for mapping <info>%s</info>', $mapping));

foreach($mappings[$mapping] as $key => $value) {
foreach ($mappings[$mapping] as $key => $value) {
$output->writeln(sprintf('<comment>%s</comment>: %s', $key, var_export($value, true)));
}
}
Expand Down
2 changes: 1 addition & 1 deletion Command/MappingListClassesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln('Looking for uploadable classes.');

$metadataReader = $this->getContainer()->get('vich_uploader.metadata_reader');
$metadataReader = $this->getContainer()->get('vich_uploader.metadata_reader');
$uploadableClasses = $metadataReader->getUploadableClasses();

foreach ($uploadableClasses as $class) {
Expand Down
9 changes: 4 additions & 5 deletions DependencyInjection/Compiler/RegisterPropelModelsPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

use Vich\UploaderBundle\Exception\MappingNotFoundException;

/**
* Register the uploadable models in BazingaPropelEventDispatcherBundle
* Register the uploadable models in BazingaPropelEventDispatcherBundle.
*
* @author Kévin Gomez <[email protected]>
*/
Expand Down Expand Up @@ -37,9 +36,9 @@ public function process(ContainerBuilder $container)
return;
}

$serviceTypes = array(
$serviceTypes = [
'inject', 'clean', 'remove', 'upload',
);
];

$metadata = $container->get('vich_uploader.metadata_reader');

Expand All @@ -63,7 +62,7 @@ public function process(ContainerBuilder $container)
$definition = $container->getDefinition(sprintf('vich_uploader.listener.%s.%s', $type, $field['mapping']));
$definition->setClass($container->getDefinition($definition->getParent())->getClass());
$definition->setPublic(true);
$definition->addTag('propel.event_subscriber', array('class' => $class));
$definition->addTag('propel.event_subscriber', ['class' => $class]);
}
}
}
Expand Down
30 changes: 20 additions & 10 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*/
class Configuration implements ConfigurationInterface
{
protected $supportedDbDrivers = array('orm', 'mongodb', 'propel', 'phpcr');
protected $supportedStorages = array('gaufrette', 'flysystem', 'file_system');
protected $supportedDbDrivers = ['orm', 'mongodb', 'propel', 'phpcr'];
protected $supportedStorages = ['gaufrette', 'flysystem', 'file_system'];

/**
* Gets the configuration tree builder for the extension.
Expand Down Expand Up @@ -44,24 +44,28 @@ protected function addGeneralSection(ArrayNodeDefinition $node)
->isRequired()
->beforeNormalization()
->ifString()
->then(function ($v) { return strtolower($v); })
->then(function ($v) {
return strtolower($v);
})
->end()
->validate()
->ifNotInArray($this->supportedDbDrivers)
->thenInvalid('The db driver %s is not supported. Please choose one of ' . implode(', ', $this->supportedDbDrivers))
->thenInvalid('The db driver %s is not supported. Please choose one of '.implode(', ', $this->supportedDbDrivers))
->end()
->end()
->scalarNode('storage')
->defaultValue('file_system')
->beforeNormalization()
->ifString()
->then(function ($v) { return strtolower($v); })
->then(function ($v) {
return strtolower($v);
})
->end()
->validate()
->ifTrue(function ($storage) {
return strpos($storage, '@') !== 0 && !in_array($storage, $this->supportedStorages, true);
})
->thenInvalid('The storage %s is not supported. Please choose one of ' . implode(', ', $this->supportedStorages) . ' or provide a service name prefixed with "@".')
->thenInvalid('The storage %s is not supported. Please choose one of '.implode(', ', $this->supportedStorages).' or provide a service name prefixed with "@".')
->end()
->end()
->scalarNode('twig')->defaultTrue()->end()
Expand Down Expand Up @@ -112,7 +116,9 @@ protected function addMappingsSection(ArrayNodeDefinition $node)
->addDefaultsIfNotSet()
->beforeNormalization()
->ifString()
->then(function ($v) { return array('service' => $v, 'options' => array()); })
->then(function ($v) {
return ['service' => $v, 'options' => []];
})
->end()
->children()
->scalarNode('service')->defaultNull()->end()
Expand All @@ -123,7 +129,9 @@ protected function addMappingsSection(ArrayNodeDefinition $node)
->addDefaultsIfNotSet()
->beforeNormalization()
->ifString()
->then(function ($v) { return array('service' => $v, 'options' => array()); })
->then(function ($v) {
return ['service' => $v, 'options' => []];
})
->end()
->children()
->scalarNode('service')->defaultNull()->end()
Expand All @@ -137,11 +145,13 @@ protected function addMappingsSection(ArrayNodeDefinition $node)
->defaultNull()
->beforeNormalization()
->ifString()
->then(function ($v) { return strtolower($v); })
->then(function ($v) {
return strtolower($v);
})
->end()
->validate()
->ifNotInArray($this->supportedDbDrivers)
->thenInvalid('The db driver %s is not supported. Please choose one of ' . implode(', ', $this->supportedDbDrivers))
->thenInvalid('The db driver %s is not supported. Please choose one of '.implode(', ', $this->supportedDbDrivers))
->end()
->end()
->end()
Expand Down
40 changes: 20 additions & 20 deletions DependencyInjection/VichUploaderExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
class VichUploaderExtension extends Extension
{
/**
* @var array $tagMap
* @var array
*/
protected $tagMap = array(
'orm' => 'doctrine.event_subscriber',
'mongodb' => 'doctrine_mongodb.odm.event_subscriber',
'phpcr' => 'doctrine_phpcr.event_subscriber'
);
protected $tagMap = [
'orm' => 'doctrine.event_subscriber',
'mongodb' => 'doctrine_mongodb.odm.event_subscriber',
'phpcr' => 'doctrine_phpcr.event_subscriber',
];

/**
* Loads the extension.
Expand All @@ -47,7 +47,7 @@ public function load(array $configs, ContainerBuilder $container)
if (strpos($config['storage'], '@') === 0) {
$container->setAlias('vich_uploader.storage', substr($config['storage'], 1));
} else {
$container->setAlias('vich_uploader.storage', 'vich_uploader.storage.' . $config['storage']);
$container->setAlias('vich_uploader.storage', 'vich_uploader.storage.'.$config['storage']);
}

$this->loadServicesFiles($container, $config);
Expand All @@ -61,17 +61,17 @@ protected function loadServicesFiles(ContainerBuilder $container, array $config)
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));

$toLoad = array(
$toLoad = [
'adapter.xml', 'listener.xml', 'storage.xml', 'injector.xml',
'templating.xml', 'mapping.xml', 'factory.xml', 'namer.xml',
'form.xml', 'handler.xml'
);
'form.xml', 'handler.xml',
];
foreach ($toLoad as $file) {
$loader->load($file);
}

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

if ($config['twig']) {
Expand All @@ -84,7 +84,7 @@ protected function registerMetadataDirectories(ContainerBuilder $container, arra
$bundles = $container->getParameter('kernel.bundles');

// directories
$directories = array();
$directories = [];
if ($config['metadata']['auto_detection']) {
foreach ($bundles as $class) {
$ref = new \ReflectionClass($class);
Expand Down Expand Up @@ -152,11 +152,11 @@ protected function fixDbDriverConfig(array $config)

protected function registerListeners(ContainerBuilder $container, array $config)
{
$servicesMap = array(
'inject_on_load' => array('name' => 'inject', 'priority' => 0),
'delete_on_update' => array('name' => 'clean', 'priority' => 50),
'delete_on_remove' => array('name' => 'remove', 'priority' => 0)
);
$servicesMap = [
'inject_on_load' => ['name' => 'inject', 'priority' => 0],
'delete_on_update' => ['name' => 'clean', 'priority' => 50],
'delete_on_remove' => ['name' => 'remove', 'priority' => 0],
];

foreach ($config['mappings'] as $name => $mapping) {
$driver = $mapping['db_driver'];
Expand Down Expand Up @@ -188,7 +188,7 @@ protected function createNamerServices(ContainerBuilder $container, array $confi

protected function createNamerService(ContainerBuilder $container, $mappingName, array $mapping)
{
$serviceId = sprintf('%s.%s', $mapping['namer']['service'], $mappingName);
$serviceId = sprintf('%s.%s', $mapping['namer']['service'], $mappingName);
$container->setDefinition(
$serviceId, new DefinitionDecorator($mapping['namer']['service'])
);
Expand All @@ -207,7 +207,7 @@ protected function createListener(ContainerBuilder $container, $name, $type, $dr

// propel does not require tags to work
if (isset($this->tagMap[$driver])) {
$definition->addTag($this->tagMap[$driver], array('priority' => $priority));
$definition->addTag($this->tagMap[$driver], ['priority' => $priority]);
}
}
}
1 change: 0 additions & 1 deletion Event/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Vich\UploaderBundle\Event;

use Symfony\Component\EventDispatcher\Event as BaseEvent;

use Vich\UploaderBundle\Mapping\PropertyMapping;

/**
Expand Down
Loading

0 comments on commit 5e3d634

Please sign in to comment.