diff --git a/src/PhpFileCleaner.php b/src/PhpFileCleaner.php index 4591aa2..c2de14a 100644 --- a/src/PhpFileCleaner.php +++ b/src/PhpFileCleaner.php @@ -24,7 +24,7 @@ class PhpFileCleaner private static $typeConfig; /** @var non-empty-string */ - private static $restPattern; + private static $rejectChars; /** * @readonly @@ -60,7 +60,7 @@ public static function setTypeConfig(array $types): void ]; } - self::$restPattern = '{[^?"\'index += 1; - if ($this->match(self::$restPattern, $match)) { - $clean .= $char . $match[0]; - $this->index += \strlen($match[0]); + $skip = strcspn($this->contents, self::$rejectChars, $this->index); + if ($skip > 0) { + $clean .= $char . \substr($this->contents, $this->index, $skip); + $this->index += $skip; } else { $clean .= $char; }