@@ -359,15 +359,13 @@ protected function extractParameters(string $string): string
359
359
360
360
// Replace all matches of our pattern with #{\d} for replacement later
361
361
return preg_replace_callback (
362
- $ this ->pattern ,
363
- function ($ matches ) {
364
- static $ index = - 1 ;
362
+ pattern: $ this ->pattern ,
363
+ callback: static function ($ matches ) {
364
+ static $ index = 0 ;
365
365
366
- $ index ++;
367
-
368
- return '#{ ' . $ index . '} ' ;
366
+ return '#{ ' . $ index ++ . '} ' ;
369
367
},
370
- $ string
368
+ subject: $ string
371
369
);
372
370
}
373
371
@@ -384,9 +382,9 @@ protected function injectParameters(string $string, array $replacements): string
384
382
$ string = preg_replace ('/#\{\s*(\d+)\s*\}/ ' , '#{$1} ' , $ string );
385
383
386
384
return preg_replace_callback (
387
- '/\#{(\d+)}/ ' ,
388
- fn ($ matches ) => $ replacements [$ matches [1 ]],
389
- $ string
385
+ pattern: '/\#{(\d+)}/ ' ,
386
+ callback: static fn ($ matches ) => $ replacements [$ matches [1 ]],
387
+ subject: $ string
390
388
);
391
389
}
392
390
@@ -424,10 +422,10 @@ protected function getParameters(string $string): array
424
422
public function getResponse (string $ string ): array
425
423
{
426
424
$ queryArray = array_merge ($ this ->urlParams , [
427
- 'sl ' => $ this ->source ,
428
- 'tl ' => $ this ->target ,
429
- 'tk ' => $ this ->tokenProvider ->generateToken ($ this ->source , $ this ->target , $ string ),
430
- 'q ' => $ string
425
+ 'sl ' => $ this ->source ,
426
+ 'tl ' => $ this ->target ,
427
+ 'tk ' => $ this ->tokenProvider ->generateToken ($ this ->source , $ this ->target , $ string ),
428
+ 'q ' => $ string
431
429
]);
432
430
433
431
// Remove array indexes from URL so that "&dt[2]=" turns into "&dt=" and so on.
0 commit comments