Make WordPress Core


Ignore:
Timestamp:
04/05/2020 03:00:44 AM (4 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use strict type check for in_array() and array_search() where strings are involved.

This reduces the number of WordPress.PHP.StrictInArray.MissingTrueStrict issues from 486 to 50.

Includes minor code layout fixes for better readability.

See #49542.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/plugin-editor.php

    r47198 r47550  
    113113        $ext = strtolower( $matches[1] );
    114114        // If extension is not in the acceptable list, skip it.
    115         if ( ! in_array( $ext, $editable_extensions ) ) {
     115        if ( ! in_array( $ext, $editable_extensions, true ) ) {
    116116            wp_die( sprintf( '<p>%s</p>', __( 'Files of this type are not editable.' ) ) );
    117117        }
     
    245245    $plugin_editable_files = array();
    246246    foreach ( $plugin_files as $plugin_file ) {
    247         if ( preg_match( '/\.([^.]+)$/', $plugin_file, $matches ) && in_array( $matches[1], $editable_extensions ) ) {
     247        if ( preg_match( '/\.([^.]+)$/', $plugin_file, $matches ) && in_array( $matches[1], $editable_extensions, true ) ) {
    248248            $plugin_editable_files[] = $plugin_file;
    249249        }
     
    278278    <?php if ( is_writeable( $real_file ) ) : ?>
    279279        <div class="editor-notices">
    280         <?php if ( in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) ) { ?>
     280        <?php if ( in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) ) { ?>
    281281            <div class="notice notice-warning inline active-plugin-edit-warning">
    282282                <p><?php _e( '<strong>Warning:</strong> Making changes to active plugins is not recommended.' ); ?></p>
Note: See TracChangeset for help on using the changeset viewer.