Skip to content

Commit 3d3fdbe

Browse files
authored
Simplify NoSuperfluousConcatenationFixer (#720)
1 parent 0003401 commit 3d3fdbe

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

src/Fixer/NoSuperfluousConcatenationFixer.php

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -181,24 +181,10 @@ private function getContentForBorder(string $content, string $targetBorder, bool
181181
$content = \str_replace('$', '\\$', $content);
182182

183183
// escape double quote
184-
$pieces = \explode('\\\\', $content);
185-
$pieces = \array_map(
186-
static function (string $piece): string {
187-
$piece = Preg::replace(
188-
'/(?<=\\\\)"/',
189-
'\\\\\"',
190-
$piece
191-
);
192-
193-
return Preg::replace(
194-
'/(?<!\\\\)"/',
195-
'\\"',
196-
$piece
197-
);
198-
},
199-
$pieces
184+
return Preg::replace(
185+
'/(?<!\\\\)((\\\\{2})*)(\\\\)?"/',
186+
'$1\\\\$3$3"',
187+
$content
200188
);
201-
202-
return \implode('\\\\', $pieces);
203189
}
204190
}

0 commit comments

Comments
 (0)