8000 bug #40160 [PropertyInfo] fix extracting mixed type-hinted property t… · symfony/symfony@4a32fd0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4a32fd0

Browse files
committed
bug #40160 [PropertyInfo] fix extracting mixed type-hinted property types (xabbuh)
This PR was merged into the 4.4 branch. Discussion ---------- [PropertyInfo] fix extracting mixed type-hinted property types | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #39947 | License | MIT | Doc PR | Commits ------- be6432e fix extracting mixed type-hinted property types
2 parents 4626100 + be6432e commit 4a32fd0

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ public function getTypes($class, $property, array $context = []): ?array
162162
try {
163163
$reflectionProperty = new \ReflectionProperty($class, $property);
164164
$type = $reflectionProperty->getType();
165-
if (null !== $type) {
166-
return $this->extractFromReflectionType($type, $reflectionProperty->getDeclaringClass());
165+
if (null !== $type && $types = $this->extractFromReflectionType($type, $reflectionProperty->getDeclaringClass())) {
166+
return $types;
167167
}
168168
} catch (\ReflectionException $e) {
169169
// noop

src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ public function php80TypesProvider()
239239
['string', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Stringable'), new Type(Type::BUILTIN_TYPE_STRING)]],
240240
['payload', null],
241241
['data', null],
242+
['mixedProperty', null],
242243
];
243244
}
244245

src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php80Dummy.php

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

55
class Php80Dummy
66
{
7+
public mixed $mixedProperty;
8+
79
public function getFoo(): array|null
810
{
911
}

0 commit comments

Comments
 (0)
0