diff --git a/src/Command.php b/src/Command.php index a3bfe11..2c5278f 100644 --- a/src/Command.php +++ b/src/Command.php @@ -19,10 +19,13 @@ class Command /** @var callable $handler The handler */ private $handler; - public function __construct(string $name, callable $handler) + private ?array $signature; + + public function __construct(string $name, callable $handler, ?array $signature = null) { $this->name = $name; $this->handler = $handler; + $this->signature = $signature; } public function getName(): string @@ -66,5 +69,10 @@ class Command return $args; } + public function getSignature(): array + { + return $this->signature ?? $this->parameters(); + } + } diff --git a/tests/CommandTest.php b/tests/CommandTest.php index 54d30f0..f5fe8fe 100644 --- a/tests/CommandTest.php +++ b/tests/CommandTest.php @@ -31,8 +31,8 @@ class CommandTest extends \PHPUnit\Framework\TestCase $command = new Command("test", function (string $a, ?int $b, bool $c = false) { }); $expect = [ 'a' => 'string', - 'b' => 'int', - 'c' => '?bool' + 'b' => '?int', + 'c' => 'bool=false' ]; $this->assertEquals($expect, $command->parameters()); }