mirror of
https://hk.gh-proxy.com/https://github.com/wp-cli/profile-command.git
synced 2025-08-21 06:39:02 +08:00
#156 Fix PHPCS errors/warnings
This commit is contained in:
parent
40fc69ae4e
commit
d101e43756
4 changed files with 15 additions and 8 deletions
|
@ -415,7 +415,7 @@ class Command {
|
||||||
* @param string $file
|
* @param string $file
|
||||||
*/
|
*/
|
||||||
private static function include_file( $file ) {
|
private static function include_file( $file ) {
|
||||||
include( $file );
|
include $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Formatter {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 'time' !== $fields[0] ) {
|
if ( 'time' !== $fields[0] ) {
|
||||||
$this->total_cell_index = array_search( $fields[0], $format_args['fields'] );
|
$this->total_cell_index = array_search( $fields[0], $format_args['fields'], true );
|
||||||
}
|
}
|
||||||
|
|
||||||
$format_args['fields'] = array_map( 'trim', $format_args['fields'] );
|
$format_args['fields'] = array_map( 'trim', $format_args['fields'] );
|
||||||
|
@ -104,7 +104,7 @@ class Formatter {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$location_index = array_search( 'location', $fields );
|
$location_index = array_search( 'location', $fields, true );
|
||||||
foreach ( $items as $item ) {
|
foreach ( $items as $item ) {
|
||||||
$values = array_values( \WP_CLI\Utils\pick_fields( $item, $fields ) );
|
$values = array_values( \WP_CLI\Utils\pick_fields( $item, $fields ) );
|
||||||
foreach ( $values as $i => $value ) {
|
foreach ( $values as $i => $value ) {
|
||||||
|
|
|
@ -38,7 +38,9 @@ class Logger {
|
||||||
global $wpdb, $wp_object_cache;
|
global $wpdb, $wp_object_cache;
|
||||||
$this->start_time = microtime( true );
|
$this->start_time = microtime( true );
|
||||||
$this->query_offset = ! empty( $wpdb->queries ) ? count( $wpdb->queries ) : 0;
|
$this->query_offset = ! empty( $wpdb->queries ) ? count( $wpdb->queries ) : 0;
|
||||||
if ( false === ( $key = array_search( $this, self::$active_loggers ) ) ) {
|
$key = array_search( $this, self::$active_loggers, true );
|
||||||
|
|
||||||
|
if ( false === $key ) {
|
||||||
self::$active_loggers[] = $this;
|
self::$active_loggers[] = $this;
|
||||||
}
|
}
|
||||||
$this->cache_hit_offset = ! empty( $wp_object_cache->cache_hits ) ? $wp_object_cache->cache_hits : 0;
|
$this->cache_hit_offset = ! empty( $wp_object_cache->cache_hits ) ? $wp_object_cache->cache_hits : 0;
|
||||||
|
@ -62,7 +64,10 @@ class Logger {
|
||||||
$this->time += microtime( true ) - $this->start_time;
|
$this->time += microtime( true ) - $this->start_time;
|
||||||
}
|
}
|
||||||
if ( ! is_null( $this->query_offset ) && isset( $wpdb ) && ! empty( $wpdb->queries ) ) {
|
if ( ! is_null( $this->query_offset ) && isset( $wpdb ) && ! empty( $wpdb->queries ) ) {
|
||||||
for ( $i = $this->query_offset; $i < count( $wpdb->queries ); $i++ ) {
|
|
||||||
|
$query_total_count = count( $wpdb->queries );
|
||||||
|
|
||||||
|
for ( $i = $this->query_offset; $i < $query_total_count; $i++ ) {
|
||||||
$this->query_time += $wpdb->queries[ $i ][1];
|
$this->query_time += $wpdb->queries[ $i ][1];
|
||||||
$this->query_count++;
|
$this->query_count++;
|
||||||
}
|
}
|
||||||
|
@ -84,7 +89,9 @@ class Logger {
|
||||||
$this->query_offset = null;
|
$this->query_offset = null;
|
||||||
$this->cache_hit_offset = null;
|
$this->cache_hit_offset = null;
|
||||||
$this->cache_miss_offset = null;
|
$this->cache_miss_offset = null;
|
||||||
if ( false !== ( $key = array_search( $this, self::$active_loggers ) ) ) {
|
$key = array_search( $this, self::$active_loggers, true );
|
||||||
|
|
||||||
|
if ( false !== $key ) {
|
||||||
unset( self::$active_loggers[ $key ] );
|
unset( self::$active_loggers[ $key ] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -460,7 +460,7 @@ class Profiler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ob_start();
|
ob_start();
|
||||||
require_once( ABSPATH . WPINC . '/template-loader.php' );
|
require_once ABSPATH . WPINC . '/template-loader.php';
|
||||||
ob_get_clean();
|
ob_get_clean();
|
||||||
if ( $this->running_hook ) {
|
if ( $this->running_hook ) {
|
||||||
$this->loggers[ $this->running_hook ]->stop();
|
$this->loggers[ $this->running_hook ]->stop();
|
||||||
|
@ -567,7 +567,7 @@ class Profiler {
|
||||||
global $wp_filter;
|
global $wp_filter;
|
||||||
|
|
||||||
if ( ! isset( $wp_filter[ $filter ] ) && class_exists( 'WP_Hook' ) ) {
|
if ( ! isset( $wp_filter[ $filter ] ) && class_exists( 'WP_Hook' ) ) {
|
||||||
$wp_filter[ $filter ] = new \WP_Hook;
|
$wp_filter[ $filter ] = new \WP_Hook();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( is_a( $wp_filter[ $filter ], 'WP_Hook' ) ) {
|
if ( is_a( $wp_filter[ $filter ], 'WP_Hook' ) ) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue