Completed
Push — V6 ( 802207...a1dd44 )
by Georges
02:13
created
src/phpFastCache/Drivers/Files/Driver.php 2 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 
61 61
     /**
62 62
      * @param \Psr\Cache\CacheItemInterface $item
63
-     * @return mixed
63
+     * @return boolean
64 64
      * @throws \InvalidArgumentException
65 65
      */
66 66
     protected function driverWrite(CacheItemInterface $item)
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
     /**
147 147
      * @param string $optionName
148 148
      * @param mixed $optionValue
149
-     * @return bool
149
+     * @return boolean|null
150 150
      * @throws \InvalidArgumentException
151 151
      */
152 152
     public static function isValidOption($optionName, $optionValue)
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
     }
175 175
 
176 176
     /**
177
-     * @return array
177
+     * @return string[]
178 178
      */
179 179
     public static function getValidOptions()
180 180
     {
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
     }
183 183
 
184 184
     /**
185
-     * @return array
185
+     * @return string[]
186 186
      */
187 187
     public static function getRequiredOptions()
188 188
     {
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -215,11 +215,11 @@
 block discarded – undo
215 215
         }
216 216
 
217 217
         $stat->setData(implode(', ', array_keys($this->itemInstances)))
218
-          ->setRawData([
218
+            ->setRawData([
219 219
             'tmp' => $this->tmp
220
-          ])
221
-          ->setSize(Directory::dirSize($path))
222
-          ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path));
220
+            ])
221
+            ->setSize(Directory::dirSize($path))
222
+            ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path));
223 223
 
224 224
         return $stat;
225 225
     }
Please login to merge, or discard this patch.
src/phpFastCache/Core/Pool/IO/IOHelperTrait.php 4 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -186,9 +186,9 @@  discard block
 block discarded – undo
186 186
     protected static function cleanFileName($filename)
187 187
     {
188 188
         $regex = [
189
-          '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/',
190
-          '/\.$/',
191
-          '/^\./',
189
+            '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/',
190
+            '/\.$/',
191
+            '/^\./',
192 192
         ];
193 193
         $replace = ['-', '', ''];
194 194
 
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
             $tmpFilename = Directory::getAbsolutePath(dirname($file) . '/tmp_' . md5(
278 278
                 str_shuffle(uniqid($this->getDriverName(), false))
279 279
                 . str_shuffle(uniqid($this->getDriverName(), false))
280
-              ));
280
+                ));
281 281
 
282 282
             $f = fopen($tmpFilename, 'w+');
283 283
             flock($f, LOCK_EX);
Please login to merge, or discard this patch.
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
     }
131 131
 
132 132
     /**
133
-     * @param $keyword
133
+     * @param string|false $keyword
134 134
      * @param bool $skip
135 135
      * @return string
136 136
      * @throws phpFastCacheIOException
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
     /**
178 178
      * @param $filename
179
-     * @return mixed
179
+     * @return string
180 180
      */
181 181
     protected static function cleanFileName($filename)
182 182
     {
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
     }
192 192
 
193 193
     /**
194
-     * @param $path
194
+     * @param string $path
195 195
      * @param bool $create
196 196
      * @throws phpFastCacheIOException
197 197
      */
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 
226 226
 
227 227
     /**
228
-     * @param $file
228
+     * @param string $file
229 229
      * @return string
230 230
      * @throws phpFastCacheIOException
231 231
      */
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
                 return $tmp_dir;
98 98
             }
99 99
             return $full_path;
