Completed
Push — V6 ( 95d57b...cfd763 )
by Georges
06:57
created
tests/UnsupportedKeyCharacters.test.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,28 +19,28 @@
 block discarded – undo
19 19
 try {
20 20
     $driverInstance->getItem('test{test');
21 21
     $testHelper->printFailText('1/4 An unsupported key character did not get caught by regular expression');
22
-}catch(phpFastCacheInvalidArgumentException $e){
22
+} catch (phpFastCacheInvalidArgumentException $e) {
23 23
     $testHelper->printPassText('1/4 An unsupported key character has been caught by regular expression');
24 24
 }
25 25
 
26 26
 try {
27 27
     $driverInstance->getItem(':testtest');
28 28
     $testHelper->printFailText('2/4 An unsupported key character did not get caught by regular expression');
29
-}catch(phpFastCacheInvalidArgumentException $e){
29
+} catch (phpFastCacheInvalidArgumentException $e) {
30 30
     $testHelper->printPassText('2/4 An unsupported key character has been caught by regular expression');
31 31
 }
32 32
 
33 33
 try {
34 34
     $driverInstance->getItem('testtest}');
35 35
     $testHelper->printFailText('3/4 An unsupported key character did not get caught by regular expression');
36
-}catch(phpFastCacheInvalidArgumentException $e){
36
+} catch (phpFastCacheInvalidArgumentException $e) {
37 37
     $testHelper->printPassText('3/4 An unsupported key character has been caught by regular expression');
38 38
 }
39 39
 
40 40
 try {
41 41
     $driverInstance->getItem('testtest');
42 42
     $testHelper->printPassText('4/4 No exception caught while trying with a key without unsupported character');
43
-}catch(phpFastCacheInvalidArgumentException $e){
43
+} catch (phpFastCacheInvalidArgumentException $e) {
44 44
     $testHelper->printFailText('4/4 An exception has been caught while trying with a key without unsupported character');
45 45
 }
46 46
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,28 +19,28 @@
 block discarded – undo
19 19
 try {
20 20
     $driverInstance->getItem('test{test');
21 21
     $testHelper->printFailText('1/4 An unsupported key character did not get caught by regular expression');
22
-}catch(phpFastCacheInvalidArgumentException $e){
22
+} catch(phpFastCacheInvalidArgumentException $e){
23 23
     $testHelper->printPassText('1/4 An unsupported key character has been caught by regular expression');
24 24
 }
25 25
 
26 26
 try {
27 27
     $driverInstance->getItem(':testtest');
28 28
     $testHelper->printFailText('2/4 An unsupported key character did not get caught by regular expression');
29
-}catch(phpFastCacheInvalidArgumentException $e){
29
+} catch(phpFastCacheInvalidArgumentException $e){
30 30
     $testHelper->printPassText('2/4 An unsupported key character has been caught by regular expression');
31 31
 }
32 32
 
33 33
 try {
34 34
     $driverInstance->getItem('testtest}');
35 35
     $testHelper->printFailText('3/4 An unsupported key character did not get caught by regular expression');
36
-}catch(phpFastCacheInvalidArgumentException $e){
36
+} catch(phpFastCacheInvalidArgumentException $e){
37 37
     $testHelper->printPassText('3/4 An unsupported key character has been caught by regular expression');
38 38
 }
39 39
 
40 40
 try {
41 41
     $driverInstance->getItem('testtest');
42 42
     $testHelper->printPassText('4/4 No exception caught while trying with a key without unsupported character');
43
-}catch(phpFastCacheInvalidArgumentException $e){
43
+} catch(phpFastCacheInvalidArgumentException $e){
44 44
     $testHelper->printFailText('4/4 An exception has been caught while trying with a key without unsupported character');
45 45
 }
46 46
 
