From 926dfd9f133b70611f63860881f432b2f3fd9b3b Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Wed, 8 Jun 2022 08:43:47 +0200 Subject: [PATCH] Correct operation constructor paramter types --- src/Generator/Client.php | 2 +- src/Generator/Operation.php | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Generator/Client.php b/src/Generator/Client.php index 32ce242..284eb5c 100644 --- a/src/Generator/Client.php +++ b/src/Generator/Client.php @@ -31,7 +31,7 @@ public static function generate(string $operationGroup, string $namespace, strin foreach ($operationDetails['operation']->parameters as $parameter) { $params[] = new Node\Arg(new Node\Expr\Variable($parameter->name)); $param = new Param($parameter->name); - if ($parameter->schema->default !== null) { + if ($parameter->schema->type !== null) { $param->setType( str_replace([ 'integer', diff --git a/src/Generator/Operation.php b/src/Generator/Operation.php index 2ccf5f2..543b485 100644 --- a/src/Generator/Operation.php +++ b/src/Generator/Operation.php @@ -54,9 +54,10 @@ public static function generate(string $path, string $method, string $namespace, $requestReplaces = []; $query = []; foreach ($operation->parameters as $parameter) { - $paramterStmt = $factory-> - property($parameter->name)-> - setDocComment('/**' . (string)$parameter->description . '**/'); + $paramterStmt = $factory->property($parameter->name); + if (strlen((string)$parameter->description) > 0) { + $paramterStmt->setDocComment('/**' . (string)$parameter->description . '**/'); + } if ($parameter->schema->type !== null) { $paramterStmt->setType(str_replace([ 'integer', @@ -68,10 +69,10 @@ public static function generate(string $path, string $method, string $namespace, 'bool', ], $parameter->schema->type)); } - $class->addStmt($paramterStmt); + $class->addStmt($paramterStmt->makeReadonly()->makePrivate()); $param = new Param($parameter->name); - if ($parameter->schema->default !== null) { + if ($parameter->schema->type !== null) { $param->setType( str_replace([ 'integer',