Skip to content

Commit

Permalink
check whether schema is available
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed Nov 3, 2024
1 parent 843dcc1 commit 0798e38
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Generator/CodeGeneratorAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,22 @@ protected function supportsExtends(): bool

private function supportsMap(Code\Name $name, MapDefinitionType $type): bool
{
return !!$this->writeMap($name, $this->generator->getType($type->getSchema()), $type);
$schema = $type->getSchema();
if (!$schema instanceof PropertyTypeAbstract) {
return false;
}

return !!$this->writeMap($name, $this->generator->getType($schema), $type);
}

private function supportsArray(Code\Name $name, ArrayDefinitionType $type): bool
{
return !!$this->writeArray($name, $this->generator->getType($type->getSchema()), $type);
$schema = $type->getSchema();
if (!$schema instanceof PropertyTypeAbstract) {
return false;
}

return !!$this->writeArray($name, $this->generator->getType($schema), $type);
}

abstract protected function writeStruct(Code\Name $name, array $properties, ?string $extends, ?array $generics, ?array $templates, StructDefinitionType $origin): string;
Expand Down

0 comments on commit 0798e38

Please sign in to comment.