Skip to content

Commit 840716d

Browse files
committed
fixed PHPStan errors
1 parent 6438202 commit 840716d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
2-
level: 5
2+
level: 8
33

44
paths:
55
- src

src/CommandLine/Parser.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Parser
5252
/** @param array<string, array<string, mixed>> $defaults */
5353
public function __construct(string $help = '', array $defaults = [])
5454
{
55-
$this->args = isset($_SERVER['argv']) ? array_slice($_SERVER['argv'], 1) : [];
55+
$this->args = array_values(array_map(strval(...), isset($_SERVER['argv']) ? array_slice($_SERVER['argv'], 1) : []));
5656

5757
if ($help || $defaults) {
5858
$this->addFromHelp($help, $defaults);
@@ -73,12 +73,12 @@ public function addFromHelp(string $help, array $defaults = []): static
7373
throw new \InvalidArgumentException("Unable to parse '$line[1]'.");
7474
}
7575

76-
$name = end($m[1]);
76+
$name = (string) end($m[1]);
7777
$defaults[$name] = ($defaults[$name] ?? []) + [
7878
self::Argument => (bool) end($m[2]),
79-
self::Optional => isset($line[2]) || (str_starts_with(end($m[2]), '[')),
79+
self::Optional => isset($line[2]) || (str_starts_with((string) end($m[2]), '[')),
8080
self::Repeatable => (bool) end($m[3]),
81-
self::Enum => count($enums = explode('|', trim(end($m[2]), '<[]>'))) > 1 ? $enums : null,
81+
self::Enum => count($enums = explode('|', trim((string) end($m[2]), '<[]>'))) > 1 ? $enums : null,
8282
self::Default => $line[2] ?? null,
8383
];
8484
$aliases[$name] = $name !== $m[1][0] ? $m[1][0] : null;

0 commit comments

Comments
 (0)