Skip to content

Commit 873c8fb

Browse files
committed
PHP CS fixes
1 parent f5d8f28 commit 873c8fb

File tree

3 files changed

+28
-22
lines changed

3 files changed

+28
-22
lines changed

Imagine/Cache/CacheManager.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ class CacheManager
5555
protected $defaultResolver;
5656

5757
/**
58-
* @var bool
58+
* @var CacheWarmer
5959
*/
60-
private $webpGenerate;
60+
protected $cacheWarmer;
6161

6262
/**
63-
* @var CacheWarmer
63+
* @var bool
6464
*/
65-
protected $cacheWarmer;
65+
private $webpGenerate;
6666

6767
/**
6868
* Constructs the cache manager to handle Resolvers based on the provided FilterConfiguration.

Imagine/Cache/CacheWarmer.php

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

3+
/*
4+
* This file is part of the `liip/LiipImagineBundle` project.
5+
*
6+
* (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
7+
*
8+
* For the full copyright and license information, please view the LICENSE.md
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Liip\ImagineBundle\Imagine\Cache;
413

514
use Liip\ImagineBundle\Imagine\Cache\Warmer\WarmerInterface;
@@ -13,11 +22,10 @@
1322
*/
1423
class CacheWarmer
1524
{
16-
1725
/**
1826
* @var WarmerInterface[]
1927
*/
20-
protected $warmers = array();
28+
protected $warmers = [];
2129

2230
/**
2331
* Chunk size to query warmer in one step
@@ -97,34 +105,34 @@ public function addWarmer($name, WarmerInterface $warmer)
97105

98106
/**
99107
* @param bool $force If set to true, cache is warmed up for paths already stored in cached (regenerate thumbs)
100-
* @param null|array $selectedWarmers An optional array of warmers to process, if null - all warmers will be processed
108+
* @param array|null $selectedWarmers An optional array of warmers to process, if null - all warmers will be processed
101109
*
102-
* @return void
103110
* @throws \InvalidArgumentException
111+
*
112+
* @return void
104113
*/
105114
public function warm($force = false, $selectedWarmers = null)
106115
{
107116
$filtersByWarmer = $this->getFiltersByWarmers();
108117
if (!$filtersByWarmer) {
109-
$this->log(sprintf('No warmes are configured - add some as `warmers` param in your filter sets'));
118+
$this->log('No warmes are configured - add some as `warmers` param in your filter sets');
119+
110120
return;
111121
}
112122

113123
foreach ($filtersByWarmer as $warmerName => $filters) {
114-
if (isset($selectedWarmers) && !empty($selectedWarmers) && !in_array($warmerName, $selectedWarmers)) {
124+
if (isset($selectedWarmers) && !empty($selectedWarmers) && !in_array($warmerName, $selectedWarmers, true)) {
115125
$this->log(
116126
sprintf(
117127
'Skipping warmer %s as it\'s not listed in selected warmers: [%s]',
118128
$warmerName,
119-
join(', ', $selectedWarmers)
129+
implode(', ', $selectedWarmers)
120130
)
121131
);
122132
continue;
123133
}
124134
if (!isset($this->warmers[$warmerName])) {
125-
throw new \InvalidArgumentException(sprintf(
126-
'Could not find warmer "%s"', $warmerName
127-
));
135+
throw new \InvalidArgumentException(sprintf('Could not find warmer "%s"', $warmerName));
128136
}
129137

130138
$this->log(sprintf('Processing warmer "%s"', $warmerName));
@@ -153,9 +161,7 @@ public function clearWarmed($paths, $filters)
153161
foreach ($filtersByWarmer as $warmerName => $warmerFilters) {
154162
if (array_intersect($filters, $warmerFilters)) {
155163
if (!isset($this->warmers[$warmerName])) {
156-
throw new \InvalidArgumentException(sprintf(
157-
'Could not find warmer "%s"', $warmerName
158-
));
164+
throw new \InvalidArgumentException(sprintf('Could not find warmer "%s"', $warmerName));
159165
}
160166
$warmer = $this->warmers[$warmerName];
161167
$warmer->clearWarmed($paths);
@@ -166,12 +172,12 @@ public function clearWarmed($paths, $filters)
166172
protected function getFiltersByWarmers()
167173
{
168174
$all = $this->filterManager->getFilterConfiguration()->all();
169-
$warmers = array();
175+
$warmers = [];
170176
foreach ($all as $filterSet => $config) {
171177
if (isset($config['warmers']) && $config['warmers']) {
172178
foreach ($config['warmers'] as $warmer) {
173179
if (!isset($warmers[$warmer])) {
174-
$warmers[$warmer] = array($filterSet);
180+
$warmers[$warmer] = [$filterSet];
175181
} else {
176182
$warmers[$warmer][] = $filterSet;
177183
}
@@ -194,14 +200,14 @@ protected function warmPaths($paths, $filters, $force)
194200
$successfulWarmedPaths = [];
195201
foreach ($paths as $pathData) {
196202
$aPath = $pathData['path'];
197-
$binaries = array();
203+
$binaries = [];
198204
foreach ($filters as $filter) {
199205
$this->log(sprintf('Warming up path "%s" for filter "%s"', $aPath, $filter));
200206

201207
$isStored = $this->cacheManager->isStored($aPath, $filter);
202208
if ($force || !$isStored) {
203209
// this is to avoid loading binary with the same loader for multiple filters
204-
$loader = $this->dataManager->getLoader($filter);
210+
$loader = $this->dataManager->getLoader($filter);
205211
$isStored = false;
206212

207213
try {

LiipImagineBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function build(ContainerBuilder $container)
4949
$container->addCompilerPass(new PostProcessorsCompilerPass());
5050
$container->addCompilerPass(new ResolversCompilerPass());
5151
$container->addCompilerPass(new MetadataReaderCompilerPass());
52-
$container->addCompilerPass(new CacheWarmersCompilerPass);
52+
$container->addCompilerPass(new CacheWarmersCompilerPass());
5353

5454
if (class_exists(AddTopicMetaPass::class)) {
5555
$container->addCompilerPass(AddTopicMetaPass::create()

0 commit comments

Comments
 (0)