100
-        }else{
100
+        } else{
101 101
             if (!isset($this->tmp[ $full_path_hash ]) || (!@file_exists($full_path) || !@is_writable($full_path))) {
102 102
                 if (!@file_exists($full_path)) {
103 103
                     @mkdir($full_path, $this->setChmodAuto(), true);
104
-                }else if (!@is_writable($full_path)) {
104
+                } else if (!@is_writable($full_path)) {
105 105
                     @chmod($full_path, $this->setChmodAuto());
106 106
                 }
107 107
 
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
             if(!rename($tmpFilename, $file)){
313 313
                 throw new phpFastCacheIOException(sprintf('Failed to rename %s to %s', $tmpFilename, $file));
314 314
             }
315
-        }else{
315
+        } else{
316 316
             $f = fopen($file, 'w+');
317 317
             $octetWritten = fwrite($f, $data);
318 318
             fclose($f);
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -41,10 +41,10 @@  discard block
 block discarded – undo
41 41
          * Calculate the security key
42 42
          */
43 43
         {
44
-            $securityKey = array_key_exists('securityKey', $this->config) ? $this->config[ 'securityKey' ] : '';
44
+            $securityKey = array_key_exists('securityKey', $this->config) ? $this->config['securityKey'] : '';
45 45
             if (!$securityKey || $securityKey === 'auto') {
46
-                if (isset($_SERVER[ 'HTTP_HOST' ])) {
47
-                    $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER[ 'HTTP_HOST' ])));
46
+                if (isset($_SERVER['HTTP_HOST'])) {
47
+                    $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER['HTTP_HOST'])));
48 48
                 } else {
49 49
                     $securityKey = ($this->isPHPModule() ? 'web' : 'cli');
50 50
                 }
@@ -63,10 +63,10 @@  discard block
 block discarded – undo
63 63
          */
64 64
         $tmp_dir = rtrim($tmp_dir, '/') . DIRECTORY_SEPARATOR;
65 65
 
