|
25 | 25 | /** @var \DCarbone\PHPFHIR\Definition\Type|null $parentType */
|
26 | 26 |
|
27 | 27 | $typeClassName = $type->getClassName();
|
28 |
| -$constructorParamName = 'data'; |
29 | 28 | $valueProperty = null;
|
30 | 29 | if ($type->isValueContainer()) {
|
31 |
| - $constructorParamName = 'value'; |
32 | 30 | $valueProperty = $type->getLocalProperties()->getProperty(PHPFHIR_VALUE_PROPERTY_NAME);
|
33 | 31 | }
|
34 | 32 |
|
35 | 33 | ob_start(); ?>
|
36 | 34 | /**
|
37 | 35 | * <?php echo $typeClassName; ?> Constructor
|
38 |
| - * @param null|array<?php if ($type->isValueContainer()) : ?>|<?php echo TypeHintUtils::propertySetterTypeHint($config, $valueProperty, false); endif; ?> $<?php echo $constructorParamName; ?> |
| 36 | + * @param null|array<?php if ($type->isValueContainer()) : ?>|<?php echo TypeHintUtils::propertySetterTypeHint($config, $valueProperty, false); endif; ?> $data |
39 | 37 |
|
40 | 38 | */
|
41 |
| - public function __construct(null|array<?php if ($type->isValueContainer()) : ?>|<?php echo TypeHintUtils::propertySetterTypeHint($config, $valueProperty, false); endif; ?> $<?php echo $constructorParamName; ?> = null) |
| 39 | + public function __construct(null|array<?php if ($type->isValueContainer()) : ?>|<?php echo TypeHintUtils::propertySetterTypeHint($config, $valueProperty, false); endif; ?> $data = null) |
42 | 40 | {
|
43 |
| - if (null === $<?php echo $constructorParamName; ?> || [] === $<?php echo $constructorParamName; ?>) { |
| 41 | + if (null === $data|| [] === $data) { |
44 | 42 | return;
|
45 | 43 | }
|
46 | 44 | <?php if ($type->isValueContainer()) : ?>
|
47 |
| - if (!is_array($<?php echo $constructorParamName; ?>)) { |
48 |
| - $this->setValue($<?php echo $constructorParamName; ?>); |
| 45 | + if (!is_array($data)) { |
| 46 | + $this->setValue($data); |
49 | 47 | return;
|
50 | 48 | }
|
51 | 49 | <?php endif; if ($type->hasParentWithLocalProperties()) : // add parent constructor call ?>
|
52 |
| - parent::__construct($<?php echo $constructorParamName; ?>);<?php endif; ?><?php if ($type->isCommentContainer() && !$type->hasCommentContainerParent()) : // only parse comments if parent isn't already doing it. ?> |
| 50 | + parent::__construct($data);<?php endif; ?><?php if ($type->isCommentContainer() && !$type->hasCommentContainerParent()) : // only parse comments if parent isn't already doing it. ?> |
53 | 51 |
|
54 |
| - if (isset($<?php echo $constructorParamName; ?>[PHPFHIRConstants::JSON_FIELD_FHIR_COMMENTS])) { |
55 |
| - if (is_array($<?php echo $constructorParamName; ?>[PHPFHIRConstants::JSON_FIELD_FHIR_COMMENTS])) { |
56 |
| - $this->_setFHIRComments($<?php echo $constructorParamName; ?>[PHPFHIRConstants::JSON_FIELD_FHIR_COMMENTS]); |
57 |
| - } elseif (is_string($<?php echo $constructorParamName; ?>[PHPFHIRConstants::JSON_FIELD_FHIR_COMMENTS])) { |
58 |
| - $this->_addFHIRComment($<?php echo $constructorParamName; ?>[PHPFHIRConstants::JSON_FIELD_FHIR_COMMENTS]); |
| 52 | + if (isset($data[PHPFHIRConstants::JSON_FIELD_FHIR_COMMENTS])) { |
| 53 | + if (is_array($data[PHPFHIRConstants::JSON_FIELD_FHIR_COMMENTS])) { |
| 54 | + $this->_setFHIRComments($data[PHPFHIRConstants::JSON_FIELD_FHIR_COMMENTS]); |
| 55 | + } elseif (is_string($data[PHPFHIRConstants::JSON_FIELD_FHIR_COMMENTS])) { |
| 56 | + $this->_addFHIRComment($data[PHPFHIRConstants::JSON_FIELD_FHIR_COMMENTS]); |
59 | 57 | }
|
60 | 58 | }<?php endif; ?>
|
61 | 59 |
|
|
0 commit comments