diff --git a/docs/book/v2/ruleset.md b/docs/book/v2/ruleset.md index e4c5d2fb..c7b6c357 100644 --- a/docs/book/v2/ruleset.md +++ b/docs/book/v2/ruleset.md @@ -953,25 +953,25 @@ Force whitespace before and after concatenation ### Squiz.Strings.DoubleQuoteUsage #### Squiz.Strings.DoubleQuoteUsage.ContainsVar -Double quote strings may only be used if they contain variables. SQL queries containing single quotes are an exception +Double quote strings may only be used if they contain variables, control characters or if using single quotes would +result in more escaped characters than necessary. For instance, SQL queries containing single quotes are an exception to the rule. -*Valid: Double quote strings are only used when it contains a variable.* +*Valid: Double quote strings are only used when it contains a variable, control characters or single quotes.* ```php - - - Variable "%s" not allowed in double quoted string; use sprintf() or concatenation instead + + diff --git a/test/expected-report.txt b/test/expected-report.txt index a90ee1c0..1dccd6c2 100644 --- a/test/expected-report.txt +++ b/test/expected-report.txt @@ -10,7 +10,7 @@ test/fixable/class-properties.php 6 0 test/fixable/classes-traits-interfaces.php 17 1 test/fixable/closures.php 19 0 test/fixable/commenting.php 26 0 -test/fixable/concatenation-spacing.php 21 0 +test/fixable/concatenation-spacing.php 19 0 test/fixable/control-structures.php 6 0 test/fixable/example-class.php 29 0 test/fixable/extends-and-implements-multiline.php 13 0 @@ -30,6 +30,7 @@ test/fixable/return-type-on-methods.php 17 0 test/fixable/semicolon-spacing.php 5 0 test/fixable/spacing.php 18 1 test/fixable/statement-alignment.php 19 0 +test/fixable/strings-double-quote-usage.php 6 0 test/fixable/test-case.php 4 0 test/fixable/traits-uses.php 9 0 test/fixable/UnusedVariables.php 1 0 @@ -37,9 +38,9 @@ test/fixable/useless-semicolon.php 8 0 test/fixable/variable-names.php 5 2 test/fixable/visibility-declaration.php 1 0 ---------------------------------------------------------------------- -A TOTAL OF 441 ERRORS AND 6 WARNINGS WERE FOUND IN 33 FILES +A TOTAL OF 445 ERRORS AND 6 WARNINGS WERE FOUND IN 34 FILES ---------------------------------------------------------------------- -PHPCBF CAN FIX 377 OF THESE SNIFF VIOLATIONS AUTOMATICALLY +PHPCBF CAN FIX 381 OF THESE SNIFF VIOLATIONS AUTOMATICALLY ---------------------------------------------------------------------- diff --git a/test/fixable/strings-double-quote-usage.php b/test/fixable/strings-double-quote-usage.php new file mode 100644 index 00000000..a1f37b1a --- /dev/null +++ b/test/fixable/strings-double-quote-usage.php @@ -0,0 +1,16 @@ +