From: Joshua Spence Date: Mon, 19 May 2014 14:49:51 +0000 (-0700) Subject: Improve autofixing of double quotes in XHPAST linter. X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=1b0ab48f15d434956708000ae1ddaa809977098a;p=arcanist.git Improve autofixing of double quotes in XHPAST linter. Summary: The XHPAST double quotes rule autofixes strings which use double quotes where single quotes would suffice. In the case in which the double-quoted string contained an escaped double quote, the autofix string can be improved by removing the escape symbol. Test Plan: Modified existing unit tests to cover this case. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D9196 --- diff --git a/src/lint/linter/ArcanistXHPASTLinter.php b/src/lint/linter/ArcanistXHPASTLinter.php index 7e364d47..06b983b1 100644 --- a/src/lint/linter/ArcanistXHPASTLinter.php +++ b/src/lint/linter/ArcanistXHPASTLinter.php @@ -2428,7 +2428,7 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter { $valid = true; } else if (!$contains_special_chars && !$single_quoted) { $invalid_nodes[] = $string; - $fixes[$string->getID()] = "'".$contents."'"; + $fixes[$string->getID()] = "'".str_replace('\"', '"', $contents)."'"; } } diff --git a/src/lint/linter/__tests__/xhpast/double-quote.lint-test b/src/lint/linter/__tests__/xhpast/double-quote.lint-test index de452462..0c9f619d 100644 --- a/src/lint/linter/__tests__/xhpast/double-quote.lint-test +++ b/src/lint/linter/__tests__/xhpast/double-quote.lint-test @@ -1,6 +1,6 @@