Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump WPCS to v3.0.0 #809

Merged
merged 2 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions admin/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function perflab_load_modules_page( $modules = null, $focus_areas = null ) {
add_settings_field(
$module_slug,
$module_data['name'],
static function() use ( $module_slug, $module_data, $module_settings ) {
static function () use ( $module_slug, $module_data, $module_settings ) {
perflab_render_modules_page_field( $module_slug, $module_data, $module_settings );
},
PERFLAB_MODULES_SCREEN,
Expand Down Expand Up @@ -238,7 +238,7 @@ function perflab_get_modules( $modules_root = null ) {

// Modules are organized as {focus}/{module-slug} in the modules folder.
if ( $modules_dir ) {
// phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
// phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
while ( ( $focus = readdir( $modules_dir ) ) !== false ) {
if ( '.' === substr( $focus, 0, 1 ) ) {
continue;
Expand All @@ -253,7 +253,7 @@ function perflab_get_modules( $modules_root = null ) {
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
$focus_dir = @opendir( $modules_root . '/' . $focus );
if ( $focus_dir ) {
// phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
// phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
while ( ( $file = readdir( $focus_dir ) ) !== false ) {
// Unlike plugins, modules must be in a directory.
if ( ! is_dir( $modules_root . '/' . $focus . '/' . $file ) ) {
Expand All @@ -264,7 +264,7 @@ function perflab_get_modules( $modules_root = null ) {
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
$module_dir = @opendir( $modules_root . '/' . $focus . '/' . $file );
if ( $module_dir ) {
// phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
// phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
while ( ( $subfile = readdir( $module_dir ) ) !== false ) {
if ( '.' === substr( $subfile, 0, 1 ) ) {
continue;
Expand Down Expand Up @@ -304,7 +304,7 @@ function perflab_get_modules( $modules_root = null ) {

uasort(
$modules,
static function( $a, $b ) {
static function ( $a, $b ) {
return strnatcasecmp( $a['name'], $b['name'] );
}
);
Expand Down
6 changes: 3 additions & 3 deletions admin/server-timing.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static function () {
add_settings_section(
'benchmarking',
__( 'Benchmarking', 'performance-lab' ),
static function() {
static function () {
?>
<p>
<?php
Expand Down Expand Up @@ -125,7 +125,7 @@ static function() {
add_settings_field(
'benchmarking_actions',
__( 'Actions', 'performance-lab' ),
static function() {
static function () {
perflab_render_server_timing_page_hooks_field( 'benchmarking_actions' );
},
PERFLAB_SERVER_TIMING_SCREEN,
Expand All @@ -135,7 +135,7 @@ static function() {
add_settings_field(
'benchmarking_filters',
__( 'Filters', 'performance-lab' ),
static function() {
static function () {
perflab_render_server_timing_page_hooks_field( 'benchmarking_filters' );
},
PERFLAB_SERVER_TIMING_SCREEN,
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"phpunit/phpunit": "^4|^5|^6|^7|^8|^9",
"squizlabs/php_codesniffer": "^3.5",
"szepeviktor/phpstan-wordpress": "^1.3.0",
"wp-coding-standards/wpcs": "^2.2",
"wp-coding-standards/wpcs": "^3.0.0",
"wp-phpunit/wp-phpunit": "^5.8",
"yoast/phpunit-polyfills": "^1.0",
"phpstan/phpstan-phpunit": "^1.3",
Expand Down
167 changes: 156 additions & 11 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions load.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function perflab_get_modules_setting_default() {
$default_enabled_modules = require PERFLAB_PLUGIN_DIR_PATH . 'default-enabled-modules.php';
$default_option = array_reduce(
$default_enabled_modules,
static function( $module_settings, $module_dir ) {
static function ( $module_settings, $module_dir ) {
$module_settings[ $module_dir ] = array( 'enabled' => true );
return $module_settings;
},
Expand All @@ -97,7 +97,7 @@ function perflab_sanitize_modules_setting( $value ) {
// Ensure that every element is an array with an 'enabled' key.
return array_filter(
array_map(
static function( $module_settings ) {
static function ( $module_settings ) {
if ( ! is_array( $module_settings ) ) {
return array();
}
Expand Down Expand Up @@ -152,7 +152,7 @@ function perflab_get_active_modules() {
$modules = array_keys(
array_filter(
perflab_get_module_settings(),
static function( $module_settings ) {
static function ( $module_settings ) {
return isset( $module_settings['enabled'] ) && $module_settings['enabled'];
}
)
Expand Down Expand Up @@ -531,7 +531,7 @@ function perflab_deactivate_module( $module_dir_path ) {
* @param string $option Name of the option to add.
* @param mixed $value Value of the option.
*/
static function( $option, $value ) {
static function ( $option, $value ) {
perflab_run_module_activation_deactivation( perflab_get_modules_setting_default(), $value );
},
10,
Expand Down
2 changes: 1 addition & 1 deletion modules/images/fetchpriority/can-load.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
exit; // Exit if accessed directly.
}

return static function() {
return static function () {
return ! function_exists( 'wp_get_loading_optimization_attributes' );
};
2 changes: 1 addition & 1 deletion modules/images/fetchpriority/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function fetchpriority_render_generator() {
if ( function_exists( 'wp_get_loading_optimization_attributes' ) && ! str_starts_with( FETCHPRIORITY_VERSION, 'Performance Lab ' ) ) {
add_action(
'admin_notices',
static function() {
static function () {
?>
<div class="notice notice-warning">
<p>
Expand Down
2 changes: 1 addition & 1 deletion modules/images/webp-uploads/can-load.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
exit; // Exit if accessed directly.
}

return static function() {
return static function () {
return ! function_exists( 'wp_image_use_alternate_mime_types' );
};
2 changes: 1 addition & 1 deletion modules/images/webp-uploads/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
if ( ! require __DIR__ . '/can-load.php' ) {
add_action(
'admin_notices',
static function() {
static function () {
printf(
'<div class="notice notice-error"><p>%s</p></div>',
esc_html__( 'The WebP Uploads feature cannot be loaded from within the plugin since it is already merged into WordPress core.', 'performance-lab' )
Expand Down
5 changes: 2 additions & 3 deletions modules/images/webp-uploads/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
*
* @param WP_REST_Response $response The original response object.
* @param WP_Post $post The post object.
* @param WP_REST_Request $request The request object.
* @return WP_REST_Response A new response object for the attachment with additional sources.
*/
function webp_uploads_update_rest_attachment( WP_REST_Response $response, WP_Post $post, WP_REST_Request $request ) {
function webp_uploads_update_rest_attachment( WP_REST_Response $response, WP_Post $post ) {
$data = $response->get_data();
if ( ! isset( $data['media_details'] ) || ! is_array( $data['media_details'] ) || ! isset( $data['media_details']['sizes'] ) || ! is_array( $data['media_details']['sizes'] ) ) {
return $response;
Expand Down Expand Up @@ -51,4 +50,4 @@ function webp_uploads_update_rest_attachment( WP_REST_Response $response, WP_Pos

return rest_ensure_response( $data );
}
add_filter( 'rest_prepare_attachment', 'webp_uploads_update_rest_attachment', 10, 3 );
add_filter( 'rest_prepare_attachment', 'webp_uploads_update_rest_attachment', 10, 2 );
Loading
Loading