Skip to content

Commit

Permalink
TASK: Load stubs depending on TYPO3 version
Browse files Browse the repository at this point in the history
This reverts commit a30c83a.
  • Loading branch information
sabbelasichon committed Feb 15, 2024
1 parent a30c83a commit bb14d3e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 25 deletions.
10 changes: 1 addition & 9 deletions extension.neon
Expand Up @@ -140,17 +140,9 @@ parameters:
routeEnhancers: array
websiteTitle: string
stubFiles:
- stubs/DomainObjectInterface.stub
- stubs/EventDispatcher.stub
- stubs/ObjectStorage.stub
- stubs/QueryFactory.stub
- stubs/QueryInterface.stub
- stubs/QueryResultInterface.stub
- stubs/Repository.stub
# See SaschaEgerer\PhpstanTypo3\Stubs\StubFilesExtensionLoader
# GeneralUtility.stub is only used if TYPO3 version is < 12
#- stubs/GeneralUtility.stub
#- stubs/QueryResult.stub
# Some stubs are loaded depending on the TYPO3 version used. See SaschaEgerer\PhpstanTypo3\Stubs\StubFilesExtensionLoader
dynamicConstantNames:
- TYPO3_MODE
- TYPO3_REQUESTTYPE
Expand Down
7 changes: 6 additions & 1 deletion src/Stubs/StubFilesExtensionLoader.php
Expand Up @@ -20,7 +20,12 @@ public function getFiles(): array
$files[] = $stubsDir . '/GeneralUtility.stub';
}
if ($versionParser->parseConstraints($typo3Version->getVersion())->matches($versionParser->parseConstraints('<= 12.2.0'))) {
$files[] = $stubsDir . '/QueryResult.stub';
$files[] = $stubsDir . '/QueryFactory.stub';
$files[] = $stubsDir . '/QueryFactory.stub';
$files[] = $stubsDir . '/Repository.stub';
$files[] = $stubsDir . '/DomainObjectInterface.stub';
$files[] = $stubsDir . '/QueryInterface.stub';
$files[] = $stubsDir . '/QueryResultInterface.stub';
}

return $files;
Expand Down
3 changes: 0 additions & 3 deletions stubs/QueryInterface.stub
Expand Up @@ -6,9 +6,6 @@ namespace TYPO3\CMS\Extbase\Persistence;
*/
interface QueryInterface
{
public const ORDER_ASCENDING = 'ASC';
public const ORDER_DESCENDING = 'DESC';

/**
* @param bool $returnRawQueryResult
* @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface<ModelType>|array<string, mixed>
Expand Down
7 changes: 0 additions & 7 deletions stubs/Repository.stub
Expand Up @@ -61,11 +61,4 @@ 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
* @phpstan-return QueryResultInterface<TEntityClass>|list<TEntityClass>
*/
public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null);
}
5 changes: 0 additions & 5 deletions tests/Unit/Type/data/repository-stub-files.php
Expand Up @@ -159,11 +159,6 @@ 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

0 comments on commit bb14d3e

Please sign in to comment.