-
-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Labels
Description
I am getting an error when creating a custom repository with a createQuery method:
Return type (TYPO3\CMS\Extbase\Persistence\QueryInterface<TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface>) of method Example\Example\Domain\Repository\NewsRepository::createQuery()
should be compatible with return type (TYPO3\CMS\Extbase\Persistence\QueryInterface<object>)
of method TYPO3\CMS\Extbase\Persistence\RepositoryInterface<object>::createQuery()
My repository looks like this:
<?php
declare(strict_types = 1);
namespace Example\Example\Domain\Repository;
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
use TYPO3\CMS\Extbase\Persistence\Repository;
use Example\Example\Domain\Model\News;
/**
* @extends Repository<News>
*/
class NewsRepository extends Repository {
public function createQuery(): QueryInterface {
$query = parent::createQuery();
$query->getQuerySettings()->setRespectStoragePage(false);
return $query;
}
}I think, the Repository stub is not needed any more in TYPO3 v12. The default Extbase Repository also has a Template:
/**
* The base repository - will usually be extended by a more concrete repository.
* @template T of \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface
* @implements RepositoryInterface<T>
*/
class Repository implements RepositoryInterface, SingletonInterfaceBut PHPStan TYPO3 overwrites this with its own template:
/**
* @template TEntityClass of \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface
*/
class RepositoryWhen I remove the stub, the PHPStan error disappears.