Passed
Push — main ( 2cb152...6ff26f )
by TARIQ
23:50
created
brighty/system/Session/Handlers/FileHandler.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
     {
67 67
         parent::__construct($config, $ipAddress);
68 68
 
69
-        if (! empty($config->sessionSavePath)) {
69
+        if (!empty($config->sessionSavePath)) {
70 70
             $this->savePath = rtrim($config->sessionSavePath, '/\\');
71 71
             ini_set('session.save_path', $config->sessionSavePath);
72 72
         } else {
73 73
             $sessionPath = rtrim(ini_get('session.save_path'), '/\\');
74 74
 
75
-            if (! $sessionPath) {
75
+            if (!$sessionPath) {
76 76
                 $sessionPath = WRITEPATH . 'session';
77 77
             }
78 78
 
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
      */
95 95
     public function open($path, $name): bool
96 96
     {
97
-        if (! is_dir($path) && ! mkdir($path, 0700, true)) {
97
+        if (!is_dir($path) && !mkdir($path, 0700, true)) {
98 98
             throw SessionException::forInvalidSavePath($this->savePath);
99 99
         }
100 100
 
101
-        if (! is_writable($path)) {
101
+        if (!is_writable($path)) {
102 102
             throw SessionException::forWriteProtectedSavePath($this->savePath);
103 103
         }
104 104
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         // This might seem weird, but PHP 5.6 introduced session_reset(),
125 125
         // which re-reads session data
126 126
         if ($this->fileHandle === null) {
127
-            $this->fileNew = ! is_file($this->filePath . $id);
127
+            $this->fileNew = !is_file($this->filePath . $id);
128 128
 
129 129
             if (($this->fileHandle = fopen($this->filePath . $id, 'c+b')) === false) {
130 130
                 $this->logger->error("Session: Unable to open file '" . $this->filePath . $id . "'.");
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
                 return false;
141 141
             }
142 142
 
143
-            if (! isset($this->sessionID)) {
143
+            if (!isset($this->sessionID)) {
144 144
                 $this->sessionID = $id;
145 145
             }
146 146
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
             $this->sessionID = $id;
185 185
         }
186 186
 
187
-        if (! is_resource($this->fileHandle)) {
187
+        if (!is_resource($this->fileHandle)) {
188 188
             return false;
189 189
         }
190 190
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
             return ($this->fileNew) ? true : touch($this->filePath . $id);
193 193
         }
194 194
 
195
-        if (! $this->fileNew) {
195
+        if (!$this->fileNew) {
196 196
             ftruncate($this->fileHandle, 0);
197 197
             rewind($this->fileHandle);
198 198
         }
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
                 }
207 207
             }
208 208
 
209
-            if (! is_int($result)) {
209
+            if (!is_int($result)) {
210 210
                 $this->fingerprint = md5(substr($data, 0, $written));
211 211
                 $this->logger->error('Session: Unable to write data.');
212 212
 
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
     #[ReturnTypeWillChange]
271 271
     public function gc($max_lifetime)
272 272
     {
273
-        if (! is_dir($this->savePath) || ($directory = opendir($this->savePath)) === false) {
273
+        if (!is_dir($this->savePath) || ($directory = opendir($this->savePath)) === false) {
274 274
             $this->logger->debug("Session: Garbage collector couldn't list files under directory '" . $this->savePath . "'.");
275 275
 
276 276
             return false;
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
 
290 290
         while (($file = readdir($directory)) !== false) {
291 291
             // If the filename doesn't match this pattern, it's either not a session file or is not ours
292
-            if (! preg_match($pattern, $file)
293
-                || ! is_file($this->savePath . DIRECTORY_SEPARATOR . $file)
292
+            if (!preg_match($pattern, $file)
293
+                || !is_file($this->savePath . DIRECTORY_SEPARATOR . $file)
294 294
                 || ($mtime = filemtime($this->savePath . DIRECTORY_SEPARATOR . $file)) === false
295 295
                 || $mtime > $ts
296 296
             ) {
Please login to merge, or discard this patch.
brighty/system/Session/Handlers/RedisHandler.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         }
70 70
 
71 71
         if (preg_match('#(?:tcp://)?([^:?]+)(?:\:(\d+))?(\?.+)?#', $this->savePath, $matches)) {
72
-            if (! isset($matches[3])) {
72
+            if (!isset($matches[3])) {
73 73
                 $matches[3] = ''; // Just to avoid undefined index notices below
74 74
             }
75 75
 
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
 
110 110
         $redis = new Redis();
111 111
 
112
-        if (! $redis->connect($this->savePath['host'], $this->savePath['port'], $this->savePath['timeout'])) {
112
+        if (!$redis->connect($this->savePath['host'], $this->savePath['port'], $this->savePath['timeout'])) {
113 113
             $this->logger->error('Session: Unable to connect to Redis with the configured settings.');
114
-        } elseif (isset($this->savePath['password']) && ! $redis->auth($this->savePath['password'])) {
114
+        } elseif (isset($this->savePath['password']) && !$redis->auth($this->savePath['password'])) {
115 115
             $this->logger->error('Session: Unable to authenticate to Redis instance.');
116
-        } elseif (isset($this->savePath['database']) && ! $redis->select($this->savePath['database'])) {
116
+        } elseif (isset($this->savePath['database']) && !$redis->select($this->savePath['database'])) {
117 117
             $this->logger->error('Session: Unable to select Redis database with index ' . $this->savePath['database']);
118 118
         } else {
119 119
             $this->redis = $redis;
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
     public function read($id)
137 137
     {
138 138
         if (isset($this->redis) && $this->lockSession($id)) {
139
-            if (! isset($this->sessionID)) {
139
+            if (!isset($this->sessionID)) {
140 140
                 $this->sessionID = $id;
141 141
             }
142 142
 
@@ -164,12 +164,12 @@  discard block
 block discarded – undo
164 164
      */
165 165
     public function write($id, $data): bool
166 166
     {
167
-        if (! isset($this->redis)) {
167
+        if (!isset($this->redis)) {
168 168
             return false;
169 169
         }
170 170
 
171 171
         if ($this->sessionID !== $id) {
172
-            if (! $this->releaseLock() || ! $this->lockSession($id)) {
172
+            if (!$this->releaseLock() || !$this->lockSession($id)) {
173 173
                 return false;
174 174
             }
175 175
 
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
                         $this->redis->del($this->lockKey);
212 212
                     }
213 213
 
214
-                    if (! $this->redis->close()) {
214
+                    if (!$this->redis->close()) {
215 215
                         return false;
216 216
                     }
217 217
                 }
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
                 continue;
284 284
             }
285 285
 
286
-            if (! $this->redis->setex($lockKey, 300, (string) time())) {
286
+            if (!$this->redis->setex($lockKey, 300, (string) time())) {
287 287
                 $this->logger->error('Session: Error while trying to obtain lock for ' . $this->keyPrefix . $sessionID);
288 288
 
289 289
                 return false;
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
     protected function releaseLock(): bool
315 315
     {
316 316
         if (isset($this->redis, $this->lockKey) && $this->lock) {
317
-            if (! $this->redis->del($this->lockKey)) {
317
+            if (!$this->redis->del($this->lockKey)) {
318 318
                 $this->logger->error('Session: Error while trying to free lock for ' . $this->lockKey);
319 319
 
320 320
                 return false;
Please login to merge, or discard this patch.
brighty/system/Session/Handlers/MemcachedHandler.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
             $this->keyPrefix .= $this->ipAddress . ':';
65 65
         }
66 66
 
67
-        if (! empty($this->keyPrefix)) {
67
+        if (!empty($this->keyPrefix)) {
68 68
             ini_set('memcached.sess_prefix', $this->keyPrefix);
69 69
         }
70 70
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
             $serverList[] = $server['host'] . ':' . $server['port'];
89 89
         }
90 90
 
91
-        if (! preg_match_all('#,?([^,:]+)\:(\d{1,5})(?:\:(\d+))?#', $this->savePath, $matches, PREG_SET_ORDER)) {
91
+        if (!preg_match_all('#,?([^,:]+)\:(\d{1,5})(?:\:(\d+))?#', $this->savePath, $matches, PREG_SET_ORDER)) {
92 92
             $this->memcached = null;
93 93
             $this->logger->error('Session: Invalid Memcached save path format: ' . $this->savePath);
94 94
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
                 continue;
104 104
             }
105 105
 
106
-            if (! $this->memcached->addServer($match[1], $match[2], $match[3] ?? 0)) {
106
+            if (!$this->memcached->addServer($match[1], $match[2], $match[3] ?? 0)) {
107 107
                 $this->logger->error('Could not add ' . $match[1] . ':' . $match[2] . ' to Memcached server pool.');
108 108
             } else {
109 109
                 $serverList[] = $match[1] . ':' . $match[2];
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     public function read($id)
132 132
     {
133 133
         if (isset($this->memcached) && $this->lockSession($id)) {
134
-            if (! isset($this->sessionID)) {
134
+            if (!isset($this->sessionID)) {
135 135
                 $this->sessionID = $id;
136 136
             }
137 137
 
@@ -153,12 +153,12 @@  discard block
 block discarded – undo
153 153
      */
154 154
     public function write($id, $data): bool
155 155
     {
156
-        if (! isset($this->memcached)) {
156
+        if (!isset($this->memcached)) {
157 157
             return false;
158 158
         }
159 159
 
160 160
         if ($this->sessionID !== $id) {
161
-            if (! $this->releaseLock() || ! $this->lockSession($id)) {
161
+            if (!$this->releaseLock() || !$this->lockSession($id)) {
162 162
                 return false;
163 163
             }
164 164
 
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
                 $this->memcached->delete($this->lockKey);
196 196
             }
197 197
 
198
-            if (! $this->memcached->quit()) {
198
+            if (!$this->memcached->quit()) {
199 199
                 return false;
200 200
             }
201 201
 
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
                 continue;
259 259
             }
260 260
 
261
-            if (! $this->memcached->set($lockKey, time(), 300)) {
261
+            if (!$this->memcached->set($lockKey, time(), 300)) {
262 262
                 $this->logger->error('Session: Error while trying to obtain lock for ' . $this->keyPrefix . $sessionID);
263 263
 
264 264
                 return false;
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
     {
287 287
         if (isset($this->memcached, $this->lockKey) && $this->lock) {
288 288
             if (
289
-                ! $this->memcached->delete($this->lockKey)
289
+                !$this->memcached->delete($this->lockKey)
290 290
                 && $this->memcached->getResultCode() !== Memcached::RES_NOTFOUND
291 291
             ) {
292 292
                 $this->logger->error('Session: Error while trying to free lock for ' . $this->lockKey);
Please login to merge, or discard this patch.
brighty/system/Test/FilterTestTrait.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -126,14 +126,14 @@  discard block
 block discarded – undo
126 126
      */
127 127
     protected function getFilterCaller($filter, string $position): Closure
128 128
     {
129
-        if (! in_array($position, ['before', 'after'], true)) {
129
+        if (!in_array($position, ['before', 'after'], true)) {
130 130
             throw new InvalidArgumentException('Invalid filter position passed: ' . $position);
131 131
         }
132 132
 
133 133
         if (is_string($filter)) {
134 134
             // Check for an alias (no namespace)
135 135
             if (strpos($filter, '\\') === false) {
136
-                if (! isset($this->filtersConfig->aliases[$filter])) {
136
+                if (!isset($this->filtersConfig->aliases[$filter])) {
137 137
                     throw new RuntimeException("No filter found with alias '{$filter}'");
138 138
                 }
139 139
 
@@ -144,21 +144,21 @@  discard block
 block discarded – undo
144 144
             $filter = new $filter();
145 145
         }
146 146
 
147
-        if (! $filter instanceof FilterInterface) {
147
+        if (!$filter instanceof FilterInterface) {
148 148
             throw FilterException::forIncorrectInterface(get_class($filter));
149 149
         }
150 150
 
151 151
         $request = clone $this->request;
152 152
 
153 153
         if ($position === 'before') {
154
-            return static function (?array $params = null) use ($filter, $request) {
154
+            return static function(?array $params = null) use ($filter, $request) {
155 155
                 return $filter->before($request, $params);
156 156
             };
157 157
         }
158 158
 
159 159
         $response = clone $this->response;
160 160
 
161
-        return static function (?array $params = null) use ($filter, $request, $response) {
161
+        return static function(?array $params = null) use ($filter, $request, $response) {
162 162
             return $filter->after($request, $response, $params);
163 163
         };
164 164
     }
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
      */
175 175
     protected function getFiltersForRoute(string $route, string $position): array
176 176
     {
177
-        if (! in_array($position, ['before', 'after'], true)) {
177
+        if (!in_array($position, ['before', 'after'], true)) {
178 178
             throw new InvalidArgumentException('Invalid filter position passed:' . $position);
179 179
         }
180 180
 
Please login to merge, or discard this patch.
brighty/system/Test/ControllerTestTrait.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
             $this->appConfig = config('App');
100 100
         }
101 101
 
102
-        if (! $this->uri instanceof URI) {
102
+        if (!$this->uri instanceof URI) {
103 103
             $this->uri = Services::uri($this->appConfig->baseURL ?? 'http://example.com/', false);
104 104
         }
105 105
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      */
131 131
     public function controller(string $name)
132 132
     {
133
-        if (! class_exists($name)) {
133
+        if (!class_exists($name)) {
134 134
             throw new InvalidArgumentException('Invalid Controller: ' . $name);
135 135
         }
136 136
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
      */
152 152
     public function execute(string $method, ...$params)
153 153
     {
154
-        if (! method_exists($this->controller, $method) || ! is_callable([$this->controller, $method])) {
154
+        if (!method_exists($this->controller, $method) || !is_callable([$this->controller, $method])) {
155 155
             throw new InvalidArgumentException('Method does not exist or is not callable in controller: ' . $method);
156 156
         }
157 157
 
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
         }
178 178
 
179 179
         // If the controller did not return a response then start one
180
-        if (! $response instanceof Response) {
180
+        if (!$response instanceof Response) {
181 181
             $response = $this->response;
182 182
         }
183 183
 
Please login to merge, or discard this patch.
brighty/system/Test/Mock/MockCache.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
     {
115 115
         $key = static::validateKey($key, $this->prefix);
116 116
 
117
-        if (! isset($this->cache[$key])) {
117
+        if (!isset($this->cache[$key])) {
118 118
             return false;
119 119
         }
120 120
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 
155 155
         if (empty($data)) {
156 156
             $data = 0;
157
-        } elseif (! is_int($data)) {
157
+        } elseif (!is_int($data)) {
158 158
             return false;
159 159
         }
160 160
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 
175 175
         if (empty($data)) {
176 176
             $data = 0;
177
-        } elseif (! is_int($data)) {
177
+        } elseif (!is_int($data)) {
178 178
             return false;
179 179
         }
180 180
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
     public function getMetaData(string $key)
217 217
     {
218 218
         // Misses return null
219
-        if (! array_key_exists($key, $this->expirations)) {
219
+        if (!array_key_exists($key, $this->expirations)) {
220 220
             return null;
221 221
         }
222 222
 
Please login to merge, or discard this patch.
brighty/system/Test/Mock/MockCommon.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
  * the LICENSE file that was distributed with this source code.
10 10
  */
11 11
 
12
-if (! function_exists('is_cli')) {
12
+if (!function_exists('is_cli')) {
13 13
     /**
14 14
      * Is CLI?
15 15
      *
Please login to merge, or discard this patch.
brighty/system/Test/Mock/MockConnection.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
 
52 52
         $query->setQuery($sql, $binds, $setEscapeFlags);
53 53
 
54
-        if (! empty($this->swapPre) && ! empty($this->DBPrefix)) {
54
+        if (!empty($this->swapPre) && !empty($this->DBPrefix)) {
55 55
             $query->swapPrefix($this->DBPrefix, $this->swapPre);
56 56
         }
57 57
 
Please login to merge, or discard this patch.
brighty/system/Test/ControllerTester.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
             $this->appConfig = config('App');
100 100
         }
101 101
 
102
-        if (! $this->uri instanceof URI) {
102
+        if (!$this->uri instanceof URI) {
103 103
             $this->uri = Services::uri($this->appConfig->baseURL ?? 'http://example.com/', false);
104 104
         }
105 105
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      */
131 131
     public function controller(string $name)
132 132
     {
133
-        if (! class_exists($name)) {
133
+        if (!class_exists($name)) {
134 134
             throw new InvalidArgumentException('Invalid Controller: ' . $name);
135 135
         }
136 136
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
      */
152 152
     public function execute(string $method, ...$params)
153 153
     {
154
-        if (! method_exists($this->controller, $method) || ! is_callable([$this->controller, $method])) {
154
+        if (!method_exists($this->controller, $method) || !is_callable([$this->controller, $method])) {
155 155
             throw new InvalidArgumentException('Method does not exist or is not callable in controller: ' . $method);
156 156
         }
157 157
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
                 $output = $response;
192 192
                 $result->response()->setBody($output);
193 193
                 $result->setBody($output);
194
-            } elseif (! empty($response) && ! empty($response->getBody())) {
194
+            } elseif (!empty($response) && !empty($response->getBody())) {
195 195
                 $result->setBody($response->getBody());
196 196
             } else {
197 197
                 $result->setBody('');
Please login to merge, or discard this patch.