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
$valid = true;
} else if (!$contains_special_chars && !$single_quoted) {
$invalid_nodes[] = $string;
- $fixes[$string->getID()] = "'".$contents."'";
+ $fixes[$string->getID()] = "'".str_replace('\"', '"', $contents)."'";
}
}
<?php
'foobar';
-"foobar";
+"foo\"bar";
"foobar\n";
"'foobar'";
"foo{$bar}";
~~~~~~~~~~
<?php
'foobar';
-'foobar';
+'foo"bar';
"foobar\n";
"'foobar'";
"foo{$bar}";