diff --git a/_inc/lib/debugger/class-jetpack-cxn-tests.php b/_inc/lib/debugger/class-jetpack-cxn-tests.php index 2c9f8c780ee6..7df08dad36b9 100644 --- a/_inc/lib/debugger/class-jetpack-cxn-tests.php +++ b/_inc/lib/debugger/class-jetpack-cxn-tests.php @@ -7,13 +7,12 @@ use Automattic\Jetpack\Connection\Client; use Automattic\Jetpack\Connection\Manager as Connection_Manager; +use Automattic\Jetpack\Redirect; use Automattic\Jetpack\Status; -use Automattic\Jetpack\Connection\Utils as Connection_Utils; -use Automattic\Jetpack\Sync\Modules; -use Automattic\Jetpack\Sync\Settings as Sync_Settings; use Automattic\Jetpack\Sync\Health as Sync_Health; +use Automattic\Jetpack\Sync\Modules; use Automattic\Jetpack\Sync\Sender as Sync_Sender; -use Automattic\Jetpack\Redirect; +use Automattic\Jetpack\Sync\Settings as Sync_Settings; /** * Class Jetpack_Cxn_Tests contains all of the actual tests. diff --git a/_inc/lib/debugger/class-jetpack-debug-data.php b/_inc/lib/debugger/class-jetpack-debug-data.php index 416252e83065..177d48428736 100644 --- a/_inc/lib/debugger/class-jetpack-debug-data.php +++ b/_inc/lib/debugger/class-jetpack-debug-data.php @@ -5,12 +5,12 @@ * @package jetpack */ +use Automattic\Jetpack\Connection\Manager as Connection_Manager; use Automattic\Jetpack\Constants; -use Automattic\Jetpack\Sync\Modules; +use Automattic\Jetpack\Redirect; use Automattic\Jetpack\Sync\Functions; +use Automattic\Jetpack\Sync\Modules; use Automattic\Jetpack\Sync\Sender; -use Automattic\Jetpack\Redirect; -use Automattic\Jetpack\Connection\Manager as Connection_Manager; /** * Class Jetpack_Debug_Data diff --git a/_inc/lib/debugger/class-jetpack-debugger.php b/_inc/lib/debugger/class-jetpack-debugger.php index 00fd3a2b0c15..c339f24de127 100644 --- a/_inc/lib/debugger/class-jetpack-debugger.php +++ b/_inc/lib/debugger/class-jetpack-debugger.php @@ -5,8 +5,8 @@ * @package jetpack */ -use Automattic\Jetpack\Status; use Automattic\Jetpack\Redirect; +use Automattic\Jetpack\Status; /** * Class Jetpack_Debugger diff --git a/_inc/lib/debugger/debug-functions.php b/_inc/lib/debugger/debug-functions.php index 59410f086f74..38b858ce2573 100644 --- a/_inc/lib/debugger/debug-functions.php +++ b/_inc/lib/debugger/debug-functions.php @@ -52,7 +52,7 @@ function jetpack_debugger_site_status_tests( $core_tests ) { * @type string $test Unique test identifier. * } */ - 'test' => function() use ( $test, $cxn_tests ) { + 'test' => function () use ( $test, $cxn_tests ) { $results = $cxn_tests->run_test( $test['name'] ); if ( is_wp_error( $results ) ) { return; diff --git a/packages/abtest/src/class-abtest.php b/packages/abtest/src/class-abtest.php index 8bf6b34ef113..b69b4caedc70 100644 --- a/packages/abtest/src/class-abtest.php +++ b/packages/abtest/src/class-abtest.php @@ -8,7 +8,6 @@ namespace Automattic\Jetpack; use Automattic\Jetpack\Connection\Client; -use Automattic\Jetpack\Error; /** * This class provides an interface to the WP.com A/B tests. diff --git a/packages/abtest/tests/php/test-abtest.php b/packages/abtest/tests/php/test-abtest.php index 31908cbc6c06..29c415c09e35 100644 --- a/packages/abtest/tests/php/test-abtest.php +++ b/packages/abtest/tests/php/test-abtest.php @@ -1,4 +1,4 @@ -setNamespace( __NAMESPACE__ ) ->setName( 'is_wp_error' ) ->setFunction( - function( $object ) { + function ( $object ) { return is_a( $object, __NAMESPACE__ . '\\Error' ); } ); diff --git a/packages/assets/src/class-assets.php b/packages/assets/src/class-assets.php index 85708af9ec55..c9e12d94893d 100644 --- a/packages/assets/src/class-assets.php +++ b/packages/assets/src/class-assets.php @@ -163,7 +163,7 @@ public static function enqueue_async_script( $handle, $min_path, $non_min_path, public static function add_resource_hint( $urls, $type = 'dns-prefetch' ) { add_filter( 'wp_resource_hints', - function( $hints, $resource_type ) use ( $urls, $type ) { + function ( $hints, $resource_type ) use ( $urls, $type ) { if ( $resource_type === $type ) { // Type casting to array required since the function accepts a single string. foreach ( (array) $urls as $url ) { diff --git a/packages/assets/tests/php/test-assets.php b/packages/assets/tests/php/test-assets.php index 68a2d27a764a..80b52887e1fb 100644 --- a/packages/assets/tests/php/test-assets.php +++ b/packages/assets/tests/php/test-assets.php @@ -7,10 +7,10 @@ namespace Automattic\Jetpack; -use PHPUnit\Framework\TestCase; use Automattic\Jetpack\Constants as Jetpack_Constants; use Brain\Monkey; use Brain\Monkey\Filters; +use PHPUnit\Framework\TestCase; /** * Retrieves a URL within the plugins or mu-plugins directory. diff --git a/packages/autoloader/src/AutoloadProcessor.php b/packages/autoloader/src/AutoloadProcessor.php index 4db5bb113831..70501f221524 100644 --- a/packages/autoloader/src/AutoloadProcessor.php +++ b/packages/autoloader/src/AutoloadProcessor.php @@ -14,8 +14,6 @@ namespace Automattic\Jetpack\Autoloader; -use Composer\Util\Filesystem; - /** * Class AutoloadProcessor. */ diff --git a/packages/autoloader/src/CustomAutoloaderPlugin.php b/packages/autoloader/src/CustomAutoloaderPlugin.php index 159c74831854..ac8951b656f2 100644 --- a/packages/autoloader/src/CustomAutoloaderPlugin.php +++ b/packages/autoloader/src/CustomAutoloaderPlugin.php @@ -15,11 +15,11 @@ namespace Automattic\Jetpack\Autoloader; use Composer\Composer; +use Composer\EventDispatcher\EventSubscriberInterface; use Composer\IO\IOInterface; +use Composer\Plugin\PluginInterface; use Composer\Script\Event; use Composer\Script\ScriptEvents; -use Composer\Plugin\PluginInterface; -use Composer\EventDispatcher\EventSubscriberInterface; /** * Class CustomAutoloaderPlugin. @@ -81,7 +81,6 @@ public function uninstall( Composer $composer, IOInterface $io ) { */ } - /** * Tell composer to listen for events and do something with them. * diff --git a/packages/autoloader/src/autoload.php b/packages/autoloader/src/autoload.php index 993c8ccaea11..49b998d9a856 100644 --- a/packages/autoloader/src/autoload.php +++ b/packages/autoloader/src/autoload.php @@ -1,6 +1,6 @@ ID ) { $allcaps['manage_options'] = true; $allcaps['administrator'] = true; @@ -154,7 +154,7 @@ public function test_connection() { $builder->setNamespace( 'Automattic\Jetpack' ) ->setName( 'apply_filters' ) ->setFunction( - function( $hook, $value ) { + function ( $hook, $value ) { return 'jetpack_offline_mode' === $hook ? true : $value; } ); @@ -192,7 +192,7 @@ public function test_connection_plugins() { array_walk( $plugins, - function( $plugin ) { + function ( $plugin ) { ( new Connection_Plugin( $plugin['slug'] ) )->add( $plugin['name'] ); } ); diff --git a/packages/connection/tests/php/test_Error_Handler.php b/packages/connection/tests/php/test_Error_Handler.php index 97dec0476fdb..fbd9f7d63cf9 100644 --- a/packages/connection/tests/php/test_Error_Handler.php +++ b/packages/connection/tests/php/test_Error_Handler.php @@ -62,11 +62,11 @@ public function test_store_error() { $stored_errors = $this->error_handler->get_stored_errors(); - $this->assertEquals( 1, count( $stored_errors ) ); + $this->assertSame( 1, count( $stored_errors ) ); $this->arrayHasKey( 'invalid_token', $stored_errors ); - $this->assertEquals( 1, count( $stored_errors['invalid_token'] ) ); + $this->assertSame( 1, count( $stored_errors['invalid_token'] ) ); $this->arrayHasKey( '1', $stored_errors['invalid_token'] ); @@ -99,8 +99,8 @@ public function test_store_multiple_error_codes() { $this->arrayHasKey( 'invalid_token', $stored_errors ); - $this->assertEquals( 1, count( $stored_errors['invalid_token'] ) ); - $this->assertEquals( 1, count( $stored_errors['unknown_user'] ) ); + $this->assertSame( 1, count( $stored_errors['invalid_token'] ) ); + $this->assertSame( 1, count( $stored_errors['unknown_user'] ) ); $this->arrayHasKey( '1', $stored_errors['unknown_user'] ); @@ -135,7 +135,7 @@ public function test_store_multiple_error_codes_multiple_users() { $this->arrayHasKey( 'invalid_token', $stored_errors ); - $this->assertEquals( 1, count( $stored_errors['invalid_token'] ) ); + $this->assertSame( 1, count( $stored_errors['invalid_token'] ) ); $this->assertEquals( 2, count( $stored_errors['unknown_user'] ) ); $this->arrayHasKey( '2', $stored_errors['unknown_user'] ); @@ -241,7 +241,6 @@ public function test_get_user_id_from_token( $token, $expected ) { $this->assertEquals( $expected, $this->error_handler->get_user_id_from_token( $token ) ); } - /** * Test get_error_by_nonce */ @@ -310,7 +309,7 @@ public function test_garbage_collector() { // Manipulate the timestamps directly in the database. $saved_options = get_option( Error_Handler::STORED_ERRORS_OPTION ); $this->assertEquals( 3, count( $saved_options ) ); - $this->assertEquals( 1, count( $saved_options['no_user_tokens'] ) ); + $this->assertSame( 1, count( $saved_options['no_user_tokens'] ) ); $saved_options['invalid_token'][4]['timestamp'] = time() - DAY_IN_SECONDS * 4; $saved_options['no_user_tokens'][6]['timestamp'] = time() - DAY_IN_SECONDS * 4; update_option( Error_Handler::STORED_ERRORS_OPTION, $saved_options ); @@ -323,7 +322,7 @@ public function test_garbage_collector() { $this->assertArrayHasKey( 'no_user_tokens', $errors ); $this->assertArrayNotHasKey( 'invalid_token', $errors ); - $this->assertEquals( 1, count( $errors['no_user_tokens'] ) ); + $this->assertSame( 1, count( $errors['no_user_tokens'] ) ); } } diff --git a/packages/connection/tests/php/test_Manager.php b/packages/connection/tests/php/test_Manager.php index eff9706cec54..205d907cbb26 100644 --- a/packages/connection/tests/php/test_Manager.php +++ b/packages/connection/tests/php/test_Manager.php @@ -48,7 +48,7 @@ public function setUp() { $builder->setNamespace( __NAMESPACE__ ) ->setName( 'apply_filters' ) ->setFunction( - function( $filter_name, $return_value ) { + function ( $filter_name, $return_value ) { return $return_value; } ); @@ -60,7 +60,7 @@ function( $filter_name, $return_value ) { $builder->setNamespace( __NAMESPACE__ ) ->setName( 'wp_redirect' ) ->setFunction( - function( $url ) { + function ( $url ) { $this->arguments_stack['wp_redirect'] [] = array( $url ); return true; } @@ -73,7 +73,7 @@ function( $url ) { $builder->setNamespace( 'Automattic\Jetpack' ) ->setName( 'apply_filters' ) ->setFunction( - function( $filter_name, $value, $name ) { + function ( $filter_name, $value, $name ) { return constant( __NAMESPACE__ . "\Utils::DEFAULT_$name" ); } ); @@ -170,7 +170,7 @@ public function test_api_url_uses_constants_and_filters() { $this->apply_filters->disable(); - $overwrite_filter = function() { + $overwrite_filter = function () { $this->arguments_stack['jetpack_api_url'][] = array_merge( array( 'jetpack_api_url' ), func_get_args() ); return 'completely overwrite'; }; @@ -233,7 +233,6 @@ public function test_is_user_connected_with_user_id_logged_out_not_connected() { $this->assertFalse( $this->manager->is_user_connected( 1 ) ); } - /** * Test the `is_user_connected` functionality. * @@ -340,7 +339,7 @@ public function test_jetpack_connection_custom_caps( $in_offline_mode, $custom_c // Mock the apply_filters( 'jetpack_offline_mode', ) call in Status::is_offline_mode. add_filter( 'jetpack_offline_mode', - function() use ( $in_offline_mode ) { + function () use ( $in_offline_mode ) { return $in_offline_mode; } ); @@ -468,7 +467,7 @@ protected function mock_function( $function_name, $return_value = null, $namespa $builder->setNamespace( $namespace ) ->setName( $function_name ) ->setFunction( - function() use ( &$return_value ) { + function () use ( &$return_value ) { return $return_value; } ); diff --git a/packages/connection/tests/php/test_Utils.php b/packages/connection/tests/php/test_Utils.php index 001a3db04c68..6c8a5d1fa8d1 100644 --- a/packages/connection/tests/php/test_Utils.php +++ b/packages/connection/tests/php/test_Utils.php @@ -22,7 +22,6 @@ public function tearDown() { Constants::clear_constants(); } - /** * Tests the Utils::jetpack_api_constant_filter() method. * diff --git a/packages/constants/tests/php/test-constants.php b/packages/constants/tests/php/test-constants.php index 72422ea51c2d..a6c6dc5adb54 100644 --- a/packages/constants/tests/php/test-constants.php +++ b/packages/constants/tests/php/test-constants.php @@ -142,7 +142,6 @@ public function test_jetpack_constants_override_to_null_gets_null() { $this->assertNull( Constants::get_constant( 'JETPACK__VERSION' ) ); } - /** * Tests that constant will use the filter value. * @@ -156,7 +155,7 @@ public function test_jetpack_constants_get_constant_use_filter_value() { $apply_filters_spy = new Spy( 'Automattic\Jetpack', 'apply_filters', - function ( $filter_name, $value, $name ) use ( $test_constant_value ) { + function ( $filter_name, $value, $name ) use ( $test_constant_value ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable return $test_constant_value; } ); @@ -183,7 +182,7 @@ public function test_jetpack_constants_set_constants_adds_to_set_constants_array $key = 'TEST'; Constants::set_constant( $key, '1' ); $this->assertArrayHasKey( $key, Constants::$set_constants ); - $this->assertEquals( '1', Constants::$set_constants[ $key ] ); + $this->assertSame( '1', Constants::$set_constants[ $key ] ); } /** diff --git a/packages/debug-helper/class-admin.php b/packages/debug-helper/class-admin.php index a2a654489bc0..2fc91790f917 100644 --- a/packages/debug-helper/class-admin.php +++ b/packages/debug-helper/class-admin.php @@ -99,7 +99,7 @@ public function update_option() { add_action( 'plugins_loaded', - function() { + function () { new Admin(); } ); diff --git a/packages/debug-helper/modules/class-broken-token.php b/packages/debug-helper/modules/class-broken-token.php index ea1e9f16412b..6b43342a1856 100644 --- a/packages/debug-helper/modules/class-broken-token.php +++ b/packages/debug-helper/modules/class-broken-token.php @@ -486,7 +486,6 @@ public function render_admin_notice() { add_action( 'plugins_loaded', 'register_broken_token', 1000 ); - /** * Load the brokenness. */ diff --git a/packages/debug-helper/modules/class-mocker.php b/packages/debug-helper/modules/class-mocker.php index 87a5eb74833c..2038baede57a 100644 --- a/packages/debug-helper/modules/class-mocker.php +++ b/packages/debug-helper/modules/class-mocker.php @@ -82,7 +82,7 @@ public function enqueue_scripts( $hook ) { add_filter( 'script_loader_tag', - function( $tag, $handle ) { + function ( $tag, $handle ) { if ( 'mocker_script' === $handle ) { $tag = str_replace( '