Skip to content

Commit

Permalink
serialization and interface improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
dcarbone committed Apr 15, 2024
1 parent 237d3da commit 15576c4
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 41 deletions.
7 changes: 2 additions & 5 deletions src/Definition/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ public function getDirectlyImplementedInterfaces(): array
}
if ($this->isContainedType()) {
$interfaces[] = PHPFHIR_INTERFACE_CONTAINED_TYPE;
} else if ($this->getKind() !== TypeKind::PRIMITIVE) {
} else {
$interfaces[] = PHPFHIR_INTERFACE_TYPE;
}
} elseif ($this->isContainedType() && !$parentType->isContainedType()) {
Expand All @@ -749,10 +749,7 @@ public function getDirectlyUsedTraits(): array
}
$traits[] = PHPFHIR_TRAIT_VALIDATION_ASSERTIONS;
$traits[] = PHPFHIR_TRAIT_CHANGE_TRACKING;

if ($this->getKind() !== TypeKind::PRIMITIVE) {
$traits[] = PHPFHIR_TRAIT_XMLNS;
}
$traits[] = PHPFHIR_TRAIT_XMLNS;
}

return $traits;
Expand Down
5 changes: 0 additions & 5 deletions template/interfaces/phpfhir_type.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@

*/
interface <?php echo PHPFHIR_INTERFACE_TYPE; ?> extends \JsonSerializable {
/**
* @param array|null $data
*/
public function __construct(?array $data = null);

/**
* Returns the FHIR name represented by this Type
* @return string
Expand Down
2 changes: 1 addition & 1 deletion template/types/serialization/json/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
* @return \stdClass
*/
public function jsonSerialize()
public function jsonSerialize(): \stdClass
{
<?php if (null !== $type->getParentType()) : ?>
$out = parent::jsonSerialize();
Expand Down
27 changes: 0 additions & 27 deletions template/types/serialization/json/list.php

This file was deleted.

2 changes: 1 addition & 1 deletion template/types/serialization/json/primitive.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* @return <?php echo TypeHintUtils::primitivePHPValueTypeDoc($config, $type->getPrimitiveType(), true, false); ?>

*/
public function jsonSerialize()
public function jsonSerialize(): <?php echo TypeHintUtils::primitivePHPValueTypeDoc($config, $type->getPrimitiveType(), true, false); ?>
{
<?php if ($typeKind === TypeKind::PRIMITIVE && str_contains($type->getFHIRName(), 'unsigned')) : ?>
return intval($this->getValue(), 10);
Expand Down
4 changes: 2 additions & 2 deletions template/types/serialization/json/resource_container.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

ob_start(); ?>
/**
* @return object|null
* @return null|object
*/
public function jsonSerialize()
public function jsonSerialize(): null|object
{<?php foreach($properties as $property) : ?>

if (null !== ($v = $this->get<?php echo ucfirst($property->getName()); ?>())) {
Expand Down

0 comments on commit 15576c4

Please sign in to comment.