Skip to content
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

TASK: Add findBy method in Repository.stub #157

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions stubs/QueryInterface.stub
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ namespace TYPO3\CMS\Extbase\Persistence;
*/
interface QueryInterface
{
public const ORDER_ASCENDING = 'ASC';
public const ORDER_DESCENDING = 'DESC';

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have these to been added here?

/**
* @param bool $returnRawQueryResult
* @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface<ModelType>|array<string, mixed>
Expand Down
7 changes: 7 additions & 0 deletions stubs/Repository.stub
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,11 @@ class Repository
* @phpstan-return class-string<static>
*/
protected function getRepositoryClassName();

/**
* @phpstan-param array<non-empty-string, mixed> $criteria
* @phpstan-param array<non-empty-string, QueryInterface::ORDER_*>|null $orderBy
Copy link
Owner

@sascha-egerer sascha-egerer Feb 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do wo need these both? I think we have put this into a v13 specific stub. What do you think? See https://github.com/sascha-egerer/phpstan-typo3/blob/master/src/Stubs/StubFilesExtensionLoader.php

* @phpstan-return QueryResultInterface<TEntityClass>|list<TEntityClass>
*/
public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null);
}
5 changes: 5 additions & 0 deletions tests/Unit/Type/data/repository-stub-files.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ public function myTests(): void
'array<int, RepositoryStubFiles\My\Test\Extension\Domain\Model\MyModel>|TYPO3\CMS\Extbase\Persistence\QueryResultInterface<RepositoryStubFiles\My\Test\Extension\Domain\Model\MyModel>',
$this->findAll()
);

assertType(
'array<int, RepositoryStubFiles\My\Test\Extension\Domain\Model\MyModel>|TYPO3\CMS\Extbase\Persistence\QueryResultInterface<RepositoryStubFiles\My\Test\Extension\Domain\Model\MyModel>',
$this->findBy(['foo' => 'baz'])
);
}

public function findAll() // phpcs:ignore SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint
Expand Down
Loading