Skip to content

Commit 956978e

Browse files
committed
Number goes from float to int|float
1 parent 4852a3d commit 956978e

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

src/Gatherer/Operation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static function gather(
4545
[$example, $exampleNode] = (static function (string $type, ?string $format): array {
4646
if ($type === 'int' || $type === '?int') {
4747
return [13, new Node\Scalar\LNumber(13)];
48-
} elseif ($type === 'float' || $type === '?float') {
48+
} elseif ($type === 'float' || $type === '?float' || $type === 'int|float' || $type === 'null|int}float') {
4949
return [13.13, new Node\Scalar\LNumber(13.13)];
5050
} elseif ($type === 'bool' || $type === '?bool') {
5151
return [false, new Node\Expr\ConstFetch(

src/Gatherer/Property.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private static function generateExampleData(mixed $exampleData, PropertyType $ty
8585
} else if ($exampleData === null && $type->type=== 'scalar') {
8686
if ($type->payload === 'int' || $type->payload === '?int') {
8787
return 13;
88-
} elseif ($type->payload === 'float' || $type->payload === '?float') {
88+
} elseif ($type->payload === 'float' || $type->payload === '?float' || $type->payload === 'int|float' || $type->payload === 'null|int|float') {
8989
return 13.13;
9090
} elseif ($type->payload === 'bool' || $type->payload === '?bool') {
9191
return false;

src/Gatherer/Type.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static function gather(
8282
'boolean',
8383
], [
8484
'int',
85-
'float',
85+
'int|float',
8686
'',
8787
'',
8888
'bool',

src/Generator/Schema.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public static function generate(string $pathPrefix, string $namespace, \ApiClien
145145

146146
$nullable = '';
147147
if ($property->nullable) {
148-
$nullable = count($types) > 1 ? 'null|' : '?';
148+
$nullable = (count($types) > 1 || count(explode('|', implode('|', $types))) > 1) ? 'null|' : '?';
149149
}
150150

151151
$constructor->addParam($constructorParam->setType($nullable . implode('|', $types)));

0 commit comments

Comments
 (0)