Skip to content

Commit

Permalink
Merge pull request #119 from sascha-egerer/bugfix/fix-fatal-in-queryi…
Browse files Browse the repository at this point in the history
…nterface-d-r-t

[BUGFIX] Fix fatal error in QueryInterfaceDynamicReturnTypeExtension
  • Loading branch information
sascha-egerer authored Apr 13, 2023
2 parents 8421c0d + 58af904 commit 52bdb11
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Type/QueryInterfaceDynamicReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
use PHPStan\Type\ErrorType;
use PHPStan\Type\Generic\GenericObjectType;
use PHPStan\Type\IntegerType;
use PHPStan\Type\MixedType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
use SaschaEgerer\PhpstanTypo3\Helpers\Typo3ClassNamingUtilityTrait;
use TYPO3\CMS\Extbase\Persistence\Generic\QueryResult;
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
use TYPO3\CMS\Extbase\Persistence\Repository;

class QueryInterfaceDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension
{
Expand Down Expand Up @@ -51,12 +53,15 @@ public function getTypeFromMethodCall(
if ($classReflection === null) {
return new ErrorType();
}
$modelType = [new MixedType()];

$modelName = $this->translateRepositoryNameToModelName(
$classReflection->getName()
);
if ($classReflection->isSubclassOf(Repository::class)) {
$modelName = $this->translateRepositoryNameToModelName(
$classReflection->getName()
);

$modelType = [new ObjectType($modelName)];
$modelType = [new ObjectType($modelName)];
}
}

if ($argument !== null) {
Expand Down

0 comments on commit 52bdb11

Please sign in to comment.