Skip to content

Commit f65a530

Browse files
authored
Merge pull request #939 from robfrawley/feature-use-version-id-instead-of-version-numbers
Use simplified Symfony version comparison operation and CS fixes
2 parents ef1d95a + 6cef67f commit f65a530

9 files changed

+24
-27
lines changed

Async/CacheResolved.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Liip\ImagineBundle\Async;
34

45
use Enqueue\Util\JSON;
@@ -14,9 +15,9 @@ class CacheResolved implements \JsonSerializable
1415
* @var \string[]
1516
*/
1617
private $uris;
17-
18+
1819
/**
19-
* @param string $path
20+
* @param string $path
2021
* @param string[]|null $uris
2122
*/
2223
public function __construct($path, array $uris)

Async/ResolveCache.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Liip\ImagineBundle\Async;
34

45
use Enqueue\Util\JSON;
@@ -21,9 +22,9 @@ class ResolveCache implements \JsonSerializable
2122
private $force;
2223

2324
/**
24-
* @param string $path
25+
* @param string $path
2526
* @param string[]|null $filters
26-
* @param bool $force
27+
* @param bool $force
2728
*/
2829
public function __construct($path, array $filters = null, $force = false)
2930
{

Async/ResolveCacheProcessor.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Liip\ImagineBundle\Async;
34

45
use Enqueue\Client\ProducerInterface;
@@ -35,9 +36,9 @@ class ResolveCacheProcessor implements PsrProcessor, TopicSubscriberInterface, Q
3536
private $producer;
3637

3738
/**
38-
* @param CacheManager $cacheManager
39-
* @param FilterManager $filterManager
40-
* @param DataManager $dataManager
39+
* @param CacheManager $cacheManager
40+
* @param FilterManager $filterManager
41+
* @param DataManager $dataManager
4142
* @param ProducerInterface $producer
4243
*/
4344
public function __construct(

Async/Topics.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Liip\ImagineBundle\Async;
34

45
class Topics

LiipImagineBundle.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@ public function build(ContainerBuilder $container)
6464
->add(Topics::CACHE_RESOLVED, 'The topic contains messages about resolved image\'s caches')
6565
);
6666
}
67-
}
67+
}
6868
}

Tests/Async/CacheResolvedTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Liip\ImagineBundle\Tests\Async;
34

45
use Liip\ImagineBundle\Async\CacheResolved;
@@ -36,4 +37,4 @@ public function testCouldBeJsonDeSerialized()
3637
'barFilter' => 'http://example.com/barFilter/thePath',
3738
), $message->getUris());
3839
}
39-
}
40+
}

Tests/Async/ResolveCacheProcessorTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Liip\ImagineBundle\Tests\Async;
34

45
use Enqueue\Client\ProducerInterface;
@@ -260,7 +261,7 @@ public function testShouldSendMessageOnSuccessResolve()
260261
$cacheManagerMock
261262
->expects($this->atLeastOnce())
262263
->method('resolve')
263-
->willReturnCallback(function($path, $filter) {
264+
->willReturnCallback(function ($path, $filter) {
264265
return $path.$filter.'Uri';
265266
})
266267
;
@@ -278,7 +279,7 @@ public function testShouldSendMessageOnSuccessResolve()
278279
->expects($this->once())
279280
->method('send')
280281
->with(Topics::CACHE_RESOLVED, $this->isInstanceOf('Liip\ImagineBundle\Async\CacheResolved'))
281-
->willReturnCallback(function($topic, CacheResolved $message) use ($testCase) {
282+
->willReturnCallback(function ($topic, CacheResolved $message) use ($testCase) {
282283
$testCase->assertEquals('theImagePath', $message->getPath());
283284
$testCase->assertEquals(array(
284285
'fooFilter' => 'theImagePathfooFilterUri',
@@ -341,4 +342,4 @@ private function createDummyBinary()
341342
{
342343
return new Binary('theContent', 'image/png', 'png');
343344
}
344-
}
345+
}

Tests/Async/ResolveCacheTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Liip\ImagineBundle\Tests\Async;
34

45
use Liip\ImagineBundle\Async\ResolveCache;
@@ -84,4 +85,4 @@ public function testThrowIfMessageContainsNotSupportedFilters()
8485
$this->setExpectedException('LogicException', 'The message filters could be either null or array.');
8586
ResolveCache::jsonDeserialize('{"path": "aPath", "filters": "stringFilterIsNotAllowed"}');
8687
}
87-
}
88+
}

Utility/Framework/SymfonyFramework.php

+4-14
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
use Symfony\Component\HttpKernel\Kernel;
1515

16+
/**
17+
* @internal
18+
*/
1619
class SymfonyFramework
1720
{
1821
/**
@@ -75,19 +78,6 @@ public static function isKernelLessThan($major, $minor = null, $patch = null)
7578
*/
7679
private static function kernelVersionCompare($operator, $major, $minor = null, $patch = null)
7780
{
78-
$vernum = $major;
79-
$kernel = Kernel::MAJOR_VERSION;
80-
81-
if ($minor) {
82-
$vernum .= '.'.$minor;
83-
$kernel .= '.'.Kernel::MINOR_VERSION;
84-
85-
if ($patch) {
86-
$vernum .= '.'.$patch;
87-
$kernel .= '.'.Kernel::RELEASE_VERSION;
88-
}
89-
}
90-
91-
return version_compare($kernel, $vernum, $operator);
81+
return version_compare(Kernel::VERSION_ID, sprintf("%d%'.02d%'.02d", $major, $minor ?: 0, $patch ?: 0), $operator);
9282
}
9383
}

0 commit comments

Comments
 (0)