@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | // Toujours là ? Ensuite, nous pouvons essayer de faire correspondre l'URI avec |
146 | 146 | // Contrôleurs/répertoires, mais l'application peut ne pas |
147 | 147 | // vouloir ceci, comme dans le cas des API. |
148 | - if (! $this->collection->shouldAutoRoute()) { |
|
148 | + if (!$this->collection->shouldAutoRoute()) { |
|
149 | 149 | throw new PageNotFoundException("Can't find a route for '{$uri}'."); |
150 | 150 | } |
151 | 151 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | |
196 | 196 | return [ |
197 | 197 | $routeArray[0], // Controller |
198 | - $routeArray[1] ?? 'index', // Method |
|
198 | + $routeArray[1] ?? 'index', // Method |
|
199 | 199 | ]; |
200 | 200 | } |
201 | 201 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | */ |
225 | 225 | public function directory(): string |
226 | 226 | { |
227 | - return ! empty($this->directory) ? $this->directory : ''; |
|
227 | + return !empty($this->directory) ? $this->directory : ''; |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | // Are we using Closures? If so, then we need |
336 | 336 | // to collect the params into an array |
337 | 337 | // so it can be passed to the controller method later. |
338 | - if (! is_string($val) && is_callable($val)) { |
|
338 | + if (!is_string($val) && is_callable($val)) { |
|
339 | 339 | $this->controller = $val; |
340 | 340 | |
341 | 341 | // Remove the original string from the matches array |
@@ -411,18 +411,18 @@ discard block |
||
411 | 411 | } |
412 | 412 | |
413 | 413 | $controllerName = $this->controllerName(); |
414 | - if (! $this->isValidSegment($controllerName)) { |
|
414 | + if (!$this->isValidSegment($controllerName)) { |
|
415 | 415 | throw new PageNotFoundException($this->controller . ' is not a valid controller name'); |
416 | 416 | } |
417 | 417 | |
418 | 418 | // Utilise le nom de la méthode s'il existe. |
419 | 419 | // Si ce n'est pas le cas, ce n'est pas grave - le nom de la méthode par défaut |
420 | 420 | // a déjà été défini. |
421 | - if (! empty($segments)) { |
|
421 | + if (!empty($segments)) { |
|
422 | 422 | $this->setMethod(array_shift($segments) ?: $this->method); |
423 | 423 | } |
424 | 424 | |
425 | - if (! empty($segments)) { |
|
425 | + if (!empty($segments)) { |
|
426 | 426 | $this->params = $segments; |
427 | 427 | } |
428 | 428 | |
@@ -504,14 +504,14 @@ discard block |
||
504 | 504 | while ($c-- > 0) { |
505 | 505 | $segmentConvert = ucfirst($this->translateURIDashes === true ? str_replace('-', '_', $segments[0]) : $segments[0]); |
506 | 506 | // dès que nous rencontrons un segment non conforme à PSR-4, arrêtons la recherche |
507 | - if (! $this->isValidSegment($segmentConvert)) { |
|
507 | + if (!$this->isValidSegment($segmentConvert)) { |
|
508 | 508 | return $segments; |
509 | 509 | } |
510 | 510 | |
511 | 511 | $test = CONTROLLER_PATH . $this->directory . $segmentConvert; |
512 | 512 | |
513 | 513 | // tant que chaque segment n'est *pas* un fichier de contrôleur mais correspond à un répertoire, ajoutez-le à $this->répertoire |
514 | - if (! is_file($test . '.php') && is_dir($test)) { |
|
514 | + if (!is_file($test . '.php') && is_dir($test)) { |
|
515 | 515 | $this->setDirectory($segmentConvert, true, false); |
516 | 516 | array_shift($segments); |
517 | 517 | |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | $segments = explode('/', trim($dir, '/')); |
543 | 543 | |
544 | 544 | foreach ($segments as $segment) { |
545 | - if (! $this->isValidSegment($segment)) { |
|
545 | + if (!$this->isValidSegment($segment)) { |
|
546 | 546 | return; |
547 | 547 | } |
548 | 548 | } |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | |
589 | 589 | // $this->method contient déjà le nom de la méthode par défaut, |
590 | 590 | // donc ne l'écrasez pas avec le vide. |
591 | - if (! empty($method)) { |
|
591 | + if (!empty($method)) { |
|
592 | 592 | $this->setMethod($method); |
593 | 593 | } |
594 | 594 | |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | $this->method = 'index'; |
612 | 612 | } |
613 | 613 | |
614 | - if (! is_file(CONTROLLER_PATH . $this->directory . $this->makeController($class) . '.php')) { |
|
614 | + if (!is_file(CONTROLLER_PATH . $this->directory . $this->makeController($class) . '.php')) { |
|
615 | 615 | return; |
616 | 616 | } |
617 | 617 |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | */ |
218 | 218 | public function addPlaceholder($placeholder, ?string $pattern = null): self |
219 | 219 | { |
220 | - if (! is_array($placeholder)) { |
|
220 | + if (!is_array($placeholder)) { |
|
221 | 221 | $placeholder = [$placeholder => $pattern]; |
222 | 222 | } |
223 | 223 | |
@@ -775,7 +775,7 @@ discard block |
||
775 | 775 | * |
776 | 776 | * @param array|Closure|string $to |
777 | 777 | */ |
778 | - public function match(array $verbs = [], string $from = '', $to = '', ?array $options = null): self |
|
778 | + public function match(array $verbs = [], string $from = '', $to = '', ?array $options = null) : self |
|
779 | 779 | { |
780 | 780 | if (empty($from) || empty($to)) { |
781 | 781 | throw new InvalidArgumentException('You must supply the parameters: from, to.'); |
@@ -935,7 +935,7 @@ discard block |
||
935 | 935 | $to = $route['route'][$from]; |
936 | 936 | |
937 | 937 | // on ignore les closures |
938 | - if (! is_string($to)) { |
|
938 | + if (!is_string($to)) { |
|
939 | 939 | continue; |
940 | 940 | } |
941 | 941 | |
@@ -1019,7 +1019,7 @@ discard block |
||
1019 | 1019 | // Construire notre chaîne résultante, en insérant les $params dans |
1020 | 1020 | // les endroits appropriés. |
1021 | 1021 | foreach ($matches[0] as $index => $pattern) { |
1022 | - if (! preg_match('#^' . $pattern . '$#u', $params[$index])) { |
|
1022 | + if (!preg_match('#^' . $pattern . '$#u', $params[$index])) { |
|
1023 | 1023 | throw RouterException::invalidParameterType(); |
1024 | 1024 | } |
1025 | 1025 | |
@@ -1064,7 +1064,7 @@ discard block |
||
1064 | 1064 | } |
1065 | 1065 | |
1066 | 1066 | // Limitation du nom d'hôte ? |
1067 | - if (! empty($options['hostname'])) { |
|
1067 | + if (!empty($options['hostname'])) { |
|
1068 | 1068 | // @todo determine if there's a way to whitelist hosts? |
1069 | 1069 | if (isset($_SERVER['HTTP_HOST']) && strtolower($_SERVER['HTTP_HOST']) !== strtolower($options['hostname'])) { |
1070 | 1070 | return; |
@@ -1074,10 +1074,10 @@ discard block |
||
1074 | 1074 | } |
1075 | 1075 | |
1076 | 1076 | // Limitation du nom sous-domaine ? |
1077 | - elseif (! empty($options['subdomain'])) { |
|
1077 | + elseif (!empty($options['subdomain'])) { |
|
1078 | 1078 | // Si nous ne correspondons pas au sous-domaine actuel, alors |
1079 | 1079 | // nous n'avons pas besoin d'ajouter la route. |
1080 | - if (! $this->checkSubdomains($options['subdomain'])) { |
|
1080 | + if (!$this->checkSubdomains($options['subdomain'])) { |
|
1081 | 1081 | return; |
1082 | 1082 | } |
1083 | 1083 | |
@@ -1108,7 +1108,7 @@ discard block |
||
1108 | 1108 | } |
1109 | 1109 | |
1110 | 1110 | // S'il s'agit d'une redirection, aucun traitement |
1111 | - if (! isset($options['redirect']) && is_string($to)) { |
|
1111 | + if (!isset($options['redirect']) && is_string($to)) { |
|
1112 | 1112 | // Si aucun espace de noms n'est trouvé, ajouter l'espace de noms par défaut |
1113 | 1113 | if (strpos($to, '\\') === false || strpos($to, '\\') > 0) { |
1114 | 1114 | $namespace = $options['namespace'] ?? $this->defaultNamespace; |
@@ -1126,7 +1126,7 @@ discard block |
||
1126 | 1126 | // les routes manuelement définies doivent toujours être la "source de vérité". |
1127 | 1127 | // cela ne fonctionne que parce que les routes découvertes sont ajoutées juste avant |
1128 | 1128 | // pour tenter de router la requête. |
1129 | - if (isset($this->routes[$verb][$name]) && ! $overwrite) { |
|
1129 | + if (isset($this->routes[$verb][$name]) && !$overwrite) { |
|
1130 | 1130 | return; |
1131 | 1131 | } |
1132 | 1132 | |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | private function checkSubdomains($subdomains): bool |
1152 | 1152 | { |
1153 | 1153 | // Les appels CLI ne peuvent pas être sur le sous-domaine. |
1154 | - if (! isset($_SERVER['HTTP_HOST'])) { |
|
1154 | + if (!isset($_SERVER['HTTP_HOST'])) { |
|
1155 | 1155 | return false; |
1156 | 1156 | } |
1157 | 1157 | |
@@ -1159,13 +1159,13 @@ discard block |
||
1159 | 1159 | $this->currentSubdomain = $this->determineCurrentSubdomain(); |
1160 | 1160 | } |
1161 | 1161 | |
1162 | - if (! is_array($subdomains)) { |
|
1162 | + if (!is_array($subdomains)) { |
|
1163 | 1163 | $subdomains = [$subdomains]; |
1164 | 1164 | } |
1165 | 1165 | |
1166 | 1166 | // Les routes peuvent être limitées à n'importe quel sous-domaine. Dans ce cas, cependant, |
1167 | 1167 | // il nécessite la présence d'un sous-domaine. |
1168 | - if (! empty($this->currentSubdomain) && in_array('*', $subdomains, true)) { |
|
1168 | + if (!empty($this->currentSubdomain) && in_array('*', $subdomains, true)) { |
|
1169 | 1169 | return true; |
1170 | 1170 | } |
1171 | 1171 |
@@ -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 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | { |
26 | 26 | static $_is_php; |
27 | 27 | |
28 | - if (! isset($_is_php[$version])) { |
|
28 | + if (!isset($_is_php[$version])) { |
|
29 | 29 | $_is_php[$version] = version_compare(PHP_VERSION, $version, '>='); |
30 | 30 | } |
31 | 31 | |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | $host = explode(':', $_SERVER['HTTP_HOST'] ?? '')[0]; |
41 | 41 | |
42 | 42 | return |
43 | - ! empty($host) // Si c'est vide, ca veut certainement dire qu'on est en CLI, or le CLI << n'est pas >> utilisé en ligne |
|
44 | - && ! in_array($host, ['localhost', '127.0.0.1'], true) |
|
45 | - && ! preg_match('#\.dev$#', $host) |
|
46 | - && ! preg_match('#\.test$#', $host) |
|
47 | - && ! preg_match('#\.lab$#', $host) |
|
48 | - && ! preg_match('#\.loc(al)?$#', $host) |
|
49 | - && ! preg_match('#^192\.168#', $host); |
|
43 | + !empty($host) // Si c'est vide, ca veut certainement dire qu'on est en CLI, or le CLI << n'est pas >> utilisé en ligne |
|
44 | + && !in_array($host, ['localhost', '127.0.0.1'], true) |
|
45 | + && !preg_match('#\.dev$#', $host) |
|
46 | + && !preg_match('#\.test$#', $host) |
|
47 | + && !preg_match('#\.lab$#', $host) |
|
48 | + && !preg_match('#\.loc(al)?$#', $host) |
|
49 | + && !preg_match('#^192\.168#', $host); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | public static function isReallyWritable(string $file): bool |
65 | 65 | { |
66 | 66 | // If we're on a Unix server with safe_mode off we call is_writable |
67 | - if (DIRECTORY_SEPARATOR === '/' || ! ini_get('safe_mode')) { |
|
67 | + if (DIRECTORY_SEPARATOR === '/' || !ini_get('safe_mode')) { |
|
68 | 68 | return is_writable($file); |
69 | 69 | } |
70 | 70 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | |
84 | 84 | return true; |
85 | 85 | } |
86 | - if (! is_file($file) || ($fp = @fopen($file, 'ab')) === false) { |
|
86 | + if (!is_file($file) || ($fp = @fopen($file, 'ab')) === false) { |
|
87 | 87 | return false; |
88 | 88 | } |
89 | 89 | |
@@ -97,23 +97,23 @@ discard block |
||
97 | 97 | $path = parse_url($url); |
98 | 98 | $query = ''; |
99 | 99 | |
100 | - if (! empty($path['host'])) { |
|
100 | + if (!empty($path['host'])) { |
|
101 | 101 | $r = $path['scheme'] . '://'; |
102 | - if (! empty($path['user'])) { |
|
102 | + if (!empty($path['user'])) { |
|
103 | 103 | $r .= $path['user']; |
104 | - if (! empty($path['pass'])) { |
|
104 | + if (!empty($path['pass'])) { |
|
105 | 105 | $r .= ':' . $path['pass'] . '@'; |
106 | 106 | } |
107 | 107 | $r .= '@'; |
108 | 108 | } |
109 | - if (! empty($path['host'])) { |
|
109 | + if (!empty($path['host'])) { |
|
110 | 110 | $r .= $path['host']; |
111 | 111 | } |
112 | - if (! empty($path['port'])) { |
|
112 | + if (!empty($path['port'])) { |
|
113 | 113 | $r .= ':' . $path['port']; |
114 | 114 | } |
115 | 115 | $url = $r . $path['path']; |
116 | - if (! empty($path['query'])) { |
|
116 | + if (!empty($path['query'])) { |
|
117 | 117 | $query = '?' . $path['query']; |
118 | 118 | } |
119 | 119 | } |
@@ -137,12 +137,12 @@ discard block |
||
137 | 137 | $non_displayables = []; |
138 | 138 | |
139 | 139 | if ($url_encoded) { |
140 | - $non_displayables[] = '/%0[0-8bcef]/i'; // url encoded 00-08, 11, 12, 14, 15 |
|
141 | - $non_displayables[] = '/%1[0-9a-f]/i'; // url encoded 16-31 |
|
142 | - $non_displayables[] = '/%7f/i'; // url encoded 127 |
|
140 | + $non_displayables[] = '/%0[0-8bcef]/i'; // url encoded 00-08, 11, 12, 14, 15 |
|
141 | + $non_displayables[] = '/%1[0-9a-f]/i'; // url encoded 16-31 |
|
142 | + $non_displayables[] = '/%7f/i'; // url encoded 127 |
|
143 | 143 | } |
144 | 144 | |
145 | - $non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127 |
|
145 | + $non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127 |
|
146 | 146 | |
147 | 147 | do { |
148 | 148 | $str = preg_replace($non_displayables, '', $str, -1, $count); |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | return $data; |
186 | 186 | } |
187 | 187 | |
188 | - if (! in_array($context, ['html', 'js', 'css', 'url', 'attr'], true)) { |
|
188 | + if (!in_array($context, ['html', 'js', 'css', 'url', 'attr'], true)) { |
|
189 | 189 | throw new InvalidArgumentException('Invalid escape context provided.'); |
190 | 190 | } |
191 | 191 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | } |
197 | 197 | |
198 | 198 | static $escaper; |
199 | - if (! $escaper) { |
|
199 | + if (!$escaper) { |
|
200 | 200 | $escaper = new \Laminas\Escaper\Escaper($encoding); |
201 | 201 | } |
202 | 202 | |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | $double = true; |
262 | 262 | } |
263 | 263 | |
264 | - return htmlspecialchars($text, ENT_QUOTES | ENT_SUBSTITUTE, $charset ?: $defaultCharset, $double); |
|
264 | + return htmlspecialchars($text, ENT_QUOTES|ENT_SUBSTITUTE, $charset ?: $defaultCharset, $double); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | /** |
@@ -370,13 +370,13 @@ discard block |
||
370 | 370 | { |
371 | 371 | if ($key === 'HTTPS') { |
372 | 372 | if (isset($_SERVER['HTTPS'])) { |
373 | - return ! empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'; |
|
373 | + return !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'; |
|
374 | 374 | } |
375 | 375 | if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) { |
376 | - return ! empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) === 'https'; |
|
376 | + return !empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) === 'https'; |
|
377 | 377 | } |
378 | 378 | if (isset($_SERVER['HTTP_FRONT_END_HTTPS'])) { |
379 | - return ! empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off'; |
|
379 | + return !empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off'; |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | return strpos(self::env('SCRIPT_URI'), 'https://') === 0; |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | $name = self::env('SCRIPT_NAME'); |
414 | 414 | $filename = self::env('SCRIPT_FILENAME'); |
415 | 415 | $offset = 0; |
416 | - if (! strpos($name, '.php')) { |
|
416 | + if (!strpos($name, '.php')) { |
|
417 | 417 | $offset = 4; |
418 | 418 | } |
419 | 419 | |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | */ |
506 | 506 | public static function deprecationWarning(string $message, int $stackFrame = 1) |
507 | 507 | { |
508 | - if (! (error_reporting() & E_USER_DEPRECATED)) { |
|
508 | + if (!(error_reporting() & E_USER_DEPRECATED)) { |
|
509 | 509 | return; |
510 | 510 | } |
511 | 511 |
@@ -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]; |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | use BlitzPHP\Traits\Macroable; |
15 | 15 | use Transliterator; |
16 | 16 | |
17 | -if (! defined('MB_ENABLED')) { |
|
17 | +if (!defined('MB_ENABLED')) { |
|
18 | 18 | if (extension_loaded('mbstring')) { |
19 | 19 | define('MB_ENABLED', true); |
20 | 20 | // mbstring.internal_encoding est obsolète à partir de PHP 5.6 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | define('MB_ENABLED', false); |
28 | 28 | } |
29 | 29 | } |
30 | -if (! defined('ICONV_ENABLED')) { |
|
30 | +if (!defined('ICONV_ENABLED')) { |
|
31 | 31 | if (extension_loaded('iconv')) { |
32 | 32 | define('ICONV_ENABLED', true); |
33 | 33 | // iconv.internal_encoding est obsolète à partir de PHP 5.6 |
@@ -112,13 +112,13 @@ discard block |
||
112 | 112 | public static function cleanInsert(string $str, array $options): string |
113 | 113 | { |
114 | 114 | $clean = $options['clean']; |
115 | - if (! $clean) { |
|
115 | + if (!$clean) { |
|
116 | 116 | return $str; |
117 | 117 | } |
118 | 118 | if ($clean === true) { |
119 | 119 | $clean = ['method' => 'text']; |
120 | 120 | } |
121 | - if (! is_array($clean)) { |
|
121 | + if (!is_array($clean)) { |
|
122 | 122 | $clean = ['method' => $options['clean']]; |
123 | 123 | } |
124 | 124 | |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | public static function containsAll(string $haystack, array $needles): bool |
212 | 212 | { |
213 | 213 | foreach ($needles as $needle) { |
214 | - if (! static::contains($haystack, $needle)) { |
|
214 | + if (!static::contains($haystack, $needle)) { |
|
215 | 215 | return false; |
216 | 216 | } |
217 | 217 | } |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | return $options['clean'] ? static::cleanInsert($str, $options) : $str; |
412 | 412 | } |
413 | 413 | |
414 | - if (! isset($format)) { |
|
414 | + if (!isset($format)) { |
|
415 | 415 | $format = sprintf( |
416 | 416 | '/(?<!%s)%s%%s%s/', |
417 | 417 | preg_quote($options['escape'], '/'), |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | $str = str_replace($tmpHash, $tmpValue, $str); |
449 | 449 | } |
450 | 450 | |
451 | - if (! isset($options['format']) && isset($options['before'])) { |
|
451 | + if (!isset($options['format']) && isset($options['before'])) { |
|
452 | 452 | $str = str_replace($options['escape'] . $options['before'], $options['before'], $str); |
453 | 453 | } |
454 | 454 | |
@@ -749,8 +749,8 @@ discard block |
||
749 | 749 | $pattern = '/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i'; |
750 | 750 | $replace = preg_replace_callback( |
751 | 751 | $pattern, |
752 | - static function ($match) use ($strlen) { |
|
753 | - $utf8 = html_entity_decode($match[0], ENT_HTML5 | ENT_QUOTES, 'UTF-8'); |
|
752 | + static function($match) use ($strlen) { |
|
753 | + $utf8 = html_entity_decode($match[0], ENT_HTML5|ENT_QUOTES, 'UTF-8'); |
|
754 | 754 | |
755 | 755 | return str_repeat(' ', $strlen($utf8, 'UTF-8')); |
756 | 756 | }, |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | $result = ''; |
811 | 811 | |
812 | 812 | $pattern = '/(&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};)/i'; |
813 | - $parts = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
|
813 | + $parts = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); |
|
814 | 814 | |
815 | 815 | foreach ($parts as $part) { |
816 | 816 | $offset = 0; |
@@ -831,7 +831,7 @@ discard block |
||
831 | 831 | if ($offset !== 0 || $totalLength + $len > $length) { |
832 | 832 | if ( |
833 | 833 | strpos($part, '&') === 0 && preg_match($pattern, $part) |
834 | - && $part !== html_entity_decode($part, ENT_HTML5 | ENT_QUOTES, 'UTF-8') |
|
834 | + && $part !== html_entity_decode($part, ENT_HTML5|ENT_QUOTES, 'UTF-8') |
|
835 | 835 | ) { |
836 | 836 | // Entities cannot be passed substr. |
837 | 837 | continue; |
@@ -886,7 +886,7 @@ discard block |
||
886 | 886 | } |
887 | 887 | |
888 | 888 | $truncate = mb_substr($text, mb_strlen($text) - $length + mb_strlen($ellipsis)); |
889 | - if (! $exact) { |
|
889 | + if (!$exact) { |
|
890 | 890 | $spacepos = mb_strpos($truncate, ' '); |
891 | 891 | $truncate = $spacepos === false ? '' : trim(mb_substr($truncate, $spacepos)); |
892 | 892 | } |
@@ -941,7 +941,7 @@ discard block |
||
941 | 941 | } |
942 | 942 | if ($tmpOffset !== -1) { |
943 | 943 | $buffer .= substr($data, $offset, ($tmpOffset - $offset)); |
944 | - if (! $depth && $data[$tmpOffset] === $separator) { |
|
944 | + if (!$depth && $data[$tmpOffset] === $separator) { |
|
945 | 945 | $results[] = $buffer; |
946 | 946 | $buffer = ''; |
947 | 947 | } else { |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | } |
957 | 957 | } else { |
958 | 958 | if ($data[$tmpOffset] === $leftBound) { |
959 | - if (! $open) { |
|
959 | + if (!$open) { |
|
960 | 960 | $depth++; |
961 | 961 | $open = true; |
962 | 962 | } else { |
@@ -970,11 +970,11 @@ discard block |
||
970 | 970 | $offset = $length + 1; |
971 | 971 | } |
972 | 972 | } |
973 | - if (empty($results) && ! empty($buffer)) { |
|
973 | + if (empty($results) && !empty($buffer)) { |
|
974 | 974 | $results[] = $buffer; |
975 | 975 | } |
976 | 976 | |
977 | - if (! empty($results)) { |
|
977 | + if (!empty($results)) { |
|
978 | 978 | return array_map('trim', $results); |
979 | 979 | } |
980 | 980 | |
@@ -1014,7 +1014,7 @@ discard block |
||
1014 | 1014 | */ |
1015 | 1015 | public static function transliterate(string $string, $transliterator = null) |
1016 | 1016 | { |
1017 | - if (! $transliterator) { |
|
1017 | + if (!$transliterator) { |
|
1018 | 1018 | $transliterator = static::$_defaultTransliterator ?: static::$_defaultTransliteratorId; |
1019 | 1019 | } |
1020 | 1020 | |
@@ -1045,7 +1045,7 @@ discard block |
||
1045 | 1045 | $default = [ |
1046 | 1046 | 'ellipsis' => '...', 'exact' => true, 'html' => false, 'trimWidth' => false, |
1047 | 1047 | ]; |
1048 | - if (! empty($options['html']) && strtolower(mb_internal_encoding()) === 'utf-8') { |
|
1048 | + if (!empty($options['html']) && strtolower(mb_internal_encoding()) === 'utf-8') { |
|
1049 | 1049 | $default['ellipsis'] = "\xe2\x80\xa6"; |
1050 | 1050 | } |
1051 | 1051 | $options += $default; |
@@ -1065,12 +1065,12 @@ discard block |
||
1065 | 1065 | |
1066 | 1066 | foreach ($tags as $tag) { |
1067 | 1067 | $contentLength = 0; |
1068 | - if (! in_array($tag[2], static::$_defaultHtmlNoCount, true)) { |
|
1068 | + if (!in_array($tag[2], static::$_defaultHtmlNoCount, true)) { |
|
1069 | 1069 | $contentLength = self::strlen($tag[3], $options); |
1070 | 1070 | } |
1071 | 1071 | |
1072 | 1072 | if ($truncate === '') { |
1073 | - if (! preg_match('/img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param/i', $tag[2])) { |
|
1073 | + if (!preg_match('/img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param/i', $tag[2])) { |
|
1074 | 1074 | if (preg_match('/<[\w]+[^>]*>/', $tag[0])) { |
1075 | 1075 | array_unshift($openTags, $tag[2]); |
1076 | 1076 | } elseif (preg_match('/<\/([\w]+)[^>]*>/', $tag[0], $closeTag)) { |
@@ -1116,13 +1116,13 @@ discard block |
||
1116 | 1116 | |
1117 | 1117 | $result = self::substr($text, 0, $length - $ellipsisLength, $options); |
1118 | 1118 | |
1119 | - if (! $options['exact']) { |
|
1119 | + if (!$options['exact']) { |
|
1120 | 1120 | if (self::substr($text, $length - $ellipsisLength, 1, $options) !== ' ') { |
1121 | 1121 | $result = self::removeLastWord($result); |
1122 | 1122 | } |
1123 | 1123 | |
1124 | 1124 | // If result is empty, then we don't need to count ellipsis in the cut. |
1125 | - if (! strlen($result)) { |
|
1125 | + if (!strlen($result)) { |
|
1126 | 1126 | $result = self::substr($text, 0, $length, $options); |
1127 | 1127 | } |
1128 | 1128 | } |
@@ -1153,7 +1153,7 @@ discard block |
||
1153 | 1153 | { |
1154 | 1154 | preg_match('/^\s*+(?:\S++\s*+){1,' . $words . '}/u', $value, $matches); |
1155 | 1155 | |
1156 | - if (! isset($matches[0]) || static::length($value) === static::length($matches[0])) { |
|
1156 | + if (!isset($matches[0]) || static::length($value) === static::length($matches[0])) { |
|
1157 | 1157 | return $value; |
1158 | 1158 | } |
1159 | 1159 | |
@@ -1303,7 +1303,7 @@ discard block |
||
1303 | 1303 | { |
1304 | 1304 | static $languageSpecific; |
1305 | 1305 | |
1306 | - if (! isset($languageSpecific)) { |
|
1306 | + if (!isset($languageSpecific)) { |
|
1307 | 1307 | $languageSpecific = [ |
1308 | 1308 | 'bg' => [ |
1309 | 1309 | ['х', 'Х', 'щ', 'Щ', 'ъ', 'Ъ', 'ь', 'Ь'], |
@@ -1314,7 +1314,7 @@ discard block |
||
1314 | 1314 | ['ae', 'oe', 'aa', 'Ae', 'Oe', 'Aa'], |
1315 | 1315 | ], |
1316 | 1316 | 'de' => [ |
1317 | - ['ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü'], |
|
1317 | + ['ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü'], |
|
1318 | 1318 | ['ae', 'oe', 'ue', 'AE', 'OE', 'UE'], |
1319 | 1319 | ], |
1320 | 1320 | 'he' => [ |