Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,11 @@ private function extractFromReflectionType(\ReflectionType $reflectionType, \Ref
$nullable = $reflectionType->allowsNull();

foreach (($reflectionType instanceof \ReflectionUnionType || $reflectionType instanceof \ReflectionIntersectionType) ? $reflectionType->getTypes() : [$reflectionType] as $type) {
if (!$type instanceof \ReflectionNamedType) {
// Nested composite types are not supported yet.
return [];
}

$phpTypeOrClass = $type->getName();
if ('null' === $phpTypeOrClass || 'mixed' === $phpTypeOrClass || 'never' === $phpTypeOrClass) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,14 @@ public function testExtractPhp82Type($property, array $type = null)
$this->assertEquals($type, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Php82Dummy', $property, []));
}

public function php82TypesProvider()
public function php82TypesProvider(): iterable
{
yield ['nil', null];
yield ['false', [new Type(Type::BUILTIN_TYPE_FALSE)]];

// Nesting intersection and union types is not supported yet,
// but we should make sure this kind of composite types does not crash the extractor.
yield ['someCollection', null];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ class Php82Dummy
public null $nil = null;

public false $false = false;

public (\Traversable&\Countable)|null $someCollection = null;
}