@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | foreach ($data as $key => $value) { |
| 74 | 74 | $replacementKey = "\n{$key} = {$value}"; |
| 75 | - if (! str_contains($oldFileContents, $key)) { |
|
| 75 | + if (!str_contains($oldFileContents, $key)) { |
|
| 76 | 76 | if (file_put_contents($this->path, $replacementKey, FILE_APPEND) === false) { |
| 77 | 77 | return false; |
| 78 | 78 | } |
@@ -139,18 +139,18 @@ discard block |
||
| 139 | 139 | public function parse(): ?array |
| 140 | 140 | { |
| 141 | 141 | // Nous ne voulons pas imposer la présence d'un fichier .env, ils devraient être facultatifs. |
| 142 | - if (! is_file($this->path)) { |
|
| 142 | + if (!is_file($this->path)) { |
|
| 143 | 143 | return null; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | // Assurez-vous que le fichier est lisible |
| 147 | - if (! is_readable($this->path)) { |
|
| 147 | + if (!is_readable($this->path)) { |
|
| 148 | 148 | throw new InvalidArgumentException("The .env file is not readable: {$this->path}"); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | $vars = []; |
| 152 | 152 | |
| 153 | - $lines = file($this->path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|
| 153 | + $lines = file($this->path, FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); |
|
| 154 | 154 | |
| 155 | 155 | foreach ($lines as $line) { |
| 156 | 156 | // C'est un commentaire? |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | protected function setVariable(string $name, string $value = '') |
| 177 | 177 | { |
| 178 | - if (! getenv($name, true)) { |
|
| 178 | + if (!getenv($name, true)) { |
|
| 179 | 179 | putenv("{$name}={$value}"); |
| 180 | 180 | } |
| 181 | 181 | if (empty($_ENV[$name])) { |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | |
| 281 | 281 | $value = preg_replace_callback( |
| 282 | 282 | '/\${([a-zA-Z0-9_]+)}/', |
| 283 | - static function ($matchedPatterns) use ($loader): string { |
|
| 283 | + static function($matchedPatterns) use ($loader): string { |
|
| 284 | 284 | $nestedVariable = $loader->getVariable($matchedPatterns[1]); |
| 285 | 285 | |
| 286 | 286 | if (null === $nestedVariable) { |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | $file = $this->viewPath . $view; |
| 99 | 99 | |
| 100 | - if (! is_file($file)) { |
|
| 100 | + if (!is_file($file)) { |
|
| 101 | 101 | $fileOrig = $file; |
| 102 | 102 | $file = ($this->locator ?: Services::locator())->locateFile($view, 'Views'); |
| 103 | 103 | |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | foreach ($matches as $match) { |
| 282 | 282 | // Loop over each piece of $data, replacing |
| 283 | 283 | // its contents so that we know what to replace in parse() |
| 284 | - $str = ''; // holds the new contents for this tag pair. |
|
| 284 | + $str = ''; // holds the new contents for this tag pair. |
|
| 285 | 285 | |
| 286 | 286 | foreach ($data as $row) { |
| 287 | 287 | // Objects that have a `toArray()` method should be |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | |
| 324 | 324 | // Now replace our placeholders with the new content. |
| 325 | 325 | foreach ($temp as $pattern => $content) { |
| 326 | - $out = $this->replaceSingle($pattern, $content, $out, ! isset($pairs[$pattern])); |
|
| 326 | + $out = $this->replaceSingle($pattern, $content, $out, !isset($pairs[$pattern])); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | $str .= $out; |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | protected function replaceSingle(array|string $pattern, string $content, string $template, bool $escape = false): string |
| 482 | 482 | { |
| 483 | 483 | // Replace the content in the template |
| 484 | - return preg_replace_callback($pattern, function ($matches) use ($content, $escape): string { |
|
| 484 | + return preg_replace_callback($pattern, function($matches) use ($content, $escape): string { |
|
| 485 | 485 | // Check for {! !} syntax to not escape this one. |
| 486 | 486 | if ( |
| 487 | 487 | str_starts_with($matches[0], $this->leftDelimiter . '!') |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | |
| 504 | 504 | // Our regex earlier will leave all chained values on a single line |
| 505 | 505 | // so we need to break them apart so we can apply them all. |
| 506 | - $filters = ! empty($matches[1]) ? explode('|', $matches[1]) : []; |
|
| 506 | + $filters = !empty($matches[1]) ? explode('|', $matches[1]) : []; |
|
| 507 | 507 | |
| 508 | 508 | if ($escape && $filters === [] && ($context = $this->shouldAddEscaping($orig))) { |
| 509 | 509 | $filters[] = "esc({$context})"; |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | } |
| 532 | 532 | } |
| 533 | 533 | // No pipes, then we know we need to escape |
| 534 | - elseif (! str_contains($key, '|')) { |
|
| 534 | + elseif (!str_contains($key, '|')) { |
|
| 535 | 535 | $escape = 'html'; |
| 536 | 536 | } |
| 537 | 537 | // If there's a `noescape` then we're definitely false. |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | $escape = false; |
| 540 | 540 | } |
| 541 | 541 | // If no `esc` filter is found, then we'll need to add one. |
| 542 | - elseif (! preg_match('/\s+esc/u', $key)) { |
|
| 542 | + elseif (!preg_match('/\s+esc/u', $key)) { |
|
| 543 | 543 | $escape = 'html'; |
| 544 | 544 | } |
| 545 | 545 | |
@@ -576,7 +576,7 @@ discard block |
||
| 576 | 576 | $filter = $param !== [] ? trim(strtolower(substr($filter, 0, strpos($filter, '(')))) : trim($filter); |
| 577 | 577 | |
| 578 | 578 | $this->config['filters'] ??= []; |
| 579 | - if (! array_key_exists($filter, $this->config['filters'])) { |
|
| 579 | + if (!array_key_exists($filter, $this->config['filters'])) { |
|
| 580 | 580 | continue; |
| 581 | 581 | } |
| 582 | 582 | |
@@ -613,7 +613,7 @@ discard block |
||
| 613 | 613 | * $matches[1] = all parameters string in opening tag |
| 614 | 614 | * $matches[2] = content between the tags to send to the plugin. |
| 615 | 615 | */ |
| 616 | - if (! preg_match_all($pattern, $template, $matches, PREG_SET_ORDER)) { |
|
| 616 | + if (!preg_match_all($pattern, $template, $matches, PREG_SET_ORDER)) { |
|
| 617 | 617 | continue; |
| 618 | 618 | } |
| 619 | 619 | |
@@ -84,14 +84,14 @@ |
||
| 84 | 84 | $command = is_string($command) ? $command : 'command:name'; |
| 85 | 85 | $type = is_string($type) ? $type : 'basic'; |
| 86 | 86 | |
| 87 | - if (! in_array($type, ['basic', 'generator'], true)) { |
|
| 87 | + if (!in_array($type, ['basic', 'generator'], true)) { |
|
| 88 | 88 | // @codeCoverageIgnoreStart |
| 89 | 89 | $type = $this->choice(lang('CLI.generator.commandType'), ['basic', 'generator'], 'basic'); |
| 90 | 90 | $this->eol(); |
| 91 | 91 | // @codeCoverageIgnoreEnd |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - if (! is_string($group)) { |
|
| 94 | + if (!is_string($group)) { |
|
| 95 | 95 | $group = $type === 'generator' ? config('app.name', 'App') . ':Generateurs' : config('app.name', 'App'); |
| 96 | 96 | } |
| 97 | 97 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | collect(static::$data) |
| 80 | 80 | ->map( |
| 81 | 81 | static fn ($items) => collect($items) |
| 82 | - ->map(static function ($value) { |
|
| 82 | + ->map(static function($value) { |
|
| 83 | 83 | if (is_array($value)) { |
| 84 | 84 | return [$value]; |
| 85 | 85 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | ->all(); |
| 95 | 95 | })->flatten(1) |
| 96 | 96 | ) |
| 97 | - ->sortBy(static function ($data, $key): int { |
|
| 97 | + ->sortBy(static function($data, $key): int { |
|
| 98 | 98 | $index = array_search($key, ['Environnement', 'Cache', 'Gestionnaires'], true); |
| 99 | 99 | |
| 100 | 100 | return $index === false ? 99 : $index; |
@@ -118,14 +118,14 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | protected function displayDetail(Collection $data): void |
| 120 | 120 | { |
| 121 | - $data->each(function ($data, $section): void { |
|
| 121 | + $data->each(function($data, $section): void { |
|
| 122 | 122 | $this->newLine(); |
| 123 | 123 | |
| 124 | 124 | $this->justify($section, '', ['first' => ['fg' => Color::GREEN]]); |
| 125 | 125 | |
| 126 | - $data->pipe(static fn ($data) => $section !== 'Environnement' ? $data->sort() : $data)->each(function ($detail): void { |
|
| 126 | + $data->pipe(static fn ($data) => $section !== 'Environnement' ? $data->sort() : $data)->each(function($detail): void { |
|
| 127 | 127 | [$label, $value] = $detail; |
| 128 | - if (! in_array($label, static::$displayed, true)) { |
|
| 128 | + if (!in_array($label, static::$displayed, true)) { |
|
| 129 | 129 | $this->justify($label, value($value, false)); |
| 130 | 130 | static::$displayed[] = $label; |
| 131 | 131 | } |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | |
| 180 | 180 | static::addToSection('Gestionnaires', static fn () => array_filter([ |
| 181 | 181 | 'Cache' => config('cache.handler'), |
| 182 | - 'Logs' => static function ($json): string { |
|
| 182 | + 'Logs' => static function($json): string { |
|
| 183 | 183 | $handlers = []; |
| 184 | 184 | |
| 185 | 185 | foreach (config('log.handlers') as $k => $v) { |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | */ |
| 253 | 253 | public static function format(mixed $value, ?Closure $console = null, ?Closure $json = null) |
| 254 | 254 | { |
| 255 | - return static function ($isJson) use ($value, $console, $json) { |
|
| 255 | + return static function($isJson) use ($value, $console, $json) { |
|
| 256 | 256 | if ($isJson === true && $json instanceof Closure) { |
| 257 | 257 | return value($json, $value); |
| 258 | 258 | } |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | */ |
| 305 | 305 | final public function success(string $message, bool $badge = true, string $label = 'SUCCESS'): self |
| 306 | 306 | { |
| 307 | - if (! $badge) { |
|
| 307 | + if (!$badge) { |
|
| 308 | 308 | $this->writer->okBold($label); |
| 309 | 309 | } else { |
| 310 | 310 | $this->writer->boldWhiteBgGreen(" {$label} "); |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | */ |
| 319 | 319 | final public function warning(string $message, bool $badge = true, string $label = 'WARNING'): self |
| 320 | 320 | { |
| 321 | - if (! $badge) { |
|
| 321 | + if (!$badge) { |
|
| 322 | 322 | $this->writer->warnBold($label); |
| 323 | 323 | } else { |
| 324 | 324 | $this->writer->boldWhiteBgYellow(" {$label} "); |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | */ |
| 333 | 333 | final public function info(string $message, bool $badge = true, string $label = 'INFO'): self |
| 334 | 334 | { |
| 335 | - if (! $badge) { |
|
| 335 | + if (!$badge) { |
|
| 336 | 336 | $this->writer->infoBold($label); |
| 337 | 337 | } else { |
| 338 | 338 | $this->writer->boldWhiteBgCyan(" {$label} "); |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | */ |
| 347 | 347 | final public function error(string $message, bool $badge = true, string $label = 'ERROR'): self |
| 348 | 348 | { |
| 349 | - if (! $badge) { |
|
| 349 | + if (!$badge) { |
|
| 350 | 350 | $this->writer->errorBold($label); |
| 351 | 351 | } else { |
| 352 | 352 | $this->writer->boldWhiteBgRed(" {$label} "); |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | */ |
| 450 | 450 | final public function json($data): self |
| 451 | 451 | { |
| 452 | - $this->write(json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), true); |
|
| 452 | + $this->write(json_encode($data, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES), true); |
|
| 453 | 453 | |
| 454 | 454 | return $this; |
| 455 | 455 | } |
@@ -641,8 +641,8 @@ discard block |
||
| 641 | 641 | */ |
| 642 | 642 | protected function initProps() |
| 643 | 643 | { |
| 644 | - if (! is_cli()) { |
|
| 645 | - if (! file_exists($ou = TEMP_PATH . 'blitz-cli.txt')) { |
|
| 644 | + if (!is_cli()) { |
|
| 645 | + if (!file_exists($ou = TEMP_PATH . 'blitz-cli.txt')) { |
|
| 646 | 646 | file_put_contents($ou, '', LOCK_EX); |
| 647 | 647 | } |
| 648 | 648 | |