Skip to content

Commit 1128124

Browse files
authored
Merge pull request #40 from veewee/local-types
Mark types as locally configured types
2 parents 4b54ed4 + ba64911 commit 1128124

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/Metadata/Converter/Types/Configurator/AttributeBaseTypeConfigurator.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ public function __invoke(EngineType $engineType, mixed $xsdType, TypesConverterC
2323
default => null,
2424
};
2525

26+
// Attributes can have inline types. Mark the attribute as a local type in that case.
27+
$isConsideredAnInlineType = $baseType && $baseType->getName() === null;
28+
if ($isConsideredAnInlineType) {
29+
$engineType = $engineType->withMeta(
30+
static fn ($meta) => $meta->withIsLocal(true)
31+
);
32+
}
33+
2634
return (new SimpleTypeConfigurator())($engineType, $baseType, $context);
2735
}
2836
}

src/Metadata/Converter/Types/Configurator/ElementSingleConfigurator.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,19 @@ public function __invoke(EngineType $engineType, mixed $xsdType, TypesConverterC
1616
return $engineType;
1717
}
1818

19+
// Elements can have inline types. Mark the attribute as a local type in that case.
20+
$innerType = $xsdType->getType();
21+
$isConsideredAnInlineType = $innerType && $innerType->getName() === null;
22+
if ($isConsideredAnInlineType) {
23+
$engineType = $engineType->withMeta(
24+
static fn ($meta) => $meta->withIsLocal(true)
25+
);
26+
}
27+
1928
return $engineType
2029
->withMeta(
2130
static fn (TypeMeta $meta): TypeMeta => $meta
2231
->withIsQualified($xsdType->isQualified())
23-
->withIsLocal($xsdType->isLocal())
2432
->withIsNil($xsdType->isNil())
2533
->withIsNullable($meta->isNullable()->unwrapOr(false) || $xsdType->isNil())
2634
);

0 commit comments

Comments
 (0)