File tree Expand file tree Collapse file tree 3 files changed +35
-3
lines changed Expand file tree Collapse file tree 3 files changed +35
-3
lines changed Original file line number Diff line number Diff line change 1313 "nikic/php-parser" : " ^4.15.1" ,
1414 "typo3/cms-core" : " ^10.4 || ^11.5 || ^12.2" ,
1515 "typo3/cms-extbase" : " ^10.4 || ^11.5 || ^12.2" ,
16- "bnf/phpstan-psr-container" : " ^1.0"
16+ "bnf/phpstan-psr-container" : " ^1.0" ,
17+ "composer/semver" : " ^3.3"
1718 },
1819 "require-dev" : {
1920 "consistence-community/coding-standard" : " ^3.10.1" ,
Original file line number Diff line number Diff line change @@ -89,6 +89,10 @@ services:
8989 class : SaschaEgerer\PhpstanTypo3\Type\MathUtilityTypeSpecifyingExtension
9090 tags :
9191 - phpstan.typeSpecifier.staticMethodTypeSpecifyingExtension
92+ -
93+ class : SaschaEgerer\PhpstanTypo3\Stubs\StubFilesExtensionLoader
94+ tags :
95+ - phpstan.stubFilesExtension
9296parameters :
9397 bootstrapFiles :
9498 - phpstan.bootstrap.php
@@ -121,13 +125,15 @@ parameters:
121125 websiteTitle : string
122126 stubFiles :
123127 - stubs/DomainObjectInterface.stub
124- - stubs/GeneralUtility.stub
125128 - stubs/ObjectStorage.stub
126129 - stubs/QueryFactory.stub
127130 - stubs/QueryInterface.stub
128131 - stubs/QueryResultInterface.stub
129- - stubs/QueryResult.stub
130132 - stubs/Repository.stub
133+ # See SaschaEgerer\PhpstanTypo3\Stubs\StubFilesExtensionLoader
134+ # GeneralUtility.stub is only used if TYPO3 version is < 12
135+ # - stubs/GeneralUtility.stub
136+ # - stubs/QueryResult.stub
131137 dynamicConstantNames :
132138 - TYPO3_MODE
133139 - TYPO3_REQUESTTYPE
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 );
2+
3+ namespace SaschaEgerer \PhpstanTypo3 \Stubs ;
4+
5+ use Composer \InstalledVersions ;
6+ use Composer \Semver \VersionParser ;
7+
8+ class StubFilesExtensionLoader implements \PHPStan \PhpDoc \StubFilesExtension
9+ {
10+
11+ public function getFiles (): array
12+ {
13+ $ stubsDir = dirname (__DIR__ , 2 ) . '/stubs ' ;
14+ $ files = [];
15+ if (InstalledVersions::satisfies (new VersionParser (), 'typo3/cms-core ' , '< 12 ' )) {
16+ $ files [] = $ stubsDir . '/GeneralUtility.stub ' ;
17+ }
18+ if (InstalledVersions::satisfies (new VersionParser (), 'typo3/cms-core ' , '<= 12.2.0 ' )) {
19+ $ files [] = $ stubsDir . '/QueryResult.stub ' ;
20+ }
21+
22+ return $ files ;
23+ }
24+
25+ }
You can’t perform that action at this time.
0 commit comments