Skip to content

Commit d8f75be

Browse files
committed
update parser
1 parent 91cb547 commit d8f75be

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/CommandLineParser.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public function __construct(mixed $parser = null)
2222
if (is_string($fileData)) {
2323
$this->parserDescriptor = $fileData;
2424
}
25+
fclose($handler);
2526
}
26-
fclose($handler);
2727
}
2828

2929
public function execute(CommandInterface $command = null): CommandInterface
@@ -38,10 +38,16 @@ public function execute(CommandInterface $command = null): CommandInterface
3838

3939
public function setFileNames(array $fileNames): CommandInterface
4040
{
41-
$keys = array_keys($fileNames);
42-
foreach ($keys as $key) {
43-
$this->args[$key] = $fileNames[$key];
44-
}
41+
$this->args = array_reduce(
42+
array_keys($fileNames),
43+
function ($args, $key) use ($fileNames) {
44+
$args[$key] = $fileNames[$key];
45+
46+
return $args;
47+
},
48+
[]
49+
);
50+
4551
return $this;
4652
}
4753

0 commit comments

Comments
 (0)