Skip to content

Commit 5557ece

Browse files
committed
Correct constructor types
1 parent a7cc5bc commit 5557ece

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Generator/Schema.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ private static function fillUpSchema(string $name, string $namespace, string $cl
169169

170170

171171
$propertyStmt->setType(($propertyType === 'array' ? '' : $nullable) . $propertyType);
172-
$constructor->addParam((new Param($propertyName))->setType($propertyType))->addStmt(
172+
$constructorParam = (new Param($propertyName))->setType($propertyType);
173+
$constructor->addStmt(
173174
new Node\Expr\Assign(
174175
new Node\Expr\PropertyFetch(
175176
new Node\Expr\Variable('this'),
@@ -184,17 +185,20 @@ private static function fillUpSchema(string $name, string $namespace, string $cl
184185
if (is_array($property->anyOf) && $property->anyOf[0] instanceof OpenAPiSchema/* && array_key_exists(spl_object_hash($property->anyOf[0]), $schemaClassNameMap)*/) {
185186
$fqcnn = '\\' . $rootNamespace . '\\' . $schemaRegistry->get($property->anyOf[0], $className . '\\' . (new Convert($propertyName))->toPascal());
186187
$propertyStmt->setType($nullable . $fqcnn);
188+
$constructorParam->setType($nullable . $fqcnn);
187189
$setDefaylt = false;
188190
} else if (is_array($property->allOf) && $property->allOf[0] instanceof OpenAPiSchema/* && array_key_exists(spl_object_hash($property->allOf[0]), $schemaClassNameMap)*/) {
189191
$fqcnn = '\\' . $rootNamespace . '\\' . $schemaRegistry->get($property->allOf[0], $className . '\\' . (new Convert($propertyName))->toPascal());
190192
$propertyStmt->setType($nullable . $fqcnn);
193+
$constructorParam->setType($nullable . $fqcnn);
191194
$setDefaylt = false;
192195
}
193196

194197
// if (($property->type === 'object' || (is_array($property->type) && count($property->type) === 2)) && $property instanceof OpenAPiSchema/* && array_key_exists(spl_object_hash($property), $schemaClassNameMap)*/) {
195198
if ($propertyType === 'object') {
196199
$fqcnn = '\\' . $rootNamespace . '\\' . $schemaRegistry->get($property, $className . '\\' . (new Convert($propertyName))->toPascal());
197200
$propertyStmt->setType($nullable . $fqcnn);
201+
$constructorParam->setType($nullable . $fqcnn);
198202
$setDefaylt = false;
199203
}
200204

@@ -222,6 +226,7 @@ private static function fillUpSchema(string $name, string $namespace, string $cl
222226
}
223227

224228
$class->addStmt($propertyStmt);
229+
$constructor->addParam($constructorParam);
225230
}
226231

227232
if (count($constructDocBlock) > 0) {

0 commit comments

Comments
 (0)