Skip to content

Commit 6f0d9ef

Browse files
authored
Merge pull request #57 from php-api-clients/correct-operation-constructor-parameter-types
Correct operation constructor paramter types
2 parents 9acfa69 + 926dfd9 commit 6f0d9ef

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/Generator/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static function generate(string $operationGroup, string $namespace, strin
3131
foreach ($operationDetails['operation']->parameters as $parameter) {
3232
$params[] = new Node\Arg(new Node\Expr\Variable($parameter->name));
3333
$param = new Param($parameter->name);
34-
if ($parameter->schema->default !== null) {
34+
if ($parameter->schema->type !== null) {
3535
$param->setType(
3636
str_replace([
3737
'integer',

src/Generator/Operation.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ public static function generate(string $path, string $method, string $namespace,
5454
$requestReplaces = [];
5555
$query = [];
5656
foreach ($operation->parameters as $parameter) {
57-
$paramterStmt = $factory->
58-
property($parameter->name)->
59-
setDocComment('/**' . (string)$parameter->description . '**/');
57+
$paramterStmt = $factory->property($parameter->name);
58+
if (strlen((string)$parameter->description) > 0) {
59+
$paramterStmt->setDocComment('/**' . (string)$parameter->description . '**/');
60+
}
6061
if ($parameter->schema->type !== null) {
6162
$paramterStmt->setType(str_replace([
6263
'integer',
@@ -68,10 +69,10 @@ public static function generate(string $path, string $method, string $namespace,
6869
'bool',
6970
], $parameter->schema->type));
7071
}
71-
$class->addStmt($paramterStmt);
72+
$class->addStmt($paramterStmt->makeReadonly()->makePrivate());
7273

7374
$param = new Param($parameter->name);
74-
if ($parameter->schema->default !== null) {
75+
if ($parameter->schema->type !== null) {
7576
$param->setType(
7677
str_replace([
7778
'integer',

0 commit comments

Comments
 (0)