Skip to content

Commit 0d6f637

Browse files
authored
Optimized phpdoc & code (#6976)
1 parent cae216d commit 0d6f637

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

src/ParameterParser.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,8 @@ public function parseClosureOptions(Closure $closure): array
7373
}
7474

7575
$definitions = $this->closureDefinitionCollector->getParameters($closure);
76-
$options = [];
7776

78-
foreach ($definitions as $definition) {
79-
$type = $definition->getName();
80-
if (! in_array($type, ['int', 'float', 'string', 'bool'])) {
81-
continue;
82-
}
83-
$name = $definition->getMeta('name');
84-
$mode = $definition->allowsNull() ? InputOption::VALUE_OPTIONAL : InputOption::VALUE_REQUIRED;
85-
$default = $definition->getMeta('defaultValue');
86-
$options[] = new InputOption($name, null, $mode, '', $default, []);
87-
}
88-
89-
return $options;
77+
return $this->extractedOptions($definitions);
9078
}
9179

9280
/**
@@ -99,6 +87,12 @@ public function parseMethodOptions(string $class, string $method): array
9987
}
10088

10189
$definitions = $this->methodDefinitionCollector->getParameters($class, $method);
90+
91+
return $this->extractedOptions($definitions);
92+
}
93+
94+
public function extractedOptions(array $definitions): array
95+
{
10296
$options = [];
10397

10498
foreach ($definitions as $definition) {

src/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static function parse(string $expression): array
4444
*/
4545
protected static function name(string $expression): string
4646
{
47-
if (! preg_match('/[^\s]+/', $expression, $matches)) {
47+
if (! preg_match('/\S+/', $expression, $matches)) {
4848
throw new InvalidArgumentException('Unable to determine command name from signature.');
4949
}
5050

0 commit comments

Comments
 (0)