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

Update build dev dependency #293

Merged
merged 3 commits into from
Oct 18, 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
2 changes: 1 addition & 1 deletion build-cs/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"phpstan/extension-installer": "^1.2",
"slevomat/coding-standard": "^8.9",
"szepeviktor/phpstan-wordpress": "^1.1",
"wp-coding-standards/wpcs": "dev-develop#fca9d9e"
"wp-coding-standards/wpcs": "^3.0.0"
},
"config": {
"allow-plugins": {
Expand Down
324 changes: 170 additions & 154 deletions build-cs/composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion includes/CLI/Plugin_Check_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ private function flatten_file_results( $file_errors, $file_warnings ) {

usort(
$file_results,
static function( $a, $b ) {
static function ( $a, $b ) {
if ( $a['line'] < $b['line'] ) {
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion includes/Checker/Abstract_Check_Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ final public function prepare() {
return $preparation->prepare();
}

return function() {};
return function () {};
}

/**
Expand Down
4 changes: 2 additions & 2 deletions includes/Checker/Check_Categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static function get_categories() {
$categories = array_values(
array_filter(
$constants,
static function( $key ) {
static function ( $key ) {
return strpos( $key, 'CATEGORY_' ) === 0;
},
ARRAY_FILTER_USE_KEY
Expand All @@ -64,7 +64,7 @@ static function( $key ) {
public static function filter_checks_by_categories( array $checks, array $categories ) {
return array_filter(
$checks,
static function( $check ) use ( $categories ) {
static function ( $check ) use ( $categories ) {
// Return true if at least one of the check categories is among the filter categories.
return (bool) array_intersect( $check->get_categories(), $categories );
}
Expand Down
2 changes: 1 addition & 1 deletion includes/Checker/Checks.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function run_checks( Check_Context $context, array $checks ) {
// Run the checks.
array_walk(
$checks,
function( Check $check ) use ( $result ) {
function ( Check $check ) use ( $result ) {
$this->run_check_with_result( $check, $result );
}
);
Expand Down
2 changes: 1 addition & 1 deletion includes/Checker/Checks/Abstract_File_Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ final protected static function filter_files_by_extensions( array $files, array
return array_values(
array_filter(
$files,
static function( $file ) use ( $lookup ) {
static function ( $file ) use ( $lookup ) {
return isset( $lookup[ pathinfo( $file, PATHINFO_EXTENSION ) ] );
}
)
Expand Down
7 changes: 4 additions & 3 deletions includes/Checker/Checks/Enqueued_Scripts_Size_Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
*/
class Enqueued_Scripts_Size_Check extends Abstract_Runtime_Check implements With_Shared_Preparations {

use URL_Aware, Stable_Check;
use URL_Aware;
use Stable_Check;

/**
* Threshold for script size to surface a warning for.
Expand Down Expand Up @@ -79,7 +80,7 @@ public function prepare() {
// Backup the original values for the global state.
$this->backup_globals();

return function() use ( $orig_scripts ) {
return function () use ( $orig_scripts ) {
if ( is_null( $orig_scripts ) ) {
unset( $GLOBALS['wp_scripts'] );
} else {
Expand All @@ -100,7 +101,7 @@ public function prepare() {
*/
public function get_shared_preparations() {
$demo_posts = array_map(
static function( $post_type ) {
static function ( $post_type ) {
return array(
'post_title' => "Demo {$post_type} post",
'post_content' => 'Test content',
Expand Down
7 changes: 4 additions & 3 deletions includes/Checker/Checks/Enqueued_Styles_Scope_Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
*/
class Enqueued_Styles_Scope_Check extends Abstract_Runtime_Check implements With_Shared_Preparations {

use URL_Aware, Stable_Check;
use URL_Aware;
use Stable_Check;

/**
* List of viewable post types.
Expand Down Expand Up @@ -76,7 +77,7 @@ public function prepare() {
// Backup the original values for the global state.
$this->backup_globals();

return function() use ( $orig_scripts ) {
return function () use ( $orig_scripts ) {
if ( is_null( $orig_scripts ) ) {
unset( $GLOBALS['wp_styles'] );
} else {
Expand All @@ -97,7 +98,7 @@ public function prepare() {
*/
public function get_shared_preparations() {
$demo_posts = array_map(
static function( $post_type ) {
static function ( $post_type ) {
return array(
'post_title' => "Demo {$post_type} post",
'post_content' => 'Test content',
Expand Down
4 changes: 2 additions & 2 deletions includes/Checker/Checks/File_Type_Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ protected function look_for_vcs_directories( Check_Result $result, array $files
$vcs_directories = array_filter(
array_unique(
array_map(
function( $file ) {
function ( $file ) {
return dirname( $file );
},
$files
)
),
function( $directory ) use ( $directories ) {
function ( $directory ) use ( $directories ) {
return isset( $directories[ basename( $directory ) ] );
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function prepare() {
add_filter( 'default_option_active_plugins', array( $this, 'filter_active_plugins' ) );

// Return the cleanup function.
return function() {
return function () {
remove_filter( 'option_active_plugins', array( $this, 'filter_active_plugins' ) );
remove_filter( 'default_option_active_plugins', array( $this, 'filter_active_plugins' ) );
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function prepare() {
}

// Return the cleanup function.
return function() {
return function () {
global $wp_theme_directories;

remove_filter( 'template', array( $this, 'get_theme_slug' ) );
Expand Down
2 changes: 1 addition & 1 deletion includes/Checker/Runtime_Environment_Setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function can_set_up() {
} else {
// Get the correct Plugin Check directory when run too early.
if ( ! defined( 'WP_PLUGIN_CHECK_PLUGIN_DIR_PATH' ) ) {
$object_cache_copy = dirname( dirname( __DIR__ ) ) . '/plugin-check/drop-ins/object-cache.copy.php';
$object_cache_copy = dirname( __DIR__, 2 ) . '/plugin-check/drop-ins/object-cache.copy.php';
} else {
$object_cache_copy = WP_PLUGIN_CHECK_PLUGIN_DIR_PATH . 'drop-ins/object-cache.copy.php';
}
Expand Down
2 changes: 1 addition & 1 deletion includes/Utilities/Plugin_Request_Utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static function initialize_runner() {
if ( $runner->is_plugin_check() ) {
add_action(
'muplugins_loaded',
function() use ( $runner ) {
function () use ( $runner ) {
static::$cleanup = $runner->prepare();
static::$runner = $runner;
}
Expand Down
8 changes: 4 additions & 4 deletions tests/phpunit/Checker/AJAX_Runner_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function test_prepare_with_runtime_check() {

add_filter(
'wp_plugin_check_checks',
function( $checks ) {
function ( $checks ) {
return array(
'runtime_check' => new Runtime_Check(),
);
Expand Down Expand Up @@ -104,7 +104,7 @@ public function test_prepare_with_static_check() {

add_filter(
'wp_plugin_check_checks',
function( $checks ) {
function ( $checks ) {
return array(
'empty_check' => new Empty_Check(),
);
Expand Down Expand Up @@ -136,7 +136,7 @@ public function test_run() {

add_filter(
'wp_plugin_check_checks',
function( $checks ) {
function ( $checks ) {
return array(
'empty_check' => new WordPress\Plugin_Check\Test_Data\Empty_Check(),
);
Expand All @@ -160,7 +160,7 @@ public function test_run_with_errors() {

add_filter(
'wp_plugin_check_checks',
function( $checks ) {
function ( $checks ) {
return array(
'error_check' => new Error_Check(),
);
Expand Down
8 changes: 4 additions & 4 deletions tests/phpunit/Checker/CLI_Runner_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function test_prepare_with_runtime_check() {

add_filter(
'wp_plugin_check_checks',
function( $checks ) {
function ( $checks ) {
return array(
'runtime-check' => new Runtime_Check(),
);
Expand Down Expand Up @@ -102,7 +102,7 @@ public function test_prepare_with_static_check() {

add_filter(
'wp_plugin_check_checks',
function( $checks ) {
function ( $checks ) {
return array(
'empty-check' => new Empty_Check(),
);
Expand Down Expand Up @@ -137,7 +137,7 @@ public function test_run() {

add_filter(
'wp_plugin_check_checks',
function( $checks ) {
function ( $checks ) {
return array(
'empty-check' => new WordPress\Plugin_Check\Test_Data\Empty_Check(),
);
Expand All @@ -164,7 +164,7 @@ public function test_run_with_errors() {

add_filter(
'wp_plugin_check_checks',
function( $checks ) {
function ( $checks ) {
return array(
'error-check' => new Error_Check(),
);
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/Checker/Checks_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function test_run_checks() {

add_filter(
'wp_plugin_check_checks',
function( $checks ) use ( $all_checks ) {
function ( $checks ) use ( $all_checks ) {
return $all_checks;
}
);
Expand All @@ -58,7 +58,7 @@ public function test_run_checks_with_error() {

add_filter(
'wp_plugin_check_checks',
function( $checks ) use ( $all_checks ) {
function ( $checks ) use ( $all_checks ) {
return $all_checks;
}
);
Expand Down
8 changes: 4 additions & 4 deletions tests/phpunit/Utilities/Plugin_Request_Utility_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function test_destroy_runner_with_cli() {

add_filter(
'wp_plugin_check_checks',
function( $checks ) {
function ( $checks ) {
return array(
'runtime_check' => new Runtime_Check(),
);
Expand Down Expand Up @@ -138,7 +138,7 @@ public function test_destroy_runner_with_ajax() {

add_filter(
'wp_plugin_check_checks',
function( $checks ) {
function ( $checks ) {
return array(
'runtime_check' => new Runtime_Check(),
);
Expand Down Expand Up @@ -227,7 +227,7 @@ public function test_plugin_without_error_for_ignore_directories() {

add_filter(
'wp_plugin_check_checks',
function( $checks ) {
function ( $checks ) {
return array(
'i18n_usage_check' => new I18n_Usage_Check(),
);
Expand Down Expand Up @@ -271,7 +271,7 @@ public function test_plugin_with_error_for_ignore_directories() {

add_filter(
'wp_plugin_check_checks',
function( $checks ) {
function ( $checks ) {
return array(
'i18n_usage_check' => new I18n_Usage_Check(),
);
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package plugin-check
*/

define( 'TESTS_PLUGIN_DIR', dirname( dirname( __DIR__ ) ) );
define( 'TESTS_PLUGIN_DIR', dirname( __DIR__, 2 ) );
define( 'UNIT_TESTS_PLUGIN_DIR', TESTS_PLUGIN_DIR . '/tests/phpunit/testdata/plugins/' );

if ( file_exists( TESTS_PLUGIN_DIR . '/vendor/autoload.php' ) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected function prepare_environment( Check $check, Check_Context $context ) {
}

// Return the cleanup function.
return function() use ( $cleanups ) {
return function () use ( $cleanups ) {
foreach ( $cleanups as $cleanup ) {
$cleanup();
}
Expand Down
8 changes: 4 additions & 4 deletions tests/phpunit/utils/Traits/With_Mock_Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ protected function set_up_mock_filesystem() {

add_filter(
'filesystem_method_file',
function() {
function () {
return TESTS_PLUGIN_DIR . '/testdata/Filesystem/WP_Filesystem_MockFilesystem.php';
}
);
add_filter(
'filesystem_method',
function() {
function () {
return 'MockFilesystem';
}
);
Expand All @@ -45,13 +45,13 @@ protected function set_up_failing_mock_filesystem() {

add_filter(
'filesystem_method_file',
function() {
function () {
return TESTS_PLUGIN_DIR . '/testdata/Filesystem/WP_Filesystem_FailingMockFilesystem.php';
}
);
add_filter(
'filesystem_method',
function() {
function () {
return 'FailingMockFilesystem';
}
);
Expand Down