UnNecessaryDoubleQuotes
info off by default quick-fixGroup: Code style · PhpStorm name: UnNecessaryDoubleQuotesInspection
A double-quoted string that contains no interpolation and no escape sequence behaves exactly like a single-quoted one. Single quotes make it obvious that nothing is evaluated inside.
Example
php
<?php
$label = "ready";
$price = "\$9 \"net\"";
$none = "";
$dollar = "cost: $";
$kept1 = 'already single';
$kept2 = "hello {$name}";
$kept3 = "it's";
$kept4 = "line\n";
$kept5 = "C:\\temp";
$kept6 = <<<TXT
body
TXT;php
<?php
$label = 'ready';
$price = '$9 "net"';
$none = '';
$dollar = 'cost: $';Reported:
- line 2: No interpolation or escapes here; use single quotes.
- line 3: No interpolation or escapes here; use single quotes.
- line 4: No interpolation or escapes here; use single quotes.
- line 5: No interpolation or escapes here; use single quotes.
Configure
In custos.json:
json
{
"rules": {
"UnNecessaryDoubleQuotes": {
"enabled": true
}
}
}Suppress
Before the statement or declaration (or the first statement of the file), either of:
php
// @custos-ignore UnNecessaryDoubleQuotes
/**
* @noinspection UnNecessaryDoubleQuotesInspection
*/