Skip to content

Commit d93a71b

Browse files
authored
Merge pull request #101 from jrfnl/feature/cs-fixes-6
PHPCS: fix up the code base [6] - multi-line function calls
2 parents 1a1bd5c + 41fd218 commit d93a71b

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

src/Search_Replace_Command.php

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -826,23 +826,33 @@ private function log_bits( $search_regex, $old_data, $old_matches, $new ) {
826826
$i = 0;
827827
$diff = 0;
828828
$new_matches = array();
829-
$new_data = preg_replace_callback( $search_regex, function ( $matches ) use ( $old_matches, $new, $is_regex, &$new_matches, &$i, &$diff ) {
830-
if ( $is_regex ) {
831-
// Sub in any back references, "$1", "\2" etc, in the replacement string.
832-
$new = preg_replace_callback( '/(?<!\\\\)(?:\\\\\\\\)*((?:\\\\|\\$)[0-9]{1,2}|\\${[0-9]{1,2}\\})/', function ( $m ) use ( $matches ) {
833-
$idx = (int) str_replace( array( '\\', '$', '{', '}' ), '', $m[0] );
834-
return isset( $matches[ $idx ] ) ? $matches[ $idx ] : '';
835-
}, $new );
836-
$new = str_replace( '\\\\', '\\', $new ); // Unescape any backslashed backslashes.
837-
}
838-
839-
$new_matches[0][ $i ][0] = $new;
840-
$new_matches[0][ $i ][1] = $old_matches[0][ $i ][1] + $diff;
841-
842-
$diff += strlen( $new ) - strlen( $old_matches[0][ $i ][0] );
843-
$i++;
844-
return $new;
845-
}, $old_data, $this->regex_limit, $match_cnt );
829+
$new_data = preg_replace_callback(
830+
$search_regex,
831+
function ( $matches ) use ( $old_matches, $new, $is_regex, &$new_matches, &$i, &$diff ) {
832+
if ( $is_regex ) {
833+
// Sub in any back references, "$1", "\2" etc, in the replacement string.
834+
$new = preg_replace_callback(
835+
'/(?<!\\\\)(?:\\\\\\\\)*((?:\\\\|\\$)[0-9]{1,2}|\\${[0-9]{1,2}\\})/',
836+
function ( $m ) use ( $matches ) {
837+
$idx = (int) str_replace( array( '\\', '$', '{', '}' ), '', $m[0] );
838+
return isset( $matches[ $idx ] ) ? $matches[ $idx ] : '';
839+
},
840+
$new
841+
);
842+
$new = str_replace( '\\\\', '\\', $new ); // Unescape any backslashed backslashes.
843+
}
844+
845+
$new_matches[0][ $i ][0] = $new;
846+
$new_matches[0][ $i ][1] = $old_matches[0][ $i ][1] + $diff;
847+
848+
$diff += strlen( $new ) - strlen( $old_matches[0][ $i ][0] );
849+
$i++;
850+
return $new;
851+
},
852+
$old_data,
853+
$this->regex_limit,
854+
$match_cnt
855+
);
846856

847857
$old_bits = array();
848858
$new_bits = array();

0 commit comments

Comments
 (0)