Skip to content

Commit 4e31423

Browse files
committed
Merge pull request #6 from php-cache/analysis-86PZMq
Applied fixes from StyleCI
2 parents 4a1fb01 + 9c745ea commit 4e31423

File tree

5 files changed

+75
-39
lines changed

5 files changed

+75
-39
lines changed

src/DependencyInjection/Configuration.php

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of php-cache\doctrine-adapter-bundle package.
5+
*
6+
* (c) 2015-2015 Aaron Scherer <[email protected]>
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
312
namespace Cache\Adapter\DoctrineAdapterBundle\DependencyInjection;
413

514
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
@@ -21,7 +30,7 @@ class Configuration implements ConfigurationInterface
2130
public function getConfigTreeBuilder()
2231
{
2332
$treeBuilder = new TreeBuilder();
24-
$rootNode = $treeBuilder->root('cache_adapter_doctrine');
33+
$rootNode = $treeBuilder->root('cache_adapter_doctrine');
2534

2635
$rootNode->children()
2736
->append($this->getClustersNode())
@@ -36,15 +45,15 @@ public function getConfigTreeBuilder()
3645
private function getClustersNode()
3746
{
3847
$treeBuilder = new TreeBuilder();
39-
$node = $treeBuilder->root('providers');
48+
$node = $treeBuilder->root('providers');
4049

4150
$node
4251
->requiresAtLeastOneElement()
4352
->useAttributeAsKey('name')
4453
->prototype('array')
4554
->children()
4655
->enumNode('type')->isRequired()
47-
->values(array('redis', 'php_file', 'file_system', 'array', 'memcached', 'apc'))
56+
->values(['redis', 'php_file', 'file_system', 'array', 'memcached', 'apc'])
4857
->end()
4958
->scalarNode('id')
5059
->defaultNull()
@@ -135,8 +144,7 @@ function ($v) {
135144
->end()
136145
->end()
137146
->end()
138-
->end()
139-
;
147+
->end();
140148

141149
return $node;
142150
}
@@ -147,19 +155,19 @@ function ($v) {
147155
private function getMemcachedOptions()
148156
{
149157
$treeBuilder = new TreeBuilder();
150-
$node = $treeBuilder->root('memcached');
158+
$node = $treeBuilder->root('memcached');
151159

152160
if (class_exists('\Memcached')) {
153161
$node
154162
->children()
155163
->enumNode('serializer')
156-
->values(array('php', 'igbinary', 'json'))
164+
->values(['php', 'igbinary', 'json'])
157165
->end()
158166
->enumNode('hash')
159-
->values(array('default', 'md5', 'crc', 'fnv1_64', 'fnv1a_64', 'fnv1_32', 'fnv1a_32', 'hsieh', 'murmur'))
167+
->values(['default', 'md5', 'crc', 'fnv1_64', 'fnv1a_64', 'fnv1_32', 'fnv1a_32', 'hsieh', 'murmur'])
160168
->end()
161169
->enumNode('distribution')
162-
->values(array('modula', 'consistent'))
170+
->values(['modula', 'consistent'])
163171
->end()
164172
->booleanNode('compression')->end()
165173
->scalarNode('prefix_key')->end()

src/DependencyInjection/DoctrineAdapterExtension.php

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
<?php
22

3+
/*
4+
* This file is part of php-cache\doctrine-adapter-bundle package.
5+
*
6+
* (c) 2015-2015 Aaron Scherer <[email protected]>
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
312
namespace Cache\Adapter\DoctrineAdapterBundle\DependencyInjection;
413

14+
use Cache\Doctrine\CachePool;
15+
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
516
use Symfony\Component\Config\FileLocator;
617
use Symfony\Component\DependencyInjection\ContainerBuilder;
7-
use Symfony\Component\DependencyInjection\Loader;
8-
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
9-
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
10-
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1118
use Symfony\Component\DependencyInjection\Definition;
19+
use Symfony\Component\DependencyInjection\Loader;
1220
use Symfony\Component\DependencyInjection\Reference;
13-
use Cache\Doctrine\CachePool;
21+
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
1422

1523
/**
16-
*
1724
* @author Aaron Scherer <[email protected]>
1825
* @author Tobias Nyholm <[email protected]>
1926
*/
@@ -22,19 +29,19 @@ class DoctrineAdapterExtension extends Extension
2229
/**
2330
* Array of types, and their options.
2431
*
25-
* @var array
32+
* @type array
2633
*/
2734
protected static $types = [
2835
'memcache' => [
29-
'class' => 'Memcache',
36+
'class' => 'Memcache',
3037
'connect' => 'addServer',
3138
],
3239
'memcached' => [
33-
'class' => 'Cache\Adapter\DoctrineAdapterBundle\ProviderHelper\Memcached',
40+
'class' => 'Cache\Adapter\DoctrineAdapterBundle\ProviderHelper\Memcached',
3441
'connect' => 'addServer',
3542
],
3643
'redis' => [
37-
'class' => 'Redis',
44+
'class' => 'Redis',
3845
'connect' => 'connect',
3946
],
4047
];
@@ -48,7 +55,7 @@ class DoctrineAdapterExtension extends Extension
4855
public function load(array $configs, ContainerBuilder $container)
4956
{
5057
$configuration = new Configuration();
51-
$config = $this->processConfiguration($configuration, $configs);
58+
$config = $this->processConfiguration($configuration, $configs);
5259

5360
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
5461
$loader->load('services.yml');
@@ -58,8 +65,6 @@ public function load(array $configs, ContainerBuilder $container)
5865
$this->process($container);
5966
}
6067

61-
62-
6368
/**
6469
* For each configured provider, build a service.
6570
*
@@ -70,7 +75,7 @@ protected function process(ContainerBuilder $container)
7075
$providers = $container->getParameter('cache_adapter_doctrine.providers');
7176

7277
foreach ($providers as $name => $provider) {
73-
$classParameter = sprintf('cache.doctrine_adapter.%s.class',$provider['type']);
78+
$classParameter = sprintf('cache.doctrine_adapter.%s.class', $provider['type']);
7479
$doctrineServiceId = sprintf('cache.doctrine_adapter.doctrine_service.%s', $provider['type']);
7580
if (!$container->hasParameter($classParameter)) {
7681
throw new InvalidConfigurationException(
@@ -88,16 +93,14 @@ protected function process(ContainerBuilder $container)
8893
}
8994
}
9095

91-
92-
9396
/**
9497
* We need to prepare the doctrine cache providers.
9598
*
9699
* @param ContainerBuilder $container
97-
* @param string $doctrineServiceId
98-
* @param string $doctrineClass
99-
* @param string $name
100-
* @param array $provider
100+
* @param string $doctrineServiceId
101+
* @param string $doctrineClass
102+
* @param string $name
103+
* @param array $provider
101104
*/
102105
protected function createDoctrineCacheDefinition(ContainerBuilder $container, $doctrineServiceId, $doctrineClass, $name, array $provider)
103106
{
@@ -117,7 +120,7 @@ protected function createDoctrineCacheDefinition(ContainerBuilder $container, $d
117120
$providerHelperServiceId = $provider['id'];
118121
} else {
119122
// Create a new cache provider if none is defined
120-
$providerHelperServiceId = sprintf('cache_adapter_doctrine.provider.%s.helper', $name);
123+
$providerHelperServiceId = sprintf('cache_adapter_doctrine.provider.%s.helper', $name);
121124
$providerHelperDefinition = $this->createProviderHelperDefinition($type, $provider);
122125
$container->setDefinition($providerHelperServiceId, $providerHelperDefinition);
123126
}
@@ -151,8 +154,8 @@ protected function createDoctrineCacheDefinition(ContainerBuilder $container, $d
151154
* Make sure to create a PRS-6 service that wraps the doctrine service.
152155
*
153156
* @param ContainerBuilder $container
154-
* @param string $doctrineServiceId
155-
* @param string $name
157+
* @param string $doctrineServiceId
158+
* @param string $name
156159
*/
157160
protected function createPsr7CompliantService(ContainerBuilder $container, $doctrineServiceId, $name)
158161
{
@@ -162,7 +165,7 @@ protected function createPsr7CompliantService(ContainerBuilder $container, $doct
162165
// Register the CacheItemPoolInterface definition
163166
$def = new Definition(CachePool::class);
164167
$def->addArgument(new Reference($doctrineServiceId));
165-
$def->setTags(['cache.provider'=>[]]);
168+
$def->setTags(['cache.provider' => []]);
166169

167170
$container->setDefinition($serviceId, $def);
168171
$container->setAlias('cache.provider.'.$name, $serviceId);

src/DoctrineAdapterBundle.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
<?php
22

3+
/*
4+
* This file is part of php-cache\doctrine-adapter-bundle package.
5+
*
6+
* (c) 2015-2015 Aaron Scherer <[email protected]>
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
312
namespace Cache\Adapter\DoctrineAdapterBundle;
413

5-
use Cache\Adapter\DoctrineAdapterBundle\DependencyInjection\CompilerPass\ServiceBuilderPass;
614
use Cache\Adapter\DoctrineAdapterBundle\DependencyInjection\DoctrineAdapterExtension;
7-
use Symfony\Component\DependencyInjection\ContainerBuilder;
815
use Symfony\Component\HttpKernel\Bundle\Bundle;
916

1017
/**

src/ProviderHelper/Memcached.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of php-cache\doctrine-adapter-bundle package.
5+
*
6+
* (c) 2015-2015 Aaron Scherer <[email protected]>
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
312
namespace Cache\Adapter\DoctrineAdapterBundle\ProviderHelper;
413

514
/**

tests/DependencyInjection/DoctrineCacheExtensionTest.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of php-cache\doctrine-adapter-bundle package.
5+
*
6+
* (c) 2015-2015 Aaron Scherer <[email protected]>
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
312
namespace Cache\Adapter\DoctrineAdapterBundle\Tests\DependencyInjection;
413

514
use Cache\Adapter\DoctrineAdapterBundle\DependencyInjection\DoctrineAdapterExtension;
@@ -9,15 +18,15 @@ class DoctrineCacheExtensionTest extends AbstractExtensionTestCase
918
{
1019
protected function getContainerExtensions()
1120
{
12-
return array(
21+
return [
1322
new DoctrineAdapterExtension(),
14-
);
23+
];
1524
}
1625

1726
public function testThatProvidersExists()
1827
{
19-
$providers = array('foo' => ['type' => 'apc']);
20-
$this->load(array('providers' => $providers));
28+
$providers = ['foo' => ['type' => 'apc']];
29+
$this->load(['providers' => $providers]);
2130

2231
$this->assertContainerBuilderHasParameter('cache_adapter_doctrine.providers');
2332
}

0 commit comments

Comments
 (0)