Skip to content

Commit

Permalink
fixing constructors for types that extend primitive types
Browse files Browse the repository at this point in the history
  • Loading branch information
dcarbone committed Nov 30, 2019
1 parent e7158cb commit 4de1b45
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
7 changes: 3 additions & 4 deletions template/methods/constructor.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* limitations under the License.
*/

use DCarbone\PHPFHIR\Enum\TypeKindEnum;

/** @var \DCarbone\PHPFHIR\Definition\Property[] $sortedProperties */
/** @var \DCarbone\PHPFHIR\Definition\Type $type */
/** @var \DCarbone\PHPFHIR\Definition\Type|null $parentType */
Expand All @@ -30,10 +32,7 @@
ob_start();

switch (true) :
case $type->hasPrimitiveParent():
// types that are just primitive extensions do not get their own constructor.
break;
case $typeKind->isPrimitive():
case $typeKind->isOneOf([TypeKindEnum::PRIMITIVE, TypeKindEnum::_LIST]):
echo require_with(PHPFHIR_TEMPLATE_CONSTRUCTORS_DIR . '/primitive.php', $requireArgs);
break;
case $typeKind->isPrimitiveContainer():
Expand Down
18 changes: 8 additions & 10 deletions template/types/default_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,14 @@

echo "\n";

if (0 !== count($directProperties)) :
echo require_with(
PHPFHIR_TEMPLATE_METHODS_DIR . '/constructor.php',
[
'type' => $type,
'sortedProperties' => $directProperties,
'parentType' => $parentType,
]
);
endif;
echo require_with(
PHPFHIR_TEMPLATE_METHODS_DIR . '/constructor.php',
[
'type' => $type,
'sortedProperties' => $directProperties,
'parentType' => $parentType,
]
);

echo require_with(
PHPFHIR_TEMPLATE_METHODS_DIR . '/common.php',
Expand Down

0 comments on commit 4de1b45

Please sign in to comment.