Skip to content

Commit 8042cb0

Browse files
authored
Merge pull request #31 from Ardenexal/claude/fix-failing-tests-mAbNV
fix: resolve failing unit tests across multiple components
2 parents 4627308 + 4937cd5 commit 8042cb0

15 files changed

Lines changed: 131 additions & 2655 deletions

composer.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,33 @@
1313
"amphp/http-client": "^5.3.4",
1414
"composer/semver": "^3.4.4",
1515
"nette/php-generator": "^4.2.1",
16-
"symfony/console": "^6.4|^7.4.4",
16+
"symfony/console": "^6.4|^7.4",
1717
"symfony/dotenv": "^6.4|^7.4",
1818
"symfony/filesystem": "^6.4|^7.4",
1919
"symfony/flex": "^2.10",
20-
"symfony/framework-bundle": "^6.4|^7.4.5",
21-
"symfony/http-client": "^6.4|^7.4.5",
22-
"symfony/intl": "^6.4|^7.4.4",
20+
"symfony/framework-bundle": "^6.4|^7.4",
21+
"symfony/http-client": "^6.4|^7.4",
22+
"symfony/intl": "^6.4|^7.4",
2323
"symfony/polyfill-php84": "^v1.33.0",
2424
"symfony/polyfill-php85": "^v1.33.0",
25-
"symfony/property-access": "^6.4|^7.4.4",
26-
"symfony/runtime": "^6.4|^7.4.1",
27-
"symfony/serializer": "^6.4|^7.4.5",
28-
"symfony/string": "^6.4|^7.4.4",
29-
"symfony/validator": "^6.4|^7.4.5",
30-
"symfony/yaml": "^6.4|^7.4.1"
25+
"symfony/property-access": "^6.4|^7.4",
26+
"symfony/runtime": "^6.4|^7.4",
27+
"symfony/serializer": "^6.4|^7.4",
28+
"symfony/string": "^6.4|^7.4",
29+
"symfony/validator": "^6.4|^7.4",
30+
"symfony/yaml": "^6.4|^7.4"
3131
},
3232
"require-dev": {
3333
"giorgiosironi/eris": "^1.0",
3434
"laravel/pint": "^1.27.1",
3535
"phpstan/phpstan": "^2.1.39",
3636
"phpunit/phpunit": "^11.0|^12.5.11",
3737
"roave/security-advisories": "dev-latest",
38-
"symfony/browser-kit": "^6.4|^7.4.4",
38+
"symfony/browser-kit": "^6.4|^7.4",
3939
"symfony/css-selector": "^6.4|^7.4",
40-
"symfony/dom-crawler": "^6.4|^7.4.4",
40+
"symfony/dom-crawler": "^6.4|^7.4",
4141
"symfony/maker-bundle": "^1.66.0",
42-
"symfony/phpunit-bridge": "^6.4|^7.4.3"
42+
"symfony/phpunit-bridge": "^6.4|^7.4"
4343
},
4444
"config": {
4545
"allow-plugins": {

src/Bundle/FHIRBundle/Resources/config/services.yaml

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,55 @@ services:
1313
Ardenexal\FHIRTools\Bundle\FHIRBundle\Command\FHIRPathValidateCommand:
1414
arguments:
1515
$pathService: '@Ardenexal\FHIRTools\Component\FHIRPath\Service\FHIRPathService'
16-
tags: ['console.command']
16+
tags: ['console.command']
17+
18+
# Code Generation Services
19+
Ardenexal\FHIRTools\Component\CodeGeneration\Generator\FHIRModelGenerator:
20+
public: true
21+
22+
Ardenexal\FHIRTools\Component\CodeGeneration\Package\PackageLoader:
23+
public: true
24+
25+
Ardenexal\FHIRTools\Component\CodeGeneration\Generator\ErrorCollector:
26+
public: true
27+
28+
Ardenexal\FHIRTools\Component\CodeGeneration\Package\RetryHandler:
29+
public: true
30+
31+
# Serialization Services
32+
Ardenexal\FHIRTools\Component\Serialization\Metadata\FHIRMetadataExtractor: ~
33+
34+
Ardenexal\FHIRTools\Component\Serialization\Metadata\FHIRMetadataExtractorInterface:
35+
alias: 'Ardenexal\FHIRTools\Component\Serialization\Metadata\FHIRMetadataExtractor'
36+
37+
Ardenexal\FHIRTools\Component\Serialization\Validator\FHIRValidator:
38+
public: true
39+
40+
Ardenexal\FHIRTools\Serialization\FHIRSerializationService:
41+
public: true
42+
43+
# Top-level aliases for backward compatibility
44+
Ardenexal\FHIRTools\FHIRModelGenerator:
45+
alias: 'Ardenexal\FHIRTools\Component\CodeGeneration\Generator\FHIRModelGenerator'
46+
public: true
47+
48+
Ardenexal\FHIRTools\Serialization\FHIRValidator:
49+
alias: 'Ardenexal\FHIRTools\Component\Serialization\Validator\FHIRValidator'
50+
public: true
51+
52+
# Named service aliases
53+
fhir.model_generator:
54+
alias: 'Ardenexal\FHIRTools\FHIRModelGenerator'
55+
public: true
56+
57+
fhir.serialization_service:
58+
alias: 'Ardenexal\FHIRTools\Serialization\FHIRSerializationService'
59+
public: true
60+
61+
fhir.package_loader:
62+
alias: 'Ardenexal\FHIRTools\Component\CodeGeneration\Package\PackageLoader'
63+
public: true
64+
65+
fhir.validator:
66+
alias: 'Ardenexal\FHIRTools\Serialization\FHIRValidator'
67+
public: true

src/Component/FHIRPath/src/Type/FHIRTypeResolver.php

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Ardenexal\FHIRTools\Component\FHIRPath\Type;
66

7+
use Ardenexal\FHIRTools\Component\CodeGeneration\Attributes\FHIRPrimitive;
8+
79
/**
810
* Resolves and validates FHIR types using the generated FHIR models.
911
*
@@ -72,11 +74,22 @@ public function inferType(mixed $value): string
7274
}
7375

7476
if (is_object($value)) {
77+
// Check if the object has a FHIRPrimitive attribute
78+
$ref = new \ReflectionClass($value);
79+
$attrs = $ref->getAttributes(FHIRPrimitive::class);
80+
81+
if (!empty($attrs)) {
82+
/** @var FHIRPrimitive $primitive */
83+
$primitive = $attrs[0]->newInstance();
84+
85+
return $primitive->primitiveType;
86+
}
87+
7588
// Get the class name and extract the FHIR type
7689
$class = get_class($value);
7790

7891
// Check if it's a generated FHIR model
79-
if (str_contains($class, '\\FHIR\\')) {
92+
if (str_contains($class, '\\FHIR\\') || str_contains($class, '\\Models\\')) {
8093
// Extract the type name from the class name
8194
$parts = explode('\\', $class);
8295

@@ -110,13 +123,18 @@ public function isOfType(mixed $value, string $typeName): bool
110123
return true;
111124
}
112125

126+
// Case-insensitive match
127+
if (strcasecmp($actualType, $typeName) === 0) {
128+
return true;
129+
}
130+
113131
// Check for type compatibility
114132
if ($typeName === 'Any') {
115133
return true;
116134
}
117135

118-
// Check if integer is compatible with decimal
119-
if ($typeName === 'decimal' && $actualType === 'integer') {
136+
// Check if integer is compatible with decimal (case-insensitive)
137+
if (strcasecmp($typeName, 'decimal') === 0 && $actualType === 'integer') {
120138
return true;
121139
}
122140

@@ -148,12 +166,26 @@ public function castToType(mixed $value, string $typeName): mixed
148166
return $value;
149167
}
150168

169+
// Extract value from FHIR primitives before casting
170+
$castValue = $value;
171+
if (is_object($value)) {
172+
$ref = new \ReflectionClass($value);
173+
$attrs = $ref->getAttributes(FHIRPrimitive::class);
174+
175+
if (!empty($attrs) && property_exists($value, 'value')) {
176+
$castValue = $value->value;
177+
}
178+
}
179+
180+
// Normalize typeName to lowercase for matching
181+
$normalizedType = strtolower($typeName);
182+
151183
// Primitive type casting
152-
return match ($typeName) {
153-
'boolean' => $this->castToBoolean($value),
154-
'string' => $this->castToString($value),
155-
'integer' => $this->castToInteger($value),
156-
'decimal' => $this->castToDecimal($value),
184+
return match ($normalizedType) {
185+
'boolean' => $this->castToBoolean($castValue),
186+
'string' => $this->castToString($castValue),
187+
'integer' => $this->castToInteger($castValue),
188+
'decimal' => $this->castToDecimal($castValue),
157189
default => throw new \InvalidArgumentException(sprintf('Cannot cast value to type "%s"', $typeName)),
158190
};
159191
}

0 commit comments

Comments
 (0)