@@ -239,14 +239,14 @@ discard block |
||
| 239 | 239 | return $expires->setTimezone(new DateTimeZone('GMT')); // @phpstan-ignore-line |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - if (! is_string($expires) && ! is_int($expires)) { |
|
| 242 | + if (!is_string($expires) && !is_int($expires)) { |
|
| 243 | 243 | throw new InvalidArgumentException(sprintf( |
| 244 | 244 | 'Invalid type `%s` for expires. Expected an string, integer or DateTime object.', |
| 245 | 245 | getTypeName($expires) |
| 246 | 246 | )); |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - if (! is_numeric($expires)) { |
|
| 249 | + if (!is_numeric($expires)) { |
|
| 250 | 250 | $expires = strtotime($expires) ?: null; |
| 251 | 251 | } |
| 252 | 252 | |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | if (isset($data['samesite'])) { |
| 300 | 300 | // Ignorer la valeur non valide lors de l'analyse des en-têtes |
| 301 | 301 | // https://tools.ietf.org/html/draft-west-first-party-cookies-07#section-4.1 |
| 302 | - if (! in_array($data['samesite'], CookieInterface::SAMESITE_VALUES, true)) { |
|
| 302 | + if (!in_array($data['samesite'], CookieInterface::SAMESITE_VALUES, true)) { |
|
| 303 | 303 | unset($data['samesite']); |
| 304 | 304 | } |
| 305 | 305 | } |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | */ |
| 543 | 543 | public function getExpiresTimestamp(): ?int |
| 544 | 544 | { |
| 545 | - if (! $this->expiresAt) { |
|
| 545 | + if (!$this->expiresAt) { |
|
| 546 | 546 | return null; |
| 547 | 547 | } |
| 548 | 548 | |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | */ |
| 555 | 555 | public function getFormattedExpires(): string |
| 556 | 556 | { |
| 557 | - if (! $this->expiresAt) { |
|
| 557 | + if (!$this->expiresAt) { |
|
| 558 | 558 | return ''; |
| 559 | 559 | } |
| 560 | 560 | |
@@ -567,7 +567,7 @@ discard block |
||
| 567 | 567 | public function isExpired($time = null): bool |
| 568 | 568 | { |
| 569 | 569 | $time = $time ?: new DateTimeImmutable('now', new DateTimeZone('UTC')); |
| 570 | - if (! $this->expiresAt) { |
|
| 570 | + if (!$this->expiresAt) { |
|
| 571 | 571 | return false; |
| 572 | 572 | } |
| 573 | 573 | |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | */ |
| 627 | 627 | protected static function validateSameSiteValue(string $sameSite) |
| 628 | 628 | { |
| 629 | - if (! in_array($sameSite, CookieInterface::SAMESITE_VALUES, true)) { |
|
| 629 | + if (!in_array($sameSite, CookieInterface::SAMESITE_VALUES, true)) { |
|
| 630 | 630 | throw new InvalidArgumentException( |
| 631 | 631 | 'Samesite value must be either of: ' . implode(', ', CookieInterface::SAMESITE_VALUES) |
| 632 | 632 | ); |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | |
| 781 | 781 | foreach (explode(',', $string) as $pair) { |
| 782 | 782 | $key = explode('|', $pair); |
| 783 | - if (! isset($key[1])) { |
|
| 783 | + if (!isset($key[1])) { |
|
| 784 | 784 | return $key[0]; |
| 785 | 785 | } |
| 786 | 786 | $array[$key[0]] = $key[1]; |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | // Sort to get the highest results first |
| 209 | - usort($results, static function ($a, $b) { |
|
| 209 | + usort($results, static function($a, $b) { |
|
| 210 | 210 | if ($a['q'] === $b['q']) { |
| 211 | 211 | $a_ast = substr_count($a['value'], '*'); |
| 212 | 212 | $b_ast = substr_count($b['value'], '*'); |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | foreach ($supported['params'] as $label => $value) { |
| 279 | - if (! isset($acceptable['params'][$label]) || $acceptable['params'][$label] !== $value) { |
|
| 279 | + if (!isset($acceptable['params'][$label]) || $acceptable['params'][$label] !== $value) { |
|
| 280 | 280 | return false; |
| 281 | 281 | } |
| 282 | 282 | } |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | { |
| 50 | 50 | $route = Services::routes()->reverseRoute($route, ...$params); |
| 51 | 51 | |
| 52 | - if (! $route) { |
|
| 52 | + if (!$route) { |
|
| 53 | 53 | throw HttpException::invalidRedirectRoute($route); |
| 54 | 54 | } |
| 55 | 55 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | public function set($key, $value, $ttl = null): bool |
| 89 | 89 | { |
| 90 | - if ($value === '' || ! $this->_init) { |
|
| 90 | + if ($value === '' || !$this->_init) { |
|
| 91 | 91 | return false; |
| 92 | 92 | } |
| 93 | 93 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | return false; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - if (! empty($this->_config['serialize'])) { |
|
| 100 | + if (!empty($this->_config['serialize'])) { |
|
| 101 | 101 | $value = serialize($value); |
| 102 | 102 | } |
| 103 | 103 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | { |
| 131 | 131 | $key = $this->_key($key); |
| 132 | 132 | |
| 133 | - if (! $this->_init || $this->_setKey($key) === false) { |
|
| 133 | + if (!$this->_init || $this->_setKey($key) === false) { |
|
| 134 | 134 | return $default; |
| 135 | 135 | } |
| 136 | 136 | |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | $data = trim($data); |
| 169 | 169 | |
| 170 | - if ($data !== '' && ! empty($this->_config['serialize'])) { |
|
| 170 | + if ($data !== '' && !empty($this->_config['serialize'])) { |
|
| 171 | 171 | $data = unserialize($data); |
| 172 | 172 | } |
| 173 | 173 | |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | { |
| 182 | 182 | $key = $this->_key($key); |
| 183 | 183 | |
| 184 | - if ($this->_setKey($key) === false || ! $this->_init) { |
|
| 184 | + if ($this->_setKey($key) === false || !$this->_init) { |
|
| 185 | 185 | return false; |
| 186 | 186 | } |
| 187 | 187 | |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | */ |
| 204 | 204 | public function clear(): bool |
| 205 | 205 | { |
| 206 | - if (! $this->_init) { |
|
| 206 | + if (!$this->_init) { |
|
| 207 | 207 | return false; |
| 208 | 208 | } |
| 209 | 209 | $this->_File = null; |
@@ -228,14 +228,14 @@ discard block |
||
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | $realPath = $fileInfo->getRealPath(); |
| 231 | - if (! $realPath) { |
|
| 231 | + if (!$realPath) { |
|
| 232 | 232 | unset($fileInfo); |
| 233 | 233 | |
| 234 | 234 | continue; |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | $path = $realPath . DIRECTORY_SEPARATOR; |
| 238 | - if (! in_array($path, $cleared, true)) { |
|
| 238 | + if (!in_array($path, $cleared, true)) { |
|
| 239 | 239 | $this->_clearDirectory($path); |
| 240 | 240 | $cleared[] = $path; |
| 241 | 241 | } |
@@ -256,12 +256,12 @@ discard block |
||
| 256 | 256 | */ |
| 257 | 257 | protected function _clearDirectory(string $path): void |
| 258 | 258 | { |
| 259 | - if (! is_dir($path)) { |
|
| 259 | + if (!is_dir($path)) { |
|
| 260 | 260 | return; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | $dir = dir($path); |
| 264 | - if (! $dir) { |
|
| 264 | + if (!$dir) { |
|
| 265 | 265 | return; |
| 266 | 266 | } |
| 267 | 267 | |
@@ -327,13 +327,13 @@ discard block |
||
| 327 | 327 | } |
| 328 | 328 | $dir = $this->_config['path'] . $groups; |
| 329 | 329 | |
| 330 | - if (! is_dir($dir)) { |
|
| 330 | + if (!is_dir($dir)) { |
|
| 331 | 331 | mkdir($dir, 0775, true); |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | $path = new SplFileInfo($dir . $key); |
| 335 | 335 | |
| 336 | - if (! $createKey && ! $path->isFile()) { |
|
| 336 | + if (!$createKey && !$path->isFile()) { |
|
| 337 | 337 | return false; |
| 338 | 338 | } |
| 339 | 339 | if ( |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | } |
| 353 | 353 | unset($path); |
| 354 | 354 | |
| 355 | - if (! $exists && ! chmod($this->_File->getPathname(), (int) $this->_config['mask'])) { |
|
| 355 | + if (!$exists && !chmod($this->_File->getPathname(), (int) $this->_config['mask'])) { |
|
| 356 | 356 | trigger_error(sprintf( |
| 357 | 357 | 'Could not apply permission mask "%s" on cache file "%s"', |
| 358 | 358 | $this->_File->getPathname(), |
@@ -372,14 +372,14 @@ discard block |
||
| 372 | 372 | $dir = new SplFileInfo($this->_config['path']); |
| 373 | 373 | $path = $dir->getPathname(); |
| 374 | 374 | $success = true; |
| 375 | - if (! is_dir($path)) { |
|
| 375 | + if (!is_dir($path)) { |
|
| 376 | 376 | // phpcs:disable |
| 377 | 377 | $success = @mkdir($path, 0775, true); |
| 378 | 378 | // phpcs:enable |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | $isWritableDir = ($dir->isDir() && $dir->isWritable()); |
| 382 | - if (! $success || ($this->_init && ! $isWritableDir)) { |
|
| 382 | + if (!$success || ($this->_init && !$isWritableDir)) { |
|
| 383 | 383 | $this->_init = false; |
| 384 | 384 | trigger_error(sprintf( |
| 385 | 385 | '%s is not writable', |
@@ -423,8 +423,8 @@ discard block |
||
| 423 | 423 | ); |
| 424 | 424 | $filtered = new CallbackFilterIterator( |
| 425 | 425 | $contents, |
| 426 | - static function (SplFileInfo $current) use ($group, $prefix) { |
|
| 427 | - if (! $current->isFile()) { |
|
| 426 | + static function(SplFileInfo $current) use ($group, $prefix) { |
|
| 427 | + if (!$current->isFile()) { |
|
| 428 | 428 | return false; |
| 429 | 429 | } |
| 430 | 430 | |
@@ -91,11 +91,11 @@ discard block |
||
| 91 | 91 | { |
| 92 | 92 | $this->setConfig($config); |
| 93 | 93 | |
| 94 | - if (! empty($this->_config['groups'])) { |
|
| 94 | + if (!empty($this->_config['groups'])) { |
|
| 95 | 95 | sort($this->_config['groups']); |
| 96 | 96 | $this->_groupPrefix = str_repeat('%s_', count($this->_config['groups'])); |
| 97 | 97 | } |
| 98 | - if (! is_numeric($this->_config['duration'])) { |
|
| 98 | + if (!is_numeric($this->_config['duration'])) { |
|
| 99 | 99 | $this->_config['duration'] = strtotime($this->_config['duration']) - time(); |
| 100 | 100 | } |
| 101 | 101 | |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | public function ensureValidKey(string $key): void |
| 119 | 119 | { |
| 120 | - if (! is_string($key) || $key === '') { |
|
| 120 | + if (!is_string($key) || $key === '') { |
|
| 121 | 121 | throw new InvalidArgumentException('A cache key must be a non-empty string.'); |
| 122 | 122 | } |
| 123 | 123 | |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | protected function ensureValidType($iterable, string $check = self::CHECK_VALUE): void |
| 139 | 139 | { |
| 140 | - if (! is_iterable($iterable)) { |
|
| 140 | + if (!is_iterable($iterable)) { |
|
| 141 | 141 | throw new InvalidArgumentException(sprintf( |
| 142 | 142 | 'A cache %s must be either an array or a Traversable.', |
| 143 | 143 | $check === self::CHECK_VALUE ? 'key set' : 'set' |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | $result = true; |
| 267 | 267 | |
| 268 | 268 | foreach ($keys as $key) { |
| 269 | - if (! $this->delete($key)) { |
|
| 269 | + if (!$this->delete($key)) { |
|
| 270 | 270 | $result = false; |
| 271 | 271 | } |
| 272 | 272 | } |
@@ -101,16 +101,16 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | protected function factory(): CacheInterface |
| 103 | 103 | { |
| 104 | - if (! static::$_enabled) { |
|
| 104 | + if (!static::$_enabled) { |
|
| 105 | 105 | return new Dummy(); |
| 106 | 106 | } |
| 107 | - if (! empty($this->adapter)) { |
|
| 107 | + if (!empty($this->adapter)) { |
|
| 108 | 108 | return $this->adapter; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | $validHandlers = $this->config['valid_handlers'] ?? self::$validHandlers; |
| 112 | 112 | |
| 113 | - if (empty($validHandlers) || ! is_array($validHandlers)) { |
|
| 113 | + if (empty($validHandlers) || !is_array($validHandlers)) { |
|
| 114 | 114 | throw new InvalidArgumentException('Cache config must have an array of $valid_handlers.'); |
| 115 | 115 | } |
| 116 | 116 | |
@@ -121,28 +121,28 @@ discard block |
||
| 121 | 121 | throw new InvalidArgumentException('Cache config must have a handler set.'); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - if (! array_key_exists($handler, $validHandlers)) { |
|
| 124 | + if (!array_key_exists($handler, $validHandlers)) { |
|
| 125 | 125 | throw new InvalidArgumentException('Cache config has an invalid handler specified.'); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | $adapter = new $validHandlers[$handler](); |
| 129 | - if (! ($adapter instanceof BaseHandler)) { |
|
| 129 | + if (!($adapter instanceof BaseHandler)) { |
|
| 130 | 130 | if (empty($fallback)) { |
| 131 | 131 | $adapter = new Dummy(); |
| 132 | - } elseif (! array_key_exists($fallback, $validHandlers)) { |
|
| 132 | + } elseif (!array_key_exists($fallback, $validHandlers)) { |
|
| 133 | 133 | throw new InvalidArgumentException('Cache config has an invalid fallback handler specified.'); |
| 134 | 134 | } else { |
| 135 | 135 | $adapter = new $validHandlers[$fallback](); |
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - if (! ($adapter instanceof BaseHandler)) { |
|
| 139 | + if (!($adapter instanceof BaseHandler)) { |
|
| 140 | 140 | throw new InvalidArgumentException( |
| 141 | 141 | 'Cache handler must use BlitzPHP\Cache\Handlers\BaseHandler as a base class.' |
| 142 | 142 | ); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - if (! $adapter->init($this->config)) { |
|
| 145 | + if (!$adapter->init($this->config)) { |
|
| 146 | 146 | throw new RuntimeException( |
| 147 | 147 | sprintf( |
| 148 | 148 | 'Cache engine %s is not properly configured. Check error log for additional information.', |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | |
| 207 | 207 | $counts = new self(); |
| 208 | 208 | |
| 209 | - $collection->each(static function ($value) use ($counts) { |
|
| 209 | + $collection->each(static function($value) use ($counts) { |
|
| 210 | 210 | $counts[$value] = isset($counts[$value]) ? $counts[$value] + 1 : 1; |
| 211 | 211 | }); |
| 212 | 212 | |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | { |
| 325 | 325 | (new static(func_get_args())) |
| 326 | 326 | ->push($this) |
| 327 | - ->each(static function ($item) { |
|
| 327 | + ->each(static function($item) { |
|
| 328 | 328 | Helpers::r($item); |
| 329 | 329 | }); |
| 330 | 330 | |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | */ |
| 484 | 484 | public function eachSpread(callable $callback) |
| 485 | 485 | { |
| 486 | - return $this->each(static function ($chunk, $key) use ($callback) { |
|
| 486 | + return $this->each(static function($chunk, $key) use ($callback) { |
|
| 487 | 487 | $chunk[] = $key; |
| 488 | 488 | |
| 489 | 489 | return $callback(...$chunk); |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | $callback = $this->valueRetriever($key); |
| 506 | 506 | |
| 507 | 507 | foreach ($this->items as $k => $v) { |
| 508 | - if (! $callback($v, $k)) { |
|
| 508 | + if (!$callback($v, $k)) { |
|
| 509 | 509 | return false; |
| 510 | 510 | } |
| 511 | 511 | } |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | { |
| 528 | 528 | if ($keys instanceof self) { |
| 529 | 529 | $keys = $keys->all(); |
| 530 | - } elseif (! is_array($keys)) { |
|
| 530 | + } elseif (!is_array($keys)) { |
|
| 531 | 531 | $keys = func_get_args(); |
| 532 | 532 | } |
| 533 | 533 | |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | */ |
| 603 | 603 | public function unless($value, callable $callback, ?callable $default = null) |
| 604 | 604 | { |
| 605 | - return $this->when(! $value, $callback, $default); |
|
| 605 | + return $this->when(!$value, $callback, $default); |
|
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | /** |
@@ -666,7 +666,7 @@ discard block |
||
| 666 | 666 | $operator = '='; |
| 667 | 667 | } |
| 668 | 668 | |
| 669 | - return static function ($item) use ($key, $operator, $value) { |
|
| 669 | + return static function($item) use ($key, $operator, $value) { |
|
| 670 | 670 | $retrieved = Arr::get($item, $key); |
| 671 | 671 | |
| 672 | 672 | $strings = array_filter([$retrieved, $value], static fn ($value) => is_string($value) || (is_object($value) && method_exists($value, '__toString'))); |
@@ -911,14 +911,14 @@ discard block |
||
| 911 | 911 | foreach ($this->items as $key => $value) { |
| 912 | 912 | $groupKeys = $groupBy($value, $key); |
| 913 | 913 | |
| 914 | - if (! is_array($groupKeys)) { |
|
| 914 | + if (!is_array($groupKeys)) { |
|
| 915 | 915 | $groupKeys = [$groupKeys]; |
| 916 | 916 | } |
| 917 | 917 | |
| 918 | 918 | foreach ($groupKeys as $groupKey) { |
| 919 | 919 | $groupKey = is_bool($groupKey) ? (int) $groupKey : $groupKey; |
| 920 | 920 | |
| 921 | - if (! array_key_exists($groupKey, $results)) { |
|
| 921 | + if (!array_key_exists($groupKey, $results)) { |
|
| 922 | 922 | $results[$groupKey] = new static(); |
| 923 | 923 | } |
| 924 | 924 | |
@@ -928,7 +928,7 @@ discard block |
||
| 928 | 928 | |
| 929 | 929 | $result = new static($results); |
| 930 | 930 | |
| 931 | - if (! empty($nextGroups)) { |
|
| 931 | + if (!empty($nextGroups)) { |
|
| 932 | 932 | return $result->map->groupBy($nextGroups, $preserveKeys); |
| 933 | 933 | } |
| 934 | 934 | |
@@ -973,7 +973,7 @@ discard block |
||
| 973 | 973 | $keys = is_array($key) ? $key : func_get_args(); |
| 974 | 974 | |
| 975 | 975 | foreach ($keys as $value) { |
| 976 | - if (! $this->offsetExists($value)) { |
|
| 976 | + if (!$this->offsetExists($value)) { |
|
| 977 | 977 | return false; |
| 978 | 978 | } |
| 979 | 979 | } |
@@ -1044,7 +1044,7 @@ discard block |
||
| 1044 | 1044 | */ |
| 1045 | 1045 | public function isNotEmpty() |
| 1046 | 1046 | { |
| 1047 | - return ! $this->isEmpty(); |
|
| 1047 | + return !$this->isEmpty(); |
|
| 1048 | 1048 | } |
| 1049 | 1049 | |
| 1050 | 1050 | /** |
@@ -1056,7 +1056,7 @@ discard block |
||
| 1056 | 1056 | */ |
| 1057 | 1057 | protected function useAsCallable($value) |
| 1058 | 1058 | { |
| 1059 | - return ! is_string($value) && is_callable($value); |
|
| 1059 | + return !is_string($value) && is_callable($value); |
|
| 1060 | 1060 | } |
| 1061 | 1061 | |
| 1062 | 1062 | /** |
@@ -1146,7 +1146,7 @@ discard block |
||
| 1146 | 1146 | */ |
| 1147 | 1147 | public function mapSpread(callable $callback) |
| 1148 | 1148 | { |
| 1149 | - return $this->map(static function ($chunk, $key) use ($callback) { |
|
| 1149 | + return $this->map(static function($chunk, $key) use ($callback) { |
|
| 1150 | 1150 | $chunk[] = $key; |
| 1151 | 1151 | |
| 1152 | 1152 | return $callback(...$chunk); |
@@ -1171,7 +1171,7 @@ discard block |
||
| 1171 | 1171 | |
| 1172 | 1172 | $value = reset($pair); |
| 1173 | 1173 | |
| 1174 | - if (! isset($dictionary[$key])) { |
|
| 1174 | + if (!isset($dictionary[$key])) { |
|
| 1175 | 1175 | $dictionary[$key] = []; |
| 1176 | 1176 | } |
| 1177 | 1177 | |
@@ -1250,7 +1250,7 @@ discard block |
||
| 1250 | 1250 | { |
| 1251 | 1251 | $callback = $this->valueRetriever($callback); |
| 1252 | 1252 | |
| 1253 | - return $this->filter(static fn ($value) => null !== $value)->reduce(static function ($result, $item) use ($callback) { |
|
| 1253 | + return $this->filter(static fn ($value) => null !== $value)->reduce(static function($result, $item) use ($callback) { |
|
| 1254 | 1254 | $value = $callback($item); |
| 1255 | 1255 | |
| 1256 | 1256 | return null === $result || $value > $result ? $value : $result; |
@@ -1399,7 +1399,7 @@ discard block |
||
| 1399 | 1399 | : $this->operatorForWhere(...func_get_args()); |
| 1400 | 1400 | |
| 1401 | 1401 | foreach ($this->items as $key => $item) { |
| 1402 | - $partitions[(int) ! $callback($item, $key)][$key] = $item; |
|
| 1402 | + $partitions[(int) !$callback($item, $key)][$key] = $item; |
|
| 1403 | 1403 | } |
| 1404 | 1404 | |
| 1405 | 1405 | return new static($partitions); |
@@ -1541,9 +1541,9 @@ discard block |
||
| 1541 | 1541 | { |
| 1542 | 1542 | $useAsCallable = $this->useAsCallable($callback); |
| 1543 | 1543 | |
| 1544 | - return $this->filter(static function ($value, $key) use ($callback, $useAsCallable) { |
|
| 1544 | + return $this->filter(static function($value, $key) use ($callback, $useAsCallable) { |
|
| 1545 | 1545 | return $useAsCallable |
| 1546 | - ? ! $callback($value, $key) |
|
| 1546 | + ? !$callback($value, $key) |
|
| 1547 | 1547 | : $value !== $callback; |
| 1548 | 1548 | }); |
| 1549 | 1549 | } |
@@ -1592,7 +1592,7 @@ discard block |
||
| 1592 | 1592 | */ |
| 1593 | 1593 | public function search($value, $strict = false) |
| 1594 | 1594 | { |
| 1595 | - if (! $this->useAsCallable($value)) { |
|
| 1595 | + if (!$this->useAsCallable($value)) { |
|
| 1596 | 1596 | return array_search($value, $this->items, $strict); |
| 1597 | 1597 | } |
| 1598 | 1598 | |
@@ -1883,7 +1883,7 @@ discard block |
||
| 1883 | 1883 | |
| 1884 | 1884 | $exists = []; |
| 1885 | 1885 | |
| 1886 | - return $this->reject(static function ($item, $key) use ($callback, $strict, &$exists) { |
|
| 1886 | + return $this->reject(static function($item, $key) use ($callback, $strict, &$exists) { |
|
| 1887 | 1887 | if (in_array($id = $callback($item, $key), $exists, $strict)) { |
| 1888 | 1888 | return true; |
| 1889 | 1889 | } |
@@ -1975,7 +1975,7 @@ discard block |
||
| 1975 | 1975 | */ |
| 1976 | 1976 | public function jsonSerialize(): array |
| 1977 | 1977 | { |
| 1978 | - return array_map(static function ($value) { |
|
| 1978 | + return array_map(static function($value) { |
|
| 1979 | 1979 | if ($value instanceof JsonSerializable) { |
| 1980 | 1980 | return $value->jsonSerialize(); |
| 1981 | 1981 | } |
@@ -2165,7 +2165,7 @@ discard block |
||
| 2165 | 2165 | */ |
| 2166 | 2166 | public function __get($key) |
| 2167 | 2167 | { |
| 2168 | - if (! in_array($key, static::$proxies, true)) { |
|
| 2168 | + if (!in_array($key, static::$proxies, true)) { |
|
| 2169 | 2169 | throw new Exception("Property [{$key}] does not exist on this collection instance."); |
| 2170 | 2170 | } |
| 2171 | 2171 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | public static function check(array $data, string $path): bool |
| 64 | 64 | { |
| 65 | 65 | $results = self::extract($data, $path); |
| 66 | - if (! is_array($results)) { |
|
| 66 | + if (!is_array($results)) { |
|
| 67 | 67 | return false; |
| 68 | 68 | } |
| 69 | 69 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | foreach ($array as $values) { |
| 81 | 81 | if ($values instanceof Collection) { |
| 82 | 82 | $values = $values->all(); |
| 83 | - } elseif (! is_array($values)) { |
|
| 83 | + } elseif (!is_array($values)) { |
|
| 84 | 84 | continue; |
| 85 | 85 | } |
| 86 | 86 | |
@@ -120,10 +120,10 @@ discard block |
||
| 120 | 120 | return []; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - if (! empty($valuePath) && is_array($valuePath)) { |
|
| 123 | + if (!empty($valuePath) && is_array($valuePath)) { |
|
| 124 | 124 | $format = array_shift($valuePath); |
| 125 | 125 | $vals = self::format($data, $valuePath, $format); |
| 126 | - } elseif (! empty($valuePath)) { |
|
| 126 | + } elseif (!empty($valuePath)) { |
|
| 127 | 127 | $vals = self::extract($data, $valuePath); |
| 128 | 128 | } |
| 129 | 129 | if (empty($vals)) { |
@@ -136,14 +136,14 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | if ($groupPath !== null) { |
| 138 | 138 | $group = self::extract($data, $groupPath); |
| 139 | - if (! empty($group)) { |
|
| 139 | + if (!empty($group)) { |
|
| 140 | 140 | $c = count($keys); |
| 141 | 141 | |
| 142 | 142 | for ($i = 0; $i < $c; $i++) { |
| 143 | - if (! isset($group[$i])) { |
|
| 143 | + if (!isset($group[$i])) { |
|
| 144 | 144 | $group[$i] = 0; |
| 145 | 145 | } |
| 146 | - if (! isset($out[$group[$i]])) { |
|
| 146 | + if (!isset($out[$group[$i]])) { |
|
| 147 | 147 | $out[$group[$i]] = []; |
| 148 | 148 | } |
| 149 | 149 | $out[$group[$i]][$keys[$i]] = $vals[$i]; |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | } |
| 176 | 176 | $stack = []; |
| 177 | 177 | |
| 178 | - while (! empty($needle)) { |
|
| 178 | + while (!empty($needle)) { |
|
| 179 | 179 | $key = key($needle); |
| 180 | 180 | $val = $needle[$key]; |
| 181 | 181 | unset($needle[$key]); |
@@ -184,14 +184,14 @@ discard block |
||
| 184 | 184 | $next = $data[$key]; |
| 185 | 185 | unset($data[$key]); |
| 186 | 186 | |
| 187 | - if (! empty($val)) { |
|
| 187 | + if (!empty($val)) { |
|
| 188 | 188 | $stack[] = [$val, $next]; |
| 189 | 189 | } |
| 190 | - } elseif (! array_key_exists($key, $data) || $data[$key] !== $val) { |
|
| 190 | + } elseif (!array_key_exists($key, $data) || $data[$key] !== $val) { |
|
| 191 | 191 | return false; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - if (empty($needle) && ! empty($stack)) { |
|
| 194 | + if (empty($needle) && !empty($stack)) { |
|
| 195 | 195 | [$needle, $data] = array_pop($stack); |
| 196 | 196 | } |
| 197 | 197 | } |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | $results = []; |
| 272 | 272 | |
| 273 | 273 | foreach ($array as $key => $value) { |
| 274 | - if (is_array($value) && ! empty($value)) { |
|
| 274 | + if (is_array($value) && !empty($value)) { |
|
| 275 | 275 | $results = array_merge($results, static::dot($value, $prepend . $key . '.')); |
| 276 | 276 | } else { |
| 277 | 277 | $results[$prepend . $key] = $value; |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | // Simple paths. |
| 363 | - if (! preg_match('/[{\[]/', $path)) { |
|
| 363 | + if (!preg_match('/[{\[]/', $path)) { |
|
| 364 | 364 | return (array) self::get($data, $path); |
| 365 | 365 | } |
| 366 | 366 | |
@@ -500,13 +500,13 @@ discard block |
||
| 500 | 500 | |
| 501 | 501 | reset($data); |
| 502 | 502 | |
| 503 | - while (! empty($data)) { |
|
| 503 | + while (!empty($data)) { |
|
| 504 | 504 | $key = key($data); |
| 505 | 505 | $element = $data[$key]; |
| 506 | 506 | unset($data[$key]); |
| 507 | 507 | |
| 508 | - if (is_array($element) && ! empty($element)) { |
|
| 509 | - if (! empty($data)) { |
|
| 508 | + if (is_array($element) && !empty($element)) { |
|
| 509 | + if (!empty($data)) { |
|
| 510 | 510 | $stack[] = [$data, $path]; |
| 511 | 511 | } |
| 512 | 512 | $data = $element; |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | $result[$path . $key] = $element; |
| 517 | 517 | } |
| 518 | 518 | |
| 519 | - if (empty($data) && ! empty($stack)) { |
|
| 519 | + if (empty($data) && !empty($stack)) { |
|
| 520 | 520 | [$data, $path] = array_pop($stack); |
| 521 | 521 | reset($data); |
| 522 | 522 | } |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | $extracted = []; |
| 598 | 598 | $count = count($paths); |
| 599 | 599 | |
| 600 | - if (! $count) { |
|
| 600 | + if (!$count) { |
|
| 601 | 601 | return; |
| 602 | 602 | } |
| 603 | 603 | |
@@ -639,7 +639,7 @@ discard block |
||
| 639 | 639 | */ |
| 640 | 640 | public static function get($data, $path, $default = null) |
| 641 | 641 | { |
| 642 | - if (! static::accessible($data)) { |
|
| 642 | + if (!static::accessible($data)) { |
|
| 643 | 643 | return $default; |
| 644 | 644 | } |
| 645 | 645 | if (is_string($path) || is_numeric($path)) { |
@@ -697,7 +697,7 @@ discard block |
||
| 697 | 697 | { |
| 698 | 698 | $keys = (array) $keys; |
| 699 | 699 | |
| 700 | - if (! $array || $keys === []) { |
|
| 700 | + if (!$array || $keys === []) { |
|
| 701 | 701 | return false; |
| 702 | 702 | } |
| 703 | 703 | |
@@ -754,7 +754,7 @@ discard block |
||
| 754 | 754 | |
| 755 | 755 | continue; |
| 756 | 756 | } |
| 757 | - if (! $conditions) { |
|
| 757 | + if (!$conditions) { |
|
| 758 | 758 | $data[$k] = self::insert($v, $nextPath, $values); |
| 759 | 759 | } |
| 760 | 760 | } |
@@ -834,7 +834,7 @@ discard block |
||
| 834 | 834 | |
| 835 | 835 | while (($arg = next($args)) !== false) { |
| 836 | 836 | foreach ((array) $arg as $key => $val) { |
| 837 | - if (! empty($return[$key]) && is_array($return[$key]) && is_array($val)) { |
|
| 837 | + if (!empty($return[$key]) && is_array($return[$key]) && is_array($val)) { |
|
| 838 | 838 | $return[$key] = self::merge($return[$key], $val); |
| 839 | 839 | } elseif (is_int($key) && isset($return[$key])) { |
| 840 | 840 | $return[] = $val; |
@@ -1022,7 +1022,7 @@ discard block |
||
| 1022 | 1022 | // If the key doesn't exist at this depth, we will just create an empty array |
| 1023 | 1023 | // to hold the next value, allowing us to create the arrays to hold final |
| 1024 | 1024 | // values at the correct depth. Then we'll keep digging into the array. |
| 1025 | - if (! isset($array[$key]) || ! is_array($array[$key])) { |
|
| 1025 | + if (!isset($array[$key]) || !is_array($array[$key])) { |
|
| 1026 | 1026 | $array[$key] = []; |
| 1027 | 1027 | } |
| 1028 | 1028 | |
@@ -1060,7 +1060,7 @@ discard block |
||
| 1060 | 1060 | $sub_key .= '.' . $key[$i]; |
| 1061 | 1061 | } |
| 1062 | 1062 | |
| 1063 | - if (! isset($data[$key[0]])) { |
|
| 1063 | + if (!isset($data[$key[0]])) { |
|
| 1064 | 1064 | $data[$key[0]] = []; |
| 1065 | 1065 | } |
| 1066 | 1066 | |
@@ -1105,7 +1105,7 @@ discard block |
||
| 1105 | 1105 | */ |
| 1106 | 1106 | public static function sortField(array $data, string $field, int $direction = self::SORT_ASC): array |
| 1107 | 1107 | { |
| 1108 | - usort($data, static function ($a, $b) use ($field, $direction) { |
|
| 1108 | + usort($data, static function($a, $b) use ($field, $direction) { |
|
| 1109 | 1109 | $cmp1 = self::_getSortField_($a, $field); |
| 1110 | 1110 | $cmp2 = self::_getSortField_($b, $field); |
| 1111 | 1111 | |
@@ -1188,7 +1188,7 @@ discard block |
||
| 1188 | 1188 | */ |
| 1189 | 1189 | protected static function _filter($var): bool |
| 1190 | 1190 | { |
| 1191 | - return (bool) ($var === 0 || $var === '0' || ! empty($var)); |
|
| 1191 | + return (bool) ($var === 0 || $var === '0' || !empty($var)); |
|
| 1192 | 1192 | } |
| 1193 | 1193 | |
| 1194 | 1194 | /** |
@@ -1254,11 +1254,11 @@ discard block |
||
| 1254 | 1254 | $val = $cond['val'] ?? null; |
| 1255 | 1255 | |
| 1256 | 1256 | // Presence test. |
| 1257 | - if (empty($op) && empty($val) && ! isset($data[$attr])) { |
|
| 1257 | + if (empty($op) && empty($val) && !isset($data[$attr])) { |
|
| 1258 | 1258 | return false; |
| 1259 | 1259 | } |
| 1260 | 1260 | // Empty attribute = fail. |
| 1261 | - if (! (isset($data[$attr]) || array_key_exists($attr, $data))) { |
|
| 1261 | + if (!(isset($data[$attr]) || array_key_exists($attr, $data))) { |
|
| 1262 | 1262 | return false; |
| 1263 | 1263 | } |
| 1264 | 1264 | $prop = null; |
@@ -1273,7 +1273,7 @@ discard block |
||
| 1273 | 1273 | } |
| 1274 | 1274 | // Pattern matches and other operators. |
| 1275 | 1275 | if ($op === '=' && $val && $val[0] === '/') { |
| 1276 | - if (! preg_match($val, $prop)) { |
|
| 1276 | + if (!preg_match($val, $prop)) { |
|
| 1277 | 1277 | return false; |
| 1278 | 1278 | } |
| 1279 | 1279 | } elseif ( |
@@ -1318,11 +1318,11 @@ discard block |
||
| 1318 | 1318 | |
| 1319 | 1319 | return $data; |
| 1320 | 1320 | } |
| 1321 | - if (! isset($_list[$key])) { |
|
| 1321 | + if (!isset($_list[$key])) { |
|
| 1322 | 1322 | $_list[$key] = []; |
| 1323 | 1323 | } |
| 1324 | 1324 | $_list = &$_list[$key]; |
| 1325 | - if (! is_array($_list)) { |
|
| 1325 | + if (!is_array($_list)) { |
|
| 1326 | 1326 | $_list = []; |
| 1327 | 1327 | } |
| 1328 | 1328 | } elseif ($op === 'remove') { |
@@ -1331,7 +1331,7 @@ discard block |
||
| 1331 | 1331 | |
| 1332 | 1332 | return $data; |
| 1333 | 1333 | } |
| 1334 | - if (! isset($_list[$key])) { |
|
| 1334 | + if (!isset($_list[$key])) { |
|
| 1335 | 1335 | return $data; |
| 1336 | 1336 | } |
| 1337 | 1337 | $_list = &$_list[$key]; |
@@ -48,11 +48,11 @@ |
||
| 48 | 48 | |
| 49 | 49 | $object->setData($data)->setOptions($options); |
| 50 | 50 | |
| 51 | - if (! empty($this->layout) && is_string($this->layout)) { |
|
| 51 | + if (!empty($this->layout) && is_string($this->layout)) { |
|
| 52 | 52 | $object->setLayout($this->layout); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if (! empty($this->viewDatas) && is_array($this->viewDatas)) { |
|
| 55 | + if (!empty($this->viewDatas) && is_array($this->viewDatas)) { |
|
| 56 | 56 | $object->addData($this->viewDatas); |
| 57 | 57 | } |
| 58 | 58 | |