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
-------
be6432ee4c
fix extracting mixed type-hinted property types
This commit is contained in:
commit
4a32fd0446
@ -162,8 +162,8 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
|
|||||||
try {
|
try {
|
||||||
$reflectionProperty = new \ReflectionProperty($class, $property);
|
$reflectionProperty = new \ReflectionProperty($class, $property);
|
||||||
$type = $reflectionProperty->getType();
|
$type = $reflectionProperty->getType();
|
||||||
if (null !== $type) {
|
if (null !== $type && $types = $this->extractFromReflectionType($type, $reflectionProperty->getDeclaringClass())) {
|
||||||
return $this->extractFromReflectionType($type, $reflectionProperty->getDeclaringClass());
|
return $types;
|
||||||
}
|
}
|
||||||
} catch (\ReflectionException $e) {
|
} catch (\ReflectionException $e) {
|
||||||
// noop
|
// noop
|
||||||
|
@ -239,6 +239,7 @@ class ReflectionExtractorTest extends TestCase
|
|||||||
['string', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Stringable'), new Type(Type::BUILTIN_TYPE_STRING)]],
|
['string', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Stringable'), new Type(Type::BUILTIN_TYPE_STRING)]],
|
||||||
['payload', null],
|
['payload', null],
|
||||||
['data', null],
|
['data', null],
|
||||||
|
['mixedProperty', null],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ namespace Symfony\Component\PropertyInfo\Tests\Fixtures;
|
|||||||
|
|
||||||
class Php80Dummy
|
class Php80Dummy
|
||||||
{
|
{
|
||||||
|
public mixed $mixedProperty;
|
||||||
|
|
||||||
public function getFoo(): array|null
|
public function getFoo(): array|null
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user