diff --git a/Internal/Code/PhpType.php b/Internal/Code/PhpType.php index 58030cf..ed67d5b 100644 --- a/Internal/Code/PhpType.php +++ b/Internal/Code/PhpType.php @@ -62,7 +62,7 @@ public function toPhpDoc(string $paramName): string */ public static function scalar(string $nativeType, ?string $phpDocType = null, null|bool|string|int $default = null): self { - return new self($nativeType, $phpDocType, default: $default); + return new self($nativeType, $phpDocType, nullable: null === $default, default: $default); } /** diff --git a/Internal/Code/Type/ScalarTypeVisitor.php b/Internal/Code/Type/ScalarTypeVisitor.php index ba2e0ae..869f306 100644 --- a/Internal/Code/Type/ScalarTypeVisitor.php +++ b/Internal/Code/Type/ScalarTypeVisitor.php @@ -44,12 +44,12 @@ final class ScalarTypeVisitor extends DefaultTypeVisitor public function scalar(ProtoType $type, Scalar $scalar): PhpType { return match ($scalar) { - Scalar::bool => PhpType::scalar('bool', default: false), - Scalar::string => PhpType::scalar('string', default: ''), - Scalar::bytes => PhpType::scalar('string', 'bytes', ''), - Scalar::double => PhpType::scalar('float', 'double', 0), - Scalar::float => PhpType::scalar('float', default: 0), - default => PhpType::scalar('int', $scalar->value, 0), + Scalar::bool => PhpType::scalar('bool'), + Scalar::string => PhpType::scalar('string'), + Scalar::bytes => PhpType::scalar('string', 'bytes'), + Scalar::double => PhpType::scalar('float', 'double'), + Scalar::float => PhpType::scalar('float'), + default => PhpType::scalar('int', $scalar->value), }; } }