66
-        if (empty($this->config[ 'path' ]) || !is_string($this->config[ 'path' ])) {
66
+        if (empty($this->config['path']) || !is_string($this->config['path'])) {
67 67
             $path = $tmp_dir;
68 68
         } else {
69
-            $path = rtrim($this->config[ 'path' ], '/') . DIRECTORY_SEPARATOR;
69
+            $path = rtrim($this->config['path'], '/') . DIRECTORY_SEPARATOR;
70 70
         }
71 71
 
72 72
         $path_suffix = $securityKey . DIRECTORY_SEPARATOR . $this->getDriverName();
@@ -81,16 +81,16 @@  discard block
 block discarded – undo
81 81
          * return the temp dir
82 82
          */
83 83
         if ($readonly === true) {
84
-            if($this->config[ 'autoTmpFallback' ] && (!@file_exists($full_path) || !@is_writable($full_path))){
84
+            if ($this->config['autoTmpFallback'] && (!@file_exists($full_path) || !@is_writable($full_path))) {
85 85
                 return $full_path_tmp;
86 86
             }
87 87
             return $full_path;
88
-        }else{
89
-            if (!isset($this->tmp[ $full_path_hash ]) || (!@file_exists($full_path) || !@is_writable($full_path))) {
88
+        } else {
89
+            if (!isset($this->tmp[$full_path_hash]) || (!@file_exists($full_path) || !@is_writable($full_path))) {
90 90
                 if (!@file_exists($full_path)) {
91 91
                     @mkdir($full_path, $this->setChmodAuto(), true);
92
-                }else if (!@is_writable($full_path)) {
93
-                    if (!@chmod($full_path, $this->setChmodAuto()) && $this->config[ 'autoTmpFallback' ])
92
+                } else if (!@is_writable($full_path)) {
93
+                    if (!@chmod($full_path, $this->setChmodAuto()) && $this->config['autoTmpFallback'])
94 94
                     {
95 95
                         /**
96 96
                          * Switch back to tmp dir
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
                     throw new phpFastCacheIOException('PLEASE CREATE OR CHMOD ' . $full_path . ' - 0777 OR ANY WRITABLE PERMISSION!');
113 113
                 }
114 114
 
115
-                $this->tmp[ $full_path_hash ] = $full_path;
116
-                $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config[ 'htaccess' ] : false);
115
+                $this->tmp[$full_path_hash] = $full_path;
116
+                $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config['htaccess'] : false);
117 117
             }
118 118
         }
119 119
 
@@ -180,10 +180,10 @@  discard block
 block discarded – undo
180 180
      */
181 181
     public function setChmodAuto()
182 182
     {
183
-        if (!isset($this->config[ 'default_chmod' ]) || $this->config[ 'default_chmod' ] == '' || is_null($this->config[ 'default_chmod' ])) {
183
+        if (!isset($this->config['default_chmod']) || $this->config['default_chmod'] == '' || is_null($this->config['default_chmod'])) {
184 184
             return 0777;
185 185
         } else {
186
-            return $this->config[ 'default_chmod' ];
186
+            return $this->config['default_chmod'];
187 187
         }
188 188
     }
189 189
 
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
         if ($create === true) {
214 214
             if (!is_writable($path)) {
215 215
                 try {
216
-                    if(!chmod($path, 0777)){
216
+                    if (!chmod($path, 0777)) {
217 217
                         throw new phpFastCacheIOException('Chmod failed on : ' . $path);
218 218
                     }
219 219
                 } catch (phpFastCacheIOException $e) {
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
          */
285 285
         $this->eventManager->dispatch('CacheWriteFileOnDisk', $this, $file, $secureFileManipulation);
286 286
 
287
-        if($secureFileManipulation){
287
+        if ($secureFileManipulation) {
288 288
             $tmpFilename = Directory::getAbsolutePath(dirname($file) . '/tmp_' . md5(
289 289
                 str_shuffle(uniqid($this->getDriverName(), false))
290 290
                 . str_shuffle(uniqid($this->getDriverName(), false))
@@ -296,10 +296,10 @@  discard block
 block discarded – undo
296 296
             flock($f, LOCK_UN);
297 297
             fclose($f);
298 298
 
299
-            if(!rename($tmpFilename, $file)){
299
+            if (!rename($tmpFilename, $file)) {
300 300
                 throw new phpFastCacheIOException(sprintf('Failed to rename %s to %s', $tmpFilename, $file));
301 301
             }
302
-        }else{
302
+        } else {
303 303
             $f = fopen($file, 'w+');
304 304
             $octetWritten = fwrite($f, $data);
305 305
             fclose($f);
Please login to merge, or discard this patch.
tests/ReadWriteOperations.test.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,9 +23,9 @@
 block discarded – undo
23 23
 $keys = [];
24 24
 
25 25
 $dirs = [
26
-  __DIR__ . '/../var/cache/IO-',
27
-  sys_get_temp_dir() . '/phpfastcache/IO-1',
28
-  sys_get_temp_dir() . '/phpfastcache/IO-2'
26
+    __DIR__ . '/../var/cache/IO-',
27
+    sys_get_temp_dir() . '/phpfastcache/IO-1',
28
+    sys_get_temp_dir() . '/phpfastcache/IO-2'
29 29
 ];
30 30
 
31 31
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
     {
40 40
         $cacheInstanceName = 'cacheInstance' . $i;
41 41
 
42
-        $instances[$dirIndex][$cacheInstanceName] = CacheManager::getInstance('Files',array('path' => $dir . str_pad($i, 3, '0', STR_PAD_LEFT)));
42
+        $instances[$dirIndex][$cacheInstanceName] = CacheManager::getInstance('Files', array('path' => $dir . str_pad($i, 3, '0', STR_PAD_LEFT)));
43 43
 
44
-        foreach($keys[$dirIndex] as $index => $key)
44
+        foreach ($keys[$dirIndex] as $index => $key)
45 45
         {
46 46
             $items[$dirIndex][$index] = $instances[$dirIndex][$cacheInstanceName]->getItem($key);
47 47
             $items[$dirIndex][$index]->set("test-$dirIndex-$index")->expiresAfter(600);
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
         $instances[$dirIndex][$cacheInstanceName]->detachAllItems();
52 52
     }
53 53
 
54
-    foreach($instances[$dirIndex] as $cacheInstanceName => $instance)
54
+    foreach ($instances[$dirIndex] as $cacheInstanceName => $instance)
55 55
     {
56
-        foreach($keys[$dirIndex] as $index => $key)
56
+        foreach ($keys[$dirIndex] as $index => $key)
57 57
         {
58
-            if($instances[$dirIndex][$cacheInstanceName]->getItem($key)->get() === "test-$dirIndex-$index")
58
+            if ($instances[$dirIndex][$cacheInstanceName]->getItem($key)->get() === "test-$dirIndex-$index")
59 59
             {
60 60
                 echo "[PASS] Item #{$key} of instance #{$cacheInstanceName} of dir #{$dirIndex} has returned the expected value (" . gettype("test-$dirIndex-$index") . ":'" . "test-$dirIndex-$index" . "')\n";
61 61
             }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,8 +58,7 @@
 block discarded – undo
58 58
             if($instances[$dirIndex][$cacheInstanceName]->getItem($key)->get() === "test-$dirIndex-$index")
59 59
             {
60 60
                 echo "[PASS] Item #{$key} of instance #{$cacheInstanceName} of dir #{$dirIndex} has returned the expected value (" . gettype("test-$dirIndex-$index") . ":'" . "test-$dirIndex-$index" . "')\n";
61
-            }
62
-            else
61
+            } else
63 62
             {
64 63
                 echo "[FAIL] Item #{$key} of instance #{$cacheInstanceName} of dir #{$dirIndex} returned an unexpected value (" . gettype($instances[$dirIndex][$cacheInstanceName]->getItem($key)->get()) . ":'" . $instances[$dirIndex][$cacheInstanceName]->getItem($key)->get() . "') expected (" . gettype("test-$dirIndex-$index") . ":'" . "test-$dirIndex-$index" . "') \n";
65 64
                 $status = 255;
Please login to merge, or discard this patch.
tests/Memstatic.test.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -33,20 +33,20 @@
 block discarded – undo
33 33
 $cacheResult = $cacheInstance->getItem($cacheKey)->get();
34 34
 
35 35
 if($cacheResult === $randomStr){
36
-  echo "[PASS] The cache key value match, got expected value '{$cacheResult}'\n";
36
+    echo "[PASS] The cache key value match, got expected value '{$cacheResult}'\n";
37 37
 }else{
38
-  echo "[FAIL] The cache key value match expected value '{$randomStr}', got '{$cacheResult}'\n";
39
-  $status = 1;
38
+    echo "[FAIL] The cache key value match expected value '{$randomStr}', got '{$cacheResult}'\n";
39
+    $status = 1;
40 40
 }
41 41
 echo "Clearing the whole cache to test item cleaning...\n";
42 42
 $cacheInstance->clear();
43 43
 $cacheResult = ($cacheInstance->getItem($cacheKey)->isHit() === false && $cacheInstance->getItem($cacheKey)->get() === null);
44 44
 
45 45
 if($cacheResult === true){
46
-  echo "[PASS] The cache item is null as expected\n";
46
+    echo "[PASS] The cache item is null as expected\n";
47 47
 }else{
48
-  echo "[FAIL] The cache is not null'\n";
49
-  $status = 1;
48
+    echo "[FAIL] The cache is not null'\n";
49
+    $status = 1;
50 50
 }
51 51
 
52 52
 exit($status);
53 53
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
 
33 33
 $cacheResult = $cacheInstance->getItem($cacheKey)->get();
34 34
 
35
-if($cacheResult === $randomStr){
35
+if ($cacheResult === $randomStr) {
36 36
   echo "[PASS] The cache key value match, got expected value '{$cacheResult}'\n";
37
-}else{
37
+} else {
38 38
   echo "[FAIL] The cache key value match expected value '{$randomStr}', got '{$cacheResult}'\n";
39 39
   $status = 1;
40 40
 }
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
 $cacheInstance->clear();
43 43
 $cacheResult = ($cacheInstance->getItem($cacheKey)->isHit() === false && $cacheInstance->getItem($cacheKey)->get() === null);
44 44
 
45
-if($cacheResult === true){
45
+if ($cacheResult === true) {
46 46
   echo "[PASS] The cache item is null as expected\n";
47
-}else{
47
+} else {
48 48
   echo "[FAIL] The cache is not null'\n";
49 49
   $status = 1;
50 50
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 if (!class_exists('phpFastCache\CacheManager')) {
19 19
     echo "[FAIL] Autoload failed to find the CacheManager\n";
20 20
     $status = 255;
21
-}else{
21
+} else{
22 22
     echo "[PASS] Autoload successfully found the CacheManager\n";
23 23
 }
24 24
 
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 if (!interface_exists('Psr\Cache\CacheItemInterface')) {
29 29
     echo "[FAIL] Autoload failed to find the Psr CacheItemInterface\n";
30 30
     $status = 255;
31
-}else{
31
+} else{
32 32
     echo "[PASS] Autoload successfully found the Psr CacheItemInterface\n";
33 33
 }
34 34
 
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Memstatic/Driver.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
 {
30 30
     use DriverBaseTrait;
31 31
 
32
-  /**
33
-   * @var array
34
-   */
32
+    /**
33
+     * @var array
34
+     */
35 35
     protected $staticStack = [];
36 36
 
37 37
     /**
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     {
86 86
         $key = md5($item->getKey());
87 87
         if(isset($this->staticStack[$key])){
88
-          return $this->staticStack[$key];
88
+            return $this->staticStack[$key];
89 89
         }
90 90
         return null;
91 91
     }
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
          * Check for Cross-Driver type confusion
102 102
          */
103 103
         if ($item instanceof Item) {
104
-          $key = md5($item->getKey());
105
-          if(isset($this->staticStack[$key])){
106
-              unset($this->staticStack[$key]);
107
-              return true;
108
-          }
109
-          return false;
104
+            $key = md5($item->getKey());
105
+            if(isset($this->staticStack[$key])){
106
+                unset($this->staticStack[$key]);
107
+                return true;
108
+            }
109
+            return false;
110 110
         } else {
111 111
             throw new \InvalidArgumentException('Cross-Driver type confusion detected');
112 112
         }
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
      */
118 118
     protected function driverClear()
119 119
     {
120
-      unset($this->staticStack);
121
-      $this->staticStack = [];
122
-      return true;
120
+        unset($this->staticStack);
121
+        $this->staticStack = [];
122
+        return true;
123 123
     }
124 124
 
125 125
     /**
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
     {
144 144
         $stat = new driverStatistic();
145 145
         $stat->setInfo('[Memstatic] A memory static driver')
146
-          ->setSize(mb_strlen(serialize($this->staticStack)))
147
-          ->setData(implode(', ', array_keys($this->itemInstances)))
148
-          ->setRawData($this->staticStack);
146
+            ->setSize(mb_strlen(serialize($this->staticStack)))
147
+            ->setData(implode(', ', array_keys($this->itemInstances)))
148
+            ->setRawData($this->staticStack);
149 149
 
150 150
         return $stat;
151 151
     }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     protected function driverRead(CacheItemInterface $item)
85 85
     {
86 86
         $key = md5($item->getKey());
87
-        if(isset($this->staticStack[$key])){
87
+        if (isset($this->staticStack[$key])) {
88 88
           return $this->staticStack[$key];
89 89
         }
90 90
         return null;
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
          */
103 103
         if ($item instanceof Item) {
104 104
           $key = md5($item->getKey());
105
-          if(isset($this->staticStack[$key])){
105
+          if (isset($this->staticStack[$key])) {
106 106
               unset($this->staticStack[$key]);
107 107
               return true;
108 108
           }
Please login to merge, or discard this patch.