Skip to content

Commit 9846c1a

Browse files
committed
Use static functions as callables
1 parent a7dc934 commit 9846c1a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Search_Replace_Command.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ private static function esc_like( $old ) {
728728
* @return string|array An escaped string if given a string, or an array of escaped strings if given an array of strings.
729729
*/
730730
private static function esc_sql_ident( $idents ) {
731-
$backtick = function ( $v ) {
731+
$backtick = static function ( $v ) {
732732
// Escape any backticks in the identifier by doubling.
733733
return '`' . str_replace( '`', '``', $v ) . '`';
734734
};
@@ -745,7 +745,7 @@ private static function esc_sql_ident( $idents ) {
745745
* @return string|array A quoted string if given a string, or an array of quoted strings if given an array of strings.
746746
*/
747747
private static function esc_sql_value( $values ) {
748-
$quote = function ( $v ) {
748+
$quote = static function ( $v ) {
749749
// Don't quote integer values to avoid MySQL's implicit type conversion.
750750
if ( preg_match( '/^[+-]?[0-9]{1,20}$/', $v ) ) { // MySQL BIGINT UNSIGNED max 18446744073709551615 (20 digits).
751751
return esc_sql( $v );
@@ -772,7 +772,7 @@ private static function esc_sql_value( $values ) {
772772
private function get_colors( $assoc_args, $colors ) {
773773
$color_reset = WP_CLI::colorize( '%n' );
774774

775-
$color_code_callback = function ( $v ) {
775+
$color_code_callback = static function ( $v ) {
776776
return substr( $v, 1 );
777777
};
778778

@@ -891,12 +891,12 @@ private function log_bits( $search_regex, $old_data, $old_matches, $new ) {
891891
$new_matches = array();
892892
$new_data = preg_replace_callback(
893893
$search_regex,
894-
function ( $matches ) use ( $old_matches, $new, $is_regex, &$new_matches, &$i, &$diff ) {
894+
static function ( $matches ) use ( $old_matches, $new, $is_regex, &$new_matches, &$i, &$diff ) {
895895
if ( $is_regex ) {
896896
// Sub in any back references, "$1", "\2" etc, in the replacement string.
897897
$new = preg_replace_callback(
898898
'/(?<!\\\\)(?:\\\\\\\\)*((?:\\\\|\\$)[0-9]{1,2}|\\${[0-9]{1,2}\\})/',
899-
function ( $m ) use ( $matches ) {
899+
static function ( $m ) use ( $matches ) {
900900
$idx = (int) str_replace( array( '\\', '$', '{', '}' ), '', $m[0] );
901901
return isset( $matches[ $idx ] ) ? $matches[ $idx ] : '';
902902
},

0 commit comments

Comments
 (0)