diff --git a/src/Metadata/Converter/Types/Configurator/AttributeBaseTypeConfigurator.php b/src/Metadata/Converter/Types/Configurator/AttributeBaseTypeConfigurator.php index e996c3b..fbeee98 100644 --- a/src/Metadata/Converter/Types/Configurator/AttributeBaseTypeConfigurator.php +++ b/src/Metadata/Converter/Types/Configurator/AttributeBaseTypeConfigurator.php @@ -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); } } diff --git a/src/Metadata/Converter/Types/Configurator/ElementSingleConfigurator.php b/src/Metadata/Converter/Types/Configurator/ElementSingleConfigurator.php index 9bdcfef..66a3236 100644 --- a/src/Metadata/Converter/Types/Configurator/ElementSingleConfigurator.php +++ b/src/Metadata/Converter/Types/Configurator/ElementSingleConfigurator.php @@ -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()) );