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 @@ -199,9 +199,14 @@ static function (Type $type, callable $traverse) use ($objectManager): Type {
return new MixedType();
}

return $objectManager->getMetadataFactory()->hasMetadataFor($type->getClassName())
? new ArrayType(new MixedType(), new MixedType())
: $traverse($type);
if (!$objectManager->getMetadataFactory()->hasMetadataFor($type->getClassName())) {
return $traverse($type);
}

// We could return `new ArrayTyp(new MixedType(), new MixedType())`
// but the lack of precision in the array keys/values would give false positive
// @see https://github.com/phpstan/phpstan-doctrine/pull/412#issuecomment-1497092934
return new MixedType();
}
);
}
Expand Down
16 changes: 8 additions & 8 deletions tests/Type/Doctrine/data/QueryResult/queryResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,35 +155,35 @@ public function testReturnTypeOfQueryMethodsWithExplicitArrayHydrationMode(Entit
');

assertType(
'list<array>',
'list<mixed>',
$query->getResult(AbstractQuery::HYDRATE_ARRAY)
);
assertType(
'list<array>',
'list<mixed>',
$query->getArrayResult()
);
assertType(
'iterable<int, array>',
'iterable<int, mixed>',
$query->toIterable([], AbstractQuery::HYDRATE_ARRAY)
);
assertType(
'list<array>',
'list<mixed>',
$query->execute(null, AbstractQuery::HYDRATE_ARRAY)
);
assertType(
'list<array>',
'list<mixed>',
$query->executeIgnoreQueryCache(null, AbstractQuery::HYDRATE_ARRAY)
);
assertType(
'list<array>',
'list<mixed>',
$query->executeUsingQueryCache(null, AbstractQuery::HYDRATE_ARRAY)
);
assertType(
'array',
'mixed',
$query->getSingleResult(AbstractQuery::HYDRATE_ARRAY)
);
assertType(
'array|null',
'mixed',
$query->getOneOrNullResult(AbstractQuery::HYDRATE_ARRAY)
);

Expand Down