Skip to content

Commit 52bdb11

Browse files
Merge pull request #119 from sascha-egerer/bugfix/fix-fatal-in-queryinterface-d-r-t
[BUGFIX] Fix fatal error in QueryInterfaceDynamicReturnTypeExtension
2 parents 8421c0d + 58af904 commit 52bdb11

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/Type/QueryInterfaceDynamicReturnTypeExtension.php

+9-4
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
use PHPStan\Type\ErrorType;
1212
use PHPStan\Type\Generic\GenericObjectType;
1313
use PHPStan\Type\IntegerType;
14+
use PHPStan\Type\MixedType;
1415
use PHPStan\Type\ObjectType;
1516
use PHPStan\Type\Type;
1617
use SaschaEgerer\PhpstanTypo3\Helpers\Typo3ClassNamingUtilityTrait;
1718
use TYPO3\CMS\Extbase\Persistence\Generic\QueryResult;
1819
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
20+
use TYPO3\CMS\Extbase\Persistence\Repository;
1921

2022
class QueryInterfaceDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension
2123
{
@@ -51,12 +53,15 @@ public function getTypeFromMethodCall(
5153
if ($classReflection === null) {
5254
return new ErrorType();
5355
}
56+
$modelType = [new MixedType()];
5457

55-
$modelName = $this->translateRepositoryNameToModelName(
56-
$classReflection->getName()
57-
);
58+
if ($classReflection->isSubclassOf(Repository::class)) {
59+
$modelName = $this->translateRepositoryNameToModelName(
60+
$classReflection->getName()
61+
);
5862

59-
$modelType = [new ObjectType($modelName)];
63+
$modelType = [new ObjectType($modelName)];
64+
}
6065
}
6166

6267
if ($argument !== null) {

0 commit comments

Comments
 (0)