Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/QueryReflection/MysqliQueryReflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use PHPStan\Type\TypeCombinator;
use PHPStan\Type\UnionType;
use staabm\PHPStanDba\Error;
use staabm\PHPStanDba\QuerySimulationException;
use staabm\PHPStanDba\Types\MysqlIntegerRanges;

final class MysqliQueryReflector implements QueryReflector
Expand Down Expand Up @@ -119,6 +120,10 @@ public function getResultType(string $queryString, int $fetchType): ?Type
{
$result = $this->simulateQuery($queryString);
if (!\is_array($result)) {
if (QueryReflection::getRuntimeConfiguration()->isDebugEnabled() && $result instanceof mysqli_sql_exception) {
throw new QuerySimulationException(sprintf("Cannot simulate query\n %s \nbecause of a sql error: %s", $queryString, $result->getMessage()));
}

return null;
}

Expand Down
7 changes: 7 additions & 0 deletions src/QuerySimulationException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace staabm\PHPStanDba;

final class QuerySimulationException extends DbaException
{
}
Loading