You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes#504.
This adds new functionality to debug mode to warn about queries that
cannot be resolved due to the presence of non-literal string
variables in the query. This helps to identify places where you might
expect a query to be resolvable, but an inline parameter or a variable
query fragment prevent it.
Some scenarios where this might occur include string query fragments
where using `@phpstandba-inference-placeholder` may be needed, e.g.
/** @var string $condition */
$query = 'SELECT * FROM table WHERE ' . $condition;
Or when not using prepared statements, e.g.
/** @var string $param */
$query = 'SELECT * FROM table WHERE foo=' . $conn->quote($param);
Since these queries cannot be analyzed, they will now emit the
following warning:
> Unresolvable Query: Cannot resolve query with variable type: string.
> Consider replacing variable strings with prepared statements or @phpstandba-inference-placeholder.
Without this warning, errors in these queries will go undetected.
Implementation notes:
1. We make `UnresolvableQueryException` abstract, and add child classes
for each type of unresolvable query error so that we can provide
customized tips for each one.
2. Special care had to be taken to retain the ability to ignore queries
that are _entirely_ StringType, because it was explicitly desired
for these queries to not return an error (even in debug mode). This
is because such queries are likely part of a s/w layer that we know
nothing about. Therefore, we early return before checking parameters
for any query that is is a superset of `StringType` (which includes
the previous `MixedType` condition, and any mix of the two).
0 commit comments