Is there a way to avoid SQL inspections on non-SQL strings?

Answered

There's a number of place in my project where PhpStorm is assuming a piece of text is SQL, usually because the word "select" appears in the string. E.g.

$prompt = 'Select your country from the drop-down list.';

I'm pretty consistent in my use of case and always use "SELECT" in actual SQL strings, so maybe there's some way to tweak the inspection?

0
2 comments
Avatar
Permanently deleted user

Hello,

Yes, you are absolutely right - SQL query language injection is being triggered by "Select *** from" words. You can check the injection at Settings\Preferences | Editor | Language Injections.

One way is to use PHPDoc like

$prompt = /** @lang text */
    'Select your country from the drop-down list.'

Another way is to split string between "Select" and "from" like

$prompt = 'Select your country from' . ' the drop-down list.';

Would any of this be suitable?

0

Yes, the PHPDoc snippet is exactly the sort of thing I was looking for.  Thank you!

1

Please sign in to leave a comment.