Permalink
Browse files

Apply fixes from StyleCI (#103)

  • Loading branch information...
Nyholm committed Mar 6, 2018
1 parent 17e93d7 commit 2f2c23cc1dd78f70dae081c06a1675b900def5c9
Showing with 132 additions and 128 deletions.
  1. +1 −1 Loader/ExtensionConfigurationBuilder.php
  2. +1 −0 Loader/LoaderFactoryInterface.php
  3. +2 −2 PhpUnit/AbstractCompilerPassTestCase.php
  4. +8 −8 PhpUnit/AbstractContainerBuilderTestCase.php
  5. +4 −4 PhpUnit/AbstractExtensionTestCase.php
  6. +1 −1 PhpUnit/ContainerBuilderHasAliasConstraint.php
  7. +0 −1 PhpUnit/DefinitionHasArgumentConstraint.php
  8. +1 −1 PhpUnit/DefinitionHasMethodCallConstraint.php
  9. +1 −1 PhpUnit/DefinitionHasTagConstraint.php
  10. +1 −1 Tests/Fixtures/CollectServicesAndAddThemWithMethodCallsCompilerPass.php
  11. +2 −2 Tests/Fixtures/CollectServicesAndSetThemAsArgumentCompilerPass.php
  12. +3 −3 Tests/Fixtures/MatthiasDependencyInjectionTestExtension.php
  13. +1 −1 Tests/Fixtures/SimpleConfiguration.php
  14. +4 −3 Tests/Fixtures/simple.php
  15. +7 −6 Tests/Loader/LoaderFactoryTest.php
  16. +9 −9 Tests/PhpUnit/AbstractCompilerPassTestCaseTest.php
  17. +10 −10 Tests/PhpUnit/AbstractExtensionConfigurationTestCaseTest.php
  18. +5 −5 Tests/PhpUnit/AbstractExtensionTestCaseTest.php
  19. +3 −3 Tests/PhpUnit/AbstractPrependExtensionTestCaseTest.php
  20. +7 −7 Tests/PhpUnit/ContainerBuilderHasAliasConstraintTest.php
  21. +11 −11 Tests/PhpUnit/ContainerBuilderHasServiceDefinitionConstraintTest.php
  22. +7 −7 Tests/PhpUnit/ContainerHasParameterConstraintTest.php
  23. +16 −14 Tests/PhpUnit/DefinitionHasArgumentConstraintTest.php
  24. +12 −12 Tests/PhpUnit/DefinitionHasMethodCallConstraintTest.php
  25. +10 −10 Tests/PhpUnit/DefinitionHasTagConstraintTest.php
  26. +5 −5 Tests/PhpUnit/DefinitionIsChildOfConstraintTest.php
@@ -8,7 +8,7 @@
class ExtensionConfigurationBuilder
{
private $extension;
private $sources = array();
private $sources = [];
private $loaderFactory;
public function __construct(LoaderFactoryInterface $loaderFactory)
@@ -10,6 +10,7 @@
/**
* @param ContainerBuilder $container
* @param $source
*
* @return LoaderInterface
*/
public function createLoaderForSource(ContainerBuilder $container, $source);
@@ -8,14 +8,14 @@
{
/**
* Register the compiler pass under test, just like you would do inside a bundle's load()
* method:
* method:.
*
* $container->addCompilerPass(new MyCompilerPass());
*/
abstract protected function registerCompilerPass(ContainerBuilder $container);
/**
* This test will run the compile method
* This test will run the compile method.
*
* @test
*/
@@ -17,8 +17,8 @@
protected function setUp()
{
$this->container = new ContainerBuilder();
$this->container->getCompilerPassConfig()->setOptimizationPasses(array());
$this->container->getCompilerPassConfig()->setRemovingPasses(array());
$this->container->getCompilerPassConfig()->setOptimizationPasses([]);
$this->container->getCompilerPassConfig()->setRemovingPasses([]);
}
protected function tearDown()
@@ -31,6 +31,7 @@ protected function tearDown()
*
* @param $serviceId
* @param $class
*
* @return Definition
*/
protected function registerService($serviceId, $class)
@@ -101,7 +102,6 @@ protected function assertContainerBuilderNotHasService($serviceId)
);
}
/**
* Assert that the ContainerBuilder for this test has a synthetic service with the given id.
*
@@ -171,15 +171,15 @@ protected function assertContainerBuilderHasServiceDefinitionWithArgument(
* Assert that the ContainerBuilder for this test has a service definition with the given id, which has a method
* call to the given method with the given arguments.
*
* @param string $serviceId
* @param string $method
* @param array $arguments
* @param string $serviceId
* @param string $method
* @param array $arguments
* @param int|null $index
*/
protected function assertContainerBuilderHasServiceDefinitionWithMethodCall(
$serviceId,
$method,
array $arguments = array(),
array $arguments = [],
$index = null
) {
$definition = $this->container->findDefinition($serviceId);
@@ -198,7 +198,7 @@ protected function assertContainerBuilderHasServiceDefinitionWithMethodCall(
protected function assertContainerBuilderHasServiceDefinitionWithTag(
$serviceId,
$tag,
array $attributes = array()
array $attributes = []
) {
$definition = $this->container->findDefinition($serviceId);
@@ -22,13 +22,13 @@
*/
protected function getMinimalConfiguration()
{
return array();
return [];
}
/**
* Setup for each test: creates a new ContainerBuilder,
* registers the ValidateServiceDefinitionsPass which will validate all defined services when
* the container is compiled
* the container is compiled.
*
* @see AbstractExtensionTestCase::tearDown()
*/
@@ -47,9 +47,9 @@ protected function setUp()
*
* @param array $configurationValues
*/
protected function load(array $configurationValues = array())
protected function load(array $configurationValues = [])
{
$configs = array($this->getMinimalConfiguration(), $configurationValues);
$configs = [$this->getMinimalConfiguration(), $configurationValues];
foreach ($this->container->getExtensions() as $extension) {
if ($extension instanceof PrependExtensionInterface) {
@@ -29,7 +29,7 @@ public function __construct($aliasId, $expectedServiceId = null)
public function toString(): string
{
return 'has an alias "' . $this->aliasId . '" for service "' . $this->expectedServiceId . '"';
return 'has an alias "'.$this->aliasId.'" for service "'.$this->expectedServiceId.'"';
}
public function evaluate($other, $description = '', $returnResult = false)
@@ -9,7 +9,6 @@
class DefinitionHasArgumentConstraint extends Constraint
{
/**
* @var int|string
*/
@@ -12,7 +12,7 @@ class DefinitionHasMethodCallConstraint extends Constraint
private $arguments;
private $index;
public function __construct($methodName, array $arguments = array(), $index = null)
public function __construct($methodName, array $arguments = [], $index = null)
{
if ($index !== null && !is_int($index)) {
throw new \InvalidArgumentException(sprintf('Expected value of integer type for method call index, "%s" given.', is_object($index) ? get_class($index) : gettype($index)));
@@ -11,7 +11,7 @@ class DefinitionHasTagConstraint extends Constraint
private $name;
private $attributes;
public function __construct($name, array $attributes = array())
public function __construct($name, array $attributes = [])
{
parent::__construct();
$this->name = $name;
@@ -17,7 +17,7 @@ public function process(ContainerBuilder $container)
$service = $container->getDefinition('collecting_service_id');
foreach ($container->findTaggedServiceIds('collect_with_method_calls') as $serviceId => $tags) {
$service->addMethodCall('add', array(new Reference($serviceId)));
$service->addMethodCall('add', [new Reference($serviceId)]);
}
}
}
@@ -16,11 +16,11 @@ public function process(ContainerBuilder $container)
$service = $container->getDefinition('collecting_service_id');
$collectedServices = array();
$collectedServices = [];
foreach ($container->findTaggedServiceIds('collect_with_argument') as $serviceId => $tags) {
$collectedServices[] = new Reference($serviceId);
}
$service->setArguments(array($collectedServices));
$service->setArguments([$collectedServices]);
}
}
@@ -2,11 +2,11 @@
namespace Matthias\SymfonyDependencyInjectionTest\Tests\Fixtures;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\Config\FileLocator;
class MatthiasDependencyInjectionTestExtension implements ExtensionInterface
{
@@ -21,7 +21,7 @@ public function load(array $config, ContainerBuilder $container)
// manually add a service definition
$definition = new Definition('stdClass');
$definition->setArguments(array('first', 'second'));
$definition->setArguments(['first', 'second']);
$container->setDefinition('manual_service_id', $definition);
// replace an argument of a previously defined service definition
@@ -2,8 +2,8 @@
namespace Matthias\SymfonyDependencyInjectionTest\Tests\Fixtures;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
class SimpleConfiguration implements ConfigurationInterface
{
@@ -1,9 +1,10 @@
<?php
/* @var $container \Symfony\Component\DependencyInjection\ContainerBuilder */
$container->loadFromExtension(
'simple',
array(
'types' => array('php')
)
[
'types' => ['php'],
]
);
@@ -24,7 +24,8 @@ public function it_creates_the_appropriate_file_loader_based_on_the_extension($f
*/
public function it_creates_a_closure_loader_when_source_is_a_closure()
{
$source = function() {};
$source = function () {
};
$factory = new LoaderFactory();
$loader = $factory->createLoaderForSource($this->createMockContainerBuilder(), $source);
@@ -33,11 +34,11 @@ public function it_creates_a_closure_loader_when_source_is_a_closure()
public function fileProvider()
{
return array(
array('file.xml', 'Symfony\Component\DependencyInjection\Loader\XmlFileLoader'),
array('file.yml', 'Symfony\Component\DependencyInjection\Loader\YamlFileLoader'),
array('file.php', 'Symfony\Component\DependencyInjection\Loader\PhpFileLoader')
);
return [
['file.xml', 'Symfony\Component\DependencyInjection\Loader\XmlFileLoader'],
['file.yml', 'Symfony\Component\DependencyInjection\Loader\YamlFileLoader'],
['file.php', 'Symfony\Component\DependencyInjection\Loader\PhpFileLoader'],
];
}
private function createMockContainerBuilder()
@@ -38,17 +38,17 @@ public function if_compiler_pass_collects_services_by_adding_method_calls_these_
$this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
'collecting_service_id',
'add',
array(
new Reference('collected_service_1')
)
[
new Reference('collected_service_1'),
]
);
$this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
'collecting_service_id',
'add',
array(
new Reference('collected_service_2')
)
[
new Reference('collected_service_2'),
]
);
}
@@ -70,10 +70,10 @@ public function if_compiler_pass_collects_services_by_setting_constructor_argume
$this->compile();
$expectedReferences = array(
$expectedReferences = [
new Reference('collected_service_1'),
new Reference('collected_service_2')
);
new Reference('collected_service_2'),
];
$this->assertContainerBuilderHasServiceDefinitionWithArgument('collecting_service_id', 0, $expectedReferences);
}
@@ -2,9 +2,9 @@
namespace Matthias\SymfonyDependencyInjectionTest\Tests\PhpUnit;
use Matthias\SymfonyDependencyInjectionTest\Tests\Fixtures\SimpleExtension;
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionConfigurationTestCase;
use Matthias\SymfonyDependencyInjectionTest\Tests\Fixtures\SimpleConfiguration;
use Matthias\SymfonyDependencyInjectionTest\Tests\Fixtures\SimpleExtension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class AbstractExtensionConfigurationTestCaseTest extends AbstractExtensionConfigurationTestCase
@@ -24,21 +24,21 @@ protected function getConfiguration()
*/
public function it_compares_expected_configuration_values_with_values_loaded_from_files()
{
$sources = array(
__DIR__ . '/../Fixtures/simple.php',
$sources = [
__DIR__.'/../Fixtures/simple.php',
function (ContainerBuilder $container) {
$container->loadFromExtension(
'simple',
array(
'types' => array('closure')
)
[
'types' => ['closure'],
]
);
},
__DIR__ . '/../Fixtures/simple.yml',
__DIR__ . '/../Fixtures/simple.xml',
);
__DIR__.'/../Fixtures/simple.yml',
__DIR__.'/../Fixtures/simple.xml',
];
$expectedConfiguration = array('types' => array('php', 'closure', 'yml', 'xml'));
$expectedConfiguration = ['types' => ['php', 'closure', 'yml', 'xml']];
$this->assertProcessedConfigurationEquals($expectedConfiguration, $sources);
}
@@ -10,9 +10,9 @@ class AbstractExtensionTestCaseTest extends AbstractExtensionTestCase
{
protected function getContainerExtensions()
{
return array(
new MatthiasDependencyInjectionTestExtension()
);
return [
new MatthiasDependencyInjectionTestExtension(),
];
}
/**
@@ -230,7 +230,7 @@ public function if_definition_should_have_a_method_call_and_it_has_not_it_fails(
$this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
'service_with_method_calls_id',
'wrongMethodName',
array('some argument')
['some argument']
);
}
@@ -247,7 +247,7 @@ public function if_definition_should_have_a_certain_arguments_for_a_method_call_
$this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
'service_with_method_calls_id',
'theRightMethodName',
array('a wrong argument')
['a wrong argument']
);
}
@@ -11,10 +11,10 @@ class AbstractPrependExtensionTestCaseTest extends AbstractExtensionTestCase
{
protected function getContainerExtensions()
{
return array(
return [
new PrependableTestExtension(),
new NonPrependableTestExtension()
);
new NonPrependableTestExtension(),
];
}
/**
Oops, something went wrong.

0 comments on commit 2f2c23c

Please sign in to comment.