From 751bc781f7a7283b5992a2c94bb6980279eae0b4 Mon Sep 17 00:00:00 2001 From: Daniel Carbone Date: Fri, 19 Jul 2024 13:06:45 -0500 Subject: [PATCH] working through some ideas --- files/constants.php | 26 ++-- src/Render/Templates.php | 6 +- src/Version.php | 8 ++ template/core/classes/class_config.php | 47 +------ template/core/enums/enum_config_key.php | 3 +- .../interfaces/interface_fhir_version.php | 59 +++++++++ .../interfaces/interface_response_parser.php} | 20 +-- .../core/interfaces/interface_type_map.php | 93 ++++++++++++++ .../core/classes/class_fhir_version.php | 116 ++++++++++++++++++ .../core/classes/class_response_parser.php | 7 +- .../core/classes/class_type_map.php | 20 +-- template/versions/types/class_default.php | 24 ++-- template/versions/types/class_xhtml.php | 2 +- .../versions/types/methods/constructor.php | 6 +- .../types/methods/constructors/default.php | 4 +- .../constructors/primitive_container.php | 2 +- .../versions/types/properties/methods.php | 4 +- .../versions/types/serialization/json.php | 6 +- template/versions/types/serialization/xml.php | 10 +- template/versions/types/tests/unit/class.php | 6 +- .../versions/types/validation/methods.php | 8 +- 21 files changed, 364 insertions(+), 113 deletions(-) rename template/{versions/core/classes/class_version.php => core/interfaces/interface_response_parser.php} (61%) create mode 100644 template/core/interfaces/interface_type_map.php create mode 100644 template/versions/core/classes/class_fhir_version.php rename template/{ => versions}/core/classes/class_response_parser.php (96%) rename template/{ => versions}/core/classes/class_type_map.php (88%) diff --git a/files/constants.php b/files/constants.php index d469b964..3c7b07b5 100644 --- a/files/constants.php +++ b/files/constants.php @@ -65,20 +65,23 @@ // Core interfaces, traits, and classes const PHPFHIR_TEMPLATE_CORE_DIR = PHPFHIR_TEMPLATE_DIR . DIRECTORY_SEPARATOR . 'core'; -// Type rendering -const PHPFHIR_TEMPLATE_TYPES_DIR = PHPFHIR_TEMPLATE_DIR . DIRECTORY_SEPARATOR . 'types'; -const PHPFHIR_TEMPLATE_TYPES_PROPERTIES_DIR = PHPFHIR_TEMPLATE_TYPES_DIR . DIRECTORY_SEPARATOR . 'properties'; -const PHPFHIR_TEMPLATE_TYPES_METHODS_DIR = PHPFHIR_TEMPLATE_TYPES_DIR . DIRECTORY_SEPARATOR . 'methods'; -const PHPFHIR_TEMPLATE_TYPES_CONSTRUCTORS_DIR = PHPFHIR_TEMPLATE_TYPES_METHODS_DIR . DIRECTORY_SEPARATOR . 'constructors'; -const PHPFHIR_TEMPLATE_TYPES_SERIALIZATION_DIR = PHPFHIR_TEMPLATE_TYPES_DIR . DIRECTORY_SEPARATOR . 'serialization'; -const PHPFHIR_TEMPLATE_TYPES_VALIDATION_DIR = PHPFHIR_TEMPLATE_TYPES_DIR . DIRECTORY_SEPARATOR . 'validation'; +// Version interfaces, traits, and enums +const PHHPFHIR_TEMPLATE_VERSIONS_DIR = PHPFHIR_TEMPLATE_DIR . DIRECTORY_SEPARATOR . 'versions'; +const PHPFHIR_TEMPLATE_VERSIONS_CORE_DIR = PHHPFHIR_TEMPLATE_VERSIONS_DIR . DIRECTORY_SEPARATOR . 'core'; + +// Version type rendering +const PHPFHIR_TEMPLATE_VERSION_TYPES_DIR = PHHPFHIR_TEMPLATE_VERSIONS_DIR . DIRECTORY_SEPARATOR . 'types'; +const PHPFHIR_TEMPLATE_VERSION_TYPES_PROPERTIES_DIR = PHPFHIR_TEMPLATE_VERSION_TYPES_DIR . DIRECTORY_SEPARATOR . 'properties'; +const PHPFHIR_TEMPLATE_VERSION_TYPES_METHODS_DIR = PHPFHIR_TEMPLATE_VERSION_TYPES_DIR . DIRECTORY_SEPARATOR . 'methods'; +const PHPFHIR_TEMPLATE_VERSION_TYPES_CONSTRUCTORS_DIR = PHPFHIR_TEMPLATE_VERSION_TYPES_METHODS_DIR . DIRECTORY_SEPARATOR . 'constructors'; +const PHPFHIR_TEMPLATE_VERSION_TYPES_SERIALIZATION_DIR = PHPFHIR_TEMPLATE_VERSION_TYPES_DIR . DIRECTORY_SEPARATOR . 'serialization'; +const PHPFHIR_TEMPLATE_VERSION_TYPES_VALIDATION_DIR = PHPFHIR_TEMPLATE_VERSION_TYPES_DIR . DIRECTORY_SEPARATOR . 'validation'; // Fhir type test templates -const PHPFHIR_TEMPLATE_TYPE_TESTS_DIR = PHPFHIR_TEMPLATE_TYPES_DIR . DIRECTORY_SEPARATOR . 'tests'; +const PHPFHIR_TEMPLATE_VERSION_TYPE_TESTS_DIR = PHPFHIR_TEMPLATE_VERSION_TYPES_DIR . DIRECTORY_SEPARATOR . 'tests'; // Core class names -const PHPFHIR_CLASSNAME_VERSION = 'PHPFHIRVersion'; const PHPFHIR_CLASSNAME_VERSIONS = 'PHPFHIRVersions'; const PHPFHIR_CLASSNAME_AUTOLOADER = 'PHPFHIRAutoloader'; const PHPFHIR_CLASSNAME_CONFIG = 'PHPFHIRConfig'; @@ -92,6 +95,9 @@ const PHPFHIR_CLASSNAME_DEBUG_CLIENT = 'PHPFHIRDebugClient'; // Core interface names +const PHPFHIR_INTERFACE_TYPE_MAP = 'PHPFHIRTypeMapInterface'; +const PHPFHIR_INTERFACE_RESPONSE_PARSER = 'PPHPFHIRResponseParserInterface'; +const PHPFHIR_INTERFACE_FHIR_VERSION = 'PHPFHIRVersionInterface'; const PHPFHIR_INTERFACE_TYPE = 'PHPFHIRTypeInterface'; const PHPFHIR_INTERFACE_CONTAINED_TYPE = 'PHPFHIRContainedTypeInterface'; const PHPFHIR_INTERFACE_COMMENT_CONTAINER = 'PHPFHIRCommentContainerInterface'; @@ -111,6 +117,8 @@ const PHPFHIR_ENUM_API_RESOURCE_LIST = 'PHPFHIRApiResourceListEnum'; const PHPFHIR_ENUM_API_SORT = 'PHPFHIRApiSortEnum'; +// Version Co + // validation constants const PHPFHIR_VALIDATION_ENUM = 'enum'; const PHPFHIR_VALIDATION_ENUM_NAME = 'VALIDATE_ENUM'; diff --git a/src/Render/Templates.php b/src/Render/Templates.php index 8704563d..63f6b577 100644 --- a/src/Render/Templates.php +++ b/src/Render/Templates.php @@ -49,7 +49,7 @@ public static function renderCoreType(string $coreFilename, Config $config): str */ public static function renderXhtmlTypeClass(Config $config, Version $version, Types $types, Type $type): string { - return require PHPFHIR_TEMPLATE_TYPES_DIR . DIRECTORY_SEPARATOR . 'class_xhtml.php'; + return require PHPFHIR_TEMPLATE_VERSION_TYPES_DIR . DIRECTORY_SEPARATOR . 'class_xhtml.php'; } /** @@ -61,7 +61,7 @@ public static function renderXhtmlTypeClass(Config $config, Version $version, Ty */ public static function renderFhirTypeClass(Config $config, Version $version, Types $types, Type $type): string { - return require PHPFHIR_TEMPLATE_TYPES_DIR . DIRECTORY_SEPARATOR . 'class_default.php'; + return require PHPFHIR_TEMPLATE_VERSION_TYPES_DIR . DIRECTORY_SEPARATOR . 'class_default.php'; } /** @@ -74,6 +74,6 @@ public static function renderFhirTypeClass(Config $config, Version $version, Typ */ public static function renderFhirTypeClassTest(Config $config, Version $version, Types $types, Type $type, TestType $testType): string { - return require PHPFHIR_TEMPLATE_TYPE_TESTS_DIR . DIRECTORY_SEPARATOR . $testType->value . DIRECTORY_SEPARATOR .'class.php'; + return require PHPFHIR_TEMPLATE_VERSION_TYPE_TESTS_DIR . DIRECTORY_SEPARATOR . $testType->value . DIRECTORY_SEPARATOR .'class.php'; } } \ No newline at end of file diff --git a/src/Version.php b/src/Version.php index 85826802..1a9de4f3 100644 --- a/src/Version.php +++ b/src/Version.php @@ -178,6 +178,14 @@ public function getFullyQualifiedTestsName(TestType $testType, bool $leadingSlas return $this->getFullyQualifiedName($leadingSlash, $testType->namespaceSlug(), ...$bits); } + /** + * @return string + */ + public function getVersionClassname(): string + { + return ucfirst($this->name); + } + /** * @return \DCarbone\PHPFHIR\Version\Definition */ diff --git a/template/core/classes/class_config.php b/template/core/classes/class_config.php index fdc003ff..0bc2eb9f 100644 --- a/template/core/classes/class_config.php +++ b/template/core/classes/class_config.php @@ -31,7 +31,7 @@ echo "namespace {$namespace};\n\n"; endif; -echo VersionCopyright::getFullPHPFHIRCopyrightComment(); +echo $config->getBasePHPFHIRCopyrightComment(); echo "\n\n"; ?> /** @@ -43,9 +43,6 @@ */ class implements \JsonSerializable { - /** @var bool */ - private bool $registerAutoloader = false; - /** @var int */ private int $libxmlOpts; @@ -61,47 +58,13 @@ class implements \JsonSerializable */ public function __construct(array $config = []) { - foreach(::values() as $k => $_) { - if (isset($config[$k]) || array_key_exists($k, $config)) { - $this->setKey($k, $config[$k]); + foreach(::cases() as $key) { + if (isset($config[$key->value]) || array_key_exists($key->value, $config)) { + $this->{"set$key->value"}($config[$key->value); } } } - /** - * Set arbitrary key on this config - * - * @param getFullyQualifiedName(true, PHPFHIR_ENUM_CONFIG_KEY); ?>|string $key - * @param mixed $value - * @return static - */ - public function setKey(|string $key, mixed $value): self - { - if (!is_string($key)) { - $key = $key->value; - } - $this->{'set'.$key}($value); - return $this; - } - - /** - * @param bool $registerAutoloader - * @return static - */ - public function setRegisterAutoloader(bool $registerAutoloader): self - { - $this->registerAutoloader = $registerAutoloader; - return $this; - } - - /** - * @return bool - */ - public function getRegisterAutoloader(): bool - { - return $this->registerAutoloader; - } - /** * Sets the option flags to provide to libxml when unserializing XML * @@ -171,7 +134,7 @@ public function jsonSerialize(): \stdClass { $out = new \stdClass(); foreach(::cases() as $key) { - $out->{$k} = $this->{$key->getter()}(); + $out->{$key->value} = $this->{"get$key->value"}(); } return $out; } diff --git a/template/core/enums/enum_config_key.php b/template/core/enums/enum_config_key.php index bc8cbe65..201fca96 100644 --- a/template/core/enums/enum_config_key.php +++ b/template/core/enums/enum_config_key.php @@ -31,7 +31,7 @@ echo "namespace {$namespace};\n\n"; endif; -echo VersionCopyright::getFullPHPFHIRCopyrightComment(); +echo $config->getBasePHPFHIRCopyrightComment(); echo "\n\n"; ?> /** @@ -43,7 +43,6 @@ */ enum : string { - case REGISTER_AUTOLOADER = 'registerAutoloader'; case LIBXML_OPTS = 'libxmlOpts'; case ROOT_XMLNS = 'rootXmlns'; case OVERRIDE_SOURCE_XMLNS = 'overrideSourceXmlns'; diff --git a/template/core/interfaces/interface_fhir_version.php b/template/core/interfaces/interface_fhir_version.php index 5d43b2b3..813a2667 100644 --- a/template/core/interfaces/interface_fhir_version.php +++ b/template/core/interfaces/interface_fhir_version.php @@ -16,3 +16,62 @@ * limitations under the License. */ +/** @var \DCarbone\PHPFHIR\Config $config */ + +$namespace = $config->getFullyQualifiedName(false); + +ob_start(); + +echo "getBasePHPFHIRCopyrightComment(); + +echo "\n\n"; +?> +/** + * Interface + + * @package \ + + + */ +interface + +{ + /** + * Must return the "name" of this version, e.g. DSTU1, STU3, R5, etc. + * @return string + */ + public function getName(): string; + + /** + * Must return the source this version was generated from + * @return string + */ + public function getSourceUrl(): string; + + /** + * Must return the date this FHIR version's source was generated + * @return string + */ + public function getFhirGenerationDate(): string; + + /** + * Must return config for this version + * @return getFullyQualifiedName(true, PHPFHIR_CLASSNAME_CONFIG); ?> + + */ + public function getConfig(): ; + + /** + * Must return the type map class for this version + * @return getFullyQualifiedName(true, PHPFHIR_INTERFACE_TYPE_MAP); ?> + + */ + public function getTypeMap(): ; +} +getFullyQualifiedName(false); @@ -29,22 +28,27 @@ echo "namespace {$namespace};\n\n"; endif; -echo $version->getCopyright()->getFullPHPFHIRCopyrightComment(); +echo $config->getBasePHPFHIRCopyrightComment(); echo "\n\n"; ?> /** - * Class + * Interface * @package \ */ -class +interface { - public const NAME = 'getName(); ?>'; - public const SOURCE_URL = 'getSourceUrl(); ?>'; - public const FHIR_GENERATION_DATE = 'getCopyright()->getFHIRGenerationDate(); ?>'; + /** + * Must attempt to parse the provided input into FHIR objects. + * + * @param null|string|array|\stdClass|\SimpleXMLElement|\DOMDocument $input + * @return null|getFullyQualifiedName(true, PHPFHIR_INTERFACE_TYPE); ?> + + * @throws \Exception + */ + public function parse(null|string|array|\stdClass|\SimpleXMLElement|\DOMDocument $input): null|; } -getFullyQualifiedName(false); + +ob_start(); + +echo "getBasePHPFHIRCopyrightComment(); + +echo "\n\n"; +?> +/** + * Interface + + * @package \ + + + */ +interface + +{ + /** + * Must return the fully qualified class name for FHIR Type name. Must return null if type not found + * @param string $typeName + * @return string|null + */ + public function getTypeClass(string $typeName): null|string; + + /** + * Must return the full internal class map + * @return array + */ + public function getMap(): array; + + /** + * Must return the full list of containable resource types + * @return array + */ + public function getContainableTypes(): array; + + /** + * @param string $typeName Name of FHIR object reference by a version's container type + * @return string|null Name of class as string or null if type is not contained in map + */ + public function getContainedTypeClassName(string $typeName): null|string; + + /** + * Must attempt to determine if the provided value is or describes a containable resource type + * @param string|array|\SimpleXMLElement| $type + * @return bool + * @throws \InvalidArgumentException + */ + public function isContainableResource(string|array|\SimpleXMLElement| $type): bool; + + /** + * @param \SimpleXMLElement $node Parent element containing inline resource + * @param getFullyQualifiedName(true, PHPFHIR_CLASSNAME_CONFIG); ?> $config + * @return null|getfullyQualifiedName(true, PHPFHIR_INTERFACE_CONTAINED_TYPE); ?> + + */ + public function getContainedTypeFromXML(\SimpleXMLElement $node, $config): null|; + + /** + * @param array|null $data + * @return null|getfullyQualifiedName(true, PHPFHIR_INTERFACE_CONTAINED_TYPE); ?> + + */ + public function getContainedTypeFromArray(null|array $data): null|; +} +getFullyQualifiedName(false); + +ob_start(); + +echo "getCopyright()->getFullPHPFHIRCopyrightComment(); + +echo "\n\n"; +?> +/** + * Class getVersionClassname(); if ('' !== $namespace) : ?> + + * @package \ + + + */ +class getVersionClassname(); ?> implements + +{ + public const NAME = 'getName(); ?>'; + public const SOURCE_URL = 'getSourceUrl(); ?>'; + public const FHIR_GENERATION_DATE = 'getCopyright()->getFHIRGenerationDate(); ?>'; + + /** @var getFullyQualifiedName(true, PHPFHIR_CLASSNAME_CONFIG); ?> */ + private $_config; + + /** @var getFullyQualifiedName(true, PHPFHIR_INTERFACE_TYPE_MAP); ?> */ + private static $_typeMap; + + /** + * getVersionClassname(); ?> Constructor + * @param getFullyQualifiedName(true, PHPFHIR_CLASSNAME_CONFIG); ?> $config + */ + public function __construct(null| $config = null) + { + if (null === $config) { + $this->_config = new (); + } else { + $this->_config = $config; + } + } + + /** + * @return string + */ + public function getName(): string + { + return self::NAME; + } + + /** + * @return string + */ + public function getSourceUrl(): string + { + return self::SOURCE_URL; + } + + /** + * @return string + */ + public function getFhirGenerationDate(): string + { + return self::FHIR_GENERATION_DATE; + } + + /** + * @return getFullyQualifiedName(true, PHPFHIR_CLASSNAME_CONFIG); ?> + + */ + public function getConfig(): + + { + return $this->_config; + } + + /** + * @return getFullyQualifiedName(true, PHPFHIR_INTERFACE_TYPE_MAP); ?> + + */ + public function getTypeMap(): + + { + if (!isset(static::$_typeMap)) { + static::$_typeMap = new getVersionClassname(); ?>(); + } + return self::$_typeMap; + } +} +getFullyQualifiedName(false); +$namespace = $version->getFullyQualifiedName(false); ob_start(); @@ -31,7 +32,7 @@ echo "namespace {$namespace};\n\n"; endif; -echo VersionCopyright::getFullPHPFHIRCopyrightComment(); +echo $config->getBasePHPFHIRCopyrightComment(); echo "\n\n"; ?> @@ -42,7 +43,7 @@ */ -class +class implements { private const XML_START = ['<']; diff --git a/template/core/classes/class_type_map.php b/template/versions/core/classes/class_type_map.php similarity index 88% rename from template/core/classes/class_type_map.php rename to template/versions/core/classes/class_type_map.php index 6d4ab008..9de0fd4a 100644 --- a/template/core/classes/class_type_map.php +++ b/template/versions/core/classes/class_type_map.php @@ -17,9 +17,9 @@ */ use DCarbone\PHPFHIR\Enum\TypeKind; -use DCarbone\PHPFHIR\Version\VersionCopyright; /** @var \DCarbone\PHPFHIR\Config $config */ +/** @var \DCarbone\PHPFHIR\Version $version */ /** @var \DCarbone\PHPFHIR\Version\Definition\Types $types */ $namespace = $config->getFullyQualifiedName(false); @@ -51,7 +51,7 @@ echo "namespace {$namespace};\n\n"; endif; -echo VersionCopyright::getFullPHPFHIRCopyrightComment(); +echo $version->getCopyright()->getFullPHPFHIRCopyrightComment(); echo "\n\n"; ?> @@ -62,7 +62,7 @@ */ -abstract class +abstract class implements { /** @@ -86,7 +86,7 @@ abstract class * @param string $typeName * @return string|null */ - public static function getTypeClass(string $typeName): null|string + public function getTypeClass(string $typeName): null|string { return self::TYPE_MAP[$typeName] ?? null; } @@ -95,7 +95,7 @@ public static function getTypeClass(string $typeName): null|string * Returns the full internal class map * @return array */ - public static function getMap(): array + public function getMap(): array { return self::TYPE_MAP; } @@ -104,7 +104,7 @@ public static function getMap(): array * Returns the full list of containable resource types * @return array */ - public static function getContainableTypes(): array + public function getContainableTypes(): array { return self::CONTAINABLE_TYPES; } @@ -114,7 +114,7 @@ public static function getContainableTypes(): array * @return string|null Name of class as string or null if type is not contained in map */ - public static function getContainedTypeClassName(string $typeName): null|string + public function getContainedTypeClassName(string $typeName): null|string { return self::CONTAINABLE_TYPES[$typeName] ?? null; } @@ -125,7 +125,7 @@ public static function getContainedTypeClassName(string $typeName): null|string * @return bool * @throws \InvalidArgumentException */ - public static function isContainableResource(string|array|\SimpleXMLElement| $type): bool + public function isContainableResource(string|array|\SimpleXMLElement| $type): bool { $tt = gettype($type); if ('object' === $tt) { @@ -149,7 +149,7 @@ public static function isContainableResource(string|array|\SimpleXMLElement|getfullyQualifiedName(true, PHPFHIR_INTERFACE_CONTAINED_TYPE); ?> */ - public static function getContainedTypeFromXML(\SimpleXMLElement $node, $config): null| + public function getContainedTypeFromXML(\SimpleXMLElement $node, $config): null| { $typeName = $node->getName(); @@ -166,7 +166,7 @@ public static function getContainedTypeFromXML(\SimpleXMLElement $node, getfullyQualifiedName(true, PHPFHIR_INTERFACE_CONTAINED_TYPE); ?> */ - public static function getContainedTypeFromArray(null|array $data): null| + public function getContainedTypeFromArray(null|array $data): null| { if (null === $data || [] === $data) { diff --git a/template/versions/types/class_default.php b/template/versions/types/class_default.php index 2de3248a..60d6724e 100644 --- a/template/versions/types/class_default.php +++ b/template/versions/types/class_default.php @@ -57,7 +57,7 @@ */ $config, 'type' => $type, @@ -76,7 +76,7 @@ foreach ($localProperties as $property) { echo require_with( - PHPFHIR_TEMPLATE_TYPES_PROPERTIES_DIR . DIRECTORY_SEPARATOR . 'constants.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_PROPERTIES_DIR . DIRECTORY_SEPARATOR . 'constants.php', [ 'config' => $config, 'property' => $property, @@ -88,7 +88,7 @@ foreach ($localProperties as $property) { echo require_with( - PHPFHIR_TEMPLATE_TYPES_PROPERTIES_DIR . DIRECTORY_SEPARATOR . 'declaration.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_PROPERTIES_DIR . DIRECTORY_SEPARATOR . 'declaration.php', [ 'config' => $config, 'property' => $property, @@ -99,7 +99,7 @@ echo "\n"; echo require_with( - PHPFHIR_TEMPLATE_TYPES_VALIDATION_DIR . DIRECTORY_SEPARATOR . 'field_map.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_VALIDATION_DIR . DIRECTORY_SEPARATOR . 'field_map.php', [ 'config' => $config, 'type' => $type, @@ -109,7 +109,7 @@ echo "\n"; echo require_with( - PHPFHIR_TEMPLATE_TYPES_SERIALIZATION_DIR . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'primitive_xml_location_map.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_SERIALIZATION_DIR . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'primitive_xml_location_map.php', [ 'config' => $config, 'type' => $type, @@ -119,7 +119,7 @@ echo "\n"; echo require_with( - PHPFHIR_TEMPLATE_TYPES_METHODS_DIR . DIRECTORY_SEPARATOR . 'constructor.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_METHODS_DIR . DIRECTORY_SEPARATOR . 'constructor.php', [ 'config' => $config, 'type' => $type, @@ -130,7 +130,7 @@ } echo require_with( - PHPFHIR_TEMPLATE_TYPES_METHODS_DIR . DIRECTORY_SEPARATOR . 'common.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_METHODS_DIR . DIRECTORY_SEPARATOR . 'common.php', [ 'config' => $config, 'type' => $type, @@ -142,7 +142,7 @@ echo "\n"; echo require_with( - PHPFHIR_TEMPLATE_TYPES_METHODS_DIR . DIRECTORY_SEPARATOR . 'contained_type.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_METHODS_DIR . DIRECTORY_SEPARATOR . 'contained_type.php', [ 'config' => $config, 'type' => $type, @@ -152,7 +152,7 @@ if (0 < count($localProperties)) { echo require_with( - PHPFHIR_TEMPLATE_TYPES_PROPERTIES_DIR . DIRECTORY_SEPARATOR . 'methods.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_PROPERTIES_DIR . DIRECTORY_SEPARATOR . 'methods.php', [ 'config' => $config, 'type' => $type, @@ -163,7 +163,7 @@ echo "\n"; echo require_with( - PHPFHIR_TEMPLATE_TYPES_VALIDATION_DIR . DIRECTORY_SEPARATOR . 'methods.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_VALIDATION_DIR . DIRECTORY_SEPARATOR . 'methods.php', [ 'config' => $config, 'type' => $type, @@ -173,7 +173,7 @@ echo "\n"; echo require_with( - PHPFHIR_TEMPLATE_TYPES_SERIALIZATION_DIR . DIRECTORY_SEPARATOR . 'xml.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_SERIALIZATION_DIR . DIRECTORY_SEPARATOR . 'xml.php', [ 'config' => $config, 'type' => $type, @@ -186,7 +186,7 @@ echo "\n"; echo require_with( - PHPFHIR_TEMPLATE_TYPES_SERIALIZATION_DIR . DIRECTORY_SEPARATOR . 'json.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_SERIALIZATION_DIR . DIRECTORY_SEPARATOR . 'json.php', [ 'config' => $config, 'type' => $type, diff --git a/template/versions/types/class_xhtml.php b/template/versions/types/class_xhtml.php index c794be93..4caa657a 100644 --- a/template/versions/types/class_xhtml.php +++ b/template/versions/types/class_xhtml.php @@ -184,7 +184,7 @@ public function getXMLReader(null| $confi $config, 'type' => $type, diff --git a/template/versions/types/methods/constructor.php b/template/versions/types/methods/constructor.php index 783bcd81..996051b9 100644 --- a/template/versions/types/methods/constructor.php +++ b/template/versions/types/methods/constructor.php @@ -34,9 +34,9 @@ ob_start(); echo match ($typeKind) { - TypeKind::PRIMITIVE, TypeKind::LIST => require_with(PHPFHIR_TEMPLATE_TYPES_CONSTRUCTORS_DIR . DIRECTORY_SEPARATOR . 'primitive.php', $requireArgs), - TypeKind::PRIMITIVE_CONTAINER => require_with(PHPFHIR_TEMPLATE_TYPES_CONSTRUCTORS_DIR . DIRECTORY_SEPARATOR . 'primitive_container.php', $requireArgs), - default => require_with(PHPFHIR_TEMPLATE_TYPES_CONSTRUCTORS_DIR . DIRECTORY_SEPARATOR . 'default.php', $requireArgs), + TypeKind::PRIMITIVE, TypeKind::LIST => require_with(PHPFHIR_TEMPLATE_VERSION_TYPES_CONSTRUCTORS_DIR . DIRECTORY_SEPARATOR . 'primitive.php', $requireArgs), + TypeKind::PRIMITIVE_CONTAINER => require_with(PHPFHIR_TEMPLATE_VERSION_TYPES_CONSTRUCTORS_DIR . DIRECTORY_SEPARATOR . 'primitive_container.php', $requireArgs), + default => require_with(PHPFHIR_TEMPLATE_VERSION_TYPES_CONSTRUCTORS_DIR . DIRECTORY_SEPARATOR . 'default.php', $requireArgs), }; echo "\n"; diff --git a/template/versions/types/methods/constructors/default.php b/template/versions/types/methods/constructors/default.php index b2b08515..4682d892 100644 --- a/template/versions/types/methods/constructors/default.php +++ b/template/versions/types/methods/constructors/default.php @@ -62,7 +62,7 @@ public function __construct(null|arrayisValueContainer()) : ?>| } if (($propType = $property->getValueFHIRType()) && $propType->getKind()->isOneOf(TypeKind::RESOURCE_INLINE, TypeKind::RESOURCE_CONTAINER)) : echo require_with( - PHPFHIR_TEMPLATE_TYPES_CONSTRUCTORS_DIR . DIRECTORY_SEPARATOR . 'resource_container_property_setter_call.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_CONSTRUCTORS_DIR . DIRECTORY_SEPARATOR . 'resource_container_property_setter_call.php', [ 'config' => $config, 'type' => $type, @@ -71,7 +71,7 @@ public function __construct(null|arrayisValueContainer()) : ?>| ); else : echo require_with( - PHPFHIR_TEMPLATE_TYPES_CONSTRUCTORS_DIR . DIRECTORY_SEPARATOR . 'default_property_setter_call.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_CONSTRUCTORS_DIR . DIRECTORY_SEPARATOR . 'default_property_setter_call.php', [ 'config' => $config, 'type' => $type, diff --git a/template/versions/types/methods/constructors/primitive_container.php b/template/versions/types/methods/constructors/primitive_container.php index 9e507d10..afedac63 100644 --- a/template/versions/types/methods/constructors/primitive_container.php +++ b/template/versions/types/methods/constructors/primitive_container.php @@ -64,7 +64,7 @@ public function __construct( $config, 'type' => $type, diff --git a/template/versions/types/properties/methods.php b/template/versions/types/properties/methods.php index 8ac4e8f1..f464de76 100644 --- a/template/versions/types/properties/methods.php +++ b/template/versions/types/properties/methods.php @@ -26,7 +26,7 @@ if ($type->getKind()->isOneOf(TypeKind::PRIMITIVE, TypeKind::LIST)) : echo require_with( - PHPFHIR_TEMPLATE_TYPES_PROPERTIES_DIR . DIRECTORY_SEPARATOR . 'methods' . DIRECTORY_SEPARATOR . 'primitive.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_PROPERTIES_DIR . DIRECTORY_SEPARATOR . 'methods' . DIRECTORY_SEPARATOR . 'primitive.php', [ 'config' => $config, 'type' => $type @@ -34,7 +34,7 @@ ); else : echo require_with( - PHPFHIR_TEMPLATE_TYPES_PROPERTIES_DIR . DIRECTORY_SEPARATOR . 'methods' . DIRECTORY_SEPARATOR . 'default.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_PROPERTIES_DIR . DIRECTORY_SEPARATOR . 'methods' . DIRECTORY_SEPARATOR . 'default.php', [ 'config' => $config, 'type' => $type, diff --git a/template/versions/types/serialization/json.php b/template/versions/types/serialization/json.php index 648f5f30..7f88a1f7 100644 --- a/template/versions/types/serialization/json.php +++ b/template/versions/types/serialization/json.php @@ -27,7 +27,7 @@ ob_start(); if ($typeKind->isOneOf(TypeKind::PRIMITIVE, TypeKind::LIST)) : echo require_with( - PHPFHIR_TEMPLATE_TYPES_SERIALIZATION_DIR . DIRECTORY_SEPARATOR . 'json' . DIRECTORY_SEPARATOR . 'primitive.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_SERIALIZATION_DIR . DIRECTORY_SEPARATOR . 'json' . DIRECTORY_SEPARATOR . 'primitive.php', [ 'config' => $config, 'type' => $type, @@ -36,7 +36,7 @@ ); elseif ($typeKind->isOneOf(TypeKind::RESOURCE_CONTAINER, TypeKind::RESOURCE_INLINE)) : echo require_with( - PHPFHIR_TEMPLATE_TYPES_SERIALIZATION_DIR . DIRECTORY_SEPARATOR . 'json' . DIRECTORY_SEPARATOR . 'resource_container.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_SERIALIZATION_DIR . DIRECTORY_SEPARATOR . 'json' . DIRECTORY_SEPARATOR . 'resource_container.php', [ 'config' => $config, 'properties' => $localProperties, @@ -44,7 +44,7 @@ ); else: echo require_with( - PHPFHIR_TEMPLATE_TYPES_SERIALIZATION_DIR . DIRECTORY_SEPARATOR . 'json' . DIRECTORY_SEPARATOR . 'default.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_SERIALIZATION_DIR . DIRECTORY_SEPARATOR . 'json' . DIRECTORY_SEPARATOR . 'default.php', [ 'config' => $config, 'type' => $type, diff --git a/template/versions/types/serialization/xml.php b/template/versions/types/serialization/xml.php index 225a7850..1aa22b64 100644 --- a/template/versions/types/serialization/xml.php +++ b/template/versions/types/serialization/xml.php @@ -34,7 +34,7 @@ // unserialize portion echo require_with( - PHPFHIR_TEMPLATE_TYPES_SERIALIZATION_DIR . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'unserialize' . DIRECTORY_SEPARATOR . 'header.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_SERIALIZATION_DIR . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'unserialize' . DIRECTORY_SEPARATOR . 'header.php', [ 'config' => $config, 'type' => $type, @@ -48,7 +48,7 @@ if (0 < count($properties)) : echo require_with( - PHPFHIR_TEMPLATE_TYPES_SERIALIZATION_DIR . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'unserialize' . DIRECTORY_SEPARATOR . 'body.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_SERIALIZATION_DIR . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'unserialize' . DIRECTORY_SEPARATOR . 'body.php', [ 'config' => $config, 'type' => $type, @@ -65,7 +65,7 @@ // ResourceContainer and Resource.Inline types have their own special xml serialization mechanism if ($typeKind->isOneOf(TypeKind::RESOURCE_CONTAINER, TypeKind::RESOURCE_INLINE)) { echo require_with( - PHPFHIR_TEMPLATE_TYPES_SERIALIZATION_DIR . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'serialize' . DIRECTORY_SEPARATOR . 'resource_container.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_SERIALIZATION_DIR . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'serialize' . DIRECTORY_SEPARATOR . 'resource_container.php', [ 'config' => $config, 'type' => $type, @@ -74,7 +74,7 @@ } else { // everything else shares a common header echo require_with( - PHPFHIR_TEMPLATE_TYPES_SERIALIZATION_DIR . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'serialize' . DIRECTORY_SEPARATOR . 'header.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_SERIALIZATION_DIR . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'serialize' . DIRECTORY_SEPARATOR . 'header.php', [ 'config' => $config, 'type' => $type, @@ -84,7 +84,7 @@ if (0 < count($localProperties)) { echo require_with( - PHPFHIR_TEMPLATE_TYPES_SERIALIZATION_DIR . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'serialize' . DIRECTORY_SEPARATOR . 'body.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_SERIALIZATION_DIR . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'serialize' . DIRECTORY_SEPARATOR . 'body.php', [ 'config' => $config, 'type' => $type, diff --git a/template/versions/types/tests/unit/class.php b/template/versions/types/tests/unit/class.php index 1e5beb24..b3691374 100644 --- a/template/versions/types/tests/unit/class.php +++ b/template/versions/types/tests/unit/class.php @@ -28,7 +28,7 @@ ob_start(); echo require_with( - PHPFHIR_TEMPLATE_TYPE_TESTS_DIR . DIRECTORY_SEPARATOR . $testType->value . DIRECTORY_SEPARATOR . 'header.php', + PHPFHIR_TEMPLATE_VERSION_TYPE_TESTS_DIR . DIRECTORY_SEPARATOR . $testType->value . DIRECTORY_SEPARATOR . 'header.php', [ 'config' => $config, 'type' => $type, @@ -36,7 +36,7 @@ ); echo require_with( - PHPFHIR_TEMPLATE_TYPE_TESTS_DIR . DIRECTORY_SEPARATOR . $testType->value . DIRECTORY_SEPARATOR . 'body_base.php', + PHPFHIR_TEMPLATE_VERSION_TYPE_TESTS_DIR . DIRECTORY_SEPARATOR . $testType->value . DIRECTORY_SEPARATOR . 'body_base.php', [ 'config' => $config, 'type' => $type, @@ -45,7 +45,7 @@ if ($typeKind === TypeKind::PRIMITIVE) : echo require_with( - PHPFHIR_TEMPLATE_TYPE_TESTS_DIR . DIRECTORY_SEPARATOR . $testType->value . DIRECTORY_SEPARATOR . 'body_primitive.php', + PHPFHIR_TEMPLATE_VERSION_TYPE_TESTS_DIR . DIRECTORY_SEPARATOR . $testType->value . DIRECTORY_SEPARATOR . 'body_primitive.php', [ 'config' => $config, 'type' => $type, diff --git a/template/versions/types/validation/methods.php b/template/versions/types/validation/methods.php index 75c272a0..dd3c86c5 100644 --- a/template/versions/types/validation/methods.php +++ b/template/versions/types/validation/methods.php @@ -61,12 +61,12 @@ public function _getValidationErrors(): array if (null === $propertyType) { if ($property->isCollection()) { echo require_with( - PHPFHIR_TEMPLATE_TYPES_VALIDATION_DIR . DIRECTORY_SEPARATOR . 'methods' . DIRECTORY_SEPARATOR . 'collection_typed.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_VALIDATION_DIR . DIRECTORY_SEPARATOR . 'methods' . DIRECTORY_SEPARATOR . 'collection_typed.php', $requireArgs + ['property' => $property] ); } else { echo require_with( - PHPFHIR_TEMPLATE_TYPES_VALIDATION_DIR . DIRECTORY_SEPARATOR . 'methods' . DIRECTORY_SEPARATOR . 'primitive.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_VALIDATION_DIR . DIRECTORY_SEPARATOR . 'methods' . DIRECTORY_SEPARATOR . 'primitive.php', $requireArgs + ['property' => $property] ); } @@ -75,12 +75,12 @@ public function _getValidationErrors(): array continue; } else if ($property->isCollection()) { echo require_with( - PHPFHIR_TEMPLATE_TYPES_VALIDATION_DIR . DIRECTORY_SEPARATOR . 'methods' . DIRECTORY_SEPARATOR . 'collection_typed.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_VALIDATION_DIR . DIRECTORY_SEPARATOR . 'methods' . DIRECTORY_SEPARATOR . 'collection_typed.php', $requireArgs + ['property' => $property] ); } else { echo require_with( - PHPFHIR_TEMPLATE_TYPES_VALIDATION_DIR . DIRECTORY_SEPARATOR . 'methods' . DIRECTORY_SEPARATOR . 'typed.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_VALIDATION_DIR . DIRECTORY_SEPARATOR . 'methods' . DIRECTORY_SEPARATOR . 'typed.php', $requireArgs + ['property' => $property] ); }