Skip to content

Commit

Permalink
[TASK] Only load stubs for version lower than 12
Browse files Browse the repository at this point in the history
  • Loading branch information
sabbelasichon committed May 6, 2024
1 parent a7549f5 commit 7b7d6e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
10 changes: 1 addition & 9 deletions extension.neon
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,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
9 changes: 6 additions & 3 deletions src/Stubs/StubFilesExtensionLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ public function getFiles(): array
$versionParser = new VersionParser();

if ($versionParser->parseConstraints($typo3Version->getVersion())->matches($versionParser->parseConstraints('< 12'))) {
$files[] = $stubsDir . '/GeneralUtility.stub';
}
if ($versionParser->parseConstraints($typo3Version->getVersion())->matches($versionParser->parseConstraints('<= 12.2.0'))) {
$files[] = $stubsDir . '/QueryResult.stub';
$files[] = $stubsDir . '/DomainObjectInterface.stub';
$files[] = $stubsDir . '/QueryFactory.stub';
$files[] = $stubsDir . '/QueryInterface.stub';
$files[] = $stubsDir . '/QueryResultInterface.stub';
$files[] = $stubsDir . '/Repository.stub';
$files[] = $stubsDir . '/GeneralUtility.stub';
}

return $files;
Expand Down

0 comments on commit 7b7d6e2

Please sign in to comment.