Skip to content

Commit 28bab8f

Browse files
committed
Merge pull request #14 from php-cache/analysis-87wpj8
Applied fixes from StyleCI
2 parents dc0577a + ffcb9e2 commit 28bab8f

15 files changed

+86
-89
lines changed

src/Cache/LoggingCachePool.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@
1313

1414
use Psr\Cache\CacheItemInterface;
1515
use Psr\Cache\CacheItemPoolInterface;
16-
use Psr\Cache\InvalidArgumentException;
1716

1817
/**
1918
* @author Aaron Scherer <[email protected]>
2019
*/
2120
class LoggingCachePool implements CacheItemPoolInterface
2221
{
2322
/**
24-
* @var array $calls
23+
* @type array
2524
*/
2625
private $calls = [];
2726

@@ -91,7 +90,7 @@ private function timeCall($name, array $arguments = null)
9190
$result = call_user_func_array([$this->cachePool, $name], $arguments);
9291
$time = microtime(true) - $start;
9392

94-
$object = (object)compact('name', 'arguments', 'start', 'time', 'result');
93+
$object = (object) compact('name', 'arguments', 'start', 'time', 'result');
9594

9695
return $object;
9796
}

src/CacheBundle.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111

1212
namespace Cache\CacheBundle;
1313

14-
use Symfony\Component\HttpKernel\Bundle\Bundle;
15-
use Symfony\Component\DependencyInjection\ContainerBuilder;
1614
use Cache\CacheBundle\DependencyInjection\Compiler;
15+
use Symfony\Component\DependencyInjection\ContainerBuilder;
16+
use Symfony\Component\HttpKernel\Bundle\Bundle;
1717

