From 0bca797e8d2dd9261170b8156cca81d6a355e66d Mon Sep 17 00:00:00 2001 From: Christopher Vagnetoft Date: Sat, 18 Jan 2025 14:23:46 +0100 Subject: [PATCH] Improve command signature logic --- src/Command.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Command.php b/src/Command.php index 790ada8..a3bfe11 100644 --- a/src/Command.php +++ b/src/Command.php @@ -53,13 +53,13 @@ class Command } else { $type = $parameter->getType(); if ($type instanceof ReflectionNamedType && $type->isBuiltin()) { - $type = $type->getName(); + $type = ($type->allowsNull() ? "?" : "") . $type->getName(); } else { $type = null; } } - if ($parameter->isOptional()) $type = "?{$type}"; + if ($parameter->isDefaultValueAvailable()) $type = "{$type}=".\json_encode($parameter->getDefaultValue(),\JSON_UNESCAPED_SLASHES); if ($type !== null) $args[$name] = $type; }