From 6a15f06019c4e6ec97d312d31f8edceb01b85060 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 11 Jul 2017 10:56:43 +0200 Subject: [PATCH] coding style: fixes in code --- src/Caching/Cache.php | 6 +++--- tests/Caching/Cache.php | 2 +- tests/Storages/FileStorage.call.phpt | 4 ++-- tests/Storages/FileStorage.tags.phpt | 4 ++-- tests/Storages/FileStorage.wrap.phpt | 2 +- tests/Storages/IJournalTestCase.php | 24 ++++++++++++------------ 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Caching/Cache.php b/src/Caching/Cache.php index 4d0e3653..21c69fd6 100644 --- a/src/Caching/Cache.php +++ b/src/Caching/Cache.php @@ -173,10 +173,10 @@ public function save($key, $data, array $dependencies = null) $this->storage->lock($key); try { $data = call_user_func_array($data, [&$dependencies]); - } catch (\Throwable $e) { + } catch (\Exception $e) { $this->storage->remove($key); throw $e; - } catch (\Exception $e) { + } catch (\Throwable $e) { $this->storage->remove($key); throw $e; } @@ -186,7 +186,7 @@ public function save($key, $data, array $dependencies = null) $this->storage->remove($key); } else { $dependencies = $this->completeDependencies($dependencies); - if (isset($dependencies[Cache::EXPIRATION]) && $dependencies[Cache::EXPIRATION] <= 0) { + if (isset($dependencies[self::EXPIRATION]) && $dependencies[self::EXPIRATION] <= 0) { $this->storage->remove($key); } else { $this->storage->write($key, $data, $dependencies); diff --git a/tests/Caching/Cache.php b/tests/Caching/Cache.php index 90328cbe..a47949b2 100644 --- a/tests/Caching/Cache.php +++ b/tests/Caching/Cache.php @@ -40,7 +40,7 @@ public function clean(array $conditions) class BulkReadTestStorage extends TestStorage implements IBulkReader { - function bulkRead(array $keys) + public function bulkRead(array $keys) { $result = []; foreach ($keys as $key) { diff --git a/tests/Storages/FileStorage.call.phpt b/tests/Storages/FileStorage.call.phpt index de4e227b..03619602 100644 --- a/tests/Storages/FileStorage.call.phpt +++ b/tests/Storages/FileStorage.call.phpt @@ -14,14 +14,14 @@ require __DIR__ . '/../bootstrap.php'; class Mock { - function mockFunction($x, $y) + public function mockFunction($x, $y) { $GLOBALS['called'] = true; return $x + $y; } - function __sleep() + public function __sleep() { throw new Exception; } diff --git a/tests/Storages/FileStorage.tags.phpt b/tests/Storages/FileStorage.tags.phpt index c9026c07..6e714ca9 100644 --- a/tests/Storages/FileStorage.tags.phpt +++ b/tests/Storages/FileStorage.tags.phpt @@ -55,8 +55,8 @@ $cache->clean([ 0 => 'non-existent1', 1 => 'non-existent2', 3 => 'one', - 5 => 'non-existent3' - ] + 5 => 'non-existent3', + ], ]); Assert::null($cache->load('key1')); diff --git a/tests/Storages/FileStorage.wrap.phpt b/tests/Storages/FileStorage.wrap.phpt index 5c6aeaa1..4dfcaeb4 100644 --- a/tests/Storages/FileStorage.wrap.phpt +++ b/tests/Storages/FileStorage.wrap.phpt @@ -21,7 +21,7 @@ function mockFunction($x, $y) class Test { - function mockMethod($x, $y) + public function mockMethod($x, $y) { $GLOBALS['called'] = true; return $x + $y; diff --git a/tests/Storages/IJournalTestCase.php b/tests/Storages/IJournalTestCase.php index 17f662fe..5588e938 100644 --- a/tests/Storages/IJournalTestCase.php +++ b/tests/Storages/IJournalTestCase.php @@ -162,7 +162,7 @@ final public function testDifferentCleaning() final public function testSpecialChars() { $this->journal->write('ok_test7ščřžýáíé', [ - Cache::TAGS => ['čšřýýá', 'ýřžčýž'] + Cache::TAGS => ['čšřýýá', 'ýřžčýž'], ]); Assert::same([ @@ -174,10 +174,10 @@ final public function testSpecialChars() final public function testDuplicatedSameTags() { $this->journal->write('ok_test_a', [ - Cache::TAGS => ['homepage'] + Cache::TAGS => ['homepage'], ]); $this->journal->write('ok_test_a', [ - Cache::TAGS => ['homepage'] + Cache::TAGS => ['homepage'], ]); Assert::same([ 'ok_test_a', @@ -188,11 +188,11 @@ final public function testDuplicatedSameTags() final public function testDuplicatedSamePriority() { $this->journal->write('ok_test_b', [ - Cache::PRIORITY => 12 + Cache::PRIORITY => 12, ]); $this->journal->write('ok_test_b', [ - Cache::PRIORITY => 12 + Cache::PRIORITY => 12, ]); Assert::same([ @@ -204,11 +204,11 @@ final public function testDuplicatedSamePriority() final public function testDuplicatedDifferentTags() { $this->journal->write('ok_test_ba', [ - Cache::TAGS => ['homepage'] + Cache::TAGS => ['homepage'], ]); $this->journal->write('ok_test_ba', [ - Cache::TAGS => ['homepage2'] + Cache::TAGS => ['homepage2'], ]); Assert::same([ @@ -223,11 +223,11 @@ final public function testDuplicatedDifferentTags() final public function testDuplicatedTwoDifferentTags() { $this->journal->write('ok_test_baa', [ - Cache::TAGS => ['homepage', 'aąa'] + Cache::TAGS => ['homepage', 'aąa'], ]); $this->journal->write('ok_test_baa', [ - Cache::TAGS => ['homepage2', 'aaa'] + Cache::TAGS => ['homepage2', 'aaa'], ]); Assert::same([ @@ -242,11 +242,11 @@ final public function testDuplicatedTwoDifferentTags() final public function testDuplicatedDifferentPriorities() { $this->journal->write('ok_test_bb', [ - Cache::PRIORITY => 10 + Cache::PRIORITY => 10, ]); $this->journal->write('ok_test_bb', [ - Cache::PRIORITY => 20 + Cache::PRIORITY => 20, ]); Assert::same([ @@ -261,7 +261,7 @@ final public function testDuplicatedDifferentPriorities() final public function testCleanAll() { $this->journal->write('ok_test_all_tags', [ - Cache::TAGS => ['test:all', 'test:all'] + Cache::TAGS => ['test:all', 'test:all'], ]); $this->journal->write('ok_test_all_priority', [