1818
/**
19-
* Class AequasiCacheBundle
19+
* Class AequasiCacheBundle.
2020
*
2121
* @author Aaron Scherer <[email protected]>
2222
*/
2323
class CacheBundle extends Bundle
2424
{
2525
/**
26-
* {@inheritDoc}
26+
* {@inheritdoc}
2727
*/
2828
public function build(ContainerBuilder $container)
2929
{

src/Command/CacheFlushCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
use Cache\Taggable\TaggablePoolInterface;
1515
use Psr\Cache\CacheItemPoolInterface;
1616
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
17+
use Symfony\Component\Console\Input\InputArgument;
1718
use Symfony\Component\Console\Input\InputInterface;
1819
use Symfony\Component\Console\Output\OutputInterface;
19-
use Symfony\Component\Console\Input\InputArgument;
2020

2121
/**
2222
* Class CacheFlushCommand.
@@ -41,7 +41,7 @@ protected function configure()
4141
protected function execute(InputInterface $input, OutputInterface $output)
4242
{
4343
$validTypes = ['session', 'routing', 'doctrine'];
44-
$type = $input->getArgument('type');
44+
$type = $input->getArgument('type');
4545
if ($type === 'all') {
4646
foreach ($validTypes as $type) {
4747
$this->clearCacheForType($type);
@@ -69,7 +69,7 @@ private function clearCacheForType($type)
6969
{
7070
$serviceId = $this->getContainer()->getParameter(sprintf('cache.%s%.service_id', $type));
7171

72-
/** @var CacheItemPoolInterface $service */
72+
/** @type CacheItemPoolInterface $service */
7373
$service = $this->getContainer()->get($serviceId);
7474
if ($service instanceof TaggablePoolInterface) {
7575
$service->clear([$type]);

src/DataCollector/CacheDataCollector.php

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,32 @@
1212
namespace Cache\CacheBundle\DataCollector;
1313

1414
use Cache\CacheBundle\Cache\LoggingCachePool;
15-
use Cache\CacheBundle\Service\CacheService;
1615
use Symfony\Component\HttpFoundation\Request;
1716
use Symfony\Component\HttpFoundation\Response;
1817
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
1918

2019
/**
21-
* Class CacheDataCollector
20+
* Class CacheDataCollector.
2221
*
2322
* @author Aaron Scherer <[email protected]>
2423
*/
2524
class CacheDataCollector extends DataCollector
2625
{
2726
/**
28-
* Template name
27+
* Template name.
2928
*
3029
* @type string
3130
*/
3231
const TEMPLATE = 'CacheBundle:Collector:cache.html.twig';
3332

3433
/**
35-
* @var LoggingCachePool[]
34+
* @type LoggingCachePool[]
3635
*/
3736
private $instances = [];
3837

3938
/**
40-
* @param $name
41-
* @param LoggingCachePool $instance
39+
* @param $name
40+
* @param LoggingCachePool $instance
4241
*/
4342
public function addInstance($name, LoggingCachePool $instance)
4443
{
@@ -59,7 +58,7 @@ public function collect(Request $request, Response $response, \Exception $except
5958
$empty = ['calls' => [], 'config' => [], 'options' => [], 'statistics' => []];
6059
$this->data = ['instances' => $empty, 'total' => $empty];
6160
foreach ($this->instances as $name => $instance) {
62-
$calls = $instance->getCalls();
61+
$calls = $instance->getCalls();
6362
$this->data['instances']['calls'][$name] = $calls;
6463
}
6564
$this->data['instances']['statistics'] = $this->calculateStatistics();
@@ -79,7 +78,7 @@ public function getName()
7978
}
8079

8180
/**
82-
* Method returns amount of logged Cache reads: "get" calls
81+
* Method returns amount of logged Cache reads: "get" calls.
8382
*
8483
* @return array
8584
*/
@@ -89,7 +88,7 @@ public function getStatistics()
8988
}
9089

9190
/**
92-
* Method returns the statistic totals
91+
* Method returns the statistic totals.
9392
*
9493
* @return array
9594
*/
@@ -99,7 +98,7 @@ public function getTotals()
9998
}
10099

101100
/**
102-
* Method returns all logged Cache call objects
101+
* Method returns all logged Cache call objects.
103102
*
104103
* @return mixed
105104
*/
@@ -122,24 +121,24 @@ private function calculateStatistics()
122121
'hits' => 0,
123122
'misses' => 0,
124123
'writes' => 0,
125-
'deletes' => 0
124+
'deletes' => 0,
126125
];
127126
foreach ($calls as $call) {
128127
$statistics[$name]['calls'] += 1;
129128
$statistics[$name]['time'] += $call->time;
130-
if ($call->name == 'fetch') {
129+
if ($call->name === 'fetch') {
131130
$statistics[$name]['reads'] += 1;
132131
if ($call->result !== false) {
133132
$statistics[$name]['hits'] += 1;
134133
} else {
135134
$statistics[$name]['misses'] += 1;
136135
}
137-
} elseif ($call->name == 'contains' && $call->result === false) {
136+
} elseif ($call->name === 'contains' && $call->result === false) {
138137
$statistics[$name]['reads'] += 1;
139138
$statistics[$name]['misses'] += 1;
140-
} elseif ($call->name == 'save') {
139+
} elseif ($call->name === 'save') {
141140
$statistics[$name]['writes'] += 1;
142-
} elseif ($call->name == 'delete') {
141+
} elseif ($call->name === 'delete') {
143142
$statistics[$name]['deletes'] += 1;
144143
}
145144
}

src/DependencyInjection/CacheExtension.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,18 @@
1313

1414
use Symfony\Component\Config\FileLocator;
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
16+
use Symfony\Component\DependencyInjection\Loader;
1617
use Symfony\Component\DependencyInjection\Reference;
1718
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
18-
use Symfony\Component\DependencyInjection\Loader;
19-
2019

2120
/**
22-
*
2321
* @author Aaron Scherer <[email protected]>
2422
* @author Tobias Nyholm <[email protected]>
2523
*/
2624
class CacheExtension extends Extension
2725
{
2826
/**
29-
* Loads the configs for Cache and puts data into the container
27+
* Loads the configs for Cache and puts data into the container.
3028
*
3129
* @param array $configs Array of configs
3230
* @param ContainerBuilder $container Container Object

src/DependencyInjection/Compiler/BaseCompilerPass.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
1616

1717
/**
18-
* Class BaseCompilerPass
18+
* Class BaseCompilerPass.
1919
*
2020
* @author Aaron Scherer <[email protected]>
2121
*/
2222
abstract class BaseCompilerPass implements CompilerPassInterface
2323
{
2424
/**
25-
* @var ContainerBuilder
25+
* @type ContainerBuilder
2626
*/
2727
protected $container;
2828

2929
/**
30-
* {@inheritDoc}
30+
* {@inheritdoc}
3131
*/
3232
public function process(ContainerBuilder $container)
3333
{

src/DependencyInjection/Compiler/DataCollectorCompilerPass.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@
1515
use Symfony\Component\DependencyInjection\Reference;
1616

1717
/**
18-
* Class DataCollectorCompilerPass
18+
* Class DataCollectorCompilerPass.
1919
*
2020
* @author Aaron Scherer <[email protected]>
2121
* @author Tobias Nyholm <[email protected]>
2222
*/
2323
class DataCollectorCompilerPass extends BaseCompilerPass
2424
{
2525
/**
26-
* {@inheritDoc}
26+
* {@inheritdoc}
2727
*/
2828
protected function prepare()
2929
{
3030
$collectorDefinition = $this->container->getDefinition('data_collector.cache');
31-
$serviceIds = $this->container->findTaggedServiceIds('cache.provider');
31+
$serviceIds = $this->container->findTaggedServiceIds('cache.provider');
3232

3333
foreach (array_keys($serviceIds) as $id) {
3434

src/DependencyInjection/Compiler/DoctrineSupportCompilerPass.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@
1313

1414
use Cache\Bridge\DoctrineCacheBridge;
1515
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
16-
use Symfony\Component\DependencyInjection\Definition;
1716
use Symfony\Component\DependencyInjection\Reference;
1817

1918
/**
20-
* Class DoctrineSupportCompilerPass
19+
* Class DoctrineSupportCompilerPass.
2120
*
2221
* @author Aaron Scherer <[email protected]>
2322
* @author Tobias Nyholm <[email protected]>
2423
*/
2524
class DoctrineSupportCompilerPass extends BaseCompilerPass
2625
{
2726
/**
28-
* @return void
2927
* @throws \Exception
28+
*
29+
* @return void
3030
*/
3131
protected function prepare()
3232
{
@@ -37,7 +37,7 @@ protected function prepare()
3737

3838
if (!$this->hasDoctrine()) {
3939
throw new \Exception(
40-
"Not able to find any doctrine caches to implement. Ensure you have Doctrine ORM or ODM"
40+
'Not able to find any doctrine caches to implement. Ensure you have Doctrine ORM or ODM'
4141
);
4242
}
4343

@@ -68,15 +68,15 @@ protected function enableDoctrineSupport(array $config)
6868

6969
// Doctrine can't talk to a PSR-6 cache, so we need a bridge
7070
$bridgeServiceId = sprintf('cache.provider.doctrine.%s.bridge', $cacheType);
71-
$bridgeDef = $this->container->register($bridgeServiceId, DoctrineCacheBridge::class);
71+
$bridgeDef = $this->container->register($bridgeServiceId, DoctrineCacheBridge::class);
7272
$bridgeDef->addArgument(0, new Reference($cacheData['service_id']))
7373
->setPublic(false);
7474

7575
foreach ($cacheData[$type] as $manager) {
7676
$doctrineDefinitionId =
7777
sprintf(
78-
"doctrine.%s.%s_%s_cache",
79-
($type == 'entity_managers' ? 'orm' : 'odm'),
78+
'doctrine.%s.%s_%s_cache',
79+
($type === 'entity_managers' ? 'orm' : 'odm'),
8080
$manager,
8181
$cacheType
8282
);
@@ -89,7 +89,7 @@ protected function enableDoctrineSupport(array $config)
8989
}
9090

9191
/**
92-
* Checks to see if there are ORM's or ODM's
92+
* Checks to see if there are ORM's or ODM's.
9393
*
9494
* @return bool
9595
*/

src/DependencyInjection/Compiler/SessionSupportCompilerPass.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Symfony\Component\DependencyInjection\Reference;
1818

1919
/**
20-
* Class SessionSupportCompilerPass
20+
* Class SessionSupportCompilerPass.
2121
*
2222
* @author Aaron Scherer <[email protected]>
2323
*/
@@ -35,14 +35,14 @@ protected function prepare()
3535

3636
// If there is no active session support, throw
3737
if (!$this->container->hasAlias('session.storage')) {
38-
throw new \Exception("Session cache support cannot be enabled if there is no session.storage service");
38+
throw new \Exception('Session cache support cannot be enabled if there is no session.storage service');
3939
}
4040

4141
$this->enableSessionSupport($this->container->getParameter($this->getAlias().'.session'));
4242
}
4343

4444
/**
45-
* Enables session support for memcached
45+
* Enables session support for memcached.
4646
*
4747
* @param array $config Configuration for bundle
4848
*

0 commit comments

Comments
 (0)