From 0798e38021e42cb49d437077a4b457e726cdf987 Mon Sep 17 00:00:00 2001 From: Christoph Kappestein Date: Sun, 3 Nov 2024 23:32:22 +0100 Subject: [PATCH] check whether schema is available --- src/Generator/CodeGeneratorAbstract.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Generator/CodeGeneratorAbstract.php b/src/Generator/CodeGeneratorAbstract.php index 943773d..c57d68e 100644 --- a/src/Generator/CodeGeneratorAbstract.php +++ b/src/Generator/CodeGeneratorAbstract.php @@ -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;