Skip to content
Snippets Groups Projects
Commit 2164222a authored by Oliver Klee's avatar Oliver Klee Committed by Nikita Hovratov
Browse files

[BUGFIX] Fix and improve type annotations of the Repository base class

This helps reduce warnings when extensions are type-checked with PHPStan.

Resolves: #97820
Releases: main, 11.5

Change-Id: Iee5cd28402d9e33af0bfaa34815552ba331718ee
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74991


Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarBenni Mack <benni@typo3.org>
Tested-by: default avatarNikita Hovratov <nikita.h@live.de>
Reviewed-by: default avatarBenni Mack <benni@typo3.org>
Reviewed-by: default avatarNikita Hovratov <nikita.h@live.de>
parent 95f8d6db
Branches
Tags
No related merge requests found
......@@ -2540,11 +2540,6 @@ parameters:
count: 1
path: ../../typo3/sysext/extbase/Tests/Unit/Persistence/RepositoryTest.php
-
message: "#^Parameter \\#2 \\$arguments of method TYPO3\\\\CMS\\\\Extbase\\\\Persistence\\\\Repository\\:\\:__call\\(\\) expects string, array given\\.$#"
count: 1
path: ../../typo3/sysext/extbase/Tests/Unit/Persistence/RepositoryTest.php
-
message: "#^Parameter \\#2 \\$key of method TYPO3\\\\CMS\\\\Extbase\\\\Property\\\\PropertyMappingConfiguration\\:\\:getConfigurationValue\\(\\) expects string, int given\\.$#"
count: 2
......
......@@ -24,9 +24,6 @@ use TYPO3\CMS\Extbase\Persistence\Repository;
*/
class BackendUserGroupRepository extends Repository
{
/**
* @var array Default order is by title ascending
*/
protected $defaultOrderings = [
'title' => QueryInterface::ORDER_ASCENDING,
];
......
......@@ -17,6 +17,8 @@ declare(strict_types=1);
namespace TYPO3\CMS\Core\Utility;
use TYPO3\CMS\Extbase\Persistence\RepositoryInterface;
/**
* Several functions related to naming and conversions of names
* such as translation between Repository and Model names or
......@@ -42,6 +44,10 @@ class ClassNamingUtility
* Translates a repository name to an appropriate model name
* e.g. Tx_Extbase_Domain_Repository_FooRepository to Tx_Extbase_Domain_Model_Foo
* or \TYPO3\CMS\Extbase\Domain\Repository\FooRepository to \TYPO3\CMS\Extbase\Domain\Model\Foo
*
* @param class-string<RepositoryInterface> $repositoryName
*
* @return class-string
*/
public static function translateRepositoryNameToModelName(string $repositoryName): string
{
......
......@@ -25,9 +25,6 @@ use TYPO3\CMS\Extbase\Persistence\Repository;
*/
class ContentRepository extends Repository
{
/**
* @var array
*/
protected $defaultOrderings = [
'sorting' => QueryInterface::ORDER_ASCENDING,
];
......
......@@ -25,9 +25,6 @@ use TYPO3\CMS\Extbase\Persistence\Repository;
*/
class ContentRepository extends Repository
{
/**
* @var array
*/
protected $defaultOrderings = [
'sorting' => QueryInterface::ORDER_ASCENDING,
];
......
......@@ -32,18 +32,18 @@ class Repository implements RepositoryInterface, SingletonInterface
protected $persistenceManager;
/**
* @var string
* @var class-string
*/
protected $objectType;
/**
* @var array
* @var array<non-empty-string, QueryInterface::ORDER_*>
*/
protected $defaultOrderings = [];
/**
* Override query settings created by extbase natively.
* Be careful if using this, see the comment on setDefaultQuerySettings() for more insights.
* Be careful if using this, see the comment on `setDefaultQuerySettings()` for more insights.
*
* @var \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface
*/
......@@ -169,7 +169,7 @@ class Repository implements RepositoryInterface, SingletonInterface
* 'bar' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING
* )
*
* @param array<string,string> $defaultOrderings The property names to order by
* @param array<non-empty-string, QueryInterface::ORDER_*> $defaultOrderings The property names to order by
*/
public function setDefaultOrderings(array $defaultOrderings)
{
......@@ -212,8 +212,8 @@ class Repository implements RepositoryInterface, SingletonInterface
/**
* Dispatches magic methods (findBy[Property]())
*
* @param string $methodName The name of the magic method
* @param string $arguments The arguments of the magic method
* @param non-empty-string $methodName The name of the magic method
* @param array<int, mixed> $arguments The arguments of the magic method
* @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\UnsupportedMethodException
* @return mixed
*/
......@@ -248,7 +248,7 @@ class Repository implements RepositoryInterface, SingletonInterface
/**
* Returns the class name of this class.
*
* @return string Class name of the repository.
* @return class-string<RepositoryInterface> Class name of the repository.
*/
protected function getRepositoryClassName()
{
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment