How to ignore error for a query wich is defined in several lines

I have to write a query like that

$sep = "";
$query = "SELECT * FROM `my_table` WHERE `id` IN(";
foreach ($my_array as $item_id) {   $query .= $sep . $item_id;
   $sep = ',';}
$query .= ")";

The final $query is OK, but phpstorm mark an error on the IN( -expression expect-

I tried with /** @codeCoverageIgnoreStart */

and /** @codeCoverageIgnoreEnd */

but the "error" is not ignored


Hi there,

Why not prepare that part of the query in advance and then simply use the variable inside the string? This kind of approach:

$in_part = implode(', ', $my_array);
$query = "SELECT * FROM `my_table` WHERE `id` IN($in_part)";


I tried with /** @codeCoverageIgnoreStart */

codeCoverage has nothing to do here.

If anything, it's suppressing a specific inspection for the line (or the whole file) by using

/** @noinspection InspectionNameHere */


Andriy: in this case I know that the query can be fixed... it just an example. I search solution for more complex situations like that

/** @noinspection InspectionNameHere */

seam to be the solution, but how I know the "InspectionNameHere"


@Ernesto Aides

The link I gave in the previous comment shows with animated pictures how it can be added via context menu: the IDE will add such a comment with the right name for you.

This is how it can be done in your code sample for undefined $my_array variable (assuming that's the only code in a file):

/** @noinspection PhpUndefinedVariableInspection */


The thing is: if the error comes from a (lower) Lexer/Parser level, then it's about actual language syntax... and these kinds of errors cannot be suppressed ("this part is broken/incomplete and I may not continue there" kind of overall message --  sadly you cannot just say to the IDE "ignore broken syntax and treat it as a correct/valid").

AFAIK this is the case here (you are ending your SQL with `... IN(` -- there is no closing `)`)

The only way here would be telling the IDE that it's not an SQL in the string but an ordinary plain text:

$query = /** @lang Text */ "SELECT * FROM `my_table` WHERE `id` IN(";

(hurray, no SQL error any more)


Thanks, Andriy Bazanov, the 

/** @lang Text */

is OK for my issue

Thanks a lot!


Please sign in to leave a comment.