File tree Expand file tree Collapse file tree 1 file changed +2
-10
lines changed Expand file tree Collapse file tree 1 file changed +2
-10
lines changed Original file line number Diff line number Diff line change @@ -147,19 +147,11 @@ private function prepareReplacements(array $statements): array
147
147
private function performReplacements (string $ s , array $ replacements ): string
148
148
{
149
149
usort ($ replacements , function ($ a , $ b ) { // sort by position in file
150
- return $ a [0 ] <=> $ b [0 ];
150
+ return $ b [0 ] <=> $ a [0 ];
151
151
});
152
152
153
- $ correctiveOffset = 0 ;
154
153
foreach ($ replacements as [$ start , $ end , $ replacement ]) {
155
- $ replacingStringLength = $ end - $ start + 1 ;
156
- $ s = substr_replace (
157
- $ s ,
158
- $ replacement ,
159
- $ correctiveOffset + $ start ,
160
- $ replacingStringLength
161
- );
162
- $ correctiveOffset += strlen ($ replacement ) - $ replacingStringLength ;
154
+ $ s = substr_replace ($ s , $ replacement , $ start , $ end - $ start + 1 );
163
155
}
164
156
return $ s ;
165
157
}
You can’t perform that action at this time.
0 commit comments