Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark types as locally configured types #40

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading