File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ class PhpFileCleaner
2424 private static $ typeConfig ;
2525
2626 /** @var non-empty-string */
27- private static $ restPattern ;
27+ private static $ rejectChars ;
2828
2929 /**
3030 * @readonly
@@ -60,7 +60,7 @@ public static function setTypeConfig(array $types): void
6060 ];
6161 }
6262
63- self ::$ restPattern = '{[^ ?" \'</ ' .implode ('' , array_keys (self ::$ typeConfig )). ' ]+}A ' ;
63+ self ::$ rejectChars = '?" \'</ ' .implode ('' , array_keys (self ::$ typeConfig ));
6464 }
6565
6666 public function __construct (string $ contents , int $ maxMatches )
@@ -128,9 +128,10 @@ public function clean(): string
128128 }
129129
130130 $ this ->index += 1 ;
131- if ($ this ->match (self ::$ restPattern , $ match )) {
132- $ clean .= $ char . $ match [0 ];
133- $ this ->index += \strlen ($ match [0 ]);
131+ $ skip = strcspn ($ this ->contents , self ::$ rejectChars , $ this ->index );
132+ if ($ skip > 0 ) {
133+ $ clean .= $ char . \substr ($ this ->contents , $ this ->index , $ skip );
134+ $ this ->index += $ skip ;
134135 } else {
135136 $ clean .= $ char ;
136137 }
You can’t perform that action at this time.
0 commit comments