Passed
Push — v7 ( 2da68a...ef6b54 )
by Georges
01:58
created
lib/Phpfastcache/Config/Config.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,4 +14,4 @@
 block discarded – undo
14 14
  * @package phpFastCache\Config
15 15
  * @see ConfigurationOption
16 16
  */
17
-class Config extends ConfigurationOption{}
18 17
\ No newline at end of file
18
+class Config extends ConfigurationOption {}
19 19
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Phpfastcache/Config/ConfigurationOption.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -92,33 +92,33 @@  discard block
 block discarded – undo
92 92
     public function __construct(...$args)
93 93
     {
94 94
         parent::__construct(...$args);
95
-        $array =& $this->getArray();
95
+        $array = & $this->getArray();
96 96
 
97 97
         /**
98 98
          * Detect unwanted keys and throw an exception.
99 99
          * No more kidding now, it's 21th century.
100 100
          */
101
-        if(array_diff_key($array, get_object_vars($this))){
101
+        if (array_diff_key($array, get_object_vars($this))) {
102 102
             throw new PhpfastcacheInvalidConfigurationException(\sprintf(
103 103
               'Invalid option(s) for the config %s: %s',
104 104
               static::class,
105
-              implode(', ',  array_keys(array_diff_key($array, get_object_vars($this))))
105
+              implode(', ', array_keys(array_diff_key($array, get_object_vars($this))))
106 106
             ));
107 107
         }
108 108
 
109 109
         foreach (get_object_vars($this) as $property => $value) {
110 110
 
111
-            if(array_key_exists($property, $array)){
112
-                $this->$property = &$array[ $property ];
113
-            }else{
114
-                $array[ $property ] = &$this->$property;
111
+            if (array_key_exists($property, $array)) {
112
+                $this->$property = &$array[$property];
113
+            } else {
114
+                $array[$property] = &$this->$property;
115 115
             }
116 116
         }
117 117
 
118 118
         foreach (get_class_methods($this) as $method) {
119
-            if(strpos($method, 'set') === 0){
119
+            if (strpos($method, 'set') === 0) {
120 120
                 $value = null;
121
-                try{
121
+                try {
122 122
                     /**
123 123
                      * We use property instead of getter
124 124
                      * because of is/get conditions and
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
                      */
128 128
                     $value = $this->{lcfirst(substr($method, 3))};
129 129
                     $this->{$method}($value);
130
-                }catch(\TypeError $e){
130
+                } catch (\TypeError $e) {
131 131
                     $typeHintGot = \is_object($value) ? \get_class($value) : \gettype($value);
132 132
                     $reflectionMethod = new \ReflectionMethod($this, $method);
133 133
                     $parameter = $reflectionMethod->getParameters()[0] ?? null;
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
      */
217 217
     public function setIgnoreSymfonyNotice(bool $ignoreSymfonyNotice): self
218 218
     {
219
-        if($ignoreSymfonyNotice){
219
+        if ($ignoreSymfonyNotice) {
220 220
             \trigger_error('Configuration option "ignoreSymfonyNotice" is deprecated as of the V7', E_USER_DEPRECATED);
221 221
         }
222 222
         $this->ignoreSymfonyNotice = $ignoreSymfonyNotice;
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
      */
332 332
     public function setFallbackConfig($fallbackConfig): self
333 333
     {
334
-        if($fallbackConfig !== null && !($fallbackConfig instanceof self)){
334
+        if ($fallbackConfig !== null && !($fallbackConfig instanceof self)) {
335 335
             throw new PhpfastcacheInvalidArgumentException(\sprintf(
336 336
               'Invalid argument "%s" for %s',
337 337
               gettype($fallbackConfig) === 'object' ? get_class($fallbackConfig) : gettype($fallbackConfig),
Please login to merge, or discard this patch.
lib/Phpfastcache/EventManager.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
          * due to performance issue on huge
79 79
          * loop dispatching operations
80 80
          */
81
-        if (isset($this->events[ $eventName ])) {
82
-            foreach ($this->events[ $eventName ] as $event) {
81
+        if (isset($this->events[$eventName])) {
82
+            foreach ($this->events[$eventName] as $event) {
83 83
                 \call_user_func_array($event, $args);
84 84
             }
85 85
         }
@@ -95,14 +95,14 @@  discard block
 block discarded – undo
95 95
     {
96 96
         if (\strpos($name, 'on') === 0) {
97 97
             $name = \substr($name, 2);
98
-            if (\is_callable($arguments[ 0 ])) {
99
-                if (isset($arguments[ 1 ]) && \is_string($arguments[ 0 ])) {
100
-                    $this->events[ $name ][ $arguments[ 1 ] ] = $arguments[ 0 ];
98
+            if (\is_callable($arguments[0])) {
99
+                if (isset($arguments[1]) && \is_string($arguments[0])) {
100
+                    $this->events[$name][$arguments[1]] = $arguments[0];
101 101
                 } else {
102
-                    $this->events[ $name ][] = $arguments[ 0 ];
102
+                    $this->events[$name][] = $arguments[0];
103 103
                 }
104 104
             } else {
105
-                throw new PhpfastcacheInvalidArgumentException(\sprintf('Expected Callable, got "%s"', \gettype($arguments[ 0 ])));
105
+                throw new PhpfastcacheInvalidArgumentException(\sprintf('Expected Callable, got "%s"', \gettype($arguments[0])));
106 106
             }
107 107
         } else {
108 108
             throw new \BadMethodCallException('An event must start with "on" such as "onCacheGetItem"');
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
      */
117 117
     public function unbindEventCallback(string $eventName, string $callbackName): bool
118 118
     {
119
-        $return = isset($this->events[ $eventName ][ $callbackName ]);
120
-        unset($this->events[ $eventName ][ $callbackName ]);
119
+        $return = isset($this->events[$eventName][$callbackName]);
120
+        unset($this->events[$eventName][$callbackName]);
121 121
 
122 122
         return $return;
123 123
     }
Please login to merge, or discard this patch.
lib/Phpfastcache/Exceptions/PhpfastcacheIOException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
     public function __construct($message = "", $code = 0, $previous = null)
28 28
     {
29 29
         $lastError = error_get_last();
30
-        if($lastError){
30
+        if ($lastError) {
31 31
             $message .= "\n";
32 32
             $message .= "Additional information provided by error_get_last():\n";
33 33
             $message .= "{$lastError['message']} in {$lastError['file']} line {$lastError['line']}";
Please login to merge, or discard this patch.
lib/Phpfastcache/Util/Directory.php 1 patch
Spacing   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -87,8 +87,7 @@  discard block
 block discarded – undo
87 87
             return \unlink($source);
88 88
         }
89 89
 
90
-        $files = new RecursiveIteratorIterator
91
-        (
90
+        $files = new RecursiveIteratorIterator(
92 91
           new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS),
93 92
           RecursiveIteratorIterator::CHILD_FIRST
94 93
         );
@@ -138,8 +137,8 @@  discard block
 block discarded – undo
138 137
         /**
139 138
          * Allows to dereference char
140 139
          */
141
-        $__FILE__ = \preg_replace('~^(([a-z0-9\-]+)://)~', '', __FILE__);// remove file protocols such as "phar://" etc.
142
-        $prefix = $__FILE__[ 0 ] === \DIRECTORY_SEPARATOR ? \DIRECTORY_SEPARATOR : '';
140
+        $__FILE__ = \preg_replace('~^(([a-z0-9\-]+)://)~', '', __FILE__); // remove file protocols such as "phar://" etc.
141
+        $prefix = $__FILE__[0] === \DIRECTORY_SEPARATOR ? \DIRECTORY_SEPARATOR : '';
143 142
         return $prefix . \implode(\DIRECTORY_SEPARATOR, $absolutes);
144 143
     }
145 144
 }
146 145
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Phpfastcache/Util/ClassNamespaceResolverTrait.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
         }
56 56
         $map = [];
57 57
 
58
-        if(\is_array($dir) || $dir instanceof \Traversable){
58
+        if (\is_array($dir) || $dir instanceof \Traversable) {
59 59
             foreach ($dir as $file) {
60 60
                 if (!$file->isFile()) {
61 61
                     continue;
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
                     \gc_mem_caches();
71 71
                 }
72 72
                 foreach ($classes as $class) {
73
-                    $map[ $class ] = $path;
73
+                    $map[$class] = $path;
74 74
                 }
75 75
             }
76 76
         }
@@ -94,19 +94,19 @@  discard block
 block discarded – undo
94 94
         $tokens = \token_get_all($contents);
95 95
         $classes = [];
96 96
         $namespace = '';
97
-        for ($i = 0; isset($tokens[ $i ]); ++$i) {
98
-            $token = $tokens[ $i ];
99
-            if (!isset($token[ 1 ])) {
97
+        for ($i = 0; isset($tokens[$i]); ++$i) {
98
+            $token = $tokens[$i];
99
+            if (!isset($token[1])) {
100 100
                 continue;
101 101
             }
102 102
             $class = '';
103
-            switch ($token[ 0 ]) {
103
+            switch ($token[0]) {
104 104
                 case \T_NAMESPACE:
105 105
                     $namespace = '';
106 106
                     // If there is a namespace, extract it
107
-                    while (isset($tokens[ ++$i ][ 1 ])) {
108
-                        if (\in_array($tokens[ $i ][ 0 ], [\T_STRING, \T_NS_SEPARATOR])) {
109
-                            $namespace .= $tokens[ $i ][ 1 ];
107
+                    while (isset($tokens[ ++$i][1])) {
108
+                        if (\in_array($tokens[$i][0], [\T_STRING, \T_NS_SEPARATOR])) {
109
+                            $namespace .= $tokens[$i][1];
110 110
                         }
111 111
                     }
112 112
                     $namespace .= '\\';
@@ -117,13 +117,13 @@  discard block
 block discarded – undo
117 117
                     // Skip usage of ::class constant
118 118
                     $isClassConstant = false;
119 119
                     for ($j = $i - 1; $j > 0; --$j) {
120
-                        if (!isset($tokens[ $j ][ 1 ])) {
120
+                        if (!isset($tokens[$j][1])) {
121 121
                             break;
122 122
                         }
123
-                        if (\T_DOUBLE_COLON === $tokens[ $j ][ 0 ]) {
123
+                        if (\T_DOUBLE_COLON === $tokens[$j][0]) {
124 124
                             $isClassConstant = true;
125 125
                             break;
126
-                        } elseif (!\in_array($tokens[ $j ][ 0 ], [\T_WHITESPACE, \T_DOC_COMMENT, \T_COMMENT], false)) {
126
+                        } elseif (!\in_array($tokens[$j][0], [\T_WHITESPACE, \T_DOC_COMMENT, \T_COMMENT], false)) {
127 127
                             break;
128 128
                         }
129 129
                     }
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
                         break;
132 132
                     }
133 133
                     // Find the classname
134
-                    while (isset($tokens[ ++$i ][ 1 ])) {
135
-                        $t = $tokens[ $i ];
136
-                        if (\T_STRING === $t[ 0 ]) {
137
-                            $class .= $t[ 1 ];
138
-                        } elseif ('' !== $class && \T_WHITESPACE === $t[ 0 ]) {
134
+                    while (isset($tokens[ ++$i][1])) {
135
+                        $t = $tokens[$i];
136
+                        if (\T_STRING === $t[0]) {
137
+                            $class .= $t[1];
138
+                        } elseif ('' !== $class && \T_WHITESPACE === $t[0]) {
139 139
                             break;
140 140
                         }
141 141
                     }
Please login to merge, or discard this patch.
lib/Phpfastcache/Util/ArrayObject.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
      */
33 33
     public function __construct(...$args)
34 34
     {
35
-        $this->array = (\count($args) === 1 && \is_array($args[ 0 ]) ? $args[ 0 ] : $args);
35
+        $this->array = (\count($args) === 1 && \is_array($args[0]) ? $args[0] : $args);
36 36
     }
37 37
 
38 38
     /**
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public function current()
42 42
     {
43
-        return $this->array[ $this->position ];
43
+        return $this->array[$this->position];
44 44
     }
45 45
 
46 46
     /**
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      */
99 99
     public function offsetGet($offset)
100 100
     {
101
-        return $this->array[ $offset ] ?? null;
101
+        return $this->array[$offset] ?? null;
102 102
     }
103 103
 
104 104
     /**
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
         if ($offset === null) {
114 114
             $this->array[] = $value;
115 115
         } else {
116
-            $this->array[ $offset ] = $value;
116
+            $this->array[$offset] = $value;
117 117
         }
118 118
     }
119 119
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
      */
123 123
     public function offsetUnset($offset)
124 124
     {
125
-        unset($this->array[ $offset ]);
125
+        unset($this->array[$offset]);
126 126
     }
127 127
 
128 128
     /**
Please login to merge, or discard this patch.
lib/Phpfastcache/Drivers/Zendshm/Driver.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -129,11 +129,11 @@
 block discarded – undo
129 129
      */
130 130
     public function getStats(): DriverStatistic
131 131
     {
132
-        $stats = (array)zend_shm_cache_info();
132
+        $stats = (array) zend_shm_cache_info();
133 133
         return (new DriverStatistic())
134 134
           ->setData(\implode(', ', \array_keys($this->itemInstances)))
135
-          ->setInfo(\sprintf("The Zend memory have %d item(s) in cache.\n For more information see RawData.", $stats[ 'items_total' ]))
135
+          ->setInfo(\sprintf("The Zend memory have %d item(s) in cache.\n For more information see RawData.", $stats['items_total']))
136 136
           ->setRawData($stats)
137
-          ->setSize($stats[ 'memory_total' ]);
137
+          ->setSize($stats['memory_total']);
138 138
     }
139 139
 }
140 140
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Phpfastcache/Drivers/Mongodb/Driver.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -78,16 +78,16 @@  discard block
 block discarded – undo
78 78
 
79 79
         if ($document) {
80 80
             $return = [
81
-              self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()),
82
-              self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()),
83
-              self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()),
81
+              self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[self::DRIVER_DATA_WRAPPER_INDEX]->getData()),
82
+              self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[self::DRIVER_TAGS_WRAPPER_INDEX]->getData()),
83
+              self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_EDATE_WRAPPER_INDEX]->toDateTime()->getTimestamp()),
84 84
             ];
85 85
 
86
-            if(!empty($this->getConfig()->isItemDetailedDate())){
86
+            if (!empty($this->getConfig()->isItemDetailedDate())) {
87 87
                 $return += [
88
-                  self::DRIVER_MDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_MDATE_WRAPPER_INDEX ]->toDateTime()
88
+                  self::DRIVER_MDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_MDATE_WRAPPER_INDEX]->toDateTime()
89 89
                     ->getTimestamp()),
90
-                  self::DRIVER_CDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_CDATE_WRAPPER_INDEX ]->toDateTime()
90
+                  self::DRIVER_CDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_CDATE_WRAPPER_INDEX]->toDateTime()
91 91
                     ->getTimestamp()),
92 92
                 ];
93 93
             }
@@ -117,13 +117,13 @@  discard block
 block discarded – undo
117 117
                   self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((\time() + $item->getTtl()) * 1000) : new UTCDateTime(\time() * 1000)),
118 118
                 ];
119 119
 
120
-                if(!empty($this->getConfig()->isItemDetailedDate())){
120
+                if (!empty($this->getConfig()->isItemDetailedDate())) {
121 121
                     $set += [
122 122
                       self::DRIVER_MDATE_WRAPPER_INDEX => ($item->getModificationDate() ? new UTCDateTime(($item->getModificationDate()->getTimestamp()) * 1000) : new UTCDateTime(\time() * 1000)),
123 123
                       self::DRIVER_CDATE_WRAPPER_INDEX => ($item->getCreationDate() ? new UTCDateTime(($item->getCreationDate()->getTimestamp()) * 1000) : new UTCDateTime(\time() * 1000)),
124 124
                     ];
125 125
                 }
126
-                $result = (array)$this->getCollection()->updateOne(
126
+                $result = (array) $this->getCollection()->updateOne(
127 127
                   ['_id' => $item->getEncodedKey()],
128 128
                   [
129 129
                     '$set' => $set,
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
                 throw new PhpfastcacheDriverException('Got an exception while trying to write data to MongoDB server', null, $e);
135 135
             }
136 136
 
137
-            return isset($result[ 'ok' ]) ? $result[ 'ok' ] == 1 : true;
137
+            return isset($result['ok']) ? $result['ok'] == 1 : true;
138 138
         }
139 139
 
140 140
         throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected');
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
         $host = $this->getConfig()->getHost();
227 227
         $port = $this->getConfig()->getPort();
228 228
         $username = $this->getConfig()->getUsername();
229
-        $password =  $this->getConfig()->getPassword();
229
+        $password = $this->getConfig()->getPassword();
230 230
 
231 231
         return implode('', [
232 232
           'mongodb://',
@@ -263,14 +263,14 @@  discard block
 block discarded – undo
263 263
           'recordStats' => 0,
264 264
           'repl' => 0,
265 265
           'metrics' => 0,
266
-        ]))->toArray()[ 0 ];
266
+        ]))->toArray()[0];
267 267
 
268 268
         $collectionStats = $this->instance->getManager()->executeCommand('phpFastCache', new Command([
269
-          'collStats' => (isset($this->getConfig()[ 'collectionName' ]) ? $this->getConfig()[ 'collectionName' ] : 'Cache'),
269
+          'collStats' => (isset($this->getConfig()['collectionName']) ? $this->getConfig()['collectionName'] : 'Cache'),
270 270
           'verbose' => true,
271
-        ]))->toArray()[ 0 ];
271
+        ]))->toArray()[0];
272 272
 
273
-        $array_filter_recursive = function ($array, callable $callback = null) use (&$array_filter_recursive) {
273
+        $array_filter_recursive = function($array, callable $callback = null) use (&$array_filter_recursive) {
274 274
             $array = $callback($array);
275 275
 
276 276
             if (\is_object($array) || \is_array($array)) {
@@ -282,12 +282,12 @@  discard block
 block discarded – undo
282 282
             return $array;
283 283
         };
284 284
 
285
-        $callback = function ($item) {
285
+        $callback = function($item) {
286 286
             /**
287 287
              * Remove unserializable properties
288 288
              */
289 289
             if ($item instanceof \MongoDB\BSON\UTCDateTime) {
290
-                return (string)$item;
290
+                return (string) $item;
291 291
             }
292 292
             return $item;
293 293
         };
Please login to merge, or discard this patch.