1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 14:52:40 +01:00

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
This commit is contained in:
Joshua Spence 2014-05-19 07:49:51 -07:00 committed by epriestley
parent b251615716
commit 1b0ab48f15
2 changed files with 3 additions and 3 deletions

View file

@ -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)."'";
}
}

View file

@ -1,6 +1,6 @@
<?php
'foobar';
"foobar";
"foo\"bar";
"foobar\n";
"'foobar'";
"foo{$bar}";
@ -16,7 +16,7 @@ advice:3:1
~~~~~~~~~~
<?php
'foobar';
'foobar';
'foo"bar';
"foobar\n";
"'foobar'";
"foo{$bar}";