From 89d32d5930e1ddadd2ebef198c9a526d05a69e63 Mon Sep 17 00:00:00 2001 From: Daniel Carbone Date: Sat, 4 May 2024 10:35:59 -0500 Subject: [PATCH 01/93] creating method crud --- output/{HL7 => }/.gitignore | 0 output/tmp/.gitignore | 2 - template/core/classes/class_debug_client.php | 80 +++++++++++++++----- 3 files changed, 63 insertions(+), 19 deletions(-) rename output/{HL7 => }/.gitignore (100%) delete mode 100644 output/tmp/.gitignore diff --git a/output/HL7/.gitignore b/output/.gitignore similarity index 100% rename from output/HL7/.gitignore rename to output/.gitignore diff --git a/output/tmp/.gitignore b/output/tmp/.gitignore deleted file mode 100644 index c96a04f0..00000000 --- a/output/tmp/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file diff --git a/template/core/classes/class_debug_client.php b/template/core/classes/class_debug_client.php index 64cc3dff..b4a13ff8 100644 --- a/template/core/classes/class_debug_client.php +++ b/template/core/classes/class_debug_client.php @@ -59,17 +59,25 @@ class private string $_baseUrl; /** @var array */ private array $_curlOpts; + /** @var getFullyQualifiedName(true, PHPFHIR_CLASSNAME_RESPONSE_PARSER); ?> */ + private $parser; /** * Constructor * * @param string $baseUrl URL of FHIR server to query * @param array $curlOpts Base curl options array + * @param null|getFullyQualifiedName(true, PHPFHIR_CLASSNAME_RESPONSE_PARSER); ?> $parser */ - public function __construct(string $baseUrl, array $curlOpts = [], ) + public function __construct(string $baseUrl, array $curlOpts = [], null| $parser = null) { $this->_baseUrl = $baseUrl; $this->_curlOpts = $curlOpts; + if (null === $parser) { + $this->parser = new (new ()); + } else { + $this->parser = $parser; + } } /** @@ -95,10 +103,10 @@ public function _getBaseCurlOpts(): array * @return \ */ - public function get(string $path, array $queryParams = [], array $curlOpts = []): + private function _exec(string $path, array $queryParams = [], array $curlOpts = []): { $url = sprintf('%s%s?%s', $this->_baseUrl, $path, http_build_query($queryParams, '', '&', PHP_QUERY_RFC3986)); - + $ch = curl_init($url); curl_setopt_array( $ch, @@ -119,6 +127,54 @@ public function get(string $path, array $queryParams = [], array $curlOpts = []) return $rc; } + /** + * @param string $path + * @param array $queryParams + * @param array $curlOpts + * @return \ + + */ + public function get(string $path, array $queryParams = [], array $curlOpts = []): + { + return $this->_exec($path, $queryParams, [CURLOPT_CUSTOMREQUEST => 'GET'] + $curlOpts); + } + + /** + * @param string $path + * @param array $queryParams + * @param array $curlOpts + * @return \ + + */ + public function put(string $path, array $queryParams = [], array $curlOpts = []): + { + return $this->_exec($path, $queryParams, [CURLOPT_CUSTOMREQUEST => 'PUT'] + $curlOpts); + } + + /** + * @param string $path + * @param array $queryParams + * @param array $curlOpts + * @return \ + + */ + public function post(string $path, array $queryParams = [], array $curlOpts = []): + { + return $this->_exec($path, $queryParams, [CURLOPT_CUSTOMREQUEST => 'POST'] + $curlOpts); + } + + /** + * @param string $path + * @param array $queryParams + * @param array $curlOpts + * @return \ + + */ + public function delete(string $path, array $queryParams = [], array $curlOpts = []): + { + return $this->_exec($path, $queryParams, [CURLOPT_CUSTOMREQUEST => 'DELETE'] + $curlOpts); + } + /** * Execute a read operation for a particular resource. * @@ -127,12 +183,11 @@ public function get(string $path, array $queryParams = [], array $curlOpts = []) * @param string|\ $resource * @param string $id * @param string|\ $format - * @param null|\ $parser * @return null|\ * @throws \Exception */ - public function readOne(string| $resource, string $id, string| $format = ::JSON, null| $parser = null): null| + public function readOne(string| $resource, string $id, string| $format = ::JSON): null| { if (!is_string($resource)) { @@ -151,11 +206,7 @@ public function readOne(string| $resource, strin throw new \Exception(sprintf('Error executing "%s": Expected 200 OK, saw %d', $rc->url, $rc->code)); } - if (null === $parser) { - $parser = new (new ()); - } - - return $parser->parse($rc->resp); + return $this->parser->parse($rc->resp); } /** @@ -165,12 +216,11 @@ public function readOne(string| $resource, strin * * @param string|\ $resource * @param string|\ $format - * @param null|\ $parser * @return null|\ * @throws \Exception */ - public function readFirst(string| $resource, string| $format = ::JSON, null| $parser = null): null| + public function readFirst(string| $resource, string| $format = ::JSON): null| { if (!is_string($resource)) { @@ -189,11 +239,7 @@ public function readFirst(string| $resource, str throw new \Exception(sprintf('Error executing "%s": Expected 200 OK, saw %d', $rc->url, $rc->code)); } - if (null === $parser) { - $parser = new (new ()); - } - - return $parser->parse($rc->resp); + return $this->parser->parse($rc->resp); } } Date: Sun, 5 May 2024 09:51:40 -0500 Subject: [PATCH 02/93] more client work --- files/constants.php | 8 +- template/core/classes/class_api_client.php | 268 ++++++++++++++++++ .../core/classes/class_api_client_request.php | 62 ++++ ...onse.php => class_api_client_response.php} | 6 +- template/core/classes/class_autoloader.php | 17 +- template/core/classes/class_debug_client.php | 198 +------------ .../enums/enum_fhir_api_resource_list.php | 51 ++++ template/core/enums/enum_fhir_api_sort.php | 50 ++++ template/types/tests/validation/class.php | 6 +- 9 files changed, 459 insertions(+), 207 deletions(-) create mode 100644 template/core/classes/class_api_client.php create mode 100644 template/core/classes/class_api_client_request.php rename template/core/classes/{class_debug_client_response.php => class_api_client_response.php} (83%) create mode 100644 template/core/enums/enum_fhir_api_resource_list.php create mode 100644 template/core/enums/enum_fhir_api_sort.php diff --git a/files/constants.php b/files/constants.php index 1ee06f20..8cd46072 100644 --- a/files/constants.php +++ b/files/constants.php @@ -83,9 +83,11 @@ const PHPFHIR_CLASSNAME_RESPONSE_PARSER = 'PHPFHIRResponseParser'; const PHPFHIR_CLASSNAME_CONSTANTS = 'PHPFHIRConstants'; const PHPFHIR_CLASSNAME_TYPEMAP = 'PHPFHIRTypeMap'; -const PHPFHIR_CLASSNAME_DEBUG_CLIENT = 'PHPFHIRDebugClient'; -const PHPFHIR_CLASSNAME_DEBUG_CLIENT_RESPONSE = 'PHPFHIRDebugClientResponse'; +const PHPFHIR_CLASSNAME_API_CLIENT = 'PHPFHIRApiClient'; +const PHPFHIR_CLASSNAME_API_CLIENT_REQUEST = 'PHPFHIRApiClientRequest'; +const PHPFHIR_CLASSNAME_API_CLIENT_RESPONSE = 'PHPFHIRApiClientResponse'; const PHPFHIR_CLASSNAME_XML_WRITER = 'PHPFHIRXmlWriter'; +const PHPFHIR_CLASSNAME_DEBUG_CLIENT = 'PHPFHIRDebugClient'; // Core interface names const PHPFHIR_INTERFACE_TYPE = 'PHPFHIRTypeInterface'; @@ -104,6 +106,8 @@ const PHPFHIR_ENUM_TYPE = 'PHPFHIRTypeEnum'; const PHPFHIR_ENUM_API_FORMAT = 'PHPFHIRApiFormatEnum'; const PHPFHIR_ENUM_XML_LOCATION_ENUM = 'PHPFHIRXmlLocationEnum'; +const PHPFHIR_ENUM_API_RESOURCE_LIST = 'PHPFHIRApiResourceListEnum'; +const PHPFHIR_ENUM_API_SORT = 'PHPFHIRApiSortEnum'; // validation constants const PHPFHIR_VALIDATION_ENUM = 'enum'; diff --git a/template/core/classes/class_api_client.php b/template/core/classes/class_api_client.php new file mode 100644 index 00000000..749fb945 --- /dev/null +++ b/template/core/classes/class_api_client.php @@ -0,0 +1,268 @@ +getFullyQualifiedName(false); + +ob_start(); + +echo " +/** + * This client is under active development. Its API may change significantly between major releases. + * + * Class + + * @package \ + + + */ +class + +{ + private const _METHOD_GET = 'GET'; + private const _METHOD_PUT = 'PUT'; + private const _METHOD_POST = 'POST'; + private const _METHOD_PATCH = 'PATCH'; + private const _METHOD_DELETE = 'DELETE'; + private const _METHOD_HEAD = 'HEAD'; + + private const _BASE_CURL_OPTS = [ + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_HEADER => 0, + CURLOPT_USERAGENT => 'php-fhir client (build: ; fhir version: getVersion()->getName(); ?>)', + ]; + + /** @var string */ + private string $_baseUrl; + /** @var array */ + private array $_curlOpts; + /** @var getFullyQualifiedName(true, PHPFHIR_CLASSNAME_RESPONSE_PARSER); ?> */ + private $parser; + + /** + * Constructor + * + * @param string $baseUrl URL of FHIR server to query + * @param array $curlOpts Base curl options array + * @param null|getFullyQualifiedName(true, PHPFHIR_CLASSNAME_RESPONSE_PARSER); ?> $parser + */ + public function __construct(string $baseUrl, array $curlOpts = [], null| $parser = null) + { + $this->_baseUrl = $baseUrl; + $this->_curlOpts = $curlOpts; + if (null === $parser) { + $this->parser = new (new ()); + } else { + $this->parser = $parser; + } + } + + /** + * @return string + */ + public function _getBaseUrl(): string + { + return $this->_baseUrl; + } + + /** + * @return array + */ + public function _getBaseCurlOpts(): array + { + return $this->_curlOpts; + } + + /** + * @param string $path + * @param array $queryParams + * @param array $curlOpts + * @return getFullyQualifiedName(true, PHPFHIR_CLASSNAME_API_CLIENT_RESPONSE); ?> + + */ + private function _exec(string $path, array $queryParams = [], array $curlOpts = []): + { + $url = sprintf('%s%s?%s', $this->_baseUrl, $path, http_build_query($queryParams, '', '&', PHP_QUERY_RFC3986)); + + $ch = curl_init($url); + curl_setopt_array( + $ch, + self::_BASE_CURL_OPTS + $this->_curlOpts + $curlOpts + ); + + $resp = curl_exec($ch); + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); + $err = curl_error($ch); + curl_close($ch); + + $rc = new (); + $rc->url = $url; + $rc->code = $code; + $rc->resp = $resp; + $rc->err = $err; + + return $rc; + } + + /** + * @param string $path + * @param array $queryParams + * @param array $curlOpts + * @return getFullyQualifiedName(true, PHPFHIR_CLASSNAME_API_CLIENT_RESPONSE); ?> + + */ + public function get(string $path, array $queryParams = [], array $curlOpts = []): + { + return $this->_exec($path, $queryParams, [CURLOPT_CUSTOMREQUEST => self::_METHOD_GET] + $curlOpts); + } + + /** + * @param string $path + * @param array $queryParams + * @param array $curlOpts + * @return getFullyQualifiedName(true, PHPFHIR_CLASSNAME_API_CLIENT_RESPONSE); ?> + + */ + public function put(string $path, array $queryParams = [], array $curlOpts = []): + { + return $this->_exec($path, $queryParams, [CURLOPT_CUSTOMREQUEST => self::_METHOD_PUT] + $curlOpts); + } + + /** + * @param string $path + * @param array $queryParams + * @param array $curlOpts + * @return getFullyQualifiedName(true, PHPFHIR_CLASSNAME_API_CLIENT_RESPONSE); ?> + + */ + public function post(string $path, array $queryParams = [], array $curlOpts = []): + { + return $this->_exec($path, $queryParams, [CURLOPT_CUSTOMREQUEST => self::_METHOD_POST] + $curlOpts); + } + + /** + * @param string $path + * @param array $queryParams + * @param array $curlOpts + * @return getFullyQualifiedName(true, PHPFHIR_CLASSNAME_API_CLIENT_RESPONSE); ?> + + */ + public function patch(string $path, array $queryParams = [], array $curlOpts = []): + { + return $this->_exec($path, $queryParams, [CURLOPT_CUSTOMREQUEST => self::_METHOD_PATCH] + $curlOpts); + } + + /** + * @param string $path + * @param array $queryParams + * @param array $curlOpts + * @return getFullyQualifiedName(true, PHPFHIR_CLASSNAME_API_CLIENT_RESPONSE); ?> + + */ + public function delete(string $path, array $queryParams = [], array $curlOpts = []): + { + return $this->_exec($path, $queryParams, [CURLOPT_CUSTOMREQUEST => self::_METHOD_DELETE] + $curlOpts); + } + + /** + * @param string $path + * @param array $queryParams + * @param array $curlOpts + * @return getFullyQualifiedName(true, PHPFHIR_CLASSNAME_API_CLIENT_RESPONSE); ?> + + */ + public function head(string $path, array $queryParams = [], array $curlOpts = []): + { + return $this->_exec($path, $queryParams, [CURLOPT_CUSTOMREQUEST => self::_METHOD_HEAD] + $curlOpts); + } + + /** + * Execute a read operation for a particular resource. + * + * @see https://www.hl7.org/fhir/http.html#read + * + * @param string|getFullyQualifiedName(true, PHPFHIR_ENUM_TYPE); ?> $resourceType + * @param string $id + * @param getFullyQualifiedName(true, PHPFHIR_ENUM_API_FORMAT); ?> $format + * @return null|getFullyQualifiedName(true, PHPFHIR_INTERFACE_TYPE); ?> + + * @throws \Exception + */ + public function readOne(string| $resourceType, string $id, $format = ::JSON): null| + + { + if (!is_string($resourceType)) { + $resourceType = $resourceType->value; + } + + $rc = $this->get(sprintf('/%s/%s', $resourceType, $id), ['_format' => $format->value]); + + if ('' !== $rc->err) { + throw new \Exception(sprintf('Error executing "%s": %s', $rc->url, $rc->err)); + } + if (200 !== $rc->code) { + throw new \Exception(sprintf('Error executing "%s": Expected 200 OK, saw %d', $rc->url, $rc->code)); + } + + return $this->parser->parse($rc->resp); + } + + /** + * Queries for the first available of a given resource + * + * @see https://www.hl7.org/fhir/http.html#read + * + * @param string|getFullyQualifiedName(true, PHPFHIR_ENUM_TYPE); ?> $resourceType + * @param getFullyQualifiedName(true, PHPFHIR_ENUM_API_FORMAT); ?> $format + * @return null|getFullyQualifiedName(true, PHPFHIR_INTERFACE_TYPE); ?> + + * @throws \Exception + */ + public function readFirst(string| $resourceType, $format = ::JSON): null| + + { + if (!is_string($resourceType)) { + $resourceType = $resourceType->value; + } + + $rc = $this->get(sprintf('/%s', $resourceType), ['_format' => $format->value, '_count' => '1']); + + if ('' !== $rc->err) { + throw new \Exception(sprintf('Error executing "%s": %s', $rc->url, $rc->err)); + } + if (200 !== $rc->code) { + throw new \Exception(sprintf('Error executing "%s": Expected 200 OK, saw %d', $rc->url, $rc->code)); + } + + return $this->parser->parse($rc->resp); + } +} +getFullyQualifiedName(false); + +ob_start(); + +echo " +/** + * This type is not intended to be used directly, and will have its API changed over time. + * + * Class + + * @package \ + + + */ +final class + +{ + /** @var int */ + public null|int $count = null; + /** @var null|string */ + public null|string $since = null; + /** @var null|string */ + public null|string $at = null; + + /** @var null|getFullyQualifiedName(true, PHPFHIR_ENUM_API_SORT); ?> */ + public null| $sort = null; + + /** @var null|getFullyQualifiedName(true, PHPFHIR_ENUM_API_RESOURCE_LIST); ?> */ + public null| $resourceList = null; +} + /** - * Class + * This type is not intended to be used directly, and will have its API changed over time. + * + * Class * @package \ */ -final class +final class { public string $url = ''; diff --git a/template/core/classes/class_autoloader.php b/template/core/classes/class_autoloader.php index bf89c482..58d94f48 100644 --- a/template/core/classes/class_autoloader.php +++ b/template/core/classes/class_autoloader.php @@ -103,10 +103,21 @@ require __DIR__ . DIRECTORY_SEPARATOR . '.php'; } -// debug client -if (!class_exists('getFullyQualifiedName(true, PHPFHIR_CLASSNAME_DEBUG_CLIENT_RESPONSE); ?>', false)) { - require __DIR__ . DIRECTORY_SEPARATOR . '.php'; +// api client +if (!enum_exists('getFullyQualifiedName(true, PHPFHIR_ENUM_API_RESOURCE_LIST); ?>', false)) { + require __DIR__ . DIRECTORY_SEPARATOR . '.php'; +} +if (!class_exists('getFullyQualifiedName(true, PHPFHIR_CLASSNAME_API_CLIENT_REQUEST); ?>', false)) { + require __DIR__ . DIRECTORY_SEPARATOR . '.php'; +} +if (!class_exists('getFullyQualifiedName(true, PHPFHIR_CLASSNAME_API_CLIENT_RESPONSE); ?>', false)) { + require __DIR__ . DIRECTORY_SEPARATOR . '.php'; } +if (!class_exists('getFullyQualifiedName(true, PHPFHIR_CLASSNAME_API_CLIENT); ?>', false)) { + require __DIR__ . DIRECTORY_SEPARATOR . '.php'; +} + +// debug client if (!class_exists('getFullyQualifiedName(true, PHPFHIR_CLASSNAME_DEBUG_CLIENT); ?>', false)) { require __DIR__ . DIRECTORY_SEPARATOR . '.php'; } diff --git a/template/core/classes/class_debug_client.php b/template/core/classes/class_debug_client.php index b4a13ff8..9597226c 100644 --- a/template/core/classes/class_debug_client.php +++ b/template/core/classes/class_debug_client.php @@ -45,201 +45,5 @@ */ -class - -{ - private const _BASE_CURL_OPTS = [ - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_HEADER => 0, - CURLOPT_USERAGENT => 'php-fhir debug client (build: ; fhir version: getVersion()->getName(); ?>)', - ]; - - /** @var string */ - private string $_baseUrl; - /** @var array */ - private array $_curlOpts; - /** @var getFullyQualifiedName(true, PHPFHIR_CLASSNAME_RESPONSE_PARSER); ?> */ - private $parser; - - /** - * Constructor - * - * @param string $baseUrl URL of FHIR server to query - * @param array $curlOpts Base curl options array - * @param null|getFullyQualifiedName(true, PHPFHIR_CLASSNAME_RESPONSE_PARSER); ?> $parser - */ - public function __construct(string $baseUrl, array $curlOpts = [], null| $parser = null) - { - $this->_baseUrl = $baseUrl; - $this->_curlOpts = $curlOpts; - if (null === $parser) { - $this->parser = new (new ()); - } else { - $this->parser = $parser; - } - } - - /** - * @return string - */ - public function _getBaseUrl(): string - { - return $this->_baseUrl; - } - - /** - * @return array - */ - public function _getBaseCurlOpts(): array - { - return $this->_curlOpts; - } - - /** - * @param string $path - * @param array $queryParams - * @param array $curlOpts - * @return \ - - */ - private function _exec(string $path, array $queryParams = [], array $curlOpts = []): - { - $url = sprintf('%s%s?%s', $this->_baseUrl, $path, http_build_query($queryParams, '', '&', PHP_QUERY_RFC3986)); - - $ch = curl_init($url); - curl_setopt_array( - $ch, - self::_BASE_CURL_OPTS + $this->_curlOpts + $curlOpts - ); - - $resp = curl_exec($ch); - $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); - $err = curl_error($ch); - curl_close($ch); - - $rc = new (); - $rc->url = $url; - $rc->code = $code; - $rc->resp = $resp; - $rc->err = $err; - - return $rc; - } - - /** - * @param string $path - * @param array $queryParams - * @param array $curlOpts - * @return \ - - */ - public function get(string $path, array $queryParams = [], array $curlOpts = []): - { - return $this->_exec($path, $queryParams, [CURLOPT_CUSTOMREQUEST => 'GET'] + $curlOpts); - } - - /** - * @param string $path - * @param array $queryParams - * @param array $curlOpts - * @return \ - - */ - public function put(string $path, array $queryParams = [], array $curlOpts = []): - { - return $this->_exec($path, $queryParams, [CURLOPT_CUSTOMREQUEST => 'PUT'] + $curlOpts); - } - - /** - * @param string $path - * @param array $queryParams - * @param array $curlOpts - * @return \ - - */ - public function post(string $path, array $queryParams = [], array $curlOpts = []): - { - return $this->_exec($path, $queryParams, [CURLOPT_CUSTOMREQUEST => 'POST'] + $curlOpts); - } - - /** - * @param string $path - * @param array $queryParams - * @param array $curlOpts - * @return \ - - */ - public function delete(string $path, array $queryParams = [], array $curlOpts = []): - { - return $this->_exec($path, $queryParams, [CURLOPT_CUSTOMREQUEST => 'DELETE'] + $curlOpts); - } - - /** - * Execute a read operation for a particular resource. - * - * @see https://www.hl7.org/fhir/http.html#read - * - * @param string|\ $resource - * @param string $id - * @param string|\ $format - * @return null|\ - - * @throws \Exception - */ - public function readOne(string| $resource, string $id, string| $format = ::JSON): null| - - { - if (!is_string($resource)) { - $resource = $resource->value; - } - if (!is_string($format)) { - $format = $format->value; - } - - $rc = $this->get(sprintf('/%s/%s', $resource, $id), ['_format' => $format]); - - if ('' !== $rc->err) { - throw new \Exception(sprintf('Error executing "%s": %s', $rc->url, $rc->err)); - } - if (200 !== $rc->code) { - throw new \Exception(sprintf('Error executing "%s": Expected 200 OK, saw %d', $rc->url, $rc->code)); - } - - return $this->parser->parse($rc->resp); - } - - /** - * Queries for the first available of a given resource - * - * @see https://www.hl7.org/fhir/http.html#read - * - * @param string|\ $resource - * @param string|\ $format - * @return null|\ - - * @throws \Exception - */ - public function readFirst(string| $resource, string| $format = ::JSON): null| - - { - if (!is_string($resource)) { - $resource = $resource->value; - } - if (!is_string($format)) { - $format = $format->value; - } - - $rc = $this->get(sprintf('/%s', $resource), ['_format' => $format, '_count' => '1']); - - if ('' !== $rc->err) { - throw new \Exception(sprintf('Error executing "%s": %s', $rc->url, $rc->err)); - } - if (200 !== $rc->code) { - throw new \Exception(sprintf('Error executing "%s": Expected 200 OK, saw %d', $rc->url, $rc->code)); - } - - return $this->parser->parse($rc->resp); - } -} +class extends {} getFullyQualifiedName(false); + +ob_start(); + +echo " +/** + * Enum + + * @package \ + + + */ +enum : string +{ + case CURRENT_PROBLEMS = '$current-problems'; + case CURRENT_MEDICATIONS = '$current-medications'; + case CURRENT_ALLERGIES = '$current-allergies'; + csae CURRENT_DRUG_ALLERGIES = '$current-drug-allergies'; +} +getFullyQualifiedName(false); + +ob_start(); + +echo " +/** + * Enum + + * @package \ + + + */ +enum : string +{ + case LAST_UPDATED_DESC = '-_lastUpdated'; + case LAST_UPDATED_ASC = '_lastUpdated'; + case NONE = 'none'; +} +getFullyQualifiedClassName(false); ?>; use getFullyQualifiedClassName(false); ?>; -use getFullyQualifiedName(false); ?>\; +use getFullyQualifiedName(false); ?>\; use getFullyQualifiedName(false); ?>\; use PHPUnit\Framework\AssertionFailedError; use PHPUnit\Framework\TestCase; @@ -102,8 +102,8 @@ class extends TestCase 'If a code for the unit is present, the system SHALL also be present', ]; - /** @var getFullyQualifiedName(true); ?>\ */ - private $client; + /** @var getFullyQualifiedName(true); ?>\ */ + private $client; /** @var array */ private array $_fetchedResources = []; From b13cde8e2b43031a1faf44d4c99eaf4d48d80d65 Mon Sep 17 00:00:00 2001 From: Daniel Carbone Date: Fri, 7 Jun 2024 15:17:05 -0500 Subject: [PATCH 03/93] busted thoughts --- src/Config.php | 67 +++++---- src/Config/Version.php | 136 ++++++++++-------- src/Config/VersionConfig.php | 42 +----- src/Config/VersionKeys.php | 30 ++++ src/ConfigKeys.php | 31 ++++ src/Enum/ValuesTrait.php | 2 +- .../core/classes/class_api_client_request.php | 3 + 7 files changed, 182 insertions(+), 129 deletions(-) create mode 100644 src/Config/VersionKeys.php create mode 100644 src/ConfigKeys.php diff --git a/src/Config.php b/src/Config.php index 2878b37f..d89436fa 100644 --- a/src/Config.php +++ b/src/Config.php @@ -20,6 +20,8 @@ use DCarbone\PHPFHIR\Config\Version; use DCarbone\PHPFHIR\Config\VersionConfig; +use Psr\Log\LoggerAwareInterface; +use Psr\Log\LoggerAwareTrait; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; @@ -27,17 +29,12 @@ * Class Config * @package DCarbone\PHPFHIR */ -class Config +class Config implements LoggerAwareInterface { - public const KEY_SCHEMA_PATH = 'schemaPath'; - public const KEY_CLASSES_PATH = 'classesPath'; - public const KEY_VERSIONS = 'versions'; - public const KEY_SILENT = 'silent'; - public const KEY_SKIP_TESTS = 'skipTests'; - public const KEY_LIBXML_OPTS = 'libxmlOpts'; + use LoggerAwareTrait; /** @var \DCarbone\PHPFHIR\Logger */ - protected Logger $_log; + private Logger $_log; /** @var string */ private string $schemaPath; @@ -55,44 +52,54 @@ class Config /** @var int|null */ private ?int $libxmlOpts; - /** - * @param \Psr\Log\LoggerInterface $logger - */ - public function setLogger(LoggerInterface $logger): void - { - $this->_log = new Logger($logger); - } - /** * Config constructor. - * @param array $conf + * @param array $params * @param \Psr\Log\LoggerInterface|null $logger */ - public function __construct(array $conf = [], LoggerInterface $logger = null) + public function __construct(array $params = [], LoggerInterface $logger = null) { - if (!isset($conf[self::KEY_SCHEMA_PATH])) { + foreach (ConfigKeys::cases() as $key) { + if (isset($params[$key->value])) { + $this->{$key->value} = $params[$key->value]; + } + } + if (!isset($params[self::KEY_SCHEMA_PATH])) { throw new \DomainException('Required configuration key "' . self::KEY_SCHEMA_PATH . '" missing'); } - if (!isset($conf[self::KEY_CLASSES_PATH])) { + if (!isset($params[self::KEY_CLASSES_PATH])) { throw new \DomainException('Required configuration key "' . self::KEY_CLASSES_PATH . '" missing'); } - if (!isset($conf[self::KEY_VERSIONS]) || !is_array($conf[self::KEY_VERSIONS]) || 0 == count( - $conf[self::KEY_VERSIONS] + if (!isset($params[self::KEY_VERSIONS]) || !is_array($params[self::KEY_VERSIONS]) || 0 == count( + $params[self::KEY_VERSIONS] )) { throw new \DomainException( 'Configuration key "' . self::KEY_VERSIONS . '" must be an array with at least 1 configured version.' ); } - $this->setSchemaPath($conf[self::KEY_SCHEMA_PATH]); - $this->setClassesPath($conf[self::KEY_CLASSES_PATH]); - $this->setVersions($conf[self::KEY_VERSIONS]); - $this->setSilent(isset($conf[self::KEY_SILENT]) && (bool)$conf[self::KEY_SILENT]); - $this->setSkipTests($conf[self::KEY_SKIP_TESTS] ?? false); - $this->setLibxmlOpts($conf[self::KEY_LIBXML_OPTS] ?? null); + $this->setSchemaPath($params[self::KEY_SCHEMA_PATH]); + $this->setClassesPath($params[self::KEY_CLASSES_PATH]); + $this->setVersions($params[self::KEY_VERSIONS]); + $this->setSilent(isset($params[self::KEY_SILENT]) && (bool)$params[self::KEY_SILENT]); + $this->setSkipTests($params[self::KEY_SKIP_TESTS] ?? false); + $this->setLibxmlOpts($params[self::KEY_LIBXML_OPTS] ?? null); if ($logger && !$this->isSilent()) { - $this->_log = new Logger($logger); + $this->setLogger(new Logger($logger)); } else { - $this->_log = new Logger(new NullLogger()); + $this->setLogger(new NullLogger()); + } + } + + /** + * @param \Psr\Log\LoggerInterface $logger + * @return void + */ + public function setLogger(LoggerInterface $logger): void + { + if ($logger instanceof Logger) { + $this->logger = $logger; + } else { + $this->_log = new Logger($logger); } } diff --git a/src/Config/Version.php b/src/Config/Version.php index 1e55c6d0..847f41a4 100644 --- a/src/Config/Version.php +++ b/src/Config/Version.php @@ -18,8 +18,10 @@ * limitations under the License. */ +use DCarbone\PHPFHIR\Config; +use DCarbone\PHPFHIR\Definition; +use DCarbone\PHPFHIR\Enum\TestType; use DCarbone\PHPFHIR\Utilities\NameUtils; -use DomainException; use InvalidArgumentException; /** @@ -28,40 +30,62 @@ */ class Version { - public const KEY_URL = 'url'; - public const KEY_NAMESPACE = 'namespace'; - public const KEY_TEST_ENDPOINT = 'testEndpoint'; + /** @var \DCarbone\PHPFHIR\Config */ + private Config $config; /** @var string */ private string $name; - /** @var string */ - private string $url; + private string $sourceUrl; /** @var string */ private string $namespace; /** @var string */ private string $testEndpoint; + /** @var \DCarbone\PHPFHIR\Definition */ + private Definition $definition; + /** - * Version constructor. + * @param \DCarbone\PHPFHIR\Config $config * @param string $name - * @param array $conf + * @param array $params */ - public function __construct(string $name, array $conf = []) + public function __construct(Config $config, string $name, array $params = []) { + $this->config = $config; $this->name = $name; - if (!isset($conf[self::KEY_URL])) { - throw new DomainException(sprintf('Version %s is missing required config key ', self::KEY_URL)); + if ('' === trim($this->name)) { + throw new \DomainException('Version name cannot be empty.'); + } + + // attempt to set each expectd key + foreach(VersionKeys::cases() as $key) { + if (isset($params[$key->value])) { + $this->{$key->value} = $params[$key->value]; + } + } + + // default namespace to name, if no specific namespace provided + if (!isset($this->namespace)) { + $this->namespace = $this->name; } - $this->setUrl($conf[self::KEY_URL]); - if (isset($conf[self::KEY_NAMESPACE])) { - $this->setNamespace($conf[self::KEY_NAMESPACE]); + // require a few fields + foreach (self::_requiredParamKeys() as $key) { + if (!isset($this->{$key->name})) { + throw new \DomainException(sprintf('Config must have "%s" key', $key->name)); + } } - if (isset($conf[self::KEY_TEST_ENDPOINT])) { - $this->setTestEndpoint($conf[self::KEY_TEST_ENDPOINT]); + // ensure namespace is valid + if (!NameUtils::isValidNSName($this->namespace)) { + throw new InvalidArgumentException( + sprintf( + '"%s" is not a valid PHP namespace.', + $this->namespace + ) + ); } } @@ -76,19 +100,9 @@ public function getName(): string /** * @return string */ - public function getUrl(): string - { - return $this->url; - } - - /** - * @param string $url - * @return \DCarbone\PHPFHIR\Config\Version - */ - public function setUrl(string $url): Version + public function getSourceUrl(): string { - $this->url = $url; - return $this; + return $this->sourceUrl; } /** @@ -101,51 +115,55 @@ public function getNamespace(bool $leadingSlash): string } /** - * @param string|null $namespace - * @return \DCarbone\PHPFHIR\Config\Version + * @return string|null */ - public function setNamespace(?string $namespace): Version + public function getTestEndpoint(): string|null { - if (null === $namespace) { - $this->namespace = ''; - return $this; - } - // handle no or empty namespace - $namespace = trim($namespace, PHPFHIR_NAMESPACE_TRIM_CUTSET); - if ('' === $namespace) { - $this->namespace = ''; - return $this; - } + return $this->testEndpoint ?? null; + } - if (false === NameUtils::isValidNSName($namespace)) { - throw new InvalidArgumentException( - sprintf( - 'Version "%s" namespace "%s" is not a valid PHP namespace.', - $this->name, - $this->namespace - ) - ); + /** + * @param bool $leadingSlash + * @param string ...$bits + * @return string + */ + public function getFullyQualifiedName(bool $leadingSlash, string... $bits): string + { + $ns = $this->getNamespace($leadingSlash); + $bits = array_filter($bits); + if ([] === $bits) { + return $ns; } + return sprintf('%s\\%s', $ns, implode('\\' , $bits)); + } - $this->namespace = $namespace; - return $this; + /** + * @param \DCarbone\PHPFHIR\Enum\TestType $testType + * @param bool $leadingSlash + * @param string ...$bits + * @return string + */ + public function getFullyQualifiedTestsName(TestType $testType, bool $leadingSlash, string... $bits): string + { + return $this->getFullyQualifiedName($leadingSlash, $testType->namespaceSlug(), ...$bits); } /** - * @return string|null + * @return \DCarbone\PHPFHIR\Definition */ - public function getTestEndpoint(): ?string + public function getDefinition(): Definition { - return $this->testEndpoint ?? null; + if (!isset($this->definition)) { + $this->definition = new Definition($this); + } + return $this->definition; } /** - * @param string $testEndpoint - * @return \DCarbone\PHPFHIR\Config\Version + * @return array */ - public function setTestEndpoint(string $testEndpoint): Version + private static function _requiredParamKeys(): array { - $this->testEndpoint = $testEndpoint; - return $this; + return [VersionKeys::SOURCE_URL->value, VersionKeys::NAMESPACE->value]; } } \ No newline at end of file diff --git a/src/Config/VersionConfig.php b/src/Config/VersionConfig.php index 8779d127..1c7da386 100644 --- a/src/Config/VersionConfig.php +++ b/src/Config/VersionConfig.php @@ -34,9 +34,6 @@ class VersionConfig /** @var \DCarbone\PHPFHIR\Config\Version */ private Version $version; - /** @var \DCarbone\PHPFHIR\Definition */ - private Definition $definition; - /** * BuildConfig constructor. * @param \DCarbone\PHPFHIR\Config $config @@ -77,23 +74,10 @@ public function getClassesPath(): string */ public function getUrl(): string { - return $this->version->getUrl(); + return $this->version->getSourceUrl(); } - /** - * @param bool $leadingSlash - * @param string ...$bits - * @return string - */ - public function getFullyQualifiedName(bool $leadingSlash, string... $bits): string - { - $ns = $this->version->getNamespace($leadingSlash); - $bits = array_filter($bits); - if ([] === $bits) { - return $ns; - } - return sprintf('%s\\%s', $ns, implode('\\' , $bits)); - } + /** * @return bool @@ -111,16 +95,7 @@ public function getLibxmlOpts(): ?int return $this->config->getLibxmlOpts(); } - /** - * @param \DCarbone\PHPFHIR\Enum\TestType $testType - * @param bool $leadingSlash - * @param string ...$bits - * @return string - */ - public function getFullyQualifiedTestsName(TestType $testType, bool $leadingSlash, string... $bits): string - { - return $this->getFullyQualifiedName($leadingSlash, $testType->namespaceSlug(), ...$bits); - } + /** * @return string|null @@ -145,15 +120,4 @@ public function getVersion(): Version { return $this->version; } - - /** - * @return \DCarbone\PHPFHIR\Definition - */ - public function getDefinition(): Definition - { - if (!isset($this->definition)) { - $this->definition = new Definition($this); - } - return $this->definition;; - } } \ No newline at end of file diff --git a/src/Config/VersionKeys.php b/src/Config/VersionKeys.php new file mode 100644 index 00000000..51084a27 --- /dev/null +++ b/src/Config/VersionKeys.php @@ -0,0 +1,30 @@ + { + /** @var null|string */ + public null|string $host; + /** @var int */ public null|int $count = null; /** @var null|string */ From c668ec3fea3c6885781942aad9cf112cf7078c0e Mon Sep 17 00:00:00 2001 From: Daniel Carbone Date: Thu, 18 Jul 2024 21:35:30 -0500 Subject: [PATCH 04/93] fuckin' it all up --- bin/config.php | 19 +- bin/generate.php | 9 +- composer.json | 3 +- files/constants.php | 2 + src/Builder.php | 177 +++++------ src/Builder/TypeBuilder.php | 42 +-- src/Config.php | 176 ++++++----- src/Config/VersionConfig.php | 123 -------- src/ConfigKeys.php | 22 +- src/Render/Templates.php | 39 +-- src/Utilities/CopyrightUtils.php | 277 ------------------ src/Utilities/DocumentationUtils.php | 4 +- src/Utilities/ExceptionUtils.php | 65 ++-- src/Utilities/FileUtils.php | 36 +-- src/Utilities/NameUtils.php | 22 +- src/Utilities/TypeBuilderUtils.php | 28 +- src/Utilities/TypeHintUtils.php | 72 ++--- src/{Config => }/Version.php | 92 +++--- src/{ => Version}/Definition.php | 51 ++-- ...AnnotationElementPropertyTypeDecorator.php | 16 +- .../AnnotationElementTypeDecorator.php | 12 +- .../Decorator/AnyElementTypeDecorator.php | 14 +- .../AttributeElementTypeDecorator.php | 14 +- .../ChoiceElementElementPropertyDecorator.php | 14 +- .../Decorator/ChoiceElementTypeDecorator.php | 12 +- .../ComplexContentElementTypeDecorator.php | 12 +- .../ComplexTypeElementTypeDecorator.php | 12 +- .../Decorator/ElementElementTypeDecorator.php | 18 +- .../ExtensionElementTypeDecorator.php | 14 +- .../RestrictionElementTypeDecorator.php | 12 +- .../SequenceElementTypeDecorator.php | 12 +- .../SimpleContentElementTypeDecorator.php | 12 +- .../SimpleTypeElementPropertyDecorator.php | 16 +- .../SimpleTypeElementTypeDecorator.php | 12 +- .../Decorator/UnionElementTypeDecorator.php | 12 +- .../Definition/DocumentationTrait.php | 4 +- src/{ => Version}/Definition/Enumeration.php | 14 +- .../Enumeration}/EnumerationValue.php | 3 +- src/{ => Version}/Definition/Properties.php | 59 ++-- src/{ => Version}/Definition/Property.php | 40 ++- src/{ => Version}/Definition/SourceTrait.php | 2 +- src/{ => Version}/Definition/Type.php | 106 ++++--- .../Definition/TypeDecorationValidator.php | 14 +- .../Definition/TypeDecorator.php | 86 +++--- .../Definition/TypeExtractor.php | 31 +- src/{ => Version}/Definition/TypeImport.php | 2 +- src/{ => Version}/Definition/TypeImports.php | 20 +- .../Definition/TypePropertyDecorator.php | 32 +- src/{ => Version}/Definition/Types.php | 50 ++-- src/Version/VersionCopyright.php | 173 +++++++++++ src/VersionKeys.php | 49 ++++ template/core/classes/class_api_client.php | 10 +- .../core/classes/class_api_client_request.php | 8 +- .../classes/class_api_client_response.php | 8 +- template/core/classes/class_autoloader.php | 8 +- template/core/classes/class_config.php | 8 +- template/core/classes/class_constants.php | 14 +- template/core/classes/class_debug_client.php | 8 +- .../core/classes/class_response_parser.php | 8 +- template/core/classes/class_type_map.php | 10 +- template/core/classes/class_versions.php | 47 +++ template/core/classes/class_xml_writer.php | 8 +- template/core/enums/enum_api_format.php | 8 +- template/core/enums/enum_config_key.php | 8 +- .../enums/enum_fhir_api_resource_list.php | 8 +- template/core/enums/enum_fhir_api_sort.php | 8 +- template/core/enums/enum_type.php | 8 +- template/core/enums/enum_xml_location.php | 8 +- .../interface_comment_container.php | 6 +- .../interfaces/interface_contained_type.php | 8 +- .../interfaces/interface_fhir_version.php | 12 - .../interfaces/interface_primitive_type.php | 8 +- template/core/interfaces/interface_type.php | 6 +- template/core/tests/test_class_constants.php | 8 +- template/core/tests/test_class_type_map.php | 8 +- .../core/traits/trait_change_tracking.php | 6 +- .../core/traits/trait_comment_container.php | 6 +- .../traits/trait_source_xml_namespace.php | 6 +- .../traits/trait_validation_assertions.php | 6 +- template/file/header_type.php | 10 +- .../versions/core/classes/class_version.php | 50 ++++ .../{ => versions}/types/class_default.php | 6 +- template/{ => versions}/types/class_xhtml.php | 6 +- template/{ => versions}/types/definition.php | 6 +- .../{ => versions}/types/methods/common.php | 4 +- .../types/methods/constructor.php | 8 +- .../types/methods/constructors/default.php | 8 +- .../default_property_setter_call.php | 6 +- .../types/methods/constructors/primitive.php | 6 +- .../constructors/primitive_container.php | 8 +- .../constructors/property_setter_default.php | 2 +- .../property_setter_primitive.php | 2 +- .../property_setter_primitive_container.php | 4 +- ...esource_container_property_setter_call.php | 4 +- .../types/methods/contained_type.php | 2 +- .../types/properties/constants.php | 2 +- .../types/properties/declaration.php | 4 +- .../types/properties/methods.php | 6 +- .../types/properties/methods/default.php | 6 +- .../types/properties/methods/primitive.php | 4 +- .../methods/primitive/base64_binary_type.php | 4 +- .../methods/primitive/bool_type.php | 4 +- .../methods/primitive/date_type.php | 4 +- .../methods/primitive/datetime_type.php | 4 +- .../methods/primitive/decimal_type.php | 4 +- .../methods/primitive/instant_type.php | 4 +- .../methods/primitive/integer_type.php | 4 +- .../methods/primitive/string_type.php | 4 +- .../methods/primitive/time_type.php | 4 +- .../primitive/unsigned_integer_type.php | 4 +- .../types/serialization/json.php | 4 +- .../types/serialization/json/default.php | 6 +- .../json/default_property_default.php | 2 +- .../json/default_property_primitive_list.php | 2 +- ...ult_property_value_primitive_container.php | 2 +- .../types/serialization/json/primitive.php | 4 +- .../serialization/json/resource_container.php | 2 +- .../types/serialization/xml.php | 6 +- .../xml/primitive_xml_location_map.php | 4 +- .../serialization/xml/serialize/body.php | 8 +- .../serialization/xml/serialize/header.php | 6 +- .../xml/serialize/resource_container.php | 4 +- .../serialization/xml/unserialize/body.php | 6 +- .../unserialize/body_parse_attr_primitive.php | 2 +- .../xml/unserialize/body_parse_attr_typed.php | 2 +- .../unserialize/body_parse_node_primitive.php | 2 +- .../xml/unserialize/body_parse_node_typed.php | 4 +- .../body_parse_node_typed_default.php | 2 +- ...dy_parse_node_typed_resource_container.php | 2 +- .../serialization/xml/unserialize/header.php | 6 +- .../types/tests/integration/class.php | 12 +- .../types/tests/unit/body_base.php | 4 +- .../types/tests/unit/body_primitive.php | 6 +- .../{ => versions}/types/tests/unit/class.php | 6 +- .../types/tests/unit/header.php | 8 +- .../types/tests/validation/class.php | 18 +- .../types/validation/field_map.php | 2 +- .../types/validation/methods.php | 4 +- .../methods/collection_primitive.php | 2 +- .../validation/methods/collection_typed.php | 2 +- .../types/validation/methods/primitive.php | 2 +- .../types/validation/methods/typed.php | 2 +- 142 files changed, 1374 insertions(+), 1387 deletions(-) delete mode 100644 src/Config/VersionConfig.php delete mode 100644 src/Utilities/CopyrightUtils.php rename src/{Config => }/Version.php (58%) rename src/{ => Version}/Definition.php (75%) rename src/{ => Version}/Definition/Decorator/AnnotationElementPropertyTypeDecorator.php (82%) rename src/{ => Version}/Definition/Decorator/AnnotationElementTypeDecorator.php (87%) rename src/{ => Version}/Definition/Decorator/AnyElementTypeDecorator.php (85%) rename src/{ => Version}/Definition/Decorator/AttributeElementTypeDecorator.php (88%) rename src/{ => Version}/Definition/Decorator/ChoiceElementElementPropertyDecorator.php (91%) rename src/{ => Version}/Definition/Decorator/ChoiceElementTypeDecorator.php (88%) rename src/{ => Version}/Definition/Decorator/ComplexContentElementTypeDecorator.php (87%) rename src/{ => Version}/Definition/Decorator/ComplexTypeElementTypeDecorator.php (90%) rename src/{ => Version}/Definition/Decorator/ElementElementTypeDecorator.php (91%) rename src/{ => Version}/Definition/Decorator/ExtensionElementTypeDecorator.php (87%) rename src/{ => Version}/Definition/Decorator/RestrictionElementTypeDecorator.php (90%) rename src/{ => Version}/Definition/Decorator/SequenceElementTypeDecorator.php (87%) rename src/{ => Version}/Definition/Decorator/SimpleContentElementTypeDecorator.php (84%) rename src/{ => Version}/Definition/Decorator/SimpleTypeElementPropertyDecorator.php (80%) rename src/{ => Version}/Definition/Decorator/SimpleTypeElementTypeDecorator.php (86%) rename src/{ => Version}/Definition/Decorator/UnionElementTypeDecorator.php (86%) rename src/{ => Version}/Definition/DocumentationTrait.php (95%) rename src/{ => Version}/Definition/Enumeration.php (78%) rename src/{Definition => Version/Definition/Enumeration}/EnumerationValue.php (93%) rename src/{ => Version}/Definition/Properties.php (81%) rename src/{ => Version}/Definition/Property.php (90%) rename src/{ => Version}/Definition/SourceTrait.php (96%) rename src/{ => Version}/Definition/Type.php (85%) rename src/{ => Version}/Definition/TypeDecorationValidator.php (89%) rename src/{ => Version}/Definition/TypeDecorator.php (83%) rename src/{ => Version}/Definition/TypeExtractor.php (88%) rename src/{ => Version}/Definition/TypeImport.php (98%) rename src/{ => Version}/Definition/TypeImports.php (93%) rename src/{ => Version}/Definition/TypePropertyDecorator.php (86%) rename src/{ => Version}/Definition/Types.php (82%) create mode 100644 src/Version/VersionCopyright.php create mode 100644 src/VersionKeys.php create mode 100644 template/core/classes/class_versions.php rename src/Config/VersionKeys.php => template/core/interfaces/interface_fhir_version.php (73%) create mode 100644 template/versions/core/classes/class_version.php rename template/{ => versions}/types/class_default.php (96%) rename template/{ => versions}/types/class_xhtml.php (97%) rename template/{ => versions}/types/definition.php (87%) rename template/{ => versions}/types/methods/common.php (89%) rename template/{ => versions}/types/methods/constructor.php (84%) rename template/{ => versions}/types/methods/constructors/default.php (92%) rename template/{ => versions}/types/methods/constructors/default_property_setter_call.php (90%) rename template/{ => versions}/types/methods/constructors/primitive.php (94%) rename template/{ => versions}/types/methods/constructors/primitive_container.php (91%) rename template/{ => versions}/types/methods/constructors/property_setter_default.php (97%) rename template/{ => versions}/types/methods/constructors/property_setter_primitive.php (97%) rename template/{ => versions}/types/methods/constructors/property_setter_primitive_container.php (96%) rename template/{ => versions}/types/methods/constructors/resource_container_property_setter_call.php (96%) rename template/{ => versions}/types/methods/contained_type.php (93%) rename template/{ => versions}/types/properties/constants.php (95%) rename template/{ => versions}/types/properties/declaration.php (91%) rename template/{ => versions}/types/properties/methods.php (88%) rename template/{ => versions}/types/properties/methods/default.php (98%) rename template/{ => versions}/types/properties/methods/primitive.php (97%) rename template/{ => versions}/types/properties/methods/primitive/base64_binary_type.php (94%) rename template/{ => versions}/types/properties/methods/primitive/bool_type.php (93%) rename template/{ => versions}/types/properties/methods/primitive/date_type.php (96%) rename template/{ => versions}/types/properties/methods/primitive/datetime_type.php (97%) rename template/{ => versions}/types/properties/methods/primitive/decimal_type.php (94%) rename template/{ => versions}/types/properties/methods/primitive/instant_type.php (95%) rename template/{ => versions}/types/properties/methods/primitive/integer_type.php (95%) rename template/{ => versions}/types/properties/methods/primitive/string_type.php (92%) rename template/{ => versions}/types/properties/methods/primitive/time_type.php (95%) rename template/{ => versions}/types/properties/methods/primitive/unsigned_integer_type.php (95%) rename template/{ => versions}/types/serialization/json.php (94%) rename template/{ => versions}/types/serialization/json/default.php (94%) rename template/{ => versions}/types/serialization/json/default_property_default.php (94%) rename template/{ => versions}/types/serialization/json/default_property_primitive_list.php (94%) rename template/{ => versions}/types/serialization/json/default_property_value_primitive_container.php (97%) rename template/{ => versions}/types/serialization/json/primitive.php (91%) rename template/{ => versions}/types/serialization/json/resource_container.php (93%) rename template/{ => versions}/types/serialization/xml.php (95%) rename template/{ => versions}/types/serialization/xml/primitive_xml_location_map.php (87%) rename template/{ => versions}/types/serialization/xml/serialize/body.php (97%) rename template/{ => versions}/types/serialization/xml/serialize/header.php (93%) rename template/{ => versions}/types/serialization/xml/serialize/resource_container.php (95%) rename template/{ => versions}/types/serialization/xml/unserialize/body.php (91%) rename template/{ => versions}/types/serialization/xml/unserialize/body_parse_attr_primitive.php (93%) rename template/{ => versions}/types/serialization/xml/unserialize/body_parse_attr_typed.php (96%) rename template/{ => versions}/types/serialization/xml/unserialize/body_parse_node_primitive.php (95%) rename template/{ => versions}/types/serialization/xml/unserialize/body_parse_node_typed.php (92%) rename template/{ => versions}/types/serialization/xml/unserialize/body_parse_node_typed_default.php (95%) rename template/{ => versions}/types/serialization/xml/unserialize/body_parse_node_typed_resource_container.php (94%) rename template/{ => versions}/types/serialization/xml/unserialize/header.php (94%) rename template/{ => versions}/types/tests/integration/class.php (97%) rename template/{ => versions}/types/tests/unit/body_base.php (90%) rename template/{ => versions}/types/tests/unit/body_primitive.php (91%) rename template/{ => versions}/types/tests/unit/class.php (90%) rename template/{ => versions}/types/tests/unit/header.php (85%) rename template/{ => versions}/types/tests/validation/class.php (93%) rename template/{ => versions}/types/validation/field_map.php (96%) rename template/{ => versions}/types/validation/methods.php (97%) rename template/{ => versions}/types/validation/methods/collection_primitive.php (95%) rename template/{ => versions}/types/validation/methods/collection_typed.php (93%) rename template/{ => versions}/types/validation/methods/primitive.php (95%) rename template/{ => versions}/types/validation/methods/typed.php (93%) diff --git a/bin/config.php b/bin/config.php index 39645652..d89f5002 100644 --- a/bin/config.php +++ b/bin/config.php @@ -22,8 +22,11 @@ // The path to look look for and optionally download source XSD files to 'schemaPath' => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'input/', - // The path to place generated type class files - 'classesPath' => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'output/', + // The path to place generated files + 'outputPath' => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'output/', + + // The root namespace for all generated classes + 'rootNamespace' => '\\DCarbone\\PHPFhir\\', // If true, will use a noop null logger 'silent' => false, @@ -41,29 +44,29 @@ 'DSTU1' => [ // Source URL 'url' => 'https://hl7.org/fhir/DSTU1/fhir-all-xsd.zip', - // Namespace to prefix the generated classes with - 'namespace' => '\\HL7\\FHIR\\DSTU1', + // Namespac + 'namespace' => 'Versions\\DSTU1', // if defined, enables integration and validation test generation against the provided endpoint. 'testEndpoint' => '', ], 'DSTU2' => [ 'url' => 'https://hl7.org/fhir/DSTU2/fhir-all-xsd.zip', - 'namespace' => '\\HL7\\FHIR\\DSTU2', + 'namespace' => 'Versions\\DSTU2', 'testEndpoint' => 'https://hapi.fhir.org/baseDstu2', ], 'STU3' => [ 'url' => 'https://hl7.org/fhir/STU3/fhir-all-xsd.zip', - 'namespace' => '\\HL7\\FHIR\\STU3', + 'namespace' => 'Versions\\STU3', 'testEndpoint' => 'https://hapi.fhir.org/baseDstu3', ], 'R4' => [ 'url' => 'https://hl7.org/fhir/R4/fhir-all-xsd.zip', - 'namespace' => '\\HL7\\FHIR\\R4', + 'namespace' => 'Versions\\R4', 'testEndpoint' => 'https://hapi.fhir.org/baseR4', ], 'R5' => [ 'url' => 'https://hl7.org/fhir/R5/fhir-all-xsd.zip', - 'namespace' => '\\HL7\\FHIR\\R5', + 'namespace' => 'Versions\\R5', 'testEndpoint' => 'https://hapi.fhir.org/baseR5', ] diff --git a/bin/generate.php b/bin/generate.php index 457e3634..6f2212df 100644 --- a/bin/generate.php +++ b/bin/generate.php @@ -177,7 +177,6 @@ function missing_config_text(bool $return): string * TODO: Figure out what to do with Windows... * * @param string $q - * * @return bool */ function ask(string $q): bool @@ -186,7 +185,7 @@ function ask(string $q): bool echo "{$q} [enter \"yes\" or \"no\"]: "; while (0 !== stream_select($ins, $null, $null, null)) { foreach ($ins as $in) { - $resp = stream_get_line($in, 25, "\n"); + $resp = stream_get_line($in, 8, "\n"); if (is_string($resp)) { return str_starts_with(strtolower($resp), 'y'); } @@ -241,7 +240,7 @@ function is_dir_empty(string $dir): bool $next = trim($argv[$i + 1]); } if (str_contains($arg, '=')) { - list($arg, $next) = explode('=', $arg, 2); + [$arg, $next] = explode('=', $arg, 2); $found_equal = true; } switch ($arg) { @@ -500,7 +499,7 @@ function is_dir_empty(string $dir): bool echo sprintf( 'Generating "%s" into %s%s%s%s', $version, - $config->getClassesPath(), + $config->getOutputPath(), DIRECTORY_SEPARATOR, str_replace('\\', DIRECTORY_SEPARATOR, trim($namespace, "\\")), PHP_EOL @@ -511,7 +510,7 @@ function is_dir_empty(string $dir): bool $builder = new Builder($version_config, $definition); if ($only_library) { - $builder->writeFhirTypeFiles(); + $builder->writeFhirVersionFiles(); } elseif ($only_tests) { $builder->writeFhirTestFiles(); } else { diff --git a/composer.json b/composer.json index 691924ca..999da2d4 100644 --- a/composer.json +++ b/composer.json @@ -20,10 +20,11 @@ ], "require": { "php": "^8.1", + "ext-ctype": "*", "ext-json": "*", "ext-libxml": "*", "ext-simplexml": "*", - "psr/log": "^3.0" + "psr/log": "^3.0", }, "require-dev": { "ext-curl": "*", diff --git a/files/constants.php b/files/constants.php index 8cd46072..d469b964 100644 --- a/files/constants.php +++ b/files/constants.php @@ -78,6 +78,8 @@ const PHPFHIR_TEMPLATE_TYPE_TESTS_DIR = PHPFHIR_TEMPLATE_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'; const PHPFHIR_CLASSNAME_RESPONSE_PARSER = 'PHPFHIRResponseParser'; diff --git a/src/Builder.php b/src/Builder.php index 762c0422..6bdce50e 100644 --- a/src/Builder.php +++ b/src/Builder.php @@ -18,10 +18,8 @@ * limitations under the License. */ -use DCarbone\PHPFHIR\Config\VersionConfig; use DCarbone\PHPFHIR\Enum\TestType; use DCarbone\PHPFHIR\Render\Templates; -use DCarbone\PHPFHIR\Utilities\CopyrightUtils; use DCarbone\PHPFHIR\Utilities\FileUtils; use RuntimeException; @@ -31,58 +29,30 @@ */ class Builder { - /** @var \DCarbone\PHPFHIR\Config\VersionConfig */ - protected VersionConfig $config; - - /** @var \DCarbone\PHPFHIR\Definition */ - protected Definition $definition; + /** @var \DCarbone\PHPFHIR\Config */ + protected Config $config; /** @var \DCarbone\PHPFHIR\Logger */ private Logger $log; - /** @var bool */ - private bool $preGenerationCompleted = false; - /** - * Generator constructor. - * @param \DCarbone\PHPFHIR\Config\VersionConfig $config - * @param \DCarbone\PHPFHIR\Definition $definition + * @param \DCarbone\PHPFHIR\Config $config */ - public function __construct(VersionConfig $config, Definition $definition) + public function __construct(Config $config) { $this->config = $config; - $this->definition = $definition; $this->log = $config->getLogger(); } - - /** - * @return \DCarbone\PHPFHIR\Definition - */ - public function getDefinition(): Definition - { - $log = $this->config->getLogger(); - - if (!$this->definition->isDefined()) { - $log->startBreak('XSD Parsing'); - $this->definition->buildDefinition(); - $log->endBreak('XSD Parsing'); - } - - return $this->definition; - } - /** * Generate FHIR object classes based on XSD * @throws \ErrorException */ public function render(): void { - $this->prerender(); - $this->writeCoreTypeFiles(); - $this->writeFhirTypeFiles(); + $this->writeFhirVersionFiles(); if (!$this->config->isSkipTests()) { $this->writeFhirTestFiles(); @@ -93,7 +63,7 @@ public function render(): void * Generate FHIR classes only. * @throws \ErrorException */ - public function writeFhirTypeFiles(): void + public function writeFhirVersionFiles(): void { // register custom error handler to force explosions. set_error_handler(function ($errNum, $errStr, $errFile, $errLine) { @@ -102,31 +72,38 @@ public function writeFhirTypeFiles(): void $log = $this->config->getLogger(); - $this->prerender(); + foreach($this->config->getVersions() as $version) { + $log->startBreak(sprintf('FHIR Version %s Class Generation', $version->getName())); - $definition = $this->getDefinition(); + $definition = $version->getDefinition(); - $types = $definition->getTypes(); + if (!$definition->isDefined()) { + $log->startBreak('XSD Parsing'); + $definition->buildDefinition(); + $log->endBreak('XSD Parsing'); + } - $log->startBreak('FHIR Class Generation'); - foreach ($types->getIterator() as $type) { - $log->debug("Generating class for type {$type}..."); + $types = $definition->getTypes(); - // TODO(@dcarbone): revisit with template system refactor - if (PHPFHIR_XHTML_TYPE_NAME === $type->getFHIRName()) { - $classDefinition = Templates::renderXhtmlTypeClass($this->config, $types, $type); - } else { - $classDefinition = Templates::renderFhirTypeClass($this->config, $types, $type); - } - $filepath = FileUtils::buildTypeFilePath($this->config, $type); - if (!file_put_contents($filepath, $classDefinition)) { - throw new \RuntimeException( - sprintf( - 'Unable to write Type %s class definition to file %s', - $filepath, - $type - ) - ); + foreach ($types->getIterator() as $type) { + $log->debug("Generating class for type {$type}..."); + + // TODO(@dcarbone): revisit with template system refactor + if (PHPFHIR_XHTML_TYPE_NAME === $type->getFHIRName()) { + $classDefinition = Templates::renderXhtmlTypeClass($this->config, $version, $types, $type); + } else { + $classDefinition = Templates::renderFhirTypeClass($this->config, $version, $types, $type); + } + $filepath = FileUtils::buildTypeFilePath($this->config, $type); + if (!file_put_contents($filepath, $classDefinition)) { + throw new \RuntimeException( + sprintf( + 'Unable to write Type %s class definition to file %s', + $filepath, + $type + ) + ); + } } } $log->endBreak('FHIR Class Generation'); @@ -141,62 +118,53 @@ public function writeFhirTestFiles(): void { $log = $this->config->getLogger(); - $this->prerender(); + foreach($this->config->getVersions() as $version) { + $definition = $version->getDefinition(); - $definition = $this->getDefinition(); - $types = $definition->getTypes(); + if (!$definition->isDefined()) { + $log->startBreak('XSD Parsing'); + $definition->buildDefinition(); + $log->endBreak('XSD Parsing'); + } - $log->startBreak('Test Class Generation'); + $types = $definition->getTypes(); - $testTypes = [TestType::UNIT]; - if (null !== $this->config->getTestEndpoint()) { - $testTypes[] = TestType::INTEGRATION; - $testTypes[] = TestType::VALIDATION; - } - foreach ($types->getIterator() as $type) { + $log->startBreak('Test Class Generation'); - // skip "abstract" types - if ($type->isAbstract()) { - continue; + $testTypes = [TestType::UNIT]; + if (null !== $version->getTestEndpoint()) { + $testTypes[] = TestType::INTEGRATION; + $testTypes[] = TestType::VALIDATION; } + foreach ($types->getIterator() as $type) { - foreach ($testTypes as $testType) { - // only render integration and validation tests if this is a "resource" type - if (!$type->isResourceType() && $testType->isOneOf(TestType::INTEGRATION, TestType::VALIDATION)) { + // skip "abstract" types + if ($type->isAbstract()) { continue; } - $log->debug("Generated {$testType->value} test class for type {$type}..."); - $classDefinition = Templates::renderFhirTypeClassTest($this->config, $types, $type, $testType); - $filepath = FileUtils::buildTypeTestFilePath($this->config, $type, $testType); - if (false === file_put_contents($filepath, $classDefinition)) { - throw new RuntimeException( - sprintf( - 'Unable to write Type %s class definition to file %s', - $filepath, - $type - ) - ); + foreach ($testTypes as $testType) { + // only render integration and validation tests if this is a "resource" type + if (!$type->isResourceType() && $testType->isOneOf(TestType::INTEGRATION, TestType::VALIDATION)) { + continue; + } + + $log->debug("Generated {$testType->value} test class for type {$type}..."); + $classDefinition = Templates::renderFhirTypeClassTest($this->config, $version, $types, $type, $testType); + $filepath = FileUtils::buildTypeTestFilePath($this->config, $type, $testType); + if (false === file_put_contents($filepath, $classDefinition)) { + throw new RuntimeException( + sprintf( + 'Unable to write Type %s class definition to file %s', + $filepath, + $type + ) + ); + } } } - } - - - $log->endBreak('Test Class Generation'); - } - /** - * Commands to run prior to class generation - */ - protected function prerender(): void - { - // Initialize some classes and things. - if (!$this->preGenerationCompleted) { - $this->log->startBreak('Prerender'); - $this->log->info('Compiling Copyrights...'); - CopyrightUtils::compileCopyrights($this->config); - $this->log->endBreak('Prerender'); - $this->preGenerationCompleted = true; + $log->endBreak('Test Class Generation'); } } @@ -224,9 +192,6 @@ protected function writeCoreTypeFiles(): void { $this->log->startBreak('Core Files'); - // localize types - $types = $this->getDefinition()->getTypes(); - // render each core file foreach($this->getCoreTypeFileIterator() as $fpath => $fi) { /** @var $fi \SplFileInfo */ @@ -248,7 +213,7 @@ protected function writeCoreTypeFiles(): void $suffix = ''; } else if ('test' === $ftype) { // test classes have different namespace - $ns = $this->config->getFullyQualifiedTestsName(TestType::BASE, true); + $ns = $this->config->getFullyQualifiedName(true, TestType::BASE->value); // trim subtype $fname = substr($fname, strpos($fname, '_') + 1); } @@ -267,7 +232,7 @@ protected function writeCoreTypeFiles(): void $ns, $cname, ), - Templates::renderCoreType($fpath, $this->config, $types) + Templates::renderCoreType($fpath, $this->config) ); } diff --git a/src/Builder/TypeBuilder.php b/src/Builder/TypeBuilder.php index dd9eeeeb..082a9156 100644 --- a/src/Builder/TypeBuilder.php +++ b/src/Builder/TypeBuilder.php @@ -18,47 +18,48 @@ * limitations under the License. */ -use DCarbone\PHPFHIR\Config\VersionConfig; -use DCarbone\PHPFHIR\Definition\Property; -use DCarbone\PHPFHIR\Definition\Type; +use DCarbone\PHPFHIR\Config; +use DCarbone\PHPFHIR\Version\Definition\Property; +use DCarbone\PHPFHIR\Version\Definition\Type; +use DCarbone\PHPFHIR\Version; use SimpleXMLElement; -/** - * Class TypeBuilder - * @package DCarbone\PHPFHIR\Definition\Builder - */ abstract class TypeBuilder { /** - * @param \DCarbone\PHPFHIR\Config\VersionConfig $config + * @param \DCarbone\PHPFHIR\Config $config + * @param \DCarbone\PHPFHIR\Version $version * @param string $fhirName * @param \SimpleXMLElement $sxe * @param string $sourceFilename - * @return \DCarbone\PHPFHIR\Definition\Type + * @return \DCarbone\PHPFHIR\Version\Definition\Type */ private static function buildDefaultType( - VersionConfig $config, + Config $config, + Version $version, string $fhirName, SimpleXMLElement $sxe, string $sourceFilename ): Type { - return new Type($config, $fhirName, $sxe, $sourceFilename); + return new Type($config, $version, $fhirName, $sxe, $sourceFilename); } /** - * @param \DCarbone\PHPFHIR\Config\VersionConfig $config + * @param \DCarbone\PHPFHIR\Config $config + * @param \DCarbone\PHPFHIR\Version $version * @param string $fhirName * @param \SimpleXMLElement $sxe * @param string $sourceFilename - * @return \DCarbone\PHPFHIR\Definition\Type + * @return \DCarbone\PHPFHIR\Version\Definition\Type */ private static function buildPrimitiveType( - VersionConfig $config, + Config $config, + Version $version, string $fhirName, SimpleXMLElement $sxe, string $sourceFilename ): Type { - $type = self::buildDefaultType($config, $fhirName, $sxe, $sourceFilename); + $type = self::buildDefaultType($config, $version, $fhirName, $sxe, $sourceFilename); $value = new Property($type, $sxe, $sourceFilename); $value->setName(PHPFHIR_VALUE_PROPERTY_NAME); $type->getLocalProperties()->addProperty($value); @@ -66,17 +67,18 @@ private static function buildPrimitiveType( } /** - * @param \DCarbone\PHPFHIR\Config\VersionConfig $config + * @param \DCarbone\PHPFHIR\Config $config + * @param \DCarbone\PHPFHIR\Version $version * @param string $fhirName * @param \SimpleXMLElement $sxe * @param string $sourceFilename - * @return \DCarbone\PHPFHIR\Definition\Type + * @return \DCarbone\PHPFHIR\Version\Definition\Type */ - public static function build(VersionConfig $config, string $fhirName, SimpleXMLElement $sxe, string $sourceFilename): Type + public static function build(Config $config, Version $version, string $fhirName, SimpleXMLElement $sxe, string $sourceFilename): Type { if (str_contains($fhirName, PHPFHIR_PRIMITIVE_SUFFIX) || str_contains($fhirName, PHPFHIR_LIST_SUFFIX)) { - return self::buildPrimitiveType($config, $fhirName, $sxe, $sourceFilename); + return self::buildPrimitiveType($config, $version, $fhirName, $sxe, $sourceFilename); } - return self::buildDefaultType($config, $fhirName, $sxe, $sourceFilename); + return self::buildDefaultType($config, $version, $fhirName, $sxe, $sourceFilename); } } \ No newline at end of file diff --git a/src/Config.php b/src/Config.php index d89436fa..516f8f78 100644 --- a/src/Config.php +++ b/src/Config.php @@ -18,8 +18,6 @@ * limitations under the License. */ -use DCarbone\PHPFHIR\Config\Version; -use DCarbone\PHPFHIR\Config\VersionConfig; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; use Psr\Log\LoggerInterface; @@ -37,12 +35,12 @@ class Config implements LoggerAwareInterface private Logger $_log; /** @var string */ - private string $schemaPath; + private string $outputPath; /** @var string */ - private string $classesPath; + private string $rootnamespace; - /** @var \DCarbone\PHPFHIR\Config\VersionConfig[] */ + /** @var \DCarbone\PHPFHIR\Version[] */ private array $versions = []; /** @var bool */ @@ -52,6 +50,14 @@ class Config implements LoggerAwareInterface /** @var int|null */ private ?int $libxmlOpts; + /** @var string */ + private string $_standardDate; + + /** @var array */ + private array $_phpFHIRCopyright; + /** @var string */ + private string $_basePHPFHIRCopyrightComment; + /** * Config constructor. * @param array $params @@ -59,35 +65,55 @@ class Config implements LoggerAwareInterface */ public function __construct(array $params = [], LoggerInterface $logger = null) { - foreach (ConfigKeys::cases() as $key) { - if (isset($params[$key->value])) { - $this->{$key->value} = $params[$key->value]; + foreach(ConfigKeys::required() as $key) { + if (!isset($params[$key->value])) { + throw new \DomainException(sprintf('Missing required configuration key "%s"', $key->value)); } + $this->{"set$key->value"}($params[$key->value]); } - if (!isset($params[self::KEY_SCHEMA_PATH])) { - throw new \DomainException('Required configuration key "' . self::KEY_SCHEMA_PATH . '" missing'); - } - if (!isset($params[self::KEY_CLASSES_PATH])) { - throw new \DomainException('Required configuration key "' . self::KEY_CLASSES_PATH . '" missing'); - } - if (!isset($params[self::KEY_VERSIONS]) || !is_array($params[self::KEY_VERSIONS]) || 0 == count( - $params[self::KEY_VERSIONS] - )) { - throw new \DomainException( - 'Configuration key "' . self::KEY_VERSIONS . '" must be an array with at least 1 configured version.' - ); + + foreach(ConfigKeys::optional() as $key) { + if (isset($params[$key->value])) { + $this->{"set$key->value"}($params[$key->value]); + } } - $this->setSchemaPath($params[self::KEY_SCHEMA_PATH]); - $this->setClassesPath($params[self::KEY_CLASSES_PATH]); - $this->setVersions($params[self::KEY_VERSIONS]); - $this->setSilent(isset($params[self::KEY_SILENT]) && (bool)$params[self::KEY_SILENT]); - $this->setSkipTests($params[self::KEY_SKIP_TESTS] ?? false); - $this->setLibxmlOpts($params[self::KEY_LIBXML_OPTS] ?? null); - if ($logger && !$this->isSilent()) { + + if (null !== $logger && !$this->isSilent()) { $this->setLogger(new Logger($logger)); } else { $this->setLogger(new NullLogger()); } + + $this->_standardDate = date('F jS, Y H:iO'); + + $this->_phpFHIRCopyright = [ + 'This class was generated with the PHPFHIR library (https://github.com/dcarbone/php-fhir) using', + 'class definitions from HL7 FHIR (https://www.hl7.org/fhir/)', + '', + sprintf('Class creation date: %s', $this->_standardDate), + '', + 'PHPFHIR Copyright:', + '', + sprintf('Copyright 2016-%d Daniel Carbone (daniel.p.carbone@gmail.com)', date('Y')), + '', + 'Licensed under the Apache License, Version 2.0 (the "License");', + 'you may not use this file except in compliance with the License.', + 'You may obtain a copy of the License at', + '', + ' http://www.apache.org/licenses/LICENSE-2.0', + '', + 'Unless required by applicable law or agreed to in writing, software', + 'distributed under the License is distributed on an "AS IS" BASIS,', + 'WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.', + 'See the License for the specific language governing permissions and', + 'limitations under the License.', + '', + ]; + + $this->_basePHPFHIRCopyrightComment = sprintf( + "/*!\n * %s\n */", + implode("\n * ", $this->_phpFHIRCopyright) + ); } /** @@ -168,62 +194,37 @@ public function getLogger(): Logger /** * @return string */ - public function getSchemaPath(): string + public function getOutputPath(): string { - return $this->schemaPath; + return $this->outputPath; } /** - * @param string $schemaPath + * @param string $outputPath * @return $this */ - public function setSchemaPath(string $schemaPath): self + public function setOutputPath(string $outputPath): self { - // Bunch'o validation - if (false === is_dir($schemaPath)) { - throw new \RuntimeException('Unable to locate XSD dir "' . $schemaPath . '"'); - } - if (false === is_readable($schemaPath)) { - throw new \RuntimeException('This process does not have read access to directory "' . $schemaPath . '"'); + if (!is_dir($outputPath)) { + throw new \RuntimeException('Unable to locate output dir "' . $outputPath . '"'); } - $this->schemaPath = rtrim($schemaPath, "/\\"); - return $this; - } - - /** - * @return string - */ - public function getClassesPath(): string - { - return $this->classesPath; - } - - /** - * @param string $classesPath - * @return $this - */ - public function setClassesPath(string $classesPath): self - { - if (!is_dir($classesPath)) { - throw new \RuntimeException('Unable to locate output dir "' . $classesPath . '"'); - } - if (!is_writable($classesPath)) { + if (!is_writable($outputPath)) { throw new \RuntimeException( sprintf( 'Specified output path "%s" is not writable by this process.', - $classesPath + $outputPath ) ); } - if (!is_readable($classesPath)) { + if (!is_readable($outputPath)) { throw new \RuntimeException( sprintf( 'Specified output path "%s" is not readable by this process.', - $classesPath + $outputPath ) ); } - $this->classesPath = $classesPath; + $this->outputPath = $outputPath; return $this; } @@ -234,14 +235,14 @@ public function setClassesPath(string $classesPath): self public function setVersions(array $versions): self { $this->versions = []; - foreach ($versions as $name => $version) { - $this->versions[$name] = ($version instanceof VersionConfig) ? $version : new VersionConfig($this, new Version($name, $version)); + foreach ($versions as $name => $data) { + $this->versions[$name] = ($data instanceof Version) ? $data : new Version($this, $name, $data); } return $this; } /** - * @return \DCarbone\PHPFHIR\Config\VersionConfig[] + * @return \DCarbone\PHPFHIR\Config[] */ public function getVersions(): array { @@ -259,9 +260,9 @@ public function hasVersion(string $version): bool /** * @param string $version - * @return \DCarbone\PHPFHIR\Config\VersionConfig + * @return \DCarbone\PHPFHIR\Version */ - public function getVersion(string $version): VersionConfig + public function getVersion(string $version): Version { if (!$this->hasVersion($version)) { throw new \OutOfBoundsException( @@ -281,4 +282,43 @@ public function listVersions(): array { return array_keys($this->versions); } + + /** + * @param bool $leadingSlash + * @param string ...$bits + * @return string + */ + public function getFullyQualifiedName(bool $leadingSlash, string... $bits): string + { + $ns = $leadingSlash ? "\\$this->rootnamespace" : $this->rootnamespace; + $bits = array_filter($bits); + if ([] === $bits) { + return $ns; + } + return sprintf('%s\\%s', $ns, implode('\\' , $bits)); + } + + /** + * @return string + */ + public function getStandardDate(): string + { + return $this->_standardDate; + } + + /** + * @return array + */ + public function getPHPFHIRCopyright(): array + { + return $this->_phpFHIRCopyright; + } + + /** + * @return string + */ + public function getBasePHPFHIRCopyrightComment(): string + { + return $this->_basePHPFHIRCopyrightComment; + } } diff --git a/src/Config/VersionConfig.php b/src/Config/VersionConfig.php deleted file mode 100644 index 1c7da386..00000000 --- a/src/Config/VersionConfig.php +++ /dev/null @@ -1,123 +0,0 @@ -config = $config; - $this->version = $version; - } - - /** - * @return \DCarbone\PHPFHIR\Logger - */ - public function getLogger(): Logger - { - return $this->config->getLogger(); - } - - /** - * @return string - */ - public function getSchemaPath(): string - { - return "{$this->config->getSchemaPath()}/{$this->version->getName()}"; - } - - /** - * @return string - */ - public function getClassesPath(): string - { - return $this->config->getClassesPath(); - } - - /** - * @return string - */ - public function getUrl(): string - { - return $this->version->getSourceUrl(); - } - - - - /** - * @return bool - */ - public function isSkipTests(): bool - { - return $this->config->isSkipTests(); - } - - /** - * @return int|null - */ - public function getLibxmlOpts(): ?int - { - return $this->config->getLibxmlOpts(); - } - - - - /** - * @return string|null - */ - public function getTestEndpoint(): ?string - { - return $this->version->getTestEndpoint(); - } - - /** - * @return \DCarbone\PHPFHIR\Config - */ - public function getConfig(): Config - { - return $this->config; - } - - /** - * @return \DCarbone\PHPFHIR\Config\Version - */ - public function getVersion(): Version - { - return $this->version; - } -} \ No newline at end of file diff --git a/src/ConfigKeys.php b/src/ConfigKeys.php index 06222ff2..c10bf3cd 100644 --- a/src/ConfigKeys.php +++ b/src/ConfigKeys.php @@ -22,10 +22,30 @@ enum ConfigKeys: string { - case SCHEMA_PATH = 'schemaPath'; case OUTPUT_PATH = 'outputPath'; + case ROOT_NAMESPACE = 'rootNamespace'; case VERSIONS = 'versions'; case SILENT = 'silent'; case SKIP_TESTS = 'skipTests'; case LIBXML_OPTS = 'libxmlOpts'; + + /** + * @return \DCarbone\PHPFHIR\ConfigKeys[] + */ + public static function required(): array + { + return [ + self::OUTPUT_PATH, + self::ROOT_NAMESPACE, + self::VERSIONS, + ]; + } + + /** + * @return \DCarbone\PHPFHIR\ConfigKeys[] + */ + public static function optional(): array + { + return array_diff(ConfigKeys::cases(), self::required()); + } } \ No newline at end of file diff --git a/src/Render/Templates.php b/src/Render/Templates.php index 8fa703de..8704563d 100644 --- a/src/Render/Templates.php +++ b/src/Render/Templates.php @@ -18,9 +18,10 @@ * limitations under the License. */ -use DCarbone\PHPFHIR\Config\VersionConfig; -use DCarbone\PHPFHIR\Definition\Type; -use DCarbone\PHPFHIR\Definition\Types; +use DCarbone\PHPFHIR\Config; +use DCarbone\PHPFHIR\Version; +use DCarbone\PHPFHIR\Version\Definition\Type; +use DCarbone\PHPFHIR\Version\Definition\Types; use DCarbone\PHPFHIR\Enum\TestType; /** @@ -31,45 +32,47 @@ abstract class Templates { /** * @param string $coreFilename - * @param \DCarbone\PHPFHIR\Config\VersionConfig $config - * @param \DCarbone\PHPFHIR\Definition\Types $types + * @param \DCarbone\PHPFHIR\Config $config * @return string */ - public static function renderCoreType(string $coreFilename, VersionConfig $config, Types $types): string + public static function renderCoreType(string $coreFilename, Config $config): string { return require $coreFilename; } /** - * @param \DCarbone\PHPFHIR\Config\VersionConfig $config - * @param \DCarbone\PHPFHIR\Definition\Types $types - * @param \DCarbone\PHPFHIR\Definition\Type $type + * @param \DCarbone\PHPFHIR\Config $config + * @param \DCarbone\PHPFHIR\Version $version + * @param \DCarbone\PHPFHIR\Version\Definition\Types $types + * @param \DCarbone\PHPFHIR\Version\Definition\Type $type * @return string */ - public static function renderXhtmlTypeClass(VersionConfig $config, Types $types, Type $type): string + public static function renderXhtmlTypeClass(Config $config, Version $version, Types $types, Type $type): string { return require PHPFHIR_TEMPLATE_TYPES_DIR . DIRECTORY_SEPARATOR . 'class_xhtml.php'; } /** - * @param \DCarbone\PHPFHIR\Config\VersionConfig $config - * @param \DCarbone\PHPFHIR\Definition\Types $types - * @param \DCarbone\PHPFHIR\Definition\Type $type + * @param \DCarbone\PHPFHIR\Config $config + * @param \DCarbone\PHPFHIR\Version $version + * @param \DCarbone\PHPFHIR\Version\Definition\Types $types + * @param \DCarbone\PHPFHIR\Version\Definition\Type $type * @return string */ - public static function renderFhirTypeClass(VersionConfig $config, Types $types, Type $type): string + public static function renderFhirTypeClass(Config $config, Version $version, Types $types, Type $type): string { return require PHPFHIR_TEMPLATE_TYPES_DIR . DIRECTORY_SEPARATOR . 'class_default.php'; } /** - * @param \DCarbone\PHPFHIR\Config\VersionConfig $config - * @param \DCarbone\PHPFHIR\Definition\Types $types - * @param \DCarbone\PHPFHIR\Definition\Type $type + * @param \DCarbone\PHPFHIR\Config $config + * @param \DCarbone\PHPFHIR\Version $version + * @param \DCarbone\PHPFHIR\Version\Definition\Types $types + * @param \DCarbone\PHPFHIR\Version\Definition\Type $type * @param \DCarbone\PHPFHIR\Enum\TestType $testType * @return string */ - public static function renderFhirTypeClassTest(VersionConfig $config, Types $types, Type $type, TestType $testType): string + 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'; } diff --git a/src/Utilities/CopyrightUtils.php b/src/Utilities/CopyrightUtils.php deleted file mode 100644 index 732a859e..00000000 --- a/src/Utilities/CopyrightUtils.php +++ /dev/null @@ -1,277 +0,0 @@ -getSchemaPath()); - - $config->getLogger()->debug(sprintf('Extracting FHIR copyright from "%s"...', $fhirBase)); - - self::$_fhirCopyright = []; - $fh = fopen($fhirBase, 'rb'); - if ($fh) { - $inComment = false; - while ($line = fgets($fh)) { - $line = rtrim($line); - - if ('-->' === $line) { - break; - } - - if ($inComment) { - // needed as sometimes their comment generation breaks... - $line = str_replace(['/*', '*/'], '', $line); - - $line = html_entity_decode($line); - self::$_fhirCopyright[] = $line; - $line = ltrim($line); - if (str_starts_with($line, 'Generated on ')) { - [$generated, $version] = explode('for FHIR', $line); - - $generated = trim(str_replace('Generated on', '', $generated)); - if ('' === $generated) { - throw new \DomainException( - sprintf( - 'Unable to parse FHIR source generation date from line: %s', - $line - ) - ); - } else { - self::$_fhirGenerationDate = $generated; - } - - $version = trim($version); - if (str_starts_with($version, 'v')) { - self::$_fhirVersion = $version; - } else { - throw new \LogicException( - sprintf( - 'Unable to determine FHIR version from: %s', - $line - ) - ); - } - } - } elseif ('' === $line) { + break; + } + + if ($inComment) { + // needed as sometimes their comment generation breaks... + $line = str_replace(['/*', '*/'], '', $line); + + $line = html_entity_decode($line); + $this->_fhirCopyright[] = $line; + $line = ltrim($line); + if (str_starts_with($line, 'Generated on ')) { + [$generated, $version] = explode('for FHIR', $line); + + $generated = trim(str_replace('Generated on', '', $generated)); + if ('' === $generated) { + throw new \DomainException( + sprintf( + 'Unable to parse FHIR source generation date from line: %s', + $line + ) + ); + } else { + $this->_fhirGenerationDate = $generated; + } + + $version = trim($version); + if (str_starts_with($version, 'v')) { + $this->_fhirVersion = $version; + } else { + throw new \LogicException( + sprintf( + 'Unable to determine FHIR version from: %s', + $line + ) + ); + } + } + } elseif (' {$line}\n"; + // Extract Zip + $zip->extractTo($schema_dir); + $zip->close(); + } else { + echo "ext-zip not found, trying \"unzip\" directly..." . PHP_EOL; + $cmd = "unzip -o -qq {$schema_dir}.zip -d {$schema_dir}"; + $output = []; + $code = 0; + echo "executing: {$cmd}" . PHP_EOL; + exec($cmd, $output, $code); + if (0 !== $code) { + echo "unzip failed with code {$code}" . PHP_EOL . "output:" . PHP_EOL; + foreach ($output as $line) { + echo "-----> {$line}" . PHP_EOL; + } + exit(1); } - exit(1); } } } } +echo PHP_EOL; + // create builder $builder = new Builder($config); -echo sprintf( - "\nGenerating classes for versions: %s\n\n", - implode(', ', $versions_to_generate) -); - -$builder->render(true, $versions_to_generate); +// render entities based on flags. +$builder->render($generate_core, $generate_library ? $versions_to_generate : []); echo PHP_EOL . 'Generation completed' . PHP_EOL; diff --git a/src/Builder.php b/src/Builder.php index 7417ea11..2a762c91 100644 --- a/src/Builder.php +++ b/src/Builder.php @@ -47,8 +47,7 @@ public function __construct(Config $config) * Generate FHIR object classes based on XSD * * @param bool $coreFiles If true, will generate core PHPFHIR classes, interfaces, traits, and enums. - * @param null|array $versionNames Array of version names to limit generation to. If null, all configured versions - * will be generated. + * @param null|array $versionNames Array of version names to limit generation to. If null, all configured versions will be generated. * @throws \ErrorException * @throws \Exception */ @@ -207,7 +206,7 @@ public function writeFHIRVersionTestFiles(string ...$versionNames): void * @param array $templateArgs * @return void */ - protected function writeCoreFiles(CoreFiles $coreFiles, array $templateArgs): void + public function writeCoreFiles(CoreFiles $coreFiles, array $templateArgs): void { $this->log->startBreak('Core Files'); From 7fa882e7684c68b0f92283d595b753ac647aa920 Mon Sep 17 00:00:00 2001 From: Daniel Carbone Date: Sun, 29 Dec 2024 18:20:11 -0600 Subject: [PATCH 84/93] fixing core factory test --- template/core/tests/test_class_factory_config.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/template/core/tests/test_class_factory_config.php b/template/core/tests/test_class_factory_config.php index f44e51f4..dfec3b23 100644 --- a/template/core/tests/test_class_factory_config.php +++ b/template/core/tests/test_class_factory_config.php @@ -47,7 +47,9 @@ public function testFactoryConfigVersionArrayMissingName(): void $this->expectException(\InvalidArgumentException::class); $config = new ([ 'versions' => [ - 'class' => 'some class', + [ + 'class' => 'some class', + ], ] ]); } @@ -57,7 +59,9 @@ public function testFactoryConfigVersionArrayMissingClass(): void $this->expectException(\InvalidArgumentException::class); $config = new ([ 'versions' => [ - 'name' => 'FHIRTEST', + [ + 'name' => 'FHIRTEST', + ], ] ]); } @@ -67,8 +71,10 @@ public function testFactoryConfigVersionArrayInvalidClass(): void $this->expectException(\InvalidArgumentException::class); $config = new ([ 'versions' => [ - 'name' => 'FHIRTEST', - 'class' => \stdClass::class, + [ + 'name' => 'FHIRTEST', + 'class' => '\\mygreatclass', + ], ] ]); } From 33ed4425258dd42c5fb057f4b90d0dc2bacef35f Mon Sep 17 00:00:00 2001 From: Daniel Carbone Date: Sun, 29 Dec 2024 18:22:20 -0600 Subject: [PATCH 85/93] \Iterator -> iterable --- template/core/classes/class_factory_config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/core/classes/class_factory_config.php b/template/core/classes/class_factory_config.php index 4ed05bab..d5707224 100644 --- a/template/core/classes/class_factory_config.php +++ b/template/core/classes/class_factory_config.php @@ -124,7 +124,7 @@ public function setVersions(array $versions): self * * @return getFullyQualifiedName(true, PHPFHIR_INTERFACE_VERSION_CONFIG); ?>[] */ - public function getVersionsIterator(): \Iterator + public function getVersionsIterator(): iterable { return new \ArrayIterator($this->_versions); } From 368b7426e1266ee91dcc5f8a90bd8e9286910114 Mon Sep 17 00:00:00 2001 From: Daniel Carbone Date: Sun, 29 Dec 2024 19:22:55 -0600 Subject: [PATCH 86/93] small updates, working on fleshing out client --- src/Builder.php | 4 +-- src/Config.php | 4 ++- src/Version/Definition/Enumeration.php | 2 +- src/Version/Definition/Properties.php | 14 ++++----- src/Version/Definition/Type.php | 23 +++++++------- .../Definition/TypeDecorationValidator.php | 2 +- src/Version/Definition/TypeDecorator.php | 18 +++++------ .../Definition/TypePropertyDecorator.php | 6 ++-- src/Version/Definition/Types.php | 31 ++++++++++++++++++- .../core/classes/class_version_api_client.php | 19 +++++++++--- 10 files changed, 83 insertions(+), 40 deletions(-) diff --git a/src/Builder.php b/src/Builder.php index 2a762c91..1c927382 100644 --- a/src/Builder.php +++ b/src/Builder.php @@ -112,7 +112,7 @@ public function writeFHIRVersionFiles(string ...$versionNames): void ] ); - foreach ($types->getIterator() as $type) { + foreach ($types->getGenerator() as $type) { /** @var \DCarbone\PHPFHIR\Version\Definition\Type $type */ $log->debug("Generating class for type {$type}..."); @@ -170,7 +170,7 @@ public function writeFHIRVersionTestFiles(string ...$versionNames): void TestTypeEnum::INTEGRATION, // TestTypeEnum::VALIDATION, ]; - foreach ($types->getIterator() as $type) { + foreach ($types->getGenerator() as $type) { if ($type->isAbstract()) { continue; } diff --git a/src/Config.php b/src/Config.php index 51af02bd..c0bd3689 100644 --- a/src/Config.php +++ b/src/Config.php @@ -291,7 +291,9 @@ public function setVersions(array $versions): self */ public function getVersionsIterator(): iterable { - return new \ArrayIterator($this->_versions); + foreach ($this->_versions as $v) { + yield $v; + } } /** diff --git a/src/Version/Definition/Enumeration.php b/src/Version/Definition/Enumeration.php index 46c1bc5e..4e46c77e 100644 --- a/src/Version/Definition/Enumeration.php +++ b/src/Version/Definition/Enumeration.php @@ -73,7 +73,7 @@ public function hasValue(EnumerationValue $value): bool */ public function getIterator(): iterable { - return \SplFixedArray::fromArray($this->values); + return new \ArrayIterator($this->values); } /** diff --git a/src/Version/Definition/Properties.php b/src/Version/Definition/Properties.php index 0cd1bafe..546c0c17 100644 --- a/src/Version/Definition/Properties.php +++ b/src/Version/Definition/Properties.php @@ -44,7 +44,7 @@ class Properties implements Countable /** @var bool */ private bool $cacheBuilt = false; - /** @var \DCarbone\PHPFHIR\Config*/ + /** @var \DCarbone\PHPFHIR\Config */ private Config $config; /** @var \DCarbone\PHPFHIR\Version */ @@ -160,7 +160,7 @@ public function hasProperty(string $name): bool */ public function getAllPropertiesIterator(): iterable { - return SplFixedArray::fromArray($this->properties, preserveKeys: false); + return new \ArrayIterator($this->properties); } /** @@ -171,7 +171,7 @@ public function getAllPropertiesIterator(): iterable public function getAllSortedPropertiesIterator(): iterable { $this->_buildLocalCaches(); - return SplFixedArray::fromArray($this->_sortedProperties, preserveKeys: false); + return new \ArrayIterator($this->_sortedProperties); } /** @@ -182,7 +182,7 @@ public function getAllSortedPropertiesIterator(): iterable public function getLocalPropertiesIterator(): iterable { $this->_buildLocalCaches(); - return SplFixedArray::fromArray($this->_localProperties, preserveKeys: false); + return new \ArrayIterator($this->_localProperties); } /** @@ -193,14 +193,14 @@ public function getLocalPropertiesIterator(): iterable public function getLocalSortedPropertiesIterator(): iterable { $this->_buildLocalCaches(); - return SplFixedArray::fromArray($this->_localSortedProperties, preserveKeys: false); + return new \ArrayIterator($this->_localSortedProperties); } /** * @param \DCarbone\PHPFHIR\Enum\TypeKindEnum|null ...$kinds * @return \DCarbone\PHPFHIR\Version\Definition\Property[] */ - public function getLocalPropertiesOfTypeKinds(bool $includeCollections, null|TypeKindEnum... $kinds): iterable + public function getLocalPropertiesOfTypeKinds(bool $includeCollections, null|TypeKindEnum...$kinds): iterable { $out = []; foreach ($this->getLocalPropertiesIterator() as $property) { @@ -212,7 +212,7 @@ public function getLocalPropertiesOfTypeKinds(bool $includeCollections, null|Typ $out[] = $property; } } - return SplFixedArray::fromArray($out, preserveKeys: false); + return new \ArrayIterator($out); } /** diff --git a/src/Version/Definition/Type.php b/src/Version/Definition/Type.php index 59018bb5..75ced9cb 100644 --- a/src/Version/Definition/Type.php +++ b/src/Version/Definition/Type.php @@ -111,12 +111,13 @@ class Type * @param string $sourceFilename */ public function __construct( - Config $config, - Version $version, - string $fhirName, + Config $config, + Version $version, + string $fhirName, null|SimpleXMLElement $sourceSXE = null, - string $sourceFilename = '' - ) { + string $sourceFilename = '' + ) + { if ('' === ($fhirName = trim($fhirName))) { throw new DomainException('$fhirName must be defined'); } @@ -299,7 +300,7 @@ public function getFullyQualifiedNamespace(bool $leadingSlash): string */ public function getFullyQualifiedTestNamespace(TestTypeEnum $testType, bool $leadingSlash): string { - return $this->getVersion()->getFullyQualifiedTestsName($testType, $leadingSlash,$this->getTypeNamespace()); + return $this->getVersion()->getFullyQualifiedTestsName($testType, $leadingSlash, $this->getTypeNamespace()); } /** @@ -352,7 +353,7 @@ public function hasLocalProperties(): bool */ public function hasLocalPropertiesWithValidations(): bool { - foreach($this->getlocalProperties()->getAllSortedPropertiesIterator() as $property) { + foreach ($this->getlocalProperties()->getAllSortedPropertiesIterator() as $property) { if ([] !== $property->buildValidationMap()) { return true; } @@ -366,17 +367,17 @@ public function hasLocalPropertiesWithValidations(): bool public function getAllPropertiesIterator(): iterable { $properties = []; - foreach($this->getLocalProperties()->getLocalPropertiesIterator() as $property) { + foreach ($this->getLocalProperties()->getLocalPropertiesIterator() as $property) { $properties[$property->getName()] = $property; } - foreach($this->getParentTypes() as $parentType) { - foreach($parentType->getAllPropertiesIterator() as $property) { + foreach ($this->getParentTypes() as $parentType) { + foreach ($parentType->getAllPropertiesIterator() as $property) { if (!isset($properties[$property->getName()])) { $properties[$property->getName()] = $property; } } } - return \SplFixedArray::fromArray($properties, false); + return new \ArrayIterator($properties); } /** diff --git a/src/Version/Definition/TypeDecorationValidator.php b/src/Version/Definition/TypeDecorationValidator.php index 7f096012..de871958 100644 --- a/src/Version/Definition/TypeDecorationValidator.php +++ b/src/Version/Definition/TypeDecorationValidator.php @@ -40,7 +40,7 @@ public static function validateDecoration(Config $config, Version $version, Type $versionName = $version->getName(); $seenClasses = []; - foreach ($types->getIterator() as $type) { + foreach ($types->getGenerator() as $type) { $typeKind = $type->getKind(); if ($type->isRootType()) { diff --git a/src/Version/Definition/TypeDecorator.php b/src/Version/Definition/TypeDecorator.php index 9de6caaf..9e28164b 100644 --- a/src/Version/Definition/TypeDecorator.php +++ b/src/Version/Definition/TypeDecorator.php @@ -39,7 +39,7 @@ abstract class TypeDecorator */ public static function findComponentOfTypes(Config $config, Types $types): void { - foreach ($types->getIterator() as $type) { + foreach ($types->getGenerator() as $type) { $fhirName = $type->getFHIRName(); if (!str_contains($fhirName, '.')) { continue; @@ -67,7 +67,7 @@ public static function findComponentOfTypes(Config $config, Types $types): void public static function findRestrictionBaseTypes(Version $version, Types $types): void { $logger = $version->getConfig()->getLogger(); - foreach ($types->getIterator() as $type) { + foreach ($types->getGenerator() as $type) { $fhirName = $type->getFHIRName(); // skip primitive types as they are already as base as they can go @@ -128,7 +128,7 @@ public static function findParentTypes(Config $config, Types $types): void static $knownInteger = ['totalResults']; $logger = $config->getLogger(); - foreach ($types->getIterator() as $type) { + foreach ($types->getGenerator() as $type) { $fhirName = $type->getFHIRName(); // try to locate parent type name... @@ -184,7 +184,7 @@ public static function findParentTypes(Config $config, Types $types): void public static function determinePrimitiveTypes(Config $config, Types $types): void { $logger = $config->getLogger(); - foreach ($types->getIterator() as $type) { + foreach ($types->getGenerator() as $type) { if (in_array($type->getFHIRName(), self::DSTU1_PRIMITIVES, true)) { $ptn = PrimitiveTypeEnum::STRING->value; $logger->debug(sprintf('(DSTU1 suppport) Type "%s" determined to be DSTU1 primitive', $type->getFHIRName())); @@ -343,7 +343,7 @@ private static function determineParsedTypeKind(Config $config, Version $version */ public static function determineParsedTypeKinds(Config $config, Version $version, Types $types): void { - foreach ($types->getIterator() as $type) { + foreach ($types->getGenerator() as $type) { self::determineParsedTypeKind($config, $version, $types, $type); } } @@ -357,7 +357,7 @@ public static function setContainedTypeFlag(Config $config, Version $version, Ty { $versionName = $version->getName(); - foreach ($types->getIterator() as $type) { + foreach ($types->getGenerator() as $type) { if ($types->isContainedType($type)) { $type->setContainedType(true); } @@ -376,7 +376,7 @@ public static function setValueContainerFlag(Config $config, Types $types): void TypeKindEnum::QUANTITY, ]; - foreach ($types->getIterator() as $type) { + foreach ($types->getGenerator() as $type) { // TODO: handle valueString, valueQuantity, etc. types? // skip primitive types and their child types @@ -410,7 +410,7 @@ public static function setValueContainerFlag(Config $config, Types $types): void public static function setCommentContainerFlag(Config $config, Types $types): void { static $skip = [TypeKindEnum::PRIMITIVE, TypeKindEnum::PHPFHIR_XHTML]; - foreach ($types->getIterator() as $type) { + foreach ($types->getGenerator() as $type) { $type->setCommentContainer( !$type->hasPrimitiveParent() && !$type->getKind()->isOneOf(...$skip) ); @@ -424,7 +424,7 @@ public static function setCommentContainerFlag(Config $config, Types $types): vo public static function parseUnionMemberTypes(Config $config, Types $types): void { $log = $config->getLogger(); - foreach ($types->getIterator() as $type) { + foreach ($types->getGenerator() as $type) { $unionOf = $type->getUnionOf(); if ([] === $unionOf) { continue; diff --git a/src/Version/Definition/TypePropertyDecorator.php b/src/Version/Definition/TypePropertyDecorator.php index 06a7e528..34a793d4 100644 --- a/src/Version/Definition/TypePropertyDecorator.php +++ b/src/Version/Definition/TypePropertyDecorator.php @@ -117,7 +117,7 @@ public static function findPropertyType(Config $config, Types $types, Type $type */ public static function findPropertyTypes(Config $config, Types $types): void { - foreach ($types->getIterator() as $type) { + foreach ($types->getGenerator() as $type) { foreach ($type->getLocalProperties()->getAllPropertiesIterator() as $property) { self::findPropertyType($config, $types, $type, $property); } @@ -131,7 +131,7 @@ public static function findPropertyTypes(Config $config, Types $types): void public static function findOverloadedProperties(Config $config, Types $types): void { $logger = $config->getLogger(); - foreach ($types->getIterator() as $type) { + foreach ($types->getGenerator() as $type) { if (!$type->hasParent()) { continue; } @@ -166,7 +166,7 @@ public static function findOverloadedProperties(Config $config, Types $types): v public static function setMissingPropertyNames(Config $config, Types $types): void { $log = $config->getLogger(); - foreach ($types->getIterator() as $type) { + foreach ($types->getGenerator() as $type) { foreach ($type->getLocalProperties()->getAllPropertiesIterator() as $property) { $propName = $property->getName(); if ('' === $propName || null === $propName) { diff --git a/src/Version/Definition/Types.php b/src/Version/Definition/Types.php index e1bf023b..5c95733e 100644 --- a/src/Version/Definition/Types.php +++ b/src/Version/Definition/Types.php @@ -157,7 +157,17 @@ public function addType(Type &$type): Types */ public function getIterator(): iterable { - return new ArrayIterator($this->types); + return new \ArrayIterator($this->types); + } + + /** + * @return \DCarbone\PHPFHIR\Version\Definition\Type[] + */ + public function getGenerator(): iterable + { + foreach($this->types as $type) { + yield $type; + } } /** @@ -253,6 +263,25 @@ public function getBundleType(): null|Type return $this->bundleType ?? null; } + /** + * @param string|\DCarbone\PHPFHIR\Version\Definition\Type $type + * @return \DCarbone\PHPFHIR\Version\Definition\Type[] + */ + public function getChildrenOf(string|Type $type): iterable + { + if (is_string($type)) { + $type = $this->getTypeByName($type); + if (null === $type) { + return; + } + } + foreach ($this->types as $t) { + if (in_array($type, $t->getParentTypes(), true)) { + yield $t; + } + } + } + /** * @return int */ diff --git a/template/versions/core/classes/class_version_api_client.php b/template/versions/core/classes/class_version_api_client.php index fa0acc1d..67f83187 100644 --- a/template/versions/core/classes/class_version_api_client.php +++ b/template/versions/core/classes/class_version_api_client.php @@ -19,7 +19,9 @@ /** @var \DCarbone\PHPFHIR\Version $version */ $config = $version->getConfig(); +$types = $version->getDefinition()->getTypes(); $namespace = $version->getFullyQualifiedName(false); +$bundleType = $types->getBundleType(); ob_start(); echo ' declare(strict_types=1); @@ -77,10 +79,10 @@ public function __construct( $client, * @throws \Exception */ public function readRaw(string| $resourceType, - int $count = 1, - null| $sort = null, - null| $format = null, - null|bool $parseheaders = null): + int $count = 1, + null| $sort = null, + null| $format = null, + null|bool $parseheaders = null): { if (!is_string($resourceType)) { @@ -146,5 +148,14 @@ protected function _requireOK(($rc, self::_STATUS_OK); } } +getChildrenOf('Resource') as $rsc) : if ($rsc->isAbstract()) { continue; } ?> + + public function readgetFHIRName(); ?>Raw(int $count = 1, null| $sort = null, null| $format = null, null|bool $parseheaders = null): + + { + return $this->readRaw(::getConstName(false); ?>, $count, $sort, $format, $parseheaders); + } + + } Date: Sun, 29 Dec 2024 23:00:36 -0600 Subject: [PATCH 87/93] simplfying templates a bit, adding ID access for resources in client, few other small fixes --- src/Version/Definition/Type.php | 2 +- src/Version/Definition/TypeImports.php | 5 +- .../core/classes/class_version_api_client.php | 47 ++++++-- template/versions/types/serialization/xml.php | 2 - .../serialization/xml/unserialize/body.php | 103 +++++++++++------- .../unserialize/body_parse_attr_primitive.php | 27 ----- .../xml/unserialize/body_parse_attr_typed.php | 44 -------- .../unserialize/body_parse_node_primitive.php | 35 ------ .../xml/unserialize/body_parse_node_typed.php | 52 --------- .../body_parse_node_typed_default.php | 32 ------ ...dy_parse_node_typed_resource_container.php | 34 ------ 11 files changed, 108 insertions(+), 275 deletions(-) delete mode 100644 template/versions/types/serialization/xml/unserialize/body_parse_attr_primitive.php delete mode 100644 template/versions/types/serialization/xml/unserialize/body_parse_attr_typed.php delete mode 100644 template/versions/types/serialization/xml/unserialize/body_parse_node_primitive.php delete mode 100644 template/versions/types/serialization/xml/unserialize/body_parse_node_typed.php delete mode 100644 template/versions/types/serialization/xml/unserialize/body_parse_node_typed_default.php delete mode 100644 template/versions/types/serialization/xml/unserialize/body_parse_node_typed_resource_container.php diff --git a/src/Version/Definition/Type.php b/src/Version/Definition/Type.php index 75ced9cb..8e3d3e33 100644 --- a/src/Version/Definition/Type.php +++ b/src/Version/Definition/Type.php @@ -377,7 +377,7 @@ public function getAllPropertiesIterator(): iterable } } } - return new \ArrayIterator($properties); + return \SplFixedArray::fromArray($properties, preserveKeys: false); } /** diff --git a/src/Version/Definition/TypeImports.php b/src/Version/Definition/TypeImports.php index a58e1705..f8164d07 100644 --- a/src/Version/Definition/TypeImports.php +++ b/src/Version/Definition/TypeImports.php @@ -221,10 +221,13 @@ private function buildImports(): void $pns = $parentType->getFullyQualifiedNamespace(false); $this->addImport($parentType->getClassName(), $pns); } else { - $this->addImport(PHPFHIR_CLASSNAME_VALIDATOR, $configNS); $this->addImport(PHPFHIR_TRAIT_SOURCE_XMLNS, $configNS); } + if ($this->type->hasLocalPropertiesWithValidations()) { + $this->addImport(PHPFHIR_CLASSNAME_VALIDATOR, $configNS); + } + // determine if we need to import a restriction base if ($restrictionBaseType = $this->type->getRestrictionBaseFHIRType()) { $rns = $restrictionBaseType->getFullyQualifiedNamespace(false); diff --git a/template/versions/core/classes/class_version_api_client.php b/template/versions/core/classes/class_version_api_client.php index 67f83187..d9c831b4 100644 --- a/template/versions/core/classes/class_version_api_client.php +++ b/template/versions/core/classes/class_version_api_client.php @@ -18,11 +18,16 @@ /** @var \DCarbone\PHPFHIR\Version $version */ +use DCarbone\PHPFHIR\Enum\TypeKindEnum; + $config = $version->getConfig(); $types = $version->getDefinition()->getTypes(); $namespace = $version->getFullyQualifiedName(false); $bundleType = $types->getBundleType(); +$idType = $types->getTypeByName('id'); +$idPrimitiveType = $types->getTypeByName('id-primitive'); + ob_start(); echo ' declare(strict_types=1); @@ -40,6 +45,7 @@ use getFullyQualifiedName(false, PHPFHIR_ENUM_API_SORT); ?>; use getFullyQualifiedName(false, PHPFHIR_CLASSNAME_RESPONSE_PARSER); ?>; use getFullyQualifiedName(false, PHPFHIR_INTERFACE_TYPE); ?>; +use getFullyQualifiedClassName(false); ?>; class @@ -70,7 +76,8 @@ public function __construct( $client, * @see https://www.hl7.org/fhir/http.html#read * * @param string| $resourceType - * @param int $count + * @param null|string|getFullyQualifiedClassName(true); ?>|getFullyQualifiedClassName(true); ?> $resourceID + * @param null|int $count * @param null| $sort * @param null| $format * @param null|bool $parseheaders @@ -79,7 +86,8 @@ public function __construct( $client, * @throws \Exception */ public function readRaw(string| $resourceType, - int $count = 1, + null|string|getClassName(); ?>|getClassName(); ?> $resourceID = null, + null|int $count = null, null| $sort = null, null| $format = null, null|bool $parseheaders = null): @@ -92,7 +100,12 @@ public function readRaw(string| $resourc $req = new (); $req->method = 'GET'; $req->path = "/{$resourceType}"; - $req->count = $count; + if (null !== $resourceID) { + $req->path .= "/{$resourceID}"; + } + if (null !== $count) { + $req->count = $count; + } if (null !== $sort) { $req->sort = $sort; } @@ -112,7 +125,8 @@ public function readRaw(string| $resourc * @see https://www.hl7.org/fhir/http.html#read * * @param string| $resourceType - * @param int $count + * @param null|string|getFullyQualifiedClassName(true); ?>|getFullyQualifiedClassName(true); ?> $resourceID + * @param null|int $count * @param null| $sort * @param null| $format * @param null|bool $parseheaders @@ -121,13 +135,14 @@ public function readRaw(string| $resourc * @throws \Exception */ public function read(string| $resourceType, - int $count = 1, + null|string|getClassName(); ?>|getClassName(); ?> $resourceID = null, + null|int $count = null, null| $sort = null, null| $format = null, null|bool $parseheaders = null): null| { - $rc = $this->readRaw($resourceType, $count, $sort, $format, $parseheaders); + $rc = $this->readRaw($resourceType, $resourceID, $count, $sort, $format, $parseheaders); $this->_requireOK($rc); return ::parse($this->_version, $rc->resp); } @@ -148,12 +163,26 @@ protected function _requireOK(($rc, self::_STATUS_OK); } } -getChildrenOf('Resource') as $rsc) : if ($rsc->isAbstract()) { continue; } ?> +getChildrenOf('Resource') as $rsc) : + $typeKind = $rsc->getKind(); + if ($rsc->isRootType() || $typeKind->isContainer($version) || $typeKind->isOneOf(TypeKindEnum::RESOURCE_COMPONENT)) { continue; } ?> - public function readgetFHIRName(); ?>Raw(int $count = 1, null| $sort = null, null| $format = null, null|bool $parseheaders = null): + /** + * Query for one or more getFHIRName(); ?> resources. + * + * @param null|string|getFullyQualifiedClassName(true); ?>|getFullyQualifiedClassName(true); ?> $resourceID + * @param null|int $count + * @param null| $sort + * @param null| $format + * @param null|bool $parseheaders + * @return getFullyQualifiedName(true, PHPFHIR_CLASSNAME_API_CLIENT_RESPONSE); ?> + + * @throws \Exception + */ + public function readgetFHIRName(); ?>Raw(null|string|getClassName(); ?>|getClassName(); ?> $resourceID = null, null|int $count = null, null| $sort = null, null| $format = null, null|bool $parseheaders = null): { - return $this->readRaw(::getConstName(false); ?>, $count, $sort, $format, $parseheaders); + return $this->readRaw(::getConstName(false); ?>, $resourceID, $count, $sort, $format, $parseheaders); } diff --git a/template/versions/types/serialization/xml.php b/template/versions/types/serialization/xml.php index fadea234..9b641602 100644 --- a/template/versions/types/serialization/xml.php +++ b/template/versions/types/serialization/xml.php @@ -43,8 +43,6 @@ ] ); -// when unserializing, each type handles _every_ field directly. this includes fields inherited from parents. - if (0 < count($properties)) : echo require_with( PHPFHIR_TEMPLATE_VERSION_TYPES_SERIALIZATION_DIR . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'unserialize' . DIRECTORY_SEPARATOR . 'body.php', diff --git a/template/versions/types/serialization/xml/unserialize/body.php b/template/versions/types/serialization/xml/unserialize/body.php index b5482f17..6d5231de 100644 --- a/template/versions/types/serialization/xml/unserialize/body.php +++ b/template/versions/types/serialization/xml/unserialize/body.php @@ -20,6 +20,8 @@ /** @var \DCarbone\PHPFHIR\Version\Definition\Type $type */ /** @var \DCarbone\PHPFHIR\Version\Definition\Property[] $properties */ +use DCarbone\PHPFHIR\Enum\TypeKindEnum; + $requireArgs = [ 'version' => $version, ]; @@ -27,45 +29,70 @@ ob_start(); ?> foreach ($element->children() as $n) { $childName = $n->getName(); - $property) { - if (null !== $property->getValueFHIRType()) { - echo require_with( - __DIR__ . DIRECTORY_SEPARATOR . 'body_parse_node_typed.php', - $requireArgs + [ - 'property' => $property, - 'i' => $i, - ] - ); - } else { - echo require_with( - __DIR__ . DIRECTORY_SEPARATOR . 'body_parse_node_primitive.php', - $requireArgs + [ - 'property' => $property, - 'i' => $i, - ] - ); - } -}; ?> + $property) : + $propConst = $property->getFieldConstantName(); + $propType = $property->getValueFHIRType(); + $setter = $property->getSetterName(); + + if ($i > 0) : ?> else getKind(); + $propTypeClassname = $property->getMemberOf()->getImports()->getImportByType($propType); + + if ($propTypeKind->isContainer($version)) : ?> + if (self:: === $childName) { + foreach ($n->children() as $nn) { + $typeClassName = ::getContainedTypeClassNameFromXML($nn); + $type->($typeClassName::xmlUnserialize($nn, null, $config)); + } + }if (self:: === $childName) { + $type->(::xmlUnserialize($n, null, $config)hasPrimitiveParent() || $propType->getKind()->isOneOf(TypeKindEnum::PRIMITIVE, TypeKindEnum::LIST, TypeKindEnum::PRIMITIVE_CONTAINER)) : ?>, ::ELEMENT); + }if (self:: === $childName) { + $valueAttr = $n->attributes()[self::FIELD_VALUE] ?? null; + if (null !== $valueAttr) { + $type->setValue((string)$valueAttr); + } elseif ($n->hasChildren()) { + $type->setValue($n->saveXML()); + } else { + $type->setValue((string)$n); + } + } } $attributes = $element->attributes(); - $property) { - if (null !== $property->getValueFHIRType()) { - echo require_with( - __DIR__ . DIRECTORY_SEPARATOR . 'body_parse_attr_typed.php', - $requireArgs + [ - 'property' => $property, - 'i' => $i, - ] - ); - } else { - echo require_with( - __DIR__ . DIRECTORY_SEPARATOR . 'body_parse_attr_primitive.php', - $requireArgs + [ - 'property' => $property, - 'i' => $i, - ] - ); - } -} + $property) : + $propConst = $property->getFieldConstantName(); + $propType = $property->getValueFHIRType(); + $setter = $property->getSetterName(); + + if (null !== $propType) : + $propTypeKind = $propType->getKind(); + $propTypeClassname = $property->getMemberOf()->getImports()->getImportByType($propType); + + if ($propType->hasPrimitiveParent() || $propType->getKind()->isOneOf(TypeKindEnum::PRIMITIVE, TypeKindEnum::LIST, TypeKindEnum::PRIMITIVE_CONTAINER)) : ?> + if (isset($attributes[self::])) { +isCollection()) : ?> + $type->((string)$attributes[self::], ::ATTRIBUTE); + + $pt = $type->getGetterName(); ?>(); + if (null !== $pt) { + $pt->setValue((string)$attributes[self::], ::ATTRIBUTE); + } else { + $type->((string)$attributes[self::], ::ATTRIBUTE); + } + + } + + if (isset($attributes[self::getFieldConstantName(); ?>])) { + $type->setValue((string)$attributes[self::getFieldConstantName(); ?>], ::ATTRIBUTE); + } +getValueFHIRType(); - -ob_start(); ?> - if (isset($attributes[self::getFieldConstantName(); ?>])) { - $type->setValue((string)$attributes[self::getFieldConstantName(); ?>], ::ATTRIBUTE); - } -getValueFHIRType(); -$propertyTypeClassName = $property->getMemberOf()->getImports()->getImportByType($propertyType); -$propertyName = $property->getName(); -$propertyConst = $property->getFieldConstantName(); -$setter = $property->getSetterName(); - -ob_start(); -if ($propertyType->hasPrimitiveParent() || $propertyType->getKind()->isOneOf(TypeKindEnum::PRIMITIVE, TypeKindEnum::LIST, TypeKindEnum::PRIMITIVE_CONTAINER)) : ?> - if (isset($attributes[self::])) { -isCollection()) : ?> - $type->((string)$attributes[self::], ::ATTRIBUTE); - - $pt = $type->getGetterName(); ?>(); - if (null !== $pt) { - $pt->setValue((string)$attributes[self::], ::ATTRIBUTE); - } else { - $type->((string)$attributes[self::], ::ATTRIBUTE); - } - - } -getValueFHIRType(); -$propConst = $property->getFieldConstantName(); - -ob_start(); -if ($i > 0) : ?> else if (self:: === $childName) { - $valueAttr = $n->attributes()[self::FIELD_VALUE] ?? null; - if (null !== $valueAttr) { - $type->setValue((string)$valueAttr); - } elseif ($n->hasChildren()) { - $type->setValue($n->saveXML()); - } else { - $type->setValue((string)$n); - } - }getValueFHIRType(); -$propertyTypeKind = $propertyType->getKind(); - -$requireArgs = [ - 'version' => $version, -]; - -ob_start(); - -echo match ($propertyTypeKind) { - TypeKindEnum::RESOURCE_CONTAINER, TypeKindEnum::RESOURCE_INLINE => require_with( - __DIR__ . DIRECTORY_SEPARATOR . 'body_parse_node_typed_resource_container.php', - $requireArgs + [ - 'property' => $property, - 'i' => $i, - ] - ), - - default => require_with( - __DIR__ . DIRECTORY_SEPARATOR . 'body_parse_node_typed_default.php', - $requireArgs + [ - 'property' => $property, - 'i' => $i, - ] - ) -}; - -return ob_get_clean(); \ No newline at end of file diff --git a/template/versions/types/serialization/xml/unserialize/body_parse_node_typed_default.php b/template/versions/types/serialization/xml/unserialize/body_parse_node_typed_default.php deleted file mode 100644 index 7f9dd325..00000000 --- a/template/versions/types/serialization/xml/unserialize/body_parse_node_typed_default.php +++ /dev/null @@ -1,32 +0,0 @@ -getValueFHIRType(); -$propTypeClassname = $property->getMemberOf()->getImports()->getImportByType($propType); -$propConst = $property->getFieldConstantName(); -$setter = $property->getSetterName(); - -ob_start(); -if ($i > 0) : ?> else if (self:: === $childName) { - $type->(::xmlUnserialize($n, null, $config)hasPrimitiveParent() || $propType->getKind()->isOneOf(TypeKindEnum::PRIMITIVE, TypeKindEnum::LIST, TypeKindEnum::PRIMITIVE_CONTAINER)) : ?>, ::ELEMENT); - }getConfig(); -$setter = $property->getSetterName(); -$propertyName = $property->getName(); -$propertyConst = $property->getFieldConstantName(); - -ob_start(); -if ($i > 0) : ?> else if (self:: === $childName) { - foreach ($n->children() as $nn) { - $typeClassName = ::getContainedTypeClassNameFromXML($nn); - $type->($typeClassName::xmlUnserialize($nn, null, $config)); - } - } Date: Sun, 29 Dec 2024 23:07:38 -0600 Subject: [PATCH 88/93] more template coalescing --- .../types/serialization/json/default.php | 87 ++++++++++++++----- .../json/default_property_default.php | 37 -------- .../json/default_property_primitive_list.php | 34 -------- ...ult_property_value_primitive_container.php | 64 -------------- 4 files changed, 66 insertions(+), 156 deletions(-) delete mode 100644 template/versions/types/serialization/json/default_property_default.php delete mode 100644 template/versions/types/serialization/json/default_property_primitive_list.php delete mode 100644 template/versions/types/serialization/json/default_property_value_primitive_container.php diff --git a/template/versions/types/serialization/json/default.php b/template/versions/types/serialization/json/default.php index ccd704fc..b9af2582 100644 --- a/template/versions/types/serialization/json/default.php +++ b/template/versions/types/serialization/json/default.php @@ -40,34 +40,79 @@ public function jsonSerialize(): mixed } getFieldConstantName(); + $propConstExt = $property->getFieldConstantExtensionName(); + $getter = $property->getGetterName(); + if ($property->isOverloaded()) : continue; endif; $propertyType = $property->getValueFHIRType(); if ($propertyType->getKind()->isOneOf(TypeKindEnum::PRIMITIVE, TypeKindEnum::LIST)) : - echo require_with( - __DIR__ . DIRECTORY_SEPARATOR . 'default_property_primitive_list.php', - [ - 'version' => $version, - 'property' => $property - ] - ); + if ($property->isCollection()) : ?> + if ([] !== ($vs = $this->())) { + $out->{self::} = $vs; + } + + if (null !== ($v = $this->())) { + $out->{self::} = $v; + } +isValueContainer() || $propertyType->getKind() === TypeKindEnum::PRIMITIVE_CONTAINER || $propertyType->hasPrimitiveContainerParent()) : - echo require_with( - __DIR__ . DIRECTORY_SEPARATOR . 'default_property_value_primitive_container.php', - [ - 'version' => $version, - 'property' => $property - ] - ); + $propTypeClassname = $property->getValueFHIRType()->getClassName(); + + if ($property->isCollection()) : ?> + if ([] !== ($vs = $this->())) { + $vals = []; + $exts = []; + foreach ($vs as $v) { + if (null === $v) { + continue; + } + $val = $v->getValue(); + $ext = $v->jsonSerialize(); + unset($ext->{::FIELD_VALUE}); + if (null !== $val) { + $vals[] = $val; + } + if ([] !== $ext) { + $exts[] = $ext; + } + } + if ([] !== $vals) { + $out->{self::} = $vals; + } + if (count((array)$ext) > 0) { + $out->{self::} = $exts; + } + } + + if (null !== ($v = $this->())) { + if (null !== ($val = $v->getValue())) { + $out->{self::} = $val; + } + $ext = $v->jsonSerialize(); + unset($ext->{::FIELD_VALUE}); + if (count((array)$ext) > 0) { + $out->{self::} = $ext; + } + } + $version, - 'property' => $property - ] - ); + if ($property->isCollection()) : ?> + if ([] !== ($vs = $this->())) { + $out->{self::} = []; + foreach($vs as $v) { + $out->{self::}[] = $v; + } + } + + if (null !== ($v = $this->())) { + $out->{self::} = $v; + } +isCommentContainer() && !$type->hasCommentContainerParent()) : ?> diff --git a/template/versions/types/serialization/json/default_property_default.php b/template/versions/types/serialization/json/default_property_default.php deleted file mode 100644 index cb0de0a3..00000000 --- a/template/versions/types/serialization/json/default_property_default.php +++ /dev/null @@ -1,37 +0,0 @@ -getFieldConstantName(); -$getter = $property->getGetterName(); - -ob_start(); -if ($property->isCollection()) : ?> - if ([] !== ($vs = $this->())) { - $out->{self::} = []; - foreach($vs as $v) { - $out->{self::}[] = $v; - } - } - - if (null !== ($v = $this->())) { - $out->{self::} = $v; - } -getFieldConstantName(); -$getter = $property->getGetterName(); - -ob_start(); -if ($property->isCollection()) : ?> - if ([] !== ($vs = $this->())) { - $out->{self::} = $vs; - } - - if (null !== ($v = $this->())) { - $out->{self::} = $v; - } -getValueFHIRType()->getClassName(); -$propertyFieldConst = $property->getFieldConstantName(); -$propertyFieldConstExt = $property->getFieldConstantExtensionName(); -$getter = $property->getGetterName(); - -ob_start(); -if ($property->isCollection()) : ?> - if ([] !== ($vs = $this->())) { - $vals = []; - $exts = []; - foreach ($vs as $v) { - if (null === $v) { - continue; - } - $val = $v->getValue(); - $ext = $v->jsonSerialize(); - unset($ext->{::FIELD_VALUE}); - if (null !== $val) { - $vals[] = $val; - } - if ([] !== $ext) { - $exts[] = $ext; - } - } - if ([] !== $vals) { - $out->{self::} = $vals; - } - if (count((array)$ext) > 0) { - $out->{self::} = $exts; - } - } - - if (null !== ($v = $this->())) { - if (null !== ($val = $v->getValue())) { - $out->{self::} = $val; - } - $ext = $v->jsonSerialize(); - unset($ext->{::FIELD_VALUE}); - if (count((array)$ext) > 0) { - $out->{self::} = $ext; - } - } - Date: Mon, 30 Dec 2024 10:58:28 -0600 Subject: [PATCH 89/93] validations cleanup and fleshing out api client a little bit --- src/Version/Definition/Property.php | 3 - .../classes/class_api_client_response.php | 50 +++++++++-- .../core/classes/class_version_api_client.php | 60 ++++++++------ .../interface_version_contained_type.php | 4 - template/versions/types/class_default.php | 2 +- .../types/properties/methods/default.php | 38 ++++++++- .../validation/{field_map.php => const.php} | 4 +- .../versions/types/validation/methods.php | 82 ++++++++++++------- .../methods/collection_primitive.php | 35 -------- .../validation/methods/collection_typed.php | 30 ------- .../types/validation/methods/primitive.php | 34 -------- .../types/validation/methods/typed.php | 28 ------- 12 files changed, 171 insertions(+), 199 deletions(-) rename template/versions/types/validation/{field_map.php => const.php} (89%) delete mode 100644 template/versions/types/validation/methods/collection_primitive.php delete mode 100644 template/versions/types/validation/methods/collection_typed.php delete mode 100644 template/versions/types/validation/methods/primitive.php delete mode 100644 template/versions/types/validation/methods/typed.php diff --git a/src/Version/Definition/Property.php b/src/Version/Definition/Property.php index 9fa1bd24..e98c2a35 100644 --- a/src/Version/Definition/Property.php +++ b/src/Version/Definition/Property.php @@ -397,7 +397,6 @@ public function buildValidationMap(): array $map = []; $memberOf = $this->getMemberOf(); - $pattern = $this->getPattern(); if (null === $pattern) { $pattern = $memberOf->getPattern(); @@ -433,8 +432,6 @@ public function buildValidationMap(): array } } - - return $map; } diff --git a/template/core/classes/class_api_client_response.php b/template/core/classes/class_api_client_response.php index 2dcb0845..47773991 100644 --- a/template/core/classes/class_api_client_response.php +++ b/template/core/classes/class_api_client_response.php @@ -27,11 +27,11 @@ getBasePHPFHIRCopyrightComment(false); ?> -final class +class { /** - * Request method. + * HTTP request method. * * @var string */ @@ -45,14 +45,14 @@ final class public string $url; /** - * Response status code + * HTTP response status code. * * @var int */ public int $code; /** - * Response headers. + * HTTP response headers. * * @var getFullyQualifiedName(true, PHPFHIR_CLASSNAME_API_CLIENT_RESPONSE_HEADERS); ?> @@ -60,24 +60,60 @@ final class public $headers; /** - * Response body. + * HTTP response body. * * @var string */ public string $resp; /** - * CURL error message. + * Client error. * * @var string */ public string $err; /** - * CURL error number. + * Client error number. * * @var int */ public int $errno; + + public function getMethod(): null|string + { + return $this->method ?? null; + } + + public function getUrl(): null|string + { + return $this->url ?? null; + } + + public function getCode(): null|int + { + return $this->code ?? null; + } + + public function getHeaders(): null| + + { + return $this->headers ?? null; + } + + public function getResp(): null|string + { + return $this->resp ?? null; + } + + public function getErr(): null|string + { + return $this->err ?? null; + } + + public function getErrno(): null|int + { + return $this->errno ?? null; + } } $client, * * @see https://www.hl7.org/fhir/http.html#read * - * @param string| $resourceType + * @param string|getFullyQualifiedName(true, PHPFHIR_ENUM_VERSION_TYPE); ?> $resourceType * @param null|string|getFullyQualifiedClassName(true); ?>|getFullyQualifiedClassName(true); ?> $resourceID * @param null|int $count - * @param null| $sort - * @param null| $format - * @param null|bool $parseheaders + * @param null|getFullyQualifiedName(true, PHPFHIR_ENUM_API_SORT); ?> $sort + * @param null|getFullyQualifiedName(true, PHPFHIR_ENUM_API_FORMAT); ?> $format + * @param null|array $queryParams + * @param null|bool $parseHeaders * @return getFullyQualifiedName(true, PHPFHIR_CLASSNAME_API_CLIENT_RESPONSE); ?> * @throws \Exception @@ -90,7 +91,8 @@ public function readRaw(string| $resourc null|int $count = null, null| $sort = null, null| $format = null, - null|bool $parseheaders = null): + null|array $queryParams = null, + null|bool $parseHeaders = null): { if (!is_string($resourceType)) { @@ -112,8 +114,11 @@ public function readRaw(string| $resourc if (null !== $format) { $req->format = $format; } - if (null !== $parseheaders) { - $req->parseHeaders = $parseheaders; + if (null !== $parseHeaders) { + $req->parseHeaders = $parseHeaders; + } + if (null !== $queryParams) { + $req->queryParams = $queryParams; } return $this->_client->exec($req); @@ -124,12 +129,13 @@ public function readRaw(string| $resourc * * @see https://www.hl7.org/fhir/http.html#read * - * @param string| $resourceType + * @param string|getFullyQualifiedName(true, PHPFHIR_ENUM_VERSION_TYPE); ?> $resourceType * @param null|string|getFullyQualifiedClassName(true); ?>|getFullyQualifiedClassName(true); ?> $resourceID * @param null|int $count - * @param null| $sort - * @param null| $format - * @param null|bool $parseheaders + * @param null|getFullyQualifiedName(true, PHPFHIR_ENUM_API_SORT); ?> $sort + * @param null|getFullyQualifiedName(true, PHPFHIR_ENUM_API_FORMAT); ?> $format + * @param null|array $queryParams + * @param null|bool $parseHeaders * @return null|getFullyQualifiedName(true, PHPFHIR_INTERFACE_TYPE); ?> * @throws \Exception @@ -139,10 +145,11 @@ public function read(string| $resourceTy null|int $count = null, null| $sort = null, null| $format = null, - null|bool $parseheaders = null): null| + null|array $queryParams = null, + null|bool $parseHeaders = null): null| { - $rc = $this->readRaw($resourceType, $resourceID, $count, $sort, $format, $parseheaders); + $rc = $this->readRaw($resourceType, $resourceID, $count, $sort, $format, $queryParams, $parseHeaders); $this->_requireOK($rc); return ::parse($this->_version, $rc->resp); } @@ -165,24 +172,31 @@ protected function _requireOK(getChildrenOf('Resource') as $rsc) : $typeKind = $rsc->getKind(); - if ($rsc->isRootType() || $typeKind->isContainer($version) || $typeKind->isOneOf(TypeKindEnum::RESOURCE_COMPONENT)) { continue; } ?> + if ($typeKind->isContainer($version) || $rsc->getFHIRName() === 'Bundle') { continue; } + + $rscName = $rsc->getFHIRName(); + $rscNameLen = strlen($rscName); + $rscNameIndent = str_repeat(' ', $rscNameLen); + ?> /** - * Query for one or more getFHIRName(); ?> resources. + * Read one getFHIRName(); ?> resource. * - * @param null|string|getFullyQualifiedClassName(true); ?>|getFullyQualifiedClassName(true); ?> $resourceID - * @param null|int $count - * @param null| $sort - * @param null| $format - * @param null|bool $parseheaders - * @return getFullyQualifiedName(true, PHPFHIR_CLASSNAME_API_CLIENT_RESPONSE); ?> + * @param string|getFullyQualifiedClassName(true); ?>|getFullyQualifiedClassName(true); ?> $resourceID + * @param null|getFullyQualifiedName(true, PHPFHIR_ENUM_API_FORMAT); ?> $format + * @return null|getFullyQualifiedName(true, PHPFHIR_INTERFACE_TYPE); ?> * @throws \Exception */ - public function readgetFHIRName(); ?>Raw(null|string|getClassName(); ?>|getClassName(); ?> $resourceID = null, null|int $count = null, null| $sort = null, null| $format = null, null|bool $parseheaders = null): + public function readgetFHIRName(); ?>(string|getClassName(); ?>|getClassName(); ?> $resourceID, + null| $format = null): null| { - return $this->readRaw(::getConstName(false); ?>, $resourceID, $count, $sort, $format, $parseheaders); + $rc = $this->readRaw(resourceType: ::getConstName(false); ?>, + resourceID: $resourceID, + format: $format); + $this->_requireOK($rc); + return ::parse($this->_version, $rc->resp); } diff --git a/template/versions/core/interfaces/interface_version_contained_type.php b/template/versions/core/interfaces/interface_version_contained_type.php index bd4e0226..ec7462ad 100644 --- a/template/versions/core/interfaces/interface_version_contained_type.php +++ b/template/versions/core/interfaces/interface_version_contained_type.php @@ -22,7 +22,6 @@ /** @var \DCarbone\PHPFHIR\Version\Definition\Types $types */ $config = $version->getConfig(); -$namespace = $version->getFullyQualifiedName(false); $containerType = $types->getContainerType($version); if (null === $containerType) { @@ -48,9 +47,6 @@ * * This interface is applied to any class that is containable within a getName(); ?> getClassName(); ?> instance - * @package \ - - */ interface extends diff --git a/template/versions/types/class_default.php b/template/versions/types/class_default.php index 1dfd70c2..8475b809 100644 --- a/template/versions/types/class_default.php +++ b/template/versions/types/class_default.php @@ -101,7 +101,7 @@ echo "\n"; echo require_with( - PHPFHIR_TEMPLATE_VERSION_TYPES_VALIDATION_DIR . DIRECTORY_SEPARATOR . 'field_map.php', + PHPFHIR_TEMPLATE_VERSION_TYPES_VALIDATION_DIR . DIRECTORY_SEPARATOR . 'const.php', [ 'version' => $version, 'type' => $type, diff --git a/template/versions/types/properties/methods/default.php b/template/versions/types/properties/methods/default.php index 7c92be89..29fb3c0e 100644 --- a/template/versions/types/properties/methods/default.php +++ b/template/versions/types/properties/methods/default.php @@ -29,7 +29,7 @@ $isPrimitiveType = $type->getKind()->isOneOf(TypeKindEnum::PRIMITIVE, TypeKindEnum::LIST); ob_start(); -foreach ($properties as $property) : +foreach ($properties as $i => $property) : if ($property->isOverloaded()) { continue; } @@ -41,6 +41,10 @@ $propertyType = $property->getValueFHIRType(); $propertyTypeClassName = $propertyType->getClassName(); $propertyTypeKind = $propertyType->getKind(); + + if ($i > 0) { + echo "\n"; + } ?> /** @@ -54,8 +58,33 @@ public function get(): ; + } + + + /** + * @return \ArrayIterator<getFullyQualifiedClassName(true); ?>> + */ + public function getIterator(): iterable + { + if (null === $this-> || [] === $this->) { + return new \EmptyIterator(); + } + return new \ArrayIterator($this->); } -hasPrimitiveParent() || $propertyTypeKind->isOneOf(TypeKindEnum::PRIMITIVE_CONTAINER, TypeKindEnum::PRIMITIVE, TypeKindEnum::LIST)) : ?> + + /** + * @return \Generator<getFullyQualifiedClassName(true); ?>> + */ + public function getGenerator(): \Generator + { + foreach ((array)$this-> as $v) { + yield $v; + } + } +hasPrimitiveParent() || $propertyTypeKind->isOneOf(TypeKindEnum::PRIMITIVE_CONTAINER, TypeKindEnum::PRIMITIVE, TypeKindEnum::LIST)) : ?> + /** @@ -87,6 +116,7 @@ public function getSetterName(); ?>( + /** @@ -118,6 +148,7 @@ public function set(array $isContainer($version)) : ?> + /** @@ -134,6 +165,7 @@ public function getSetterName() ?>(null| + /** @@ -177,6 +209,7 @@ public function set(array $ + /** @@ -196,6 +229,7 @@ public function getSetterName(); ?>( + /** diff --git a/template/versions/types/validation/field_map.php b/template/versions/types/validation/const.php similarity index 89% rename from template/versions/types/validation/field_map.php rename to template/versions/types/validation/const.php index d766955d..054d86d8 100644 --- a/template/versions/types/validation/field_map.php +++ b/template/versions/types/validation/const.php @@ -22,11 +22,11 @@ ob_start(); ?> /** - * Validation map for fields in type getFHIRName(); ?> + * Default validation map for fields in type getFHIRName(); ?> * @var array */ - private const _VALIDATION_RULES = [hasLocalPropertiesWithValidations()): ?>]; + private const _DEFAULT_VALIDATION_RULES = [hasLocalPropertiesWithValidations()): ?>]; buildValidationMap(); if ([] !== $validationMap) : ?> diff --git a/template/versions/types/validation/methods.php b/template/versions/types/validation/methods.php index 7a9df16d..85386007 100644 --- a/template/versions/types/validation/methods.php +++ b/template/versions/types/validation/methods.php @@ -39,7 +39,7 @@ */ public function _getValidationRules(): array { - return self::_VALIDATION_RULES; + return self::_DEFAULT_VALIDATION_RULES; } /** @@ -55,38 +55,60 @@ public function _getValidationErrors(): array $errs = []; -getKind()->isOneOf(TypeKindEnum::PRIMITIVE, TypeKindEnum::LIST)) : ?> $validationRules = $this->_getValidationRules(); - -getLocalProperties()->getLocalPropertiesIterator() as $property) { - $propertyType = $property->getValueFHIRType(); - if (null === $propertyType) { - if ($property->isCollection()) { - echo require_with( - PHPFHIR_TEMPLATE_VERSION_TYPES_VALIDATION_DIR . DIRECTORY_SEPARATOR . 'methods' . DIRECTORY_SEPARATOR . 'collection_typed.php', - $requireArgs + ['property' => $property] - ); - } else { - echo require_with( - PHPFHIR_TEMPLATE_VERSION_TYPES_VALIDATION_DIR . DIRECTORY_SEPARATOR . 'methods' . DIRECTORY_SEPARATOR . 'primitive.php', - $requireArgs + ['property' => $property] - ); - } - } else if ($propertyType->getKind() === TypeKindEnum::PHPFHIR_XHTML) { - // TODO(@dcarbone): better way to omit validation +getLocalProperties()->getLocalPropertiesIterator() as $property) : + $validations = $property->buildValidationMap(); + if ([] === $validations) { continue; - } else if ($property->isCollection()) { - echo require_with( - PHPFHIR_TEMPLATE_VERSION_TYPES_VALIDATION_DIR . DIRECTORY_SEPARATOR . 'methods' . DIRECTORY_SEPARATOR . 'collection_typed.php', - $requireArgs + ['property' => $property] - ); - } else { - echo require_with( - PHPFHIR_TEMPLATE_VERSION_TYPES_VALIDATION_DIR . DIRECTORY_SEPARATOR . 'methods' . DIRECTORY_SEPARATOR . 'typed.php', - $requireArgs + ['property' => $property] - ); } -} + $propertyType = $property->getValueFHIRType(); + if (null === $propertyType) : + if ($property->isCollection()) : ?> + if (isset($validationRules[self::FIELD_VALUE]) && [] !== ($vs = $this->getGetterName(); ?>())) { + foreach($vs as $i => $v) { + $err = ::performValidation(getMemberOf()->getTypeNameConst(true); ?>, self::getFieldConstantName(); ?>, $rule, $constraint, $v); + if (null !== $err) { + $key = sprintf('%s.%d', self::getFieldConstantName(); ?>, $i); + if (!isset($errs[$key])) { + $errs[$key] = []; + } + $errs[$key][$rule] = $err; + } + } + } + + if (isset($validationRules[self::FIELD_VALUE]) && null !== $this->value) { + foreach($validationRules[self::FIELD_VALUE] as $rule => $constraint) { + $err = ::performValidation(getMemberOf()->getTypeNameConst(true); ?>, self::getFieldConstantName(); ?>, $rule, $constraint, $this->getFormattedValue()); + if (null !== $err) { + if (!isset($errs[self::FIELD_VALUE])) { + $errs[self::FIELD_VALUE] = []; + } + $errs[self::FIELD_VALUE][$rule] = $err; + } + } + } +isCollection()) : ?> + if ([] !== ($vs = $this->getGetterName(); ?>())) { + foreach($vs as $i => $v) { + if ([] !== ($fieldErrs = $v->_getValidationErrors())) { + $errs[sprintf('%s.%d', self::getFieldConstantName(); ?>, $i)] = $fieldErrs; + } + } + } + + if (null !== ($v = $this->getGetterName(); ?>())) { + if ([] !== ($fieldErrs = $v->_getValidationErrors())) { + $errs[self::getFieldConstantName(); ?>] = $fieldErrs; + } + } +getParentType()) : $ptype = $type; while (null !== $ptype) : diff --git a/template/versions/types/validation/methods/collection_primitive.php b/template/versions/types/validation/methods/collection_primitive.php deleted file mode 100644 index a961cf40..00000000 --- a/template/versions/types/validation/methods/collection_primitive.php +++ /dev/null @@ -1,35 +0,0 @@ - - if (isset($validationRules[self::FIELD_VALUE]) && [] !== ($vs = $this->getGetterName(); ?>())) { - foreach($vs as $i => $v) { - $err = ::performValidation(getMemberOf()->getTypeNameConst(true); ?>, self::getFieldConstantName(); ?>, $rule, $constraint, $v); - if (null !== $err) { - $key = sprintf('%s.%d', self::getFieldConstantName(); ?>, $i); - if (!isset($errs[$key])) { - $errs[$key] = []; - } - $errs[$key][$rule] = $err; - } - } - } - - if ([] !== ($vs = $this->getGetterName(); ?>())) { - foreach($vs as $i => $v) { - if ([] !== ($fieldErrs = $v->_getValidationErrors())) { - $errs[sprintf('%s.%d', self::getFieldConstantName(); ?>, $i)] = $fieldErrs; - } - } - } - - if (isset($validationRules[self::FIELD_VALUE]) && null !== $this->value) { - foreach($validationRules[self::FIELD_VALUE] as $rule => $constraint) { - $err = ::performValidation(getMemberOf()->getTypeNameConst(true); ?>, self::getFieldConstantName(); ?>, $rule, $constraint, $this->getFormattedValue()); - if (null !== $err) { - if (!isset($errs[self::FIELD_VALUE])) { - $errs[self::FIELD_VALUE] = []; - } - $errs[self::FIELD_VALUE][$rule] = $err; - } - } - } - - if (null !== ($v = $this->getGetterName(); ?>())) { - if ([] !== ($fieldErrs = $v->_getValidationErrors())) { - $errs[self::getFieldConstantName(); ?>] = $fieldErrs; - } - } - Date: Mon, 30 Dec 2024 11:04:08 -0600 Subject: [PATCH 90/93] odd php 8.4 error --- composer.lock | 515 ++++++++++++++++++++++++++++---------------------- 1 file changed, 288 insertions(+), 227 deletions(-) diff --git a/composer.lock b/composer.lock index fd6d6b94..a34db51f 100644 --- a/composer.lock +++ b/composer.lock @@ -304,16 +304,16 @@ }, { "name": "nikic/php-parser", - "version": "v5.3.1", + "version": "v5.4.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b" + "reference": "447a020a1f875a434d62f2a401f53b82a396e494" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/8eea230464783aa9671db8eea6f8c6ac5285794b", - "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/447a020a1f875a434d62f2a401f53b82a396e494", + "reference": "447a020a1f875a434d62f2a401f53b82a396e494", "shasum": "" }, "require": { @@ -356,9 +356,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.3.1" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.4.0" }, - "time": "2024-10-08T18:51:32+00:00" + "time": "2024-12-30T11:07:19+00:00" }, { "name": "phar-io/manifest", @@ -480,35 +480,35 @@ }, { "name": "phpunit/php-code-coverage", - "version": "10.1.16", + "version": "11.0.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "7e308268858ed6baedc8704a304727d20bc07c77" + "reference": "418c59fd080954f8c4aa5631d9502ecda2387118" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/7e308268858ed6baedc8704a304727d20bc07c77", - "reference": "7e308268858ed6baedc8704a304727d20bc07c77", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/418c59fd080954f8c4aa5631d9502ecda2387118", + "reference": "418c59fd080954f8c4aa5631d9502ecda2387118", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.19.1 || ^5.1.0", - "php": ">=8.1", - "phpunit/php-file-iterator": "^4.1.0", - "phpunit/php-text-template": "^3.0.1", - "sebastian/code-unit-reverse-lookup": "^3.0.0", - "sebastian/complexity": "^3.2.0", - "sebastian/environment": "^6.1.0", - "sebastian/lines-of-code": "^2.0.2", - "sebastian/version": "^4.0.1", + "nikic/php-parser": "^5.3.1", + "php": ">=8.2", + "phpunit/php-file-iterator": "^5.1.0", + "phpunit/php-text-template": "^4.0.1", + "sebastian/code-unit-reverse-lookup": "^4.0.1", + "sebastian/complexity": "^4.0.1", + "sebastian/environment": "^7.2.0", + "sebastian/lines-of-code": "^3.0.1", + "sebastian/version": "^5.0.2", "theseer/tokenizer": "^1.2.3" }, "require-dev": { - "phpunit/phpunit": "^10.1" + "phpunit/phpunit": "^11.5.0" }, "suggest": { "ext-pcov": "PHP extension that provides line coverage", @@ -517,7 +517,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "10.1.x-dev" + "dev-main": "11.0.x-dev" } }, "autoload": { @@ -546,7 +546,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.16" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/11.0.8" }, "funding": [ { @@ -554,32 +554,32 @@ "type": "github" } ], - "time": "2024-08-22T04:31:57+00:00" + "time": "2024-12-11T12:34:27+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "4.1.0", + "version": "5.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "a95037b6d9e608ba092da1b23931e537cadc3c3c" + "reference": "118cfaaa8bc5aef3287bf315b6060b1174754af6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a95037b6d9e608ba092da1b23931e537cadc3c3c", - "reference": "a95037b6d9e608ba092da1b23931e537cadc3c3c", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/118cfaaa8bc5aef3287bf315b6060b1174754af6", + "reference": "118cfaaa8bc5aef3287bf315b6060b1174754af6", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "4.0-dev" + "dev-main": "5.0-dev" } }, "autoload": { @@ -607,7 +607,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", "security": "https://github.com/sebastianbergmann/php-file-iterator/security/policy", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/4.1.0" + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/5.1.0" }, "funding": [ { @@ -615,28 +615,28 @@ "type": "github" } ], - "time": "2023-08-31T06:24:48+00:00" + "time": "2024-08-27T05:02:59+00:00" }, { "name": "phpunit/php-invoker", - "version": "4.0.0", + "version": "5.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-invoker.git", - "reference": "f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7" + "reference": "c1ca3814734c07492b3d4c5f794f4b0995333da2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7", - "reference": "f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/c1ca3814734c07492b3d4c5f794f4b0995333da2", + "reference": "c1ca3814734c07492b3d4c5f794f4b0995333da2", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.2" }, "require-dev": { "ext-pcntl": "*", - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "suggest": { "ext-pcntl": "*" @@ -644,7 +644,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "4.0-dev" + "dev-main": "5.0-dev" } }, "autoload": { @@ -670,7 +670,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-invoker/issues", - "source": "https://github.com/sebastianbergmann/php-invoker/tree/4.0.0" + "security": "https://github.com/sebastianbergmann/php-invoker/security/policy", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/5.0.1" }, "funding": [ { @@ -678,32 +679,32 @@ "type": "github" } ], - "time": "2023-02-03T06:56:09+00:00" + "time": "2024-07-03T05:07:44+00:00" }, { "name": "phpunit/php-text-template", - "version": "3.0.1", + "version": "4.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "0c7b06ff49e3d5072f057eb1fa59258bf287a748" + "reference": "3e0404dc6b300e6bf56415467ebcb3fe4f33e964" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/0c7b06ff49e3d5072f057eb1fa59258bf287a748", - "reference": "0c7b06ff49e3d5072f057eb1fa59258bf287a748", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/3e0404dc6b300e6bf56415467ebcb3fe4f33e964", + "reference": "3e0404dc6b300e6bf56415467ebcb3fe4f33e964", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "4.0-dev" } }, "autoload": { @@ -730,7 +731,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-text-template/issues", "security": "https://github.com/sebastianbergmann/php-text-template/security/policy", - "source": "https://github.com/sebastianbergmann/php-text-template/tree/3.0.1" + "source": "https://github.com/sebastianbergmann/php-text-template/tree/4.0.1" }, "funding": [ { @@ -738,32 +739,32 @@ "type": "github" } ], - "time": "2023-08-31T14:07:24+00:00" + "time": "2024-07-03T05:08:43+00:00" }, { "name": "phpunit/php-timer", - "version": "6.0.0", + "version": "7.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "e2a2d67966e740530f4a3343fe2e030ffdc1161d" + "reference": "3b415def83fbcb41f991d9ebf16ae4ad8b7837b3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/e2a2d67966e740530f4a3343fe2e030ffdc1161d", - "reference": "e2a2d67966e740530f4a3343fe2e030ffdc1161d", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3b415def83fbcb41f991d9ebf16ae4ad8b7837b3", + "reference": "3b415def83fbcb41f991d9ebf16ae4ad8b7837b3", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "6.0-dev" + "dev-main": "7.0-dev" } }, "autoload": { @@ -789,7 +790,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-timer/issues", - "source": "https://github.com/sebastianbergmann/php-timer/tree/6.0.0" + "security": "https://github.com/sebastianbergmann/php-timer/security/policy", + "source": "https://github.com/sebastianbergmann/php-timer/tree/7.0.1" }, "funding": [ { @@ -797,20 +799,20 @@ "type": "github" } ], - "time": "2023-02-03T06:57:52+00:00" + "time": "2024-07-03T05:09:35+00:00" }, { "name": "phpunit/phpunit", - "version": "10.5.40", + "version": "11.5.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "e6ddda95af52f69c1e0c7b4f977cccb58048798c" + "reference": "153d0531b9f7e883c5053160cad6dd5ac28140b3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e6ddda95af52f69c1e0c7b4f977cccb58048798c", - "reference": "e6ddda95af52f69c1e0c7b4f977cccb58048798c", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/153d0531b9f7e883c5053160cad6dd5ac28140b3", + "reference": "153d0531b9f7e883c5053160cad6dd5ac28140b3", "shasum": "" }, "require": { @@ -823,23 +825,23 @@ "myclabs/deep-copy": "^1.12.1", "phar-io/manifest": "^2.0.4", "phar-io/version": "^3.2.1", - "php": ">=8.1", - "phpunit/php-code-coverage": "^10.1.16", - "phpunit/php-file-iterator": "^4.1.0", - "phpunit/php-invoker": "^4.0.0", - "phpunit/php-text-template": "^3.0.1", - "phpunit/php-timer": "^6.0.0", - "sebastian/cli-parser": "^2.0.1", - "sebastian/code-unit": "^2.0.0", - "sebastian/comparator": "^5.0.3", - "sebastian/diff": "^5.1.1", - "sebastian/environment": "^6.1.0", - "sebastian/exporter": "^5.1.2", - "sebastian/global-state": "^6.0.2", - "sebastian/object-enumerator": "^5.0.0", - "sebastian/recursion-context": "^5.0.0", - "sebastian/type": "^4.0.0", - "sebastian/version": "^4.0.1" + "php": ">=8.2", + "phpunit/php-code-coverage": "^11.0.8", + "phpunit/php-file-iterator": "^5.1.0", + "phpunit/php-invoker": "^5.0.1", + "phpunit/php-text-template": "^4.0.1", + "phpunit/php-timer": "^7.0.1", + "sebastian/cli-parser": "^3.0.2", + "sebastian/code-unit": "^3.0.2", + "sebastian/comparator": "^6.2.1", + "sebastian/diff": "^6.0.2", + "sebastian/environment": "^7.2.0", + "sebastian/exporter": "^6.3.0", + "sebastian/global-state": "^7.0.2", + "sebastian/object-enumerator": "^6.0.1", + "sebastian/type": "^5.1.0", + "sebastian/version": "^5.0.2", + "staabm/side-effects-detector": "^1.0.5" }, "suggest": { "ext-soap": "To be able to generate mocks based on WSDL files" @@ -850,7 +852,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "10.5-dev" + "dev-main": "11.5-dev" } }, "autoload": { @@ -882,7 +884,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.40" + "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.2" }, "funding": [ { @@ -898,32 +900,32 @@ "type": "tidelift" } ], - "time": "2024-12-21T05:49:06+00:00" + "time": "2024-12-21T05:51:08+00:00" }, { "name": "sebastian/cli-parser", - "version": "2.0.1", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/cli-parser.git", - "reference": "c34583b87e7b7a8055bf6c450c2c77ce32a24084" + "reference": "15c5dd40dc4f38794d383bb95465193f5e0ae180" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/c34583b87e7b7a8055bf6c450c2c77ce32a24084", - "reference": "c34583b87e7b7a8055bf6c450c2c77ce32a24084", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/15c5dd40dc4f38794d383bb95465193f5e0ae180", + "reference": "15c5dd40dc4f38794d383bb95465193f5e0ae180", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "2.0-dev" + "dev-main": "3.0-dev" } }, "autoload": { @@ -947,7 +949,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/cli-parser/issues", "security": "https://github.com/sebastianbergmann/cli-parser/security/policy", - "source": "https://github.com/sebastianbergmann/cli-parser/tree/2.0.1" + "source": "https://github.com/sebastianbergmann/cli-parser/tree/3.0.2" }, "funding": [ { @@ -955,32 +957,32 @@ "type": "github" } ], - "time": "2024-03-02T07:12:49+00:00" + "time": "2024-07-03T04:41:36+00:00" }, { "name": "sebastian/code-unit", - "version": "2.0.0", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit.git", - "reference": "a81fee9eef0b7a76af11d121767abc44c104e503" + "reference": "ee88b0cdbe74cf8dd3b54940ff17643c0d6543ca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/a81fee9eef0b7a76af11d121767abc44c104e503", - "reference": "a81fee9eef0b7a76af11d121767abc44c104e503", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/ee88b0cdbe74cf8dd3b54940ff17643c0d6543ca", + "reference": "ee88b0cdbe74cf8dd3b54940ff17643c0d6543ca", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.5" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "2.0-dev" + "dev-main": "3.0-dev" } }, "autoload": { @@ -1003,7 +1005,8 @@ "homepage": "https://github.com/sebastianbergmann/code-unit", "support": { "issues": "https://github.com/sebastianbergmann/code-unit/issues", - "source": "https://github.com/sebastianbergmann/code-unit/tree/2.0.0" + "security": "https://github.com/sebastianbergmann/code-unit/security/policy", + "source": "https://github.com/sebastianbergmann/code-unit/tree/3.0.2" }, "funding": [ { @@ -1011,32 +1014,32 @@ "type": "github" } ], - "time": "2023-02-03T06:58:43+00:00" + "time": "2024-12-12T09:59:06+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", - "version": "3.0.0", + "version": "4.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "5e3a687f7d8ae33fb362c5c0743794bbb2420a1d" + "reference": "183a9b2632194febd219bb9246eee421dad8d45e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/5e3a687f7d8ae33fb362c5c0743794bbb2420a1d", - "reference": "5e3a687f7d8ae33fb362c5c0743794bbb2420a1d", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/183a9b2632194febd219bb9246eee421dad8d45e", + "reference": "183a9b2632194febd219bb9246eee421dad8d45e", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "4.0-dev" } }, "autoload": { @@ -1058,7 +1061,8 @@ "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", "support": { "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", - "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/3.0.0" + "security": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/security/policy", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/4.0.1" }, "funding": [ { @@ -1066,36 +1070,36 @@ "type": "github" } ], - "time": "2023-02-03T06:59:15+00:00" + "time": "2024-07-03T04:45:54+00:00" }, { "name": "sebastian/comparator", - "version": "5.0.3", + "version": "6.2.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "a18251eb0b7a2dcd2f7aa3d6078b18545ef0558e" + "reference": "43d129d6a0f81c78bee378b46688293eb7ea3739" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/a18251eb0b7a2dcd2f7aa3d6078b18545ef0558e", - "reference": "a18251eb0b7a2dcd2f7aa3d6078b18545ef0558e", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/43d129d6a0f81c78bee378b46688293eb7ea3739", + "reference": "43d129d6a0f81c78bee378b46688293eb7ea3739", "shasum": "" }, "require": { "ext-dom": "*", "ext-mbstring": "*", - "php": ">=8.1", - "sebastian/diff": "^5.0", - "sebastian/exporter": "^5.0" + "php": ">=8.2", + "sebastian/diff": "^6.0", + "sebastian/exporter": "^6.0" }, "require-dev": { - "phpunit/phpunit": "^10.5" + "phpunit/phpunit": "^11.4" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "5.0-dev" + "dev-main": "6.2-dev" } }, "autoload": { @@ -1135,7 +1139,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", "security": "https://github.com/sebastianbergmann/comparator/security/policy", - "source": "https://github.com/sebastianbergmann/comparator/tree/5.0.3" + "source": "https://github.com/sebastianbergmann/comparator/tree/6.2.1" }, "funding": [ { @@ -1143,33 +1147,33 @@ "type": "github" } ], - "time": "2024-10-18T14:56:07+00:00" + "time": "2024-10-31T05:30:08+00:00" }, { "name": "sebastian/complexity", - "version": "3.2.0", + "version": "4.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "68ff824baeae169ec9f2137158ee529584553799" + "reference": "ee41d384ab1906c68852636b6de493846e13e5a0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/68ff824baeae169ec9f2137158ee529584553799", - "reference": "68ff824baeae169ec9f2137158ee529584553799", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/ee41d384ab1906c68852636b6de493846e13e5a0", + "reference": "ee41d384ab1906c68852636b6de493846e13e5a0", "shasum": "" }, "require": { - "nikic/php-parser": "^4.18 || ^5.0", - "php": ">=8.1" + "nikic/php-parser": "^5.0", + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.2-dev" + "dev-main": "4.0-dev" } }, "autoload": { @@ -1193,7 +1197,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/complexity/issues", "security": "https://github.com/sebastianbergmann/complexity/security/policy", - "source": "https://github.com/sebastianbergmann/complexity/tree/3.2.0" + "source": "https://github.com/sebastianbergmann/complexity/tree/4.0.1" }, "funding": [ { @@ -1201,33 +1205,33 @@ "type": "github" } ], - "time": "2023-12-21T08:37:17+00:00" + "time": "2024-07-03T04:49:50+00:00" }, { "name": "sebastian/diff", - "version": "5.1.1", + "version": "6.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "c41e007b4b62af48218231d6c2275e4c9b975b2e" + "reference": "b4ccd857127db5d41a5b676f24b51371d76d8544" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/c41e007b4b62af48218231d6c2275e4c9b975b2e", - "reference": "c41e007b4b62af48218231d6c2275e4c9b975b2e", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/b4ccd857127db5d41a5b676f24b51371d76d8544", + "reference": "b4ccd857127db5d41a5b676f24b51371d76d8544", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^10.0", - "symfony/process": "^6.4" + "phpunit/phpunit": "^11.0", + "symfony/process": "^4.2 || ^5" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "5.1-dev" + "dev-main": "6.0-dev" } }, "autoload": { @@ -1260,7 +1264,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", "security": "https://github.com/sebastianbergmann/diff/security/policy", - "source": "https://github.com/sebastianbergmann/diff/tree/5.1.1" + "source": "https://github.com/sebastianbergmann/diff/tree/6.0.2" }, "funding": [ { @@ -1268,27 +1272,27 @@ "type": "github" } ], - "time": "2024-03-02T07:15:17+00:00" + "time": "2024-07-03T04:53:05+00:00" }, { "name": "sebastian/environment", - "version": "6.1.0", + "version": "7.2.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "8074dbcd93529b357029f5cc5058fd3e43666984" + "reference": "855f3ae0ab316bbafe1ba4e16e9f3c078d24a0c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/8074dbcd93529b357029f5cc5058fd3e43666984", - "reference": "8074dbcd93529b357029f5cc5058fd3e43666984", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/855f3ae0ab316bbafe1ba4e16e9f3c078d24a0c5", + "reference": "855f3ae0ab316bbafe1ba4e16e9f3c078d24a0c5", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "suggest": { "ext-posix": "*" @@ -1296,7 +1300,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "6.1-dev" + "dev-main": "7.2-dev" } }, "autoload": { @@ -1324,7 +1328,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/environment/issues", "security": "https://github.com/sebastianbergmann/environment/security/policy", - "source": "https://github.com/sebastianbergmann/environment/tree/6.1.0" + "source": "https://github.com/sebastianbergmann/environment/tree/7.2.0" }, "funding": [ { @@ -1332,34 +1336,34 @@ "type": "github" } ], - "time": "2024-03-23T08:47:14+00:00" + "time": "2024-07-03T04:54:44+00:00" }, { "name": "sebastian/exporter", - "version": "5.1.2", + "version": "6.3.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "955288482d97c19a372d3f31006ab3f37da47adf" + "reference": "3473f61172093b2da7de1fb5782e1f24cc036dc3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/955288482d97c19a372d3f31006ab3f37da47adf", - "reference": "955288482d97c19a372d3f31006ab3f37da47adf", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/3473f61172093b2da7de1fb5782e1f24cc036dc3", + "reference": "3473f61172093b2da7de1fb5782e1f24cc036dc3", "shasum": "" }, "require": { "ext-mbstring": "*", - "php": ">=8.1", - "sebastian/recursion-context": "^5.0" + "php": ">=8.2", + "sebastian/recursion-context": "^6.0" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.3" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "5.1-dev" + "dev-main": "6.1-dev" } }, "autoload": { @@ -1402,7 +1406,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", "security": "https://github.com/sebastianbergmann/exporter/security/policy", - "source": "https://github.com/sebastianbergmann/exporter/tree/5.1.2" + "source": "https://github.com/sebastianbergmann/exporter/tree/6.3.0" }, "funding": [ { @@ -1410,35 +1414,35 @@ "type": "github" } ], - "time": "2024-03-02T07:17:12+00:00" + "time": "2024-12-05T09:17:50+00:00" }, { "name": "sebastian/global-state", - "version": "6.0.2", + "version": "7.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "987bafff24ecc4c9ac418cab1145b96dd6e9cbd9" + "reference": "3be331570a721f9a4b5917f4209773de17f747d7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/987bafff24ecc4c9ac418cab1145b96dd6e9cbd9", - "reference": "987bafff24ecc4c9ac418cab1145b96dd6e9cbd9", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/3be331570a721f9a4b5917f4209773de17f747d7", + "reference": "3be331570a721f9a4b5917f4209773de17f747d7", "shasum": "" }, "require": { - "php": ">=8.1", - "sebastian/object-reflector": "^3.0", - "sebastian/recursion-context": "^5.0" + "php": ">=8.2", + "sebastian/object-reflector": "^4.0", + "sebastian/recursion-context": "^6.0" }, "require-dev": { "ext-dom": "*", - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "6.0-dev" + "dev-main": "7.0-dev" } }, "autoload": { @@ -1464,7 +1468,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", "security": "https://github.com/sebastianbergmann/global-state/security/policy", - "source": "https://github.com/sebastianbergmann/global-state/tree/6.0.2" + "source": "https://github.com/sebastianbergmann/global-state/tree/7.0.2" }, "funding": [ { @@ -1472,33 +1476,33 @@ "type": "github" } ], - "time": "2024-03-02T07:19:19+00:00" + "time": "2024-07-03T04:57:36+00:00" }, { "name": "sebastian/lines-of-code", - "version": "2.0.2", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0" + "reference": "d36ad0d782e5756913e42ad87cb2890f4ffe467a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/856e7f6a75a84e339195d48c556f23be2ebf75d0", - "reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/d36ad0d782e5756913e42ad87cb2890f4ffe467a", + "reference": "d36ad0d782e5756913e42ad87cb2890f4ffe467a", "shasum": "" }, "require": { - "nikic/php-parser": "^4.18 || ^5.0", - "php": ">=8.1" + "nikic/php-parser": "^5.0", + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "2.0-dev" + "dev-main": "3.0-dev" } }, "autoload": { @@ -1522,7 +1526,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", "security": "https://github.com/sebastianbergmann/lines-of-code/security/policy", - "source": "https://github.com/sebastianbergmann/lines-of-code/tree/2.0.2" + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/3.0.1" }, "funding": [ { @@ -1530,34 +1534,34 @@ "type": "github" } ], - "time": "2023-12-21T08:38:20+00:00" + "time": "2024-07-03T04:58:38+00:00" }, { "name": "sebastian/object-enumerator", - "version": "5.0.0", + "version": "6.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "202d0e344a580d7f7d04b3fafce6933e59dae906" + "reference": "f5b498e631a74204185071eb41f33f38d64608aa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/202d0e344a580d7f7d04b3fafce6933e59dae906", - "reference": "202d0e344a580d7f7d04b3fafce6933e59dae906", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/f5b498e631a74204185071eb41f33f38d64608aa", + "reference": "f5b498e631a74204185071eb41f33f38d64608aa", "shasum": "" }, "require": { - "php": ">=8.1", - "sebastian/object-reflector": "^3.0", - "sebastian/recursion-context": "^5.0" + "php": ">=8.2", + "sebastian/object-reflector": "^4.0", + "sebastian/recursion-context": "^6.0" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "5.0-dev" + "dev-main": "6.0-dev" } }, "autoload": { @@ -1579,7 +1583,8 @@ "homepage": "https://github.com/sebastianbergmann/object-enumerator/", "support": { "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", - "source": "https://github.com/sebastianbergmann/object-enumerator/tree/5.0.0" + "security": "https://github.com/sebastianbergmann/object-enumerator/security/policy", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/6.0.1" }, "funding": [ { @@ -1587,32 +1592,32 @@ "type": "github" } ], - "time": "2023-02-03T07:08:32+00:00" + "time": "2024-07-03T05:00:13+00:00" }, { "name": "sebastian/object-reflector", - "version": "3.0.0", + "version": "4.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "24ed13d98130f0e7122df55d06c5c4942a577957" + "reference": "6e1a43b411b2ad34146dee7524cb13a068bb35f9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/24ed13d98130f0e7122df55d06c5c4942a577957", - "reference": "24ed13d98130f0e7122df55d06c5c4942a577957", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/6e1a43b411b2ad34146dee7524cb13a068bb35f9", + "reference": "6e1a43b411b2ad34146dee7524cb13a068bb35f9", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "4.0-dev" } }, "autoload": { @@ -1634,7 +1639,8 @@ "homepage": "https://github.com/sebastianbergmann/object-reflector/", "support": { "issues": "https://github.com/sebastianbergmann/object-reflector/issues", - "source": "https://github.com/sebastianbergmann/object-reflector/tree/3.0.0" + "security": "https://github.com/sebastianbergmann/object-reflector/security/policy", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/4.0.1" }, "funding": [ { @@ -1642,32 +1648,32 @@ "type": "github" } ], - "time": "2023-02-03T07:06:18+00:00" + "time": "2024-07-03T05:01:32+00:00" }, { "name": "sebastian/recursion-context", - "version": "5.0.0", + "version": "6.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "05909fb5bc7df4c52992396d0116aed689f93712" + "reference": "694d156164372abbd149a4b85ccda2e4670c0e16" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/05909fb5bc7df4c52992396d0116aed689f93712", - "reference": "05909fb5bc7df4c52992396d0116aed689f93712", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/694d156164372abbd149a4b85ccda2e4670c0e16", + "reference": "694d156164372abbd149a4b85ccda2e4670c0e16", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "5.0-dev" + "dev-main": "6.0-dev" } }, "autoload": { @@ -1697,7 +1703,8 @@ "homepage": "https://github.com/sebastianbergmann/recursion-context", "support": { "issues": "https://github.com/sebastianbergmann/recursion-context/issues", - "source": "https://github.com/sebastianbergmann/recursion-context/tree/5.0.0" + "security": "https://github.com/sebastianbergmann/recursion-context/security/policy", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/6.0.2" }, "funding": [ { @@ -1705,32 +1712,32 @@ "type": "github" } ], - "time": "2023-02-03T07:05:40+00:00" + "time": "2024-07-03T05:10:34+00:00" }, { "name": "sebastian/type", - "version": "4.0.0", + "version": "5.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "462699a16464c3944eefc02ebdd77882bd3925bf" + "reference": "461b9c5da241511a2a0e8f240814fb23ce5c0aac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/462699a16464c3944eefc02ebdd77882bd3925bf", - "reference": "462699a16464c3944eefc02ebdd77882bd3925bf", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/461b9c5da241511a2a0e8f240814fb23ce5c0aac", + "reference": "461b9c5da241511a2a0e8f240814fb23ce5c0aac", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.3" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "4.0-dev" + "dev-main": "5.1-dev" } }, "autoload": { @@ -1753,7 +1760,8 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/4.0.0" + "security": "https://github.com/sebastianbergmann/type/security/policy", + "source": "https://github.com/sebastianbergmann/type/tree/5.1.0" }, "funding": [ { @@ -1761,29 +1769,29 @@ "type": "github" } ], - "time": "2023-02-03T07:10:45+00:00" + "time": "2024-09-17T13:12:04+00:00" }, { "name": "sebastian/version", - "version": "4.0.1", + "version": "5.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "c51fa83a5d8f43f1402e3f32a005e6262244ef17" + "reference": "c687e3387b99f5b03b6caa64c74b63e2936ff874" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c51fa83a5d8f43f1402e3f32a005e6262244ef17", - "reference": "c51fa83a5d8f43f1402e3f32a005e6262244ef17", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c687e3387b99f5b03b6caa64c74b63e2936ff874", + "reference": "c687e3387b99f5b03b6caa64c74b63e2936ff874", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.2" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "4.0-dev" + "dev-main": "5.0-dev" } }, "autoload": { @@ -1806,7 +1814,8 @@ "homepage": "https://github.com/sebastianbergmann/version", "support": { "issues": "https://github.com/sebastianbergmann/version/issues", - "source": "https://github.com/sebastianbergmann/version/tree/4.0.1" + "security": "https://github.com/sebastianbergmann/version/security/policy", + "source": "https://github.com/sebastianbergmann/version/tree/5.0.2" }, "funding": [ { @@ -1814,7 +1823,59 @@ "type": "github" } ], - "time": "2023-02-07T11:34:05+00:00" + "time": "2024-10-09T05:16:32+00:00" + }, + { + "name": "staabm/side-effects-detector", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/staabm/side-effects-detector.git", + "reference": "d8334211a140ce329c13726d4a715adbddd0a163" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/staabm/side-effects-detector/zipball/d8334211a140ce329c13726d4a715adbddd0a163", + "reference": "d8334211a140ce329c13726d4a715adbddd0a163", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "phpstan/extension-installer": "^1.4.3", + "phpstan/phpstan": "^1.12.6", + "phpunit/phpunit": "^9.6.21", + "symfony/var-dumper": "^5.4.43", + "tomasvotruba/type-coverage": "1.0.0", + "tomasvotruba/unused-public": "1.0.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "lib/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A static analysis tool to detect side effects in PHP code", + "keywords": [ + "static analysis" + ], + "support": { + "issues": "https://github.com/staabm/side-effects-detector/issues", + "source": "https://github.com/staabm/side-effects-detector/tree/1.0.5" + }, + "funding": [ + { + "url": "https://github.com/staabm", + "type": "github" + } + ], + "time": "2024-10-20T05:08:20+00:00" }, { "name": "theseer/tokenizer", From dd5f0576daf8c097e38b504b8622fedb228c498b Mon Sep 17 00:00:00 2001 From: Daniel Carbone Date: Mon, 30 Dec 2024 11:04:50 -0600 Subject: [PATCH 91/93] forgot to update test for 8.4 --- .github/workflows/tests.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 565ad45d..f574ddb5 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -86,6 +86,8 @@ jobs: phpunit-version: '11.1' - php-version: '8.3' phpunit-version: '11.1' + - php-version: '8.4' + phpunit-version: '11.1' name: '${{ matrix.test-target }} - PHP ${{ matrix.php-version }} - PHPUnit ${{ matrix.phpunit-version }}' steps: From 95dc360c3a30f51a569473625228eed26cf107e5 Mon Sep 17 00:00:00 2001 From: Daniel Carbone Date: Mon, 30 Dec 2024 11:07:02 -0600 Subject: [PATCH 92/93] i see what i did. --- .github/workflows/tests.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index f574ddb5..2b6fb221 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -84,8 +84,6 @@ jobs: phpunit-version: '11.1' - php-version: '8.3' phpunit-version: '11.1' - - php-version: '8.3' - phpunit-version: '11.1' - php-version: '8.4' phpunit-version: '11.1' From f591be5e19987306756f380e17f784f8ac9f7cff Mon Sep 17 00:00:00 2001 From: Daniel Carbone Date: Mon, 30 Dec 2024 11:07:41 -0600 Subject: [PATCH 93/93] remove explicit phpunit run flags --- .github/workflows/tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 2b6fb221..42378785 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -164,4 +164,4 @@ jobs: - name: 'Run tests' # language=sh run: | - ./vendor/bin/phpunit -c 'phpunit/${{ matrix.test-target }}.xml' --display-warnings --display-skipped + ./vendor/bin/phpunit -c 'phpunit/${{ matrix.test-target }}.xml'