-
Couldn't load subscription status.
- Fork 112
Return a generic array in Query #385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,10 +3,24 @@ | |
| namespace Doctrine\ORM; | ||
|
|
||
| /** | ||
| * @template TKey as array-key | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might be conflicting with the solution propsed in #384 |
||
| * @template TResult The type of results returned by this query in HYDRATE_OBJECT mode | ||
| * | ||
| * @extends AbstractQuery<TResult> | ||
| */ | ||
| final class Query extends AbstractQuery | ||
| { | ||
| public const HYDRATE_OBJECT = 1; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was needed to fix: |
||
|
|
||
| /** | ||
| * @param int|string $hydrationMode | ||
| * | ||
| * @return ($hydrationMode is self::HYDRATE_OBJECT | ||
| * ? array<TKey, TResult> | ||
| * : mixed | ||
| * ) | ||
| */ | ||
| public function getResult($hydrationMode = self::HYDRATE_OBJECT) | ||
| { | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -232,36 +232,36 @@ public function testReturnTypeOfQueryMethodsWithExplicitNonConstantHydrationMode | |
| * Test that we return the original return type when ResultType may be | ||
| * VoidType | ||
| * | ||
| * @param Query<mixed> $query | ||
| * @param Query<array-key, mixed> $query | ||
| */ | ||
| public function testReturnTypeOfQueryMethodsWithReturnTypeIsMixed(EntityManagerInterface $em, Query $query): void | ||
| { | ||
| assertType( | ||
| 'mixed', | ||
| 'array<(int|string)>', | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TBH, I'm not really sure about these changes but all the tests pass now 🙄 |
||
| $query->getResult(AbstractQuery::HYDRATE_OBJECT) | ||
| ); | ||
| assertType( | ||
| 'iterable', | ||
| 'iterable<(int|string)>', | ||
| $query->toIterable([], AbstractQuery::HYDRATE_OBJECT) | ||
| ); | ||
| assertType( | ||
| 'mixed', | ||
| 'array<(int|string)>', | ||
| $query->execute(null, AbstractQuery::HYDRATE_OBJECT) | ||
| ); | ||
| assertType( | ||
| 'mixed', | ||
| 'array<(int|string)>', | ||
| $query->executeIgnoreQueryCache(null, AbstractQuery::HYDRATE_OBJECT) | ||
| ); | ||
| assertType( | ||
| 'mixed', | ||
| 'array<(int|string)>', | ||
| $query->executeUsingQueryCache(null, AbstractQuery::HYDRATE_OBJECT) | ||
| ); | ||
| assertType( | ||
| 'mixed', | ||
| '(int|string)', | ||
| $query->getSingleResult(AbstractQuery::HYDRATE_OBJECT) | ||
| ); | ||
| assertType( | ||
| 'mixed', | ||
| 'int|string|null', | ||
| $query->getOneOrNullResult(AbstractQuery::HYDRATE_OBJECT) | ||
| ); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo