Skip to content

Commit

Permalink
PHPCS: Fix most auto-fixable sniffs coming in new WPCS snapshot (#28176)
Browse files Browse the repository at this point in the history
We're going to update the WordPress-Coding-Standards library from a
2022-02-07 snapshot to a 2023-01-04 snapshot, which brings in a number
of new sniffs. So first we need to fix the stuff the new sniffs will
complain about.

This PR updates for the following sniffs:

* Generic.WhiteSpace.IncrementDecrementSpacing.SpaceAfterIncrement
* Modernize.FunctionCalls.Dirname
* PSR12.Functions.ReturnTypeDeclaration.SpaceBeforeColon
* PSR2.Methods.FunctionClosingBrace.SpacingBeforeClose
* Universal.Constants.UppercaseMagicConstants
* Universal.Operators.DisallowStandalonePostIncrementDecrement

Then it has to do a bit more cleanup on touched lines in some of the
excluded files. Yay tech debt.
  • Loading branch information
anomiex authored Jan 4, 2023
1 parent 54789e6 commit 5463f2e
Show file tree
Hide file tree
Showing 264 changed files with 338 additions and 456 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: PHPCS: Fix most auto-fixable sniffs coming in new WPCS snapshot. No user-visible change to the project.


1 change: 0 additions & 1 deletion projects/packages/a8c-mc-stats/src/class-a8c-mc-stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ public function get_stats_urls() {
}

return $urls;

}

/**
Expand Down
2 changes: 0 additions & 2 deletions projects/packages/a8c-mc-stats/tests/php/test_Stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public function test_add_get() {
$this->assertFalse( $stats->add( 'group2', 'test3' ) );
$this->assertFalse( $stats->add( true, 'test3' ) );
$this->assertFalse( $stats->add( array( 123 ), 'test3' ) );

}

/**
Expand All @@ -72,7 +71,6 @@ public function test_get_group_query_args() {
$this->assertCount( 1, $check );
$this->assertArrayHasKey( 'x_jetpack-group', $check );
$this->assertEquals( 'test,test2', $check['x_jetpack-group'] );

}

}
5 changes: 5 additions & 0 deletions projects/packages/admin-ui/changelog/update-wpcs-pre-phpcbf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: PHPCS: Fix most auto-fixable sniffs coming in new WPCS snapshot. No user-visible change to the project.


2 changes: 1 addition & 1 deletion projects/packages/admin-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-admin-ui",
"version": "0.2.14",
"version": "0.2.15-alpha",
"description": "Generic Jetpack wp-admin UI elements",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/admin-ui/#readme",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/admin-ui/src/class-admin-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
class Admin_Menu {

const PACKAGE_VERSION = '0.2.14';
const PACKAGE_VERSION = '0.2.15-alpha';

/**
* Whether this class has been initialized
Expand Down
1 change: 0 additions & 1 deletion projects/packages/admin-ui/tests/php/test_admin_menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public function test_page_suffix_matches( $menu_slug ) {
$wp_suffix = add_submenu_page( 'jetpack', 'Test', 'Test', 'read', $menu_slug, '__return_null' );

$this->assertSame( $our_suffix, $wp_suffix );

}

/**
Expand Down
5 changes: 5 additions & 0 deletions projects/packages/assets/changelog/update-wpcs-pre-phpcbf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: PHPCS: Fix most auto-fixable sniffs coming in new WPCS snapshot. No user-visible change to the project.


2 changes: 1 addition & 1 deletion projects/packages/assets/src/class-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public static function normalize_path( $path ) {
} elseif ( '..' === $pp[ $i ] ) {
array_splice( $pp, --$i, 2 );
} else {
$i++;
++$i;
}
}
$ret .= join( '/', $pp );
Expand Down
5 changes: 5 additions & 0 deletions projects/packages/backup/changelog/update-wpcs-pre-phpcbf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: PHPCS: Fix most auto-fixable sniffs coming in new WPCS snapshot. No user-visible change to the project.


Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public static function upgrade() {
call_user_func( array( __CLASS__, $upgrade ) );

}

}

/**
Expand Down
1 change: 0 additions & 1 deletion projects/packages/backup/src/class-jetpack-backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,6 @@ public static function get_site_current_purchases() {
return rest_ensure_response(
json_decode( $response['body'], true )
);

}

/**
Expand Down
5 changes: 5 additions & 0 deletions projects/packages/blocks/changelog/update-wpcs-pre-phpcbf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: PHPCS: Fix most auto-fixable sniffs coming in new WPCS snapshot. No user-visible change to the project.


1 change: 0 additions & 1 deletion projects/packages/blocks/tests/php/test-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ public function test_jetpack_register_block_with_editor_style() {
} finally {
remove_filter( 'jetpack_is_standalone_block', '__return_false' );
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: PHPCS: Fix most auto-fixable sniffs coming in new WPCS snapshot. No user-visible change to the project.


2 changes: 1 addition & 1 deletion projects/packages/changelogger/src/AddCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ protected function execute( InputInterface $input, OutputInterface $output ) {
if ( file_exists( "$dir/$filename" ) && $input->getOption( 'filename-auto-suffix' ) ) {
$i = 2;
while ( file_exists( "$dir/$filename#$i" ) ) {
$i++;
++$i;
}
$output->writeln( "File \"$filename\" already exists. Creating \"$filename#$i\" instead.", OutputInterface::VERBOSITY_VERBOSE );
$filename = "$filename#$i";
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/changelogger/src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
class Application extends SymfonyApplication {

const VERSION = '3.3.0';
const VERSION = '3.3.1-alpha';

/**
* Constructor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,16 @@ public function nextVersion( $version, array $changes, array $extra = array() )
$out->writeln( '<warning>Semver does not automatically move version 0.y.z to 1.0.0.</>' );
$out->writeln( '<warning>You will have to do that manually when you\'re ready for the first release.</>' );
}
$info['minor']++;
++$info['minor'];
} else {
$info['minor'] = 0;
$info['major']++;
++$info['major'];
}
} elseif ( isset( $significances['minor'] ) ) {
$info['patch'] = 0;
$info['minor']++;
++$info['minor'];
} else {
$info['patch']++;
++$info['patch'];
}

return $this->normalizeVersion( $info );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function nextVersion( $version, array $changes, array $extra = array() )
);

if ( $this->input->getOption( 'point-release' ) ) {
$info['point']++;
++$info['point'];
} else {
$info['point'] = 0;
$info['major'] += 0.1;
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/changelogger/src/ValidateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private function msg( $type, $file, $line, $msg ) {
$postfix = '</>';
}
$this->output->writeln( $prefix . $msg . $postfix );
$this->counts[ $type ]++;
++$this->counts[ $type ];
}

/**
Expand Down
6 changes: 3 additions & 3 deletions projects/packages/changelogger/src/php7/CommandLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CommandLoader extends CommandLoaderBase implements CommandLoaderInterface
* @param string $name Command name.
* @return bool
*/
public function has( $name ) : bool {
public function has( $name ): bool {
return $this->doHas( $name );
}

Expand All @@ -33,7 +33,7 @@ public function has( $name ) : bool {
* @return Command
* @throws CommandNotFoundException If the command is not found.
*/
public function get( $name ) : Command {
public function get( $name ): Command {
return $this->doGet( $name );
}

Expand All @@ -42,7 +42,7 @@ public function get( $name ) : Command {
*
* @return string[] All registered command names
*/
public function getNames() : array {
public function getNames(): array {
return $this->doGetNames();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public function process( File $phpcs_file, $stack_ptr ) {
'ShouldNotBeUsed'
);
}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: PHPCS: Fix most auto-fixable sniffs coming in new WPCS snapshot. No user-visible change to the project.


5 changes: 5 additions & 0 deletions projects/packages/connection/changelog/update-wpcs-pre-phpcbf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: PHPCS: Fix most auto-fixable sniffs coming in new WPCS snapshot. No user-visible change to the project.


6 changes: 0 additions & 6 deletions projects/packages/connection/src/class-error-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ public function store_error( \WP_Error $error ) {
}

return false;

}

/**
Expand Down Expand Up @@ -326,7 +325,6 @@ public function wp_error_to_array( \WP_Error $error ) {
);

return $error_array;

}

/**
Expand Down Expand Up @@ -380,7 +378,6 @@ public function encrypt_data_to_wpcom( $data ) {
}

return $encrypted_data;

}

/**
Expand All @@ -401,7 +398,6 @@ public function get_user_id_from_token( $token ) {
}

return $user_id;

}

/**
Expand Down Expand Up @@ -566,7 +562,6 @@ public function verify_error( $error ) {
$verified_errors[ $error_code ][ $user_id ] = $error;

update_option( self::STORED_VERIFIED_ERRORS_OPTION, $verified_errors );

}

/**
Expand Down Expand Up @@ -612,7 +607,6 @@ public function verify_xml_rpc_error( \WP_REST_Request $request ) {
}

return new \WP_REST_Response( false, 200 );

}

/**
Expand Down
1 change: 0 additions & 1 deletion projects/packages/connection/src/class-heartbeat.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ public static function generate_stats_array( $prefix = '' ) {
}

return $return;

}

/**
Expand Down
1 change: 0 additions & 1 deletion projects/packages/connection/src/class-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1778,7 +1778,6 @@ public function verify_secrets( $action, $secret_1, $user_id ) {
* Should be changed to protected.
*/
public function handle_authorization() {

}

/**
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/connection/src/class-package-version.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
class Package_Version {

const PACKAGE_VERSION = '1.48.1';
const PACKAGE_VERSION = '1.48.2-alpha';

const PACKAGE_SLUG = 'connection';

Expand Down
1 change: 0 additions & 1 deletion projects/packages/connection/src/class-plugin-storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ public static function configure() {
}

self::$configured = true;

}

/**
Expand Down
4 changes: 0 additions & 4 deletions projects/packages/connection/src/class-rest-connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ function ( &$data, $slug ) {
}

return array_values( $plugins );

}

/**
Expand Down Expand Up @@ -398,7 +397,6 @@ public static function connection_plugins_permission_check() {
}

return new WP_Error( 'invalid_user_permission_activate_plugins', self::get_user_permissions_error_msg(), array( 'status' => rest_authorization_required_code() ) );

}

/**
Expand Down Expand Up @@ -495,7 +493,6 @@ public static function get_user_connection_data( $rest_response = true ) {
}

return $response;

}

/**
Expand All @@ -513,7 +510,6 @@ public static function user_connection_data_permission_check() {
self::get_user_permissions_error_msg(),
array( 'status' => rest_authorization_required_code() )
);

}

/**
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/connection/src/class-secrets.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private function secret_callable_method() {
$attempts = 1;
$secret_length = strlen( $secret );
while ( $secret_length < 32 && $attempts < 32 ) {
$attempts++;
++$attempts;
$secret .= wp_generate_password( 32, false );
$secret_length = strlen( $secret );
}
Expand Down
1 change: 0 additions & 1 deletion projects/packages/connection/src/class-server-sandbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ private function get_new_signature( $url, $headers, $data, $method ) {
} else {
$this->log_new_signature_error( 'Empty Authorization Header' );
}

}

/**
Expand Down
1 change: 0 additions & 1 deletion projects/packages/connection/src/class-tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,5 @@ public function tracks_get_identity( $user_id ) {
'_ut' => 'anon',
'_ui' => $anon_id,
);

}
}
1 change: 0 additions & 1 deletion projects/packages/connection/src/class-webhooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public function controller( $force = false ) {
break;
// Class Jetpack::admin_page_load() still handles other cases.
}

}

/**
Expand Down
Loading

0 comments on commit 5463f2e

Please sign in to comment.