Skip to content

Commit

Permalink
ensure delimiter usage in between
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Mar 25, 2021
1 parent 3133d45 commit 508df53
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,12 @@ private function refactorArgument(Arg $arg): void

$string->value = Strings::replace($value, self::INNER_REGEX, function (array $match): string {
$innerPattern = $match['content'];
$innerPattern = str_replace($this->delimiter, '\\' . $this->delimiter, $innerPattern);
$positionDelimiter = strpos($innerPattern, $this->delimiter);
$lengthInnerPattern = strlen($innerPattern);

if ($positionDelimiter > 0 && $positionDelimiter < $lengthInnerPattern) {
$innerPattern = str_replace($this->delimiter, '\\' . $this->delimiter, $innerPattern);
}

// change delimiter
if (strlen($innerPattern) > 2 && $innerPattern[0] === $innerPattern[strlen($innerPattern) - 1]) {
Expand Down

0 comments on commit 508df53

Please sign in to comment.