Skip to content

Commit

Permalink
Do not crash on wrong QueryBuilder calls
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jul 1, 2023
1 parent a9eae20 commit 44275d6
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use PHPStan\Type\DynamicMethodReturnTypeExtension;
use PHPStan\Type\Type;
use PHPStan\Type\TypeCombinator;
use Throwable;
use function count;
use function in_array;
use function method_exists;
Expand Down Expand Up @@ -141,7 +142,11 @@ public function getTypeFromMethodCall(
return $defaultReturnType;
}

$queryBuilder->{$methodName}(...$args);
try {
$queryBuilder->{$methodName}(...$args);
} catch (Throwable $e) {
return $defaultReturnType;
}
}

$resultTypes[] = $this->getQueryType($queryBuilder->getDQL());
Expand Down

0 comments on commit 44275d6

Please sign in to comment.