Please login to merge, or discard this patch.
src/phpFastCache/Core/Pool/CacheItemPoolTrait.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     public function getItem($key)
62 62
     {
63 63
         if (is_string($key)) {
64
-            if (preg_match('~([' . preg_quote(self::$unsupportedKeyChars, '~') . ']+)~', $key, $matches)){
64
+            if (preg_match('~([' . preg_quote(self::$unsupportedKeyChars, '~') . ']+)~', $key, $matches)) {
65 65
                 throw new phpFastCacheInvalidArgumentException('Unsupported key character detected: "' . $matches[1] . '". Please check: https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV6%5D-Unsupported-characters-in-key-identifiers');
66 66
             }
67 67
             if (!array_key_exists($key, $this->itemInstances)) {
@@ -76,13 +76,13 @@  discard block
 block discarded – undo
76 76
                 $driverArray = $this->driverRead($item);
77 77
 
78 78
                 if ($driverArray) {
79
-                    if(!is_array($driverArray)){
79
+                    if (!is_array($driverArray)) {
80 80
                         throw new phpFastCacheCoreException(sprintf('The driverRead method returned an unexpected variable type: %s', gettype($driverArray)));
81 81
                     }
82 82
                     $item->set($this->driverUnwrapData($driverArray));
83 83
                     $item->expiresAt($this->driverUnwrapEdate($driverArray));
84 84
 
85
-                    if($this->config['itemDetailedDate']){
85
+                    if ($this->config['itemDetailedDate']) {
86 86
 
87 87
                         /**
88 88
                          * If the itemDetailedDate has been
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
                     } else {
107 107
                         $item->setHit(true);
108 108
                     }
109
-                }else{
110
-                    $item->expiresAfter(abs((int) $this->getConfig()[ 'defaultTtl' ]));
109
+                } else {
110
+                    $item->expiresAfter(abs((int) $this->getConfig()['defaultTtl']));
111 111
                 }
112 112
 
113 113
             }
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
          * @param $this ExtendedCacheItemPoolInterface
121 121
          * @param $this ExtendedCacheItemInterface
122 122
          */
123
-        $this->eventManager->dispatch('CacheGetItem', $this, $this->itemInstances[ $key ]);
123
+        $this->eventManager->dispatch('CacheGetItem', $this, $this->itemInstances[$key]);
124 124
 
125
-        return $this->itemInstances[ $key ];
125
+        return $this->itemInstances[$key];
126 126
     }
127 127
 
128 128
     /**
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
     public function setItem(CacheItemInterface $item)
134 134
     {
135 135
         if ($this->getClassNamespace() . '\\Item' === get_class($item)) {
136
-            $this->itemInstances[ $item->getKey() ] = $item;
136
+            $this->itemInstances[$item->getKey()] = $item;
137 137
 
138 138
             return $this;
139 139
         } else {
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     {
151 151
         $collection = [];
152 152
         foreach ($keys as $key) {
153
-            $collection[ $key ] = $this->getItem($key);
153
+            $collection[$key] = $this->getItem($key);
154 154
         }
155 155
 
156 156
         return $collection;
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
          * @var ExtendedCacheItemInterface $item
248 248
          */
249 249
         if (!array_key_exists($item->getKey(), $this->itemInstances)) {
250
-            $this->itemInstances[ $item->getKey() ] = $item;
251
-        } else if(spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])){
250
+            $this->itemInstances[$item->getKey()] = $item;
251
+        } else if (spl_object_hash($item) !== spl_object_hash($this->itemInstances[$item->getKey()])) {
252 252
             throw new \RuntimeException('Spl object hash mismatches ! You probably tried to save a detached item which has been already retrieved from cache.');
253 253
         }
254 254
 
@@ -278,8 +278,8 @@  discard block
 block discarded – undo
278 278
     public function saveDeferred(CacheItemInterface $item)
279 279
     {
280 280
         if (!array_key_exists($item->getKey(), $this->itemInstances)) {
281
-            $this->itemInstances[ $item->getKey() ] = $item;
282
-        }else if(spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])){
281
+            $this->itemInstances[$item->getKey()] = $item;
282
+        } else if (spl_object_hash($item) !== spl_object_hash($this->itemInstances[$item->getKey()])) {
283 283
             throw new \RuntimeException('Spl object hash mismatches ! You probably tried to save a detached item which has been already retrieved from cache.');
284 284
         }
285 285
 
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
          */
291 291
         $this->eventManager->dispatch('CacheSaveDeferredItem', $this, $item);
292 292
 
293
-        return $this->deferredList[ $item->getKey() ] = $item;
293
+        return $this->deferredList[$item->getKey()] = $item;
294 294
     }
295 295
 
296 296
     /**
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
         foreach ($this->deferredList as $key => $item) {
311 311
             $result = $this->save($item);
312 312
             if ($return !== false) {
313
-                unset($this->deferredList[ $key ]);
313
+                unset($this->deferredList[$key]);
314 314
                 $return = $result;
315 315
             }
316 316
         }
Please login to merge, or discard this patch.