]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Fix the `ArcanistXHPASTLinter` single quote rule.
authorJoshua Spence <josh@joshuaspence.com>
Sun, 18 May 2014 13:47:37 +0000 (06:47 -0700)
committerepriestley <git@epriestley.com>
Sun, 18 May 2014 13:47:37 +0000 (06:47 -0700)
Summary: Previously, the `ArcanistXHPASTLinter` was suggesting that `"\1"` be written as `'\1'`, which is incorrect. Therefore, I ensured that all of the cases listed in the [[http://www.php.net/manual/en/language.types.string.php | PHP documentation]] were handled correctly.

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9182

src/lint/linter/ArcanistXHPASTLinter.php
src/lint/linter/__tests__/xhpast/double-quote.lint-test

index 126e73201541d73f78ce6c56685eb6b3f9e0c7a3..a1f082dd62a7312fa360f8a2aa67a619458a44fa 100644 (file)
@@ -2389,15 +2389,22 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter {
         // Double quoted strings are allowed when the string contains the
         // following characters.
         static $allowed_chars = array(
-          '\0',
           '\n',
           '\r',
-          '\f',
           '\t',
           '\v',
-          '\x',
-          '\b',
+          '\e',
+          '\f',
           '\'',
+          '\0',
+          '\1',
+          '\2',
+          '\3',
+          '\4',
+          '\5',
+          '\6',
+          '\7',
+          '\x',
         );
 
         $contains_special_chars = false;
index b494bd23b9c0de5ce4e5f0e766e53b4e97150919..de452462d124ae24fc6839a3537a6e3ee62eabe9 100644 (file)
@@ -8,6 +8,9 @@
 pht(
   "This string requires \x12\x34 double quotes, but ".
   "this string does not. Here, they are used for consistency.");
+pht(
+  "This string also requires \123\345 double quotes, but ".
+  "this string does not. Here, they are used for consistency.");
 ~~~~~~~~~~
 advice:3:1
 ~~~~~~~~~~
@@ -21,3 +24,6 @@ advice:3:1
 pht(
   "This string requires \x12\x34 double quotes, but ".
   "this string does not. Here, they are used for consistency.");
+pht(
+  "This string also requires \123\345 double quotes, but ".
+  "this string does not. Here, they are used for consistency.");