diff --git a/src/Builder.php b/src/Builder.php index 5719fcda..93e4044b 100644 --- a/src/Builder.php +++ b/src/Builder.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Builder/Import.php b/src/Builder/Import.php index fe0332ef..b1ce95ba 100644 --- a/src/Builder/Import.php +++ b/src/Builder/Import.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Builder; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Builder/Imports.php b/src/Builder/Imports.php index 387fc57a..1e8f9d35 100644 --- a/src/Builder/Imports.php +++ b/src/Builder/Imports.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Builder; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Builder/TypeBuilder.php b/src/Builder/TypeBuilder.php index 5c34fabb..8812dab7 100644 --- a/src/Builder/TypeBuilder.php +++ b/src/Builder/TypeBuilder.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Builder; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Config.php b/src/Config.php index 0eeb8165..c32b8a87 100644 --- a/src/Config.php +++ b/src/Config.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/ConfigKeyEnum.php b/src/ConfigKeyEnum.php index d9a39a89..fe1d4dd5 100644 --- a/src/ConfigKeyEnum.php +++ b/src/ConfigKeyEnum.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR; /* - * Copyright 2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2024-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/CoreFile.php b/src/CoreFile.php index 099b2d44..63eebb5e 100644 --- a/src/CoreFile.php +++ b/src/CoreFile.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR; /* - * Copyright 2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2024-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/CoreFiles.php b/src/CoreFiles.php index 612ed684..26cfaff9 100644 --- a/src/CoreFiles.php +++ b/src/CoreFiles.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR; /* - * Copyright 2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2024-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Enum/AttributeNameEnum.php b/src/Enum/AttributeNameEnum.php index e3d7ae2d..9fde6bd4 100644 --- a/src/Enum/AttributeNameEnum.php +++ b/src/Enum/AttributeNameEnum.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Enum; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Enum/ElementNameEnum.php b/src/Enum/ElementNameEnum.php index 28d46314..00cd9239 100644 --- a/src/Enum/ElementNameEnum.php +++ b/src/Enum/ElementNameEnum.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Enum; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Enum/PrimitiveTypeEnum.php b/src/Enum/PrimitiveTypeEnum.php index ab3549e4..7737692a 100644 --- a/src/Enum/PrimitiveTypeEnum.php +++ b/src/Enum/PrimitiveTypeEnum.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Enum; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Enum/PropertyUseEnum.php b/src/Enum/PropertyUseEnum.php index c7ad6a4a..8d531ec7 100644 --- a/src/Enum/PropertyUseEnum.php +++ b/src/Enum/PropertyUseEnum.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Enum; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Enum/TypeKindEnum.php b/src/Enum/TypeKindEnum.php index 8ca62faa..282a366f 100644 --- a/src/Enum/TypeKindEnum.php +++ b/src/Enum/TypeKindEnum.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Enum; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,9 +48,8 @@ enum TypeKindEnum: string // treated a bit different case PHPFHIR_XHTML = 'phpfhir_xhtml'; - private const _DSTU1_CONTAINER_TYPE = self::RESOURCE_INLINE; - - private const _CONTAINER_TYPE = self::RESOURCE_CONTAINER; + private const _DSTU1_RESOURCE_CONTAINER_TYPE = self::RESOURCE_INLINE; + private const _RESOURCE_CONTAINER_TYPE = self::RESOURCE_CONTAINER; /** * Returns true if the provided FHIR type name is the "container" type for the provided version. @@ -62,9 +61,9 @@ enum TypeKindEnum: string public static function isContainerTypeName(Version $version, string $fhirName): bool { if ($version->getSourceMetadata()->isDSTU1()) { - return $fhirName === self::_DSTU1_CONTAINER_TYPE->value; + return $fhirName === self::_DSTU1_RESOURCE_CONTAINER_TYPE->value; } - return $fhirName === self::_CONTAINER_TYPE->value; + return $fhirName === self::_RESOURCE_CONTAINER_TYPE->value; } /** @@ -77,16 +76,16 @@ public function isOneOf(TypeKindEnum|string ...$other): bool } /** - * Returns true if this kind is the "container" kind for the provided FHIR version. + * Returns true if this kind is the "resource container" kind for the provided FHIR version. * * @param \DCarbone\PHPFHIR\Version $version * @return bool */ - public function isContainer(Version $version): bool + public function isResourceContainer(Version $version): bool { if ($version->getSourceMetadata()->isDSTU1()) { - return $this === self::_DSTU1_CONTAINER_TYPE; + return $this === self::_DSTU1_RESOURCE_CONTAINER_TYPE; } - return $this === self::_CONTAINER_TYPE; + return $this === self::_RESOURCE_CONTAINER_TYPE; } } \ No newline at end of file diff --git a/src/LogLevel.php b/src/LogLevel.php index adbb4c36..24b34dae 100644 --- a/src/LogLevel.php +++ b/src/LogLevel.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR; /* - * Copyright 2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2024-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Logger.php b/src/Logger.php index 5241ee8c..e8fa0221 100644 --- a/src/Logger.php +++ b/src/Logger.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Render/Templates.php b/src/Render/Templates.php index 412e44d2..a0949364 100644 --- a/src/Render/Templates.php +++ b/src/Render/Templates.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Render; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,6 +55,9 @@ public static function renderVersionXHTMLTypeClass(Version $version, Types $type */ public static function renderVersionTypeClass(Version $version, Types $types, Type $type): string { + if ($type->getKind()->isResourceContainer($version)) { + return require PHPFHIR_TEMPLATE_VERSION_TYPES_DIR . DIRECTORY_SEPARATOR . 'class_resource_container.php'; + } return require PHPFHIR_TEMPLATE_VERSION_TYPES_DIR . DIRECTORY_SEPARATOR . 'class_default.php'; } diff --git a/src/Utilities/DocumentationUtils.php b/src/Utilities/DocumentationUtils.php index 9e2bdb33..15c4db6f 100644 --- a/src/Utilities/DocumentationUtils.php +++ b/src/Utilities/DocumentationUtils.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Utilities; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Utilities/ExceptionUtils.php b/src/Utilities/ExceptionUtils.php index 36c22be1..34590ca7 100644 --- a/src/Utilities/ExceptionUtils.php +++ b/src/Utilities/ExceptionUtils.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Utilities; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Utilities/FileUtils.php b/src/Utilities/FileUtils.php index 8eae5d3f..663fe2d9 100644 --- a/src/Utilities/FileUtils.php +++ b/src/Utilities/FileUtils.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Utilities; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Utilities/ImportUtils.php b/src/Utilities/ImportUtils.php index d40efeb1..09acd182 100644 --- a/src/Utilities/ImportUtils.php +++ b/src/Utilities/ImportUtils.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Utilities; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,17 +48,12 @@ public static function buildVersionTypeImports(Type $type): void $typeKind = $type->getKind(); if (!$type->isAbstract()) { - $imports->addCoreFileImportsByName(PHPFHIR_ENCODING_CLASSNAME_XML_WRITER); - $imports->addCoreFileImportsByName(PHPFHIR_ENCODING_ENUM_XML_LOCATION); + $imports->addCoreFileImportsByName( + PHPFHIR_ENCODING_CLASSNAME_XML_WRITER, + PHPFHIR_ENCODING_ENUM_XML_LOCATION, + ); } - $imports->addVersionCoreFileImportsByName($type->getVersion(), PHPFHIR_CLASSNAME_VERSION); - $imports->addVersionCoreFileImportsByName($type->getVersion(), PHPFHIR_CLASSNAME_VERSION_CONSTANTS); - $imports->addCoreFileImportsByName(PHPFHIR_ENCODING_CLASSNAME_UNSERIALIZE_CONFIG); - $imports->addCoreFileImportsByName(PHPFHIR_ENCODING_CLASSNAME_SERIALIZE_CONFIG); - - $imports->addCoreFileImportsByName(PHPFHIR_INTERFACE_TYPE); - foreach ($type->getDirectlyImplementedInterfaces() as $interface => $namespace) { $imports->addImport($namespace, $interface); } @@ -67,12 +62,33 @@ public static function buildVersionTypeImports(Type $type): void $imports->addImport($namespace, $trait); } + $imports->addVersionCoreFileImportsByName( + $type->getVersion(), + PHPFHIR_CLASSNAME_VERSION, + PHPFHIR_CLASSNAME_VERSION_CONSTANTS, + ); + + $imports->addCoreFileImportsByName( + PHPFHIR_ENCODING_CLASSNAME_UNSERIALIZE_CONFIG, + PHPFHIR_ENCODING_CLASSNAME_SERIALIZE_CONFIG, + PHPFHIR_INTERFACE_TYPE, + ); + if (($type->isCommentContainer() && !$type->hasCommentContainerParent()) || $type->hasLocalPropertiesWithValidations() || ($typeKind->isOneOf(TypeKindEnum::PRIMITIVE) && !$type->hasPrimitiveParent())) { $imports->addCoreFileImportsByName(PHPFHIR_CLASSNAME_CONSTANTS); } + if ($typeKind->isResourceContainer($type->getVersion())) { + $imports->addVersionCoreFileImportsByName( + $type->getVersion(), + PHPFHIR_CLASSNAME_VERSION_TYPE_MAP, + PHPFHIR_INTERFACE_VERSION_CONTAINED_TYPE, + ); + return; + } + if ($parentType = $type->getParentType()) { $imports->addImport( $parentType->getFullyQualifiedNamespace(false), diff --git a/src/Utilities/NameUtils.php b/src/Utilities/NameUtils.php index b657deda..a2dd8011 100644 --- a/src/Utilities/NameUtils.php +++ b/src/Utilities/NameUtils.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Utilities; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Utilities/TypeHintUtils.php b/src/Utilities/TypeHintUtils.php index baa8af99..11f40fd2 100644 --- a/src/Utilities/TypeHintUtils.php +++ b/src/Utilities/TypeHintUtils.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Utilities; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version.php b/src/Version.php index 8105f529..a0a9dcde 100644 --- a/src/Version.php +++ b/src/Version.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR; /* - * Copyright 2018-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2018-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/DefaultConfig.php b/src/Version/DefaultConfig.php index cd588511..954d67e2 100644 --- a/src/Version/DefaultConfig.php +++ b/src/Version/DefaultConfig.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version; /* - * Copyright 2018-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2018-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/DefaultConfigKeyEnum.php b/src/Version/DefaultConfigKeyEnum.php index 3249ab16..76e7869b 100644 --- a/src/Version/DefaultConfigKeyEnum.php +++ b/src/Version/DefaultConfigKeyEnum.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version; /* - * Copyright 2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2024-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition.php b/src/Version/Definition.php index 43152d42..9c4f5f24 100644 --- a/src/Version/Definition.php +++ b/src/Version/Definition.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/Decorator/AnnotationElementPropertyTypeDecorator.php b/src/Version/Definition/Decorator/AnnotationElementPropertyTypeDecorator.php index bcbc2353..698b9dca 100644 --- a/src/Version/Definition/Decorator/AnnotationElementPropertyTypeDecorator.php +++ b/src/Version/Definition/Decorator/AnnotationElementPropertyTypeDecorator.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition\Decorator; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/Decorator/AnnotationElementTypeDecorator.php b/src/Version/Definition/Decorator/AnnotationElementTypeDecorator.php index 542453fa..2278b050 100644 --- a/src/Version/Definition/Decorator/AnnotationElementTypeDecorator.php +++ b/src/Version/Definition/Decorator/AnnotationElementTypeDecorator.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition\Decorator; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/Decorator/AnyElementTypeDecorator.php b/src/Version/Definition/Decorator/AnyElementTypeDecorator.php index f9861451..8b0b5ab0 100644 --- a/src/Version/Definition/Decorator/AnyElementTypeDecorator.php +++ b/src/Version/Definition/Decorator/AnyElementTypeDecorator.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition\Decorator; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/Decorator/AttributeElementTypeDecorator.php b/src/Version/Definition/Decorator/AttributeElementTypeDecorator.php index 9a250976..1924a9e3 100644 --- a/src/Version/Definition/Decorator/AttributeElementTypeDecorator.php +++ b/src/Version/Definition/Decorator/AttributeElementTypeDecorator.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition\Decorator; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/Decorator/ChoiceElementElementPropertyDecorator.php b/src/Version/Definition/Decorator/ChoiceElementElementPropertyDecorator.php index c7e23e74..73dc7cf5 100644 --- a/src/Version/Definition/Decorator/ChoiceElementElementPropertyDecorator.php +++ b/src/Version/Definition/Decorator/ChoiceElementElementPropertyDecorator.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition\Decorator; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/Decorator/ChoiceElementTypeDecorator.php b/src/Version/Definition/Decorator/ChoiceElementTypeDecorator.php index ecbba92e..f846510c 100644 --- a/src/Version/Definition/Decorator/ChoiceElementTypeDecorator.php +++ b/src/Version/Definition/Decorator/ChoiceElementTypeDecorator.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition\Decorator; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/Decorator/ComplexContentElementTypeDecorator.php b/src/Version/Definition/Decorator/ComplexContentElementTypeDecorator.php index 9c555270..edc83131 100644 --- a/src/Version/Definition/Decorator/ComplexContentElementTypeDecorator.php +++ b/src/Version/Definition/Decorator/ComplexContentElementTypeDecorator.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition\Decorator; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/Decorator/ComplexTypeElementTypeDecorator.php b/src/Version/Definition/Decorator/ComplexTypeElementTypeDecorator.php index 93708d04..25a04e74 100644 --- a/src/Version/Definition/Decorator/ComplexTypeElementTypeDecorator.php +++ b/src/Version/Definition/Decorator/ComplexTypeElementTypeDecorator.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition\Decorator; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/Decorator/ElementElementTypeDecorator.php b/src/Version/Definition/Decorator/ElementElementTypeDecorator.php index 1d5eab2d..4bf965cb 100644 --- a/src/Version/Definition/Decorator/ElementElementTypeDecorator.php +++ b/src/Version/Definition/Decorator/ElementElementTypeDecorator.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition\Decorator; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/Decorator/ExtensionElementTypeDecorator.php b/src/Version/Definition/Decorator/ExtensionElementTypeDecorator.php index a3f132ad..8ef37c57 100644 --- a/src/Version/Definition/Decorator/ExtensionElementTypeDecorator.php +++ b/src/Version/Definition/Decorator/ExtensionElementTypeDecorator.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition\Decorator; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/Decorator/RestrictionElementTypeDecorator.php b/src/Version/Definition/Decorator/RestrictionElementTypeDecorator.php index cbd25689..124fe18b 100644 --- a/src/Version/Definition/Decorator/RestrictionElementTypeDecorator.php +++ b/src/Version/Definition/Decorator/RestrictionElementTypeDecorator.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition\Decorator; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/Decorator/SequenceElementTypeDecorator.php b/src/Version/Definition/Decorator/SequenceElementTypeDecorator.php index a604ced3..1ad3a2a0 100644 --- a/src/Version/Definition/Decorator/SequenceElementTypeDecorator.php +++ b/src/Version/Definition/Decorator/SequenceElementTypeDecorator.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition\Decorator; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/Decorator/SimpleContentElementTypeDecorator.php b/src/Version/Definition/Decorator/SimpleContentElementTypeDecorator.php index 255efcb3..e4385d15 100644 --- a/src/Version/Definition/Decorator/SimpleContentElementTypeDecorator.php +++ b/src/Version/Definition/Decorator/SimpleContentElementTypeDecorator.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition\Decorator; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/Decorator/SimpleTypeElementPropertyDecorator.php b/src/Version/Definition/Decorator/SimpleTypeElementPropertyDecorator.php index cad47826..6233100f 100644 --- a/src/Version/Definition/Decorator/SimpleTypeElementPropertyDecorator.php +++ b/src/Version/Definition/Decorator/SimpleTypeElementPropertyDecorator.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition\Decorator; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/Decorator/SimpleTypeElementTypeDecorator.php b/src/Version/Definition/Decorator/SimpleTypeElementTypeDecorator.php index c1d36ae1..a3142789 100644 --- a/src/Version/Definition/Decorator/SimpleTypeElementTypeDecorator.php +++ b/src/Version/Definition/Decorator/SimpleTypeElementTypeDecorator.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition\Decorator; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/Decorator/UnionElementTypeDecorator.php b/src/Version/Definition/Decorator/UnionElementTypeDecorator.php index 78da84fa..fad6d7b9 100644 --- a/src/Version/Definition/Decorator/UnionElementTypeDecorator.php +++ b/src/Version/Definition/Decorator/UnionElementTypeDecorator.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition\Decorator; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/DocumentationTrait.php b/src/Version/Definition/DocumentationTrait.php index 59d9b235..4b8fdd26 100644 --- a/src/Version/Definition/DocumentationTrait.php +++ b/src/Version/Definition/DocumentationTrait.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/Enumeration.php b/src/Version/Definition/Enumeration.php index 4e46c77e..38c76cfa 100644 --- a/src/Version/Definition/Enumeration.php +++ b/src/Version/Definition/Enumeration.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/Enumeration/EnumerationValue.php b/src/Version/Definition/Enumeration/EnumerationValue.php index 495a88ec..3c287f11 100644 --- a/src/Version/Definition/Enumeration/EnumerationValue.php +++ b/src/Version/Definition/Enumeration/EnumerationValue.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition\Enumeration; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/Properties.php b/src/Version/Definition/Properties.php index 47d7d82a..9194d5eb 100644 --- a/src/Version/Definition/Properties.php +++ b/src/Version/Definition/Properties.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/Property.php b/src/Version/Definition/Property.php index f4032ba4..52c6e604 100644 --- a/src/Version/Definition/Property.php +++ b/src/Version/Definition/Property.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/SourceTrait.php b/src/Version/Definition/SourceTrait.php index 170c9fbe..88ba52d9 100644 --- a/src/Version/Definition/SourceTrait.php +++ b/src/Version/Definition/SourceTrait.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/Type.php b/src/Version/Definition/Type.php index f7fbda06..0dfcd9b7 100644 --- a/src/Version/Definition/Type.php +++ b/src/Version/Definition/Type.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/TypeDecorationValidator.php b/src/Version/Definition/TypeDecorationValidator.php index de285b78..da77ff1c 100644 --- a/src/Version/Definition/TypeDecorationValidator.php +++ b/src/Version/Definition/TypeDecorationValidator.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/TypeDecorator.php b/src/Version/Definition/TypeDecorator.php index 27f46912..8562753e 100644 --- a/src/Version/Definition/TypeDecorator.php +++ b/src/Version/Definition/TypeDecorator.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/TypeExtractor.php b/src/Version/Definition/TypeExtractor.php index e0ec8cb0..d0b6f3d9 100644 --- a/src/Version/Definition/TypeExtractor.php +++ b/src/Version/Definition/TypeExtractor.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/TypePropertyDecorator.php b/src/Version/Definition/TypePropertyDecorator.php index 059d150d..ca5fc516 100644 --- a/src/Version/Definition/TypePropertyDecorator.php +++ b/src/Version/Definition/TypePropertyDecorator.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Version/Definition/Types.php b/src/Version/Definition/Types.php index c424aed8..7a13abbb 100644 --- a/src/Version/Definition/Types.php +++ b/src/Version/Definition/Types.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version\Definition; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -216,7 +216,7 @@ public function getContainerType(Version $version): null|Type { if (!isset($this->containerType)) { foreach ($this->types as $type) { - if ($type->getKind()->isContainer($version)) { + if ($type->getKind()->isResourceContainer($version)) { $this->containerType = $type; break; } @@ -232,7 +232,7 @@ public function getContainerType(Version $version): null|Type public function isContainedType(Type $type): bool { // only bother with actual Resource types. - if ($type->getKind()->isContainer($type->getVersion())) { + if ($type->getKind()->isResourceContainer($type->getVersion())) { return false; } $container = $this->getContainerType($type->getVersion()); diff --git a/src/Version/SourceMetadata.php b/src/Version/SourceMetadata.php index 69684b12..2b2325ab 100644 --- a/src/Version/SourceMetadata.php +++ b/src/Version/SourceMetadata.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR\Version; /* - * Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/VersionKeys.php b/src/VersionKeys.php index a5b87ed5..8a4acd18 100644 --- a/src/VersionKeys.php +++ b/src/VersionKeys.php @@ -3,7 +3,7 @@ namespace DCarbone\PHPFHIR; /* - * Copyright 2024 Daniel Carbone (daniel.p.carbone@gmail.com) + * Copyright 2024-2025 Daniel Carbone (daniel.p.carbone@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/template/core/class_autoloader.php b/template/core/class_autoloader.php index bb4414e1..0329ccda 100644 --- a/template/core/class_autoloader.php +++ b/template/core/class_autoloader.php @@ -1,7 +1,7 @@ $ } getChildrenOf('Resource') as $rsc) : $typeKind = $rsc->getKind(); - if ($typeKind->isContainer($version) || $rsc->getFHIRName() === 'Bundle') { continue; } + if ($typeKind->isResourceContainer($version) || $rsc->getFHIRName() === 'Bundle') { continue; } $rscName = $rsc->getFHIRName(); $rscNameLen = strlen($rscName); diff --git a/template/versions/core/class_version_constants.php b/template/versions/core/class_version_constants.php index 172f7d2a..b8cd86ce 100644 --- a/template/versions/core/class_version_constants.php +++ b/template/versions/core/class_version_constants.php @@ -1,7 +1,7 @@ getName(); $className = self::getContainedTypeClassName($typeName); @@ -161,7 +160,6 @@ public static function getContainedTypeClassNameFromXML(\SimpleXMLElement $node) * @return string Fully qualified class name of contained resource type */ public static function getContainedTypeClassNameFromArray(array $data): string - { $resourceType = null; if (isset($data[::JSON_FIELD_RESOURCE_TYPE])) { diff --git a/template/versions/core/enum_version_type.php b/template/versions/core/enum_version_type.php index 432f2ed8..b8a1f144 100644 --- a/template/versions/core/enum_version_type.php +++ b/template/versions/core/enum_version_type.php @@ -1,7 +1,7 @@ $version, 'type' => $type, ] -); ?> - - // name of FHIR type this class describes - public const FHIR_TYPE_NAME = getTypeNameConst(true); ?>; -hasLocalProperties()) : @@ -99,10 +95,10 @@ // -- end field properties ?> - +hasLocalProperties()) : ?> /** @var array */ private array $_xmlLocations = []; - + getConfig(); +$coreFiles = $config->getCoreFiles(); + +$xmlWriterClass = $coreFiles->getCoreFileByEntityName(PHPFHIR_ENCODING_CLASSNAME_XML_WRITER); +$serializeConfigClass = $coreFiles->getCoreFileByEntityName(PHPFHIR_ENCODING_CLASSNAME_SERIALIZE_CONFIG); +$unserializeConfigClass = $coreFiles->getCoreFileByEntityName(PHPFHIR_ENCODING_CLASSNAME_UNSERIALIZE_CONFIG); + +$versionCoreFiles = $version->getCoreFiles(); + +$versionContainedTypeInterface = $versionCoreFiles->getCoreFileByEntityName(PHPFHIR_INTERFACE_VERSION_CONTAINED_TYPE); +$versionTypeMapClass = $versionCoreFiles->getCoreFileByEntityName(PHPFHIR_CLASSNAME_VERSION_TYPE_MAP); + +ob_start(); + +// build file header +echo require_with( + PHPFHIR_TEMPLATE_VERSION_TYPES_DIR . DIRECTORY_SEPARATOR . 'header.php', + [ + 'version' => $version, + 'type' => $type, + ] +); ?> + + /** @var null|getFullyQualifiedName(true); ?> */ + private null|getEntityName(); ?> $containedType = null; + + /** + * getClassName(); ?> Constructor + * @param null|array|getFullyQualifiedName(true); ?> $data + */ + public function __construct(null|array|getEntityName(); ?> $data = null) + { + if (null === $data || [] === $data) { + return; + } + + if ($data instanceof getEntityName(); ?>) { + $this->setContainedType($data); + return; + } + + if (isset($data[::JSON_FIELD_FHIR_COMMENTS])) { + if (is_array($data[::JSON_FIELD_FHIR_COMMENTS])) { + $this->_setFHIRComments($data[::JSON_FIELD_FHIR_COMMENTS]); + } elseif (is_string($data[::JSON_FIELD_FHIR_COMMENTS])) { + $this->_addFHIRComment($data[::JSON_FIELD_FHIR_COMMENTS]); + } + } + $class = getEntityName(); ?>::getContainedTypeClassNameFromArray($data); + $this->setContainedType(new $class($data[$class::FHIR_TYPE_NAME])); + } + + + public function _getFHIRTypeName(): string + { + return self::FHIR_TYPE_NAME; + } + + /** + * TODO: empty, pending validation system overhaul + */ + public function _getValidationRules(): array + { + return []; + } + + /** + * TODO: empty, pending validation system overhaul + */ + public function _getValidationErrors(): array + { + return []; + } + + /** + * @return null|getFullyQualifiedName(true); ?> + + */ + public function getContainedType(): null|getEntityName(); ?> + + { + return $this->containedType; + } + + /** + * @param null|getFullyQualifiedName(true); ?> $containedType + * @return static + */ + public function setContainedType(null|getEntityName(); ?> $containedType): self + { + $this->containedType = $containedType; + return $this; + } + + $version, + 'type' => $type, + ] +); +?> + foreach ($element->children() as $child) { + /** @var getFullyQualifiedName(true); ?> $class */ + $class = getEntityName(); ?>::getContainedTypeClassNameFromXML($child); + $type->setContainedType($class::xmlUnserialize($child, null, $config)); + break; + } + return $type; + } + + /** + * @param null|getFullyQualifiedName(true); ?> $xw + * @param null|getFullyQualifiedName(true); ?> $config + * @return getFullyQualifiedName(true); ?> + + */ + public function xmlSerialize(null| $xw = null, null| $config = null): + + { + $containedType = $this->getContainedType(); + if (null !== $containedType) { + return $containedType->xmlSerialize($xw, $config); + } + if (null === $xw) { + $xw = new (); + } + if (!$xw->isOpen()) { + $xw->openMemory(); + } + if (!$xw->isDocStarted()) { + $docStarted = true; + $xw->startDocument(); + } + if (null === $config) { + $config = (new ())->getConfig()->getSerializeConfig(); + } + if (!$xw->isRootOpen()) { + $rootOpened = true; + $xw->openRootNode($config, '', $this->_getSourceXMLNS()); + } + if (isset($rootOpened) && $rootOpened) { + $xw->endElement(); + } + if (isset($docStarted) && $docStarted) { + $xw->endDocument(); + } + return $xw; + } + + public function __toString(): string + { + return self::FHIR_TYPE_NAME; + } + + /** + * @return null|object + */ + public function jsonSerialize(): mixed + { + return $this->getContainedType(); + } +} +getImports(); - -$imports->addCoreFileImportsByName( - PHPFHIR_ENCODING_CLASSNAME_XML_WRITER, - PHPFHIR_ENCODING_CLASSNAME_SERIALIZE_CONFIG, -); - $config = $version->getConfig(); $coreFiles = $config->getCoreFiles(); @@ -162,9 +155,6 @@ public function getXMLReader(int $libxmlOpts): null|\XMLReader [ 'version' => $version, 'type' => $type, - 'typeKind' => $type->getKind(), - 'parentType' => null, - 'typeClassName' => $type->getClassName() ] ); ?> diff --git a/template/versions/types/header.php b/template/versions/types/header.php index 557b912c..f5ef6953 100644 --- a/template/versions/types/header.php +++ b/template/versions/types/header.php @@ -1,7 +1,7 @@ use ; - + + // name of FHIR type this class describes + public const FHIR_TYPE_NAME = getTypeNameConst(true); ?>; + +getImports(); $parentType = $type->getParentType(); - -$localProperties = $type->getProperties()->getLocalPropertiesIterator(); +$properties = $type->getProperties(); // used in a few places below. $valueProperty = $type->getProperties()->getProperty(PHPFHIR_VALUE_PROPERTY_NAME); @@ -109,7 +108,7 @@ public function __construct(_addFHIRComment($data[::JSON_FIELD_FHIR_COMMENTS]); } } -getLocalPropertiesGenerator() as $property) : if ($property->isOverloaded()) { continue; } @@ -130,20 +129,20 @@ public function __construct(isValueContainer()) : ?>| $data = null) { if (null === $data || [] === $data) { -hasConcreteParent()) : ?> +hasParent()) : ?> parent::__construct(null); return; - } -isValueContainer()) : ?> + }isValueContainer()) : ?> + if (!is_array($data)) { -hasConcreteParent()) : ?> +hasParent()) : ?> parent::__construct(null); $this->setValue($data); return; - } -hasParentWithLocalProperties()) : // add parent constructor call ?> + }hasParentWithLocalProperties() || $type->hasCommentContainerParent()) : // add parent constructor call ?> + parent::__construct($data);isCommentContainer() && !$type->hasCommentContainerParent()) : // only parse comments if parent isn't already doing it. ?> if (isset($data[::JSON_FIELD_FHIR_COMMENTS])) { @@ -154,7 +153,7 @@ public function __construct(null|arrayisValueContainer()) : ?>| } } -getLocalPropertiesGenerator() as $property) : if ($property->isOverloaded()) { continue; } diff --git a/template/versions/types/methods/constructors/default_property_setter_call.php b/template/versions/types/methods/constructors/default_property_setter_call.php index a205362c..a4399709 100644 --- a/template/versions/types/methods/constructors/default_property_setter_call.php +++ b/template/versions/types/methods/constructors/default_property_setter_call.php @@ -1,7 +1,7 @@ (array $isContainer($version)) : ?> + elseif ($propertyTypeKind->isResourceContainer($version)) : ?> /** diff --git a/template/versions/types/properties/methods/primitive.php b/template/versions/types/properties/methods/primitive.php index 19435d0e..91cc5004 100644 --- a/template/versions/types/properties/methods/primitive.php +++ b/template/versions/types/properties/methods/primitive.php @@ -1,7 +1,7 @@ $type, ] ); -elseif ($typeKind->isContainer($version)) : +elseif ($typeKind->isResourceContainer($version)) : echo require_with( PHPFHIR_TEMPLATE_VERSION_TYPES_SERIALIZATION_DIR . DIRECTORY_SEPARATOR . 'json' . DIRECTORY_SEPARATOR . 'resource_container.php', [ diff --git a/template/versions/types/serialization/json/default.php b/template/versions/types/serialization/json/default.php index 195cbe57..b92273b0 100644 --- a/template/versions/types/serialization/json/default.php +++ b/template/versions/types/serialization/json/default.php @@ -1,7 +1,7 @@ - if (isset($openedRoot) && $openedRoot) { + if (isset($rootOpened) && $rootOpened) { $xw->endElement(); } if (isset($docStarted) && $docStarted) { diff --git a/template/versions/types/serialization/xml/serialize/body.php b/template/versions/types/serialization/xml/serialize/body.php index 222d098a..45c3941b 100644 --- a/template/versions/types/serialization/xml/serialize/body.php +++ b/template/versions/types/serialization/xml/serialize/body.php @@ -1,7 +1,7 @@ getKind(); // ... and IS a container - if ($ptk->isContainer($version)) : + if ($ptk->isResourceContainer($version)) : if ($property->isCollection()) : ?> foreach($this->getGetterName(); ?>() as $v) { $xw->startElement(self::getFieldConstantName(); ?>); diff --git a/template/versions/types/serialization/xml/serialize/header.php b/template/versions/types/serialization/xml/serialize/header.php index c525630a..df5792a9 100644 --- a/template/versions/types/serialization/xml/serialize/header.php +++ b/template/versions/types/serialization/xml/serialize/header.php @@ -1,7 +1,7 @@ ())->getConfig()->getSerializeConfig(); } if (!$xw->isRootOpen()) { - $openedRoot = true; + $rootOpened = true; $xw->openRootNode($config, '', $this->_getSourceXMLNS()); } if (!$xw->isRootOpen()) { - $openedRoot = true; + $rootOpened = true; $xw->openRootNode($config, '', $this->_getSourceXMLNS()); } getKind(); - if ($propTypeKind->isContainer($version)) : ?> + if ($propTypeKind->isResourceContainer($version)) : ?> if (self:: === $childName) { foreach ($n->children() as $nn) { $typeClassName = ::getContainedTypeClassNameFromXML($nn); diff --git a/template/versions/types/serialization/xml/unserialize/header.php b/template/versions/types/serialization/xml/unserialize/header.php index a362cdeb..98110c34 100644 --- a/template/versions/types/serialization/xml/unserialize/header.php +++ b/template/versions/types/serialization/xml/unserialize/header.php @@ -1,7 +1,7 @@