@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | |
203 | 203 | $dataIsExisting = array_reduce( |
204 | 204 | array_keys($flattenedData), |
205 | - static function ($carry, $item) use ($ifExistField) { |
|
205 | + static function($carry, $item) use ($ifExistField) { |
|
206 | 206 | $pattern = sprintf('/%s/u', $ifExistField); |
207 | 207 | |
208 | 208 | return $carry || preg_match($pattern, $item) === 1; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | |
216 | 216 | unset($ifExistField, $flattenedData); |
217 | 217 | |
218 | - if (! $dataIsExisting) { |
|
218 | + if (!$dataIsExisting) { |
|
219 | 219 | // we return early if `if_exist` is not satisfied. we have nothing to do here. |
220 | 220 | return true; |
221 | 221 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | |
227 | 227 | if (in_array('permit_empty', $rules, true)) { |
228 | 228 | if ( |
229 | - ! in_array('required', $rules, true) |
|
229 | + !in_array('required', $rules, true) |
|
230 | 230 | && (is_array($value) ? $value === [] : trim((string) $value) === '') |
231 | 231 | ) { |
232 | 232 | $passed = true; |
@@ -236,13 +236,13 @@ discard block |
||
236 | 236 | $rule = $match[1]; |
237 | 237 | $param = $match[2]; |
238 | 238 | |
239 | - if (! in_array($rule, ['required_with', 'required_without'], true)) { |
|
239 | + if (!in_array($rule, ['required_with', 'required_without'], true)) { |
|
240 | 240 | continue; |
241 | 241 | } |
242 | 242 | |
243 | 243 | // Check in our rulesets |
244 | 244 | foreach ($this->ruleSetInstances as $set) { |
245 | - if (! method_exists($set, $rule)) { |
|
245 | + if (!method_exists($set, $rule)) { |
|
246 | 246 | continue; |
247 | 247 | } |
248 | 248 | |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | $passed = false; |
267 | 267 | $param = false; |
268 | 268 | |
269 | - if (! $isCallable && preg_match('/(.*?)\[(.*)\]/', $rule, $match)) { |
|
269 | + if (!$isCallable && preg_match('/(.*?)\[(.*)\]/', $rule, $match)) { |
|
270 | 270 | $rule = $match[1]; |
271 | 271 | $param = $match[2]; |
272 | 272 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | |
283 | 283 | // Check in our rulesets |
284 | 284 | foreach ($this->ruleSetInstances as $set) { |
285 | - if (! method_exists($set, $rule)) { |
|
285 | + if (!method_exists($set, $rule)) { |
|
286 | 286 | continue; |
287 | 287 | } |
288 | 288 | |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | |
297 | 297 | // If the rule wasn't found anywhere, we |
298 | 298 | // should throw an exception so the developer can find it. |
299 | - if (! $found) { |
|
299 | + if (!$found) { |
|
300 | 300 | throw ValidationException::forRuleNotFound($rule); |
301 | 301 | } |
302 | 302 | } |
@@ -403,11 +403,11 @@ discard block |
||
403 | 403 | $this->customErrors = $errors; |
404 | 404 | |
405 | 405 | foreach ($rules as $field => &$rule) { |
406 | - if (! is_array($rule)) { |
|
406 | + if (!is_array($rule)) { |
|
407 | 407 | continue; |
408 | 408 | } |
409 | 409 | |
410 | - if (! array_key_exists('errors', $rule)) { |
|
410 | + if (!array_key_exists('errors', $rule)) { |
|
411 | 411 | continue; |
412 | 412 | } |
413 | 413 | |
@@ -447,11 +447,11 @@ discard block |
||
447 | 447 | */ |
448 | 448 | public function getRuleGroup(string $group): array |
449 | 449 | { |
450 | - if (! isset($this->config->{$group})) { |
|
450 | + if (!isset($this->config->{$group})) { |
|
451 | 451 | throw ValidationException::forGroupNotFound($group); |
452 | 452 | } |
453 | 453 | |
454 | - if (! is_array($this->config->{$group})) { |
|
454 | + if (!is_array($this->config->{$group})) { |
|
455 | 455 | throw ValidationException::forGroupNotArray($group); |
456 | 456 | } |
457 | 457 | |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | */ |
482 | 482 | public function listErrors(string $template = 'list'): string |
483 | 483 | { |
484 | - if (! array_key_exists($template, $this->config->templates)) { |
|
484 | + if (!array_key_exists($template, $this->config->templates)) { |
|
485 | 485 | throw ValidationException::forInvalidTemplate($template); |
486 | 486 | } |
487 | 487 | |
@@ -495,11 +495,11 @@ discard block |
||
495 | 495 | */ |
496 | 496 | public function showError(string $field, string $template = 'single'): string |
497 | 497 | { |
498 | - if (! array_key_exists($field, $this->getErrors())) { |
|
498 | + if (!array_key_exists($field, $this->getErrors())) { |
|
499 | 499 | return ''; |
500 | 500 | } |
501 | 501 | |
502 | - if (! array_key_exists($template, $this->config->templates)) { |
|
502 | + if (!array_key_exists($template, $this->config->templates)) { |
|
503 | 503 | throw ValidationException::forInvalidTemplate($template); |
504 | 504 | } |
505 | 505 | |
@@ -539,11 +539,11 @@ discard block |
||
539 | 539 | return null; |
540 | 540 | } |
541 | 541 | |
542 | - if (! isset($this->config->{$group})) { |
|
542 | + if (!isset($this->config->{$group})) { |
|
543 | 543 | throw ValidationException::forGroupNotFound($group); |
544 | 544 | } |
545 | 545 | |
546 | - if (! is_array($this->config->{$group})) { |
|
546 | + if (!is_array($this->config->{$group})) { |
|
547 | 547 | throw ValidationException::forGroupNotArray($group); |
548 | 548 | } |
549 | 549 | |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | $replacements["{{$key}}"] = $value; |
584 | 584 | } |
585 | 585 | |
586 | - if (! empty($replacements)) { |
|
586 | + if (!empty($replacements)) { |
|
587 | 587 | foreach ($rules as &$rule) { |
588 | 588 | if (is_array($rule)) { |
589 | 589 | foreach ($rule as &$row) { |
@@ -645,7 +645,7 @@ discard block |
||
645 | 645 | // If we already have errors, we'll use those. |
646 | 646 | // If we don't, check the session to see if any were |
647 | 647 | // passed along from a redirect_with_input request. |
648 | - if (empty($this->errors) && ! is_cli() && isset($_SESSION, $_SESSION['_ci_validation_errors'])) { |
|
648 | + if (empty($this->errors) && !is_cli() && isset($_SESSION, $_SESSION['_ci_validation_errors'])) { |
|
649 | 649 | $this->errors = unserialize($_SESSION['_ci_validation_errors']); |
650 | 650 | } |
651 | 651 |
@@ -161,11 +161,11 @@ discard block |
||
161 | 161 | */ |
162 | 162 | protected function registerProperties() |
163 | 163 | { |
164 | - if (! static::$moduleConfig->shouldDiscover('registrars')) { |
|
164 | + if (!static::$moduleConfig->shouldDiscover('registrars')) { |
|
165 | 165 | return; |
166 | 166 | } |
167 | 167 | |
168 | - if (! static::$didDiscovery) { |
|
168 | + if (!static::$didDiscovery) { |
|
169 | 169 | $locator = Services::locator(); |
170 | 170 | $registrarsFiles = $locator->search('Config/Registrar.php'); |
171 | 171 | |
@@ -182,13 +182,13 @@ discard block |
||
182 | 182 | // Check the registrar class for a method named after this class' shortName |
183 | 183 | foreach (static::$registrars as $callable) { |
184 | 184 | // ignore non-applicable registrars |
185 | - if (! method_exists($callable, $shortName)) { |
|
185 | + if (!method_exists($callable, $shortName)) { |
|
186 | 186 | continue; // @codeCoverageIgnore |
187 | 187 | } |
188 | 188 | |
189 | 189 | $properties = $callable::$shortName(); |
190 | 190 | |
191 | - if (! is_array($properties)) { |
|
191 | + if (!is_array($properties)) { |
|
192 | 192 | throw new RuntimeException('Registrars must return an array of properties and their values.'); |
193 | 193 | } |
194 | 194 |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | return static::$mocks[$key]; |
183 | 183 | } |
184 | 184 | |
185 | - if (! isset(static::$instances[$key])) { |
|
185 | + if (!isset(static::$instances[$key])) { |
|
186 | 186 | // Make sure $getShared is false |
187 | 187 | $params[] = false; |
188 | 188 | |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | */ |
313 | 313 | protected static function discoverServices(string $name, array $arguments) |
314 | 314 | { |
315 | - if (! static::$discovered) { |
|
315 | + if (!static::$discovered) { |
|
316 | 316 | $config = config('Modules'); |
317 | 317 | |
318 | 318 | if ($config->shouldDiscover('services')) { |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | foreach ($files as $file) { |
329 | 329 | $classname = $locator->getClassname($file); |
330 | 330 | |
331 | - if (! in_array($classname, ['CodeIgniter\\Config\\Services'], true)) { |
|
331 | + if (!in_array($classname, ['CodeIgniter\\Config\\Services'], true)) { |
|
332 | 332 | static::$services[] = new $classname(); |
333 | 333 | } |
334 | 334 | } |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | static::$discovered = true; |
338 | 338 | } |
339 | 339 | |
340 | - if (! static::$services) { |
|
340 | + if (!static::$services) { |
|
341 | 341 | // we found stuff, but no services - this would be really bad |
342 | 342 | return null; |
343 | 343 | } |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | |
355 | 355 | protected static function buildServicesCache(): void |
356 | 356 | { |
357 | - if (! static::$discovered) { |
|
357 | + if (!static::$discovered) { |
|
358 | 358 | $config = config('Modules'); |
359 | 359 | |
360 | 360 | if ($config->shouldDiscover('services')) { |
@@ -189,7 +189,7 @@ |
||
189 | 189 | return static::getSharedInstance('email', $config); |
190 | 190 | } |
191 | 191 | |
192 | - if (empty($config) || ! (is_array($config) || $config instanceof EmailConfig)) { |
|
192 | + if (empty($config) || !(is_array($config) || $config instanceof EmailConfig)) { |
|
193 | 193 | $config = config('Email'); |
194 | 194 | } |
195 | 195 |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | // Determine the component-specific options |
83 | 83 | $options = array_merge(self::getOptions(strtolower($component)), $options); |
84 | 84 | |
85 | - if (! $options['getShared']) { |
|
85 | + if (!$options['getShared']) { |
|
86 | 86 | if ($class = self::locateClass($options, $name)) { |
87 | 87 | return new $class(...$arguments); |
88 | 88 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | } |
104 | 104 | |
105 | 105 | // Try to locate the class |
106 | - if (! $class = self::locateClass($options, $name)) { |
|
106 | + if (!$class = self::locateClass($options, $name)) { |
|
107 | 107 | return null; |
108 | 108 | } |
109 | 109 | |
@@ -147,14 +147,14 @@ discard block |
||
147 | 147 | |
148 | 148 | // Check if the class was namespaced |
149 | 149 | if (strpos($name, '\\') !== false) { |
150 | - if (! $file = $locator->locateFile($name, $options['path'])) { |
|
150 | + if (!$file = $locator->locateFile($name, $options['path'])) { |
|
151 | 151 | return null; |
152 | 152 | } |
153 | 153 | $files = [$file]; |
154 | 154 | } |
155 | 155 | // No namespace? Search for it |
156 | 156 | // Check all namespaces, prioritizing App and modules |
157 | - elseif (! $files = $locator->search($options['path'] . DIRECTORY_SEPARATOR . $name)) { |
|
157 | + elseif (!$files = $locator->search($options['path'] . DIRECTORY_SEPARATOR . $name)) { |
|
158 | 158 | return null; |
159 | 159 | } |
160 | 160 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | protected static function verifyPreferApp(array $options, string $name): bool |
180 | 180 | { |
181 | 181 | // Anything without that restriction passes |
182 | - if (! $options['preferApp']) { |
|
182 | + if (!$options['preferApp']) { |
|
183 | 183 | return true; |
184 | 184 | } |
185 | 185 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | protected static function verifyInstanceOf(array $options, string $name): bool |
201 | 201 | { |
202 | 202 | // Anything without that restriction passes |
203 | - if (! $options['instanceOf']) { |
|
203 | + if (!$options['instanceOf']) { |
|
204 | 204 | return true; |
205 | 205 | } |
206 | 206 |
@@ -22,12 +22,12 @@ |
||
22 | 22 | */ |
23 | 23 | |
24 | 24 | // Prevent access to BaseController |
25 | -$routes->add('BaseController(:any)', static function () { |
|
25 | +$routes->add('BaseController(:any)', static function() { |
|
26 | 26 | throw PageNotFoundException::forPageNotFound(); |
27 | 27 | }); |
28 | 28 | |
29 | 29 | // Prevent access to initController method |
30 | -$routes->add('(:any)/initController', static function () { |
|
30 | +$routes->add('(:any)/initController', static function() { |
|
31 | 31 | throw PageNotFoundException::forPageNotFound(); |
32 | 32 | }); |
33 | 33 |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | public function parse(): ?array |
52 | 52 | { |
53 | 53 | // We don't want to enforce the presence of a .env file, they should be optional. |
54 | - if (! is_file($this->path)) { |
|
54 | + if (!is_file($this->path)) { |
|
55 | 55 | return null; |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Ensure the file is readable |
59 | - if (! is_readable($this->path)) { |
|
59 | + if (!is_readable($this->path)) { |
|
60 | 60 | throw new InvalidArgumentException("The .env file is not readable: {$this->path}"); |
61 | 61 | } |
62 | 62 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | protected function setVariable(string $name, string $value = '') |
90 | 90 | { |
91 | - if (! getenv($name, true)) { |
|
91 | + if (!getenv($name, true)) { |
|
92 | 92 | putenv("{$name}={$value}"); |
93 | 93 | } |
94 | 94 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | protected function sanitizeValue(string $value): string |
137 | 137 | { |
138 | - if (! $value) { |
|
138 | + if (!$value) { |
|
139 | 139 | return $value; |
140 | 140 | } |
141 | 141 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | if (strpos($value, '$') !== false) { |
191 | 191 | $value = preg_replace_callback( |
192 | 192 | '/\${([a-zA-Z0-9_\.]+)}/', |
193 | - function ($matchedPatterns) { |
|
193 | + function($matchedPatterns) { |
|
194 | 194 | $nestedVariable = $this->getVariable($matchedPatterns[1]); |
195 | 195 | |
196 | 196 | if ($nestedVariable === null) { |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $files = Services::locator()->search('Config/Events.php'); |
81 | 81 | } |
82 | 82 | |
83 | - $files = array_filter(array_map(static function (string $file) { |
|
83 | + $files = array_filter(array_map(static function(string $file) { |
|
84 | 84 | if (is_file($file)) { |
85 | 85 | return realpath($file) ?: $file; |
86 | 86 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public static function on($eventName, $callback, $priority = EVENT_PRIORITY_NORMAL) |
114 | 114 | { |
115 | - if (! isset(static::$listeners[$eventName])) { |
|
115 | + if (!isset(static::$listeners[$eventName])) { |
|
116 | 116 | static::$listeners[$eventName] = [ |
117 | 117 | true, // If there's only 1 item, it's sorted. |
118 | 118 | [$priority], |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | public static function trigger($eventName, ...$arguments): bool |
138 | 138 | { |
139 | 139 | // Read in our Config/Events file so that we have them all! |
140 | - if (! static::$initialized) { |
|
140 | + if (!static::$initialized) { |
|
141 | 141 | static::initialize(); |
142 | 142 | } |
143 | 143 | |
@@ -172,12 +172,12 @@ discard block |
||
172 | 172 | */ |
173 | 173 | public static function listeners($eventName): array |
174 | 174 | { |
175 | - if (! isset(static::$listeners[$eventName])) { |
|
175 | + if (!isset(static::$listeners[$eventName])) { |
|
176 | 176 | return []; |
177 | 177 | } |
178 | 178 | |
179 | 179 | // The list is not sorted |
180 | - if (! static::$listeners[$eventName][0]) { |
|
180 | + if (!static::$listeners[$eventName][0]) { |
|
181 | 181 | // Sort it! |
182 | 182 | array_multisort(static::$listeners[$eventName][1], SORT_NUMERIC, static::$listeners[$eventName][2]); |
183 | 183 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | */ |
199 | 199 | public static function removeListener($eventName, callable $listener): bool |
200 | 200 | { |
201 | - if (! isset(static::$listeners[$eventName])) { |
|
201 | + if (!isset(static::$listeners[$eventName])) { |
|
202 | 202 | return false; |
203 | 203 | } |
204 | 204 |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | protected $escape = []; |
91 | 91 | |
92 | - public function __construct(?ConnectionInterface &$db = null, ?ValidationInterface $validation = null) |
|
92 | + public function __construct(?ConnectionInterface & $db = null, ?ValidationInterface $validation = null) |
|
93 | 93 | { |
94 | 94 | /** |
95 | 95 | * @var BaseConnection $db |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | |
226 | 226 | // Require non empty primaryKey when |
227 | 227 | // not using auto-increment feature |
228 | - if (! $this->useAutoIncrement && empty($data[$this->primaryKey])) { |
|
228 | + if (!$this->useAutoIncrement && empty($data[$this->primaryKey])) { |
|
229 | 229 | throw DataException::forEmptyPrimaryKey('insert'); |
230 | 230 | } |
231 | 231 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | |
241 | 241 | // If insertion succeeded then save the insert ID |
242 | 242 | if ($result) { |
243 | - $this->insertID = ! $this->useAutoIncrement ? $data[$this->primaryKey] : $this->db->insertID(); |
|
243 | + $this->insertID = !$this->useAutoIncrement ? $data[$this->primaryKey] : $this->db->insertID(); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | return $result; |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | foreach ($set as $row) { |
264 | 264 | // Require non empty primaryKey when |
265 | 265 | // not using auto-increment feature |
266 | - if (! $this->useAutoIncrement && empty($row[$this->primaryKey])) { |
|
266 | + if (!$this->useAutoIncrement && empty($row[$this->primaryKey])) { |
|
267 | 267 | throw DataException::forEmptyPrimaryKey('insertBatch'); |
268 | 268 | } |
269 | 269 | } |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | $builder = $builder->whereIn($this->primaryKey, $id); |
337 | 337 | } |
338 | 338 | |
339 | - if ($this->useSoftDeletes && ! $purge) { |
|
339 | + if ($this->useSoftDeletes && !$purge) { |
|
340 | 340 | if (empty($builder->getCompiledQBWhere())) { |
341 | 341 | if (CI_DEBUG) { |
342 | 342 | throw new DatabaseException( |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | return $data->{$this->primaryKey}; |
445 | 445 | } |
446 | 446 | |
447 | - if (is_array($data) && ! empty($data[$this->primaryKey])) { |
|
447 | + if (is_array($data) && !empty($data[$this->primaryKey])) { |
|
448 | 448 | return $data[$this->primaryKey]; |
449 | 449 | } |
450 | 450 | |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | $builder = clone $this->builder(); |
469 | 469 | $rows = $builder->get($size, $offset); |
470 | 470 | |
471 | - if (! $rows) { |
|
471 | + if (!$rows) { |
|
472 | 472 | throw DataException::forEmptyDataset('chunk'); |
473 | 473 | } |
474 | 474 | |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | $table = empty($table) ? $this->table : $table; |
539 | 539 | |
540 | 540 | // Ensure we have a good db connection |
541 | - if (! $this->db instanceof BaseConnection) { |
|
541 | + if (!$this->db instanceof BaseConnection) { |
|
542 | 542 | $this->db = Database::connect($this->DBGroup); |
543 | 543 | } |
544 | 544 | |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | */ |
611 | 611 | public function insert($data = null, bool $returnID = true) |
612 | 612 | { |
613 | - if (! empty($this->tempData['data'])) { |
|
613 | + if (!empty($this->tempData['data'])) { |
|
614 | 614 | if (empty($data)) { |
615 | 615 | $data = $this->tempData['data'] ?? null; |
616 | 616 | } else { |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | */ |
637 | 637 | public function update($id = null, $data = null): bool |
638 | 638 | { |
639 | - if (! empty($this->tempData['data'])) { |
|
639 | + if (!empty($this->tempData['data'])) { |
|
640 | 640 | if (empty($data)) { |
641 | 641 | $data = $this->tempData['data'] ?? null; |
642 | 642 | } else { |
@@ -668,8 +668,8 @@ discard block |
||
668 | 668 | |
669 | 669 | // Always grab the primary key otherwise updates will fail. |
670 | 670 | if ( |
671 | - method_exists($data, 'toRawArray') && (! empty($properties) && ! empty($this->primaryKey) && ! in_array($this->primaryKey, $properties, true) |
|
672 | - && ! empty($data->{$this->primaryKey})) |
|
671 | + method_exists($data, 'toRawArray') && (!empty($properties) && !empty($this->primaryKey) && !in_array($this->primaryKey, $properties, true) |
|
672 | + && !empty($data->{$this->primaryKey})) |
|
673 | 673 | ) { |
674 | 674 | $properties[$this->primaryKey] = $data->{$this->primaryKey}; |
675 | 675 | } |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | $properties = $data->toRawArray($onlyChanged); |
757 | 757 | |
758 | 758 | // Always grab the primary key otherwise updates will fail. |
759 | - if (! empty($properties) && ! empty($primaryKey) && ! in_array($primaryKey, $properties, true) && ! empty($data->{$primaryKey})) { |
|
759 | + if (!empty($properties) && !empty($primaryKey) && !in_array($primaryKey, $properties, true) && !empty($data->{$primaryKey})) { |
|
760 | 760 | $properties[$primaryKey] = $data->{$primaryKey}; |
761 | 761 | } |
762 | 762 | } else { |