Skip to content

Commit

Permalink
getting there
Browse files Browse the repository at this point in the history
  • Loading branch information
dcarbone committed Jan 7, 2025
1 parent 3e5cc08 commit 30a6185
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/Utilities/TypeHintUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ public static function typeSetterTypeHint(Version $version, Type $type, bool $nu
$tk = $type->getKind();
$types = $nullable ? ['null'] : [];

if ($tk === TypeKindEnum::PRIMITIVE_CONTAINER) {
if ($tk->isResourceContainer($version)) {
$types[] = PHPFHIR_VERSION_INTERFACE_VERSION_CONTAINED_TYPE;
} else if ($tk === TypeKindEnum::PRIMITIVE_CONTAINER) {
$pt = $type->getProperties()->getProperty('value')->getValueFHIRType();
$types = array_merge($types, $pt->getPrimitiveType()->getPHPReceiveValueTypeHints());
array_push(
Expand Down
16 changes: 13 additions & 3 deletions template/versions/types/methods/constructor.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,11 @@ public function __construct(null|array $data = null,
<?php else : ?>
/**
* <?php echo $typeClassName; ?> Constructor
* @param null|array $data<?php if ($type->isValueContainer()) : ?>
* @param null|array $data
<?php if ($type->isValueContainer()) : ?>

* @param <?php echo TypeHintUtils::propertySetterTypeHint($version, $valueProperty, true); ?> $value = null<?php endif; ?>
* @param <?php echo TypeHintUtils::propertySetterTypeHint($version, $valueProperty, true); ?> $value = null
<?php endif; ?>
<?php foreach($type->getAllPropertiesIndexedIterator() as $property) :
$pt = $property->getValueFHIRType();
if ($type->isValueContainer() && $property->isValueProperty()) {
Expand All @@ -151,7 +153,15 @@ public function __construct(null|array $data = null,
* @param <?php echo TypeHintUtils::propertySetterTypeHint($version, $property, true); ?> $<?php echo $property->getName(); ?>

<?php endforeach; ?> */
public function __construct(null|array<?php if ($type->isValueContainer()) : ?>|<?php echo TypeHintUtils::propertySetterTypeHint($version, $valueProperty, false); endif; ?> $data = null)
public function __construct(null|array $data = null<?php if ($type->isValueContainer()) : ?>,
<?php echo TypeHintUtils::propertySetterTypeHint($version, $valueProperty, true);?> $value = null<?php endif; ?>
<?php foreach($type->getAllPropertiesIndexedIterator() as $property) :
if ($type->isValueContainer() && $property->isValueProperty()) {
continue;
}
?>,
<?php echo TypeHintUtils::propertySetterTypeHint($version, $property, true); ?> $<?php echo $property->getName(); ?>
<?php endforeach; ?>)
{
if (null === $data || [] === $data) {
<?php if ($type->hasParent()) : ?>
Expand Down

0 comments on commit 30a6185

Please sign in to comment.