Skip to content

Commit

Permalink
Merge pull request #40 from veewee/local-types
Browse files Browse the repository at this point in the history
Mark types as locally configured types
  • Loading branch information
veewee authored Dec 20, 2024
2 parents 4b54ed4 + ba64911 commit 1128124
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ public function __invoke(EngineType $engineType, mixed $xsdType, TypesConverterC
default => null,
};

// Attributes can have inline types. Mark the attribute as a local type in that case.
$isConsideredAnInlineType = $baseType && $baseType->getName() === null;
if ($isConsideredAnInlineType) {
$engineType = $engineType->withMeta(
static fn ($meta) => $meta->withIsLocal(true)
);
}

return (new SimpleTypeConfigurator())($engineType, $baseType, $context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,19 @@ public function __invoke(EngineType $engineType, mixed $xsdType, TypesConverterC
return $engineType;
}

// Elements can have inline types. Mark the attribute as a local type in that case.
$innerType = $xsdType->getType();
$isConsideredAnInlineType = $innerType && $innerType->getName() === null;
if ($isConsideredAnInlineType) {
$engineType = $engineType->withMeta(
static fn ($meta) => $meta->withIsLocal(true)
);
}

return $engineType
->withMeta(
static fn (TypeMeta $meta): TypeMeta => $meta
->withIsQualified($xsdType->isQualified())
->withIsLocal($xsdType->isLocal())
->withIsNil($xsdType->isNil())
->withIsNullable($meta->isNullable()->unwrapOr(false) || $xsdType->isNil())
);
Expand Down

0 comments on commit 1128124

Please sign in to comment.