In a PHP codebase, there is a code style of always using single quotes over double quotes.
How do I configure PhpStorm to always use either single or double quotes depending on the project’s preference?
I don’t want to think about typing '
or "
, PhpStorm should transform it for me automatically.
(I am aware that I am losing support for template string if we only use '
. That’s ok.)
Advertisement
Answer
There is no automatic conversion or enforcing double quoted strings over single quoted on code reformat or whatnot.
https://youtrack.jetbrains.com/issue/WI-49520 — watch this ticket (star/vote/comment) to get notified on any progress.
Php Inspections (EA Extended) plugin has an Inspection for this (might be disabled by default).
Settings/Preferences | Editor | Inspections | PHP | Php Inspections (EA Extended) | Code Style | Unnecessary double quotes
Once enabled such strings will be marked with Weak Warning severity (which you can change to something more noticeable) with Quick Fix available.
P.S. “Replace quotes” intention for switching between different quotes in either way is also available.
Since it’s an Intention, you can batch-run it as well as batch-fix, e.g. Code | Run Inspection by Name...