Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save willemnviljoen/d20ad8ad0cc365a7e80744328246610f to your computer and use it in GitHub Desktop.
Save willemnviljoen/d20ad8ad0cc365a7e80744328246610f to your computer and use it in GitHub Desktop.
SQL language injection for PHPStorm which specifically ignores the Doctrine DQL language
<LanguageInjectionConfiguration>
<injection language="SQL" injector-id="php">
<display-name>&quot;SQL select/delete/insert/update/create&quot; Excluding Doctrine DQL</display-name>
<place><![CDATA[and(not(phpLiteralMatchesBrics(".*:.*")), phpLiteralMatchesBrics(" *(((SELECT|DELETE) .*FROM)|((INSERT|REPLACE) .*INTO)|(UPDATE .* SET)|((CREATE|DROP|ALTER) +((TEMPORARY )?TABLE|(UNIQUE )?INDEX))) .*"))]]></place>
</injection>
</LanguageInjectionConfiguration>
@willemnviljoen
Copy link
Author

Hi,

It should prevent that yes, since it stops the IDE from even considering that string to be SQL. I've done a quick experiment on some of my code, asking PHPStorm to format it, and it left it alone.

Hopefully it works for everyone.

@stof
Copy link

stof commented Sep 26, 2017

this would not work if you write the class name rather than a App:User shortcut though.

@neuro159
Copy link

neuro159 commented Oct 9, 2017

May be we can just pull this to core PhpStorm for now?.. //PS team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment