Make WordPress Core


Ignore:
Timestamp:
10/08/2020 09:13:57 PM (4 years ago)
Author:
SergeyBiryukov
Message:

General: Replace older-style PHP type conversion functions with type casts.

This improves performance, readability, and consistency throughout core.

  • intval()(int)
  • strval()(string)
  • floatval()(float)

Props ayeshrajans.
Fixes #42918.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-widgets.php

    r48576 r49108  
    606606        if ( preg_match( '/^(.+)-(\d+)$/', $widget_id, $matches ) ) {
    607607            $parsed['id_base'] = $matches[1];
    608             $parsed['number']  = intval( $matches[2] );
     608            $parsed['number']  = (int) $matches[2];
    609609        } else {
    610610            // Likely an old single widget.
     
    629629
    630630        $id_base = $matches[2];
    631         $number  = isset( $matches[3] ) ? intval( $matches[3] ) : null;
     631        $number  = isset( $matches[3] ) ? (int) $matches[3] : null;
    632632
    633633        return compact( 'id_base', 'number' );
     
    17731773        $this->sidebar_instance_count[ $index ] += 1;
    17741774        if ( ! $this->manager->selective_refresh->is_render_partials_request() ) {
    1775             printf( "\n<!--dynamic_sidebar_before:%s:%d-->\n", esc_html( $index ), intval( $this->sidebar_instance_count[ $index ] ) );
     1775            printf( "\n<!--dynamic_sidebar_before:%s:%d-->\n", esc_html( $index ), (int) $this->sidebar_instance_count[ $index ] );
    17761776        }
    17771777    }
     
    17891789        array_shift( $this->current_dynamic_sidebar_id_stack );
    17901790        if ( ! $this->manager->selective_refresh->is_render_partials_request() ) {
    1791             printf( "\n<!--dynamic_sidebar_after:%s:%d-->\n", esc_html( $index ), intval( $this->sidebar_instance_count[ $index ] ) );
     1791            printf( "\n<!--dynamic_sidebar_after:%s:%d-->\n", esc_html( $index ), (int) $this->sidebar_instance_count[ $index ] );
    17921792        }
    17931793    }
     
    18521852
    18531853        if ( isset( $context['sidebar_instance_number'] ) ) {
    1854             $this->context_sidebar_instance_number = intval( $context['sidebar_instance_number'] );
     1854            $this->context_sidebar_instance_number = (int) $context['sidebar_instance_number'];
    18551855        }
    18561856
Note: See TracChangeset for help on using the changeset viewer.