Skip to content

Commit 61cdb6d

Browse files
committed
Fix return type of QueryInterface::execute()
The `execute()` method has a boolean argument that defines if a raw result should be returned. This means that no object mapping is done but an array containing the result values is returned. It is now also supported to not just pass constant boolean values but a variable containing a boolean to the execute function. In this case it's not clear if a raw result or objects should be returned so we do now return a union type containing both.
1 parent b1c8f18 commit 61cdb6d

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

tests/Unit/Type/data/custom-query-type.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,27 @@ class SomeOtherModel extends AbstractEntity
2828
class MyModelRepository extends Repository
2929
{
3030

31-
public function findBySomething(): void
31+
public function findBySomething(bool $booleanParameter = false): void
3232
{
3333
/** @var QueryInterface<SomeOtherModel> $query */
3434
$query = $this->persistenceManager->createQueryForType(SomeOtherModel::class);
3535

3636
$result = $query->execute();
3737
assertType(
38-
'TYPO3\CMS\Extbase\Persistence\QueryInterface<CustomQueryType\My\Test\Extension\Domain\Model\SomeOtherModel>',
39-
$query
38+
'TYPO3\CMS\Extbase\Persistence\QueryResultInterface<int, CustomQueryType\My\Test\Extension\Domain\Model\SomeOtherModel>',
39+
$result
40+
);
41+
42+
$result = $query->execute(false);
43+
assertType(
44+
'TYPO3\CMS\Extbase\Persistence\QueryResultInterface<int, CustomQueryType\My\Test\Extension\Domain\Model\SomeOtherModel>',
45+
$result
46+
);
47+
48+
$result = $query->execute($booleanParameter);
49+
assertType(
50+
'list<array<string, mixed>>|TYPO3\CMS\Extbase\Persistence\QueryResultInterface<int, CustomQueryType\My\Test\Extension\Domain\Model\SomeOtherModel>',
51+
$result
4052
);
4153

4254
$rawResult = $query->execute(true);

0 commit comments

Comments
 (0)