Skip to content

Commit

Permalink
Revert "Avoid false positive about array result"
Browse files Browse the repository at this point in the history
This reverts commit b3a7b16.
  • Loading branch information
ondrejmirtes committed May 4, 2023
1 parent 84bf895 commit 24fc706
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,9 @@ static function (Type $type, callable $traverse) use ($objectManager): Type {
return new MixedType();
}

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();
return $objectManager->getMetadataFactory()->hasMetadataFor($type->getClassName())
? new ArrayType(new MixedType(), new MixedType())
: $traverse($type);
}
);
}
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<mixed>',
'list<array>',
$query->getResult(AbstractQuery::HYDRATE_ARRAY)
);
assertType(
'list<mixed>',
'list<array>',
$query->getArrayResult()
);
assertType(
'iterable<int, mixed>',
'iterable<int, array>',
$query->toIterable([], AbstractQuery::HYDRATE_ARRAY)
);
assertType(
'list<mixed>',
'list<array>',
$query->execute(null, AbstractQuery::HYDRATE_ARRAY)
);
assertType(
'list<mixed>',
'list<array>',
$query->executeIgnoreQueryCache(null, AbstractQuery::HYDRATE_ARRAY)
);
assertType(
'list<mixed>',
'list<array>',
$query->executeUsingQueryCache(null, AbstractQuery::HYDRATE_ARRAY)
);
assertType(
'mixed',
'array',
$query->getSingleResult(AbstractQuery::HYDRATE_ARRAY)
);
assertType(
'mixed',
'array|null',
$query->getOneOrNullResult(AbstractQuery::HYDRATE_ARRAY)
);

Expand Down

0 comments on commit 24fc706

Please sign in to comment.