From fe51dc221e6e7bc4039af86b43f42480ae38e927 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 28 Aug 2024 14:26:48 -0700 Subject: [PATCH] chore: better cs fixer rules (#149) --- .github/workflows/code-standards.yml | 12 +++++------- .php-cs-fixer.default.php | 16 ++++++++++++++++ composer.json | 3 ++- src/TestUtils/TestTrait.php | 3 ++- src/Utils/Flex/FlexExecCommand.php | 2 +- src/Utils/Project.php | 4 +++- src/Utils/WordPress/Project.php | 12 ++++++++---- src/Utils/WordPress/files/wp-config.php | 14 +++++++------- 8 files changed, 44 insertions(+), 22 deletions(-) create mode 100644 .php-cs-fixer.default.php diff --git a/.github/workflows/code-standards.yml b/.github/workflows/code-standards.yml index 84190e5..538f1c9 100644 --- a/.github/workflows/code-standards.yml +++ b/.github/workflows/code-standards.yml @@ -19,16 +19,14 @@ on: "@PSR2": true, "array_syntax": {"syntax":"short"}, "concat_space": {"spacing":"one"}, + "new_with_parentheses": true, "no_unused_imports": true, "ordered_imports": true, - "new_with_parentheses": true, - "whitespace_after_comma_in_array": true, - "method_argument_space": { - "keep_multiple_spaces_after_comma": true, - "on_multiline": "ignore" - }, "return_type_declaration": {"space_before": "none"}, - "single_quote": true + "single_quote": true, + "single_space_around_construct": true, + "cast_spaces": true, + "whitespace_after_comma_in_array": true } permissions: diff --git a/.php-cs-fixer.default.php b/.php-cs-fixer.default.php new file mode 100644 index 0000000..a78af4a --- /dev/null +++ b/.php-cs-fixer.default.php @@ -0,0 +1,16 @@ +setRules($rules) + ->setFinder( + PhpCsFixer\Finder::create() + ->in(__DIR__) + ) +; diff --git a/composer.json b/composer.json index 5b494b5..08bbc4d 100644 --- a/composer.json +++ b/composer.json @@ -43,6 +43,7 @@ "friendsofphp/php-cs-fixer": "^3.62", "google/cloud-dlp": "^1.10", "google/cloud-storage": "^1.33", - "google/cloud-secret-manager": "^1.12" + "google/cloud-secret-manager": "^1.12", + "symfony/yaml": "^5" } } diff --git a/src/TestUtils/TestTrait.php b/src/TestUtils/TestTrait.php index 28345cf..95ac9ba 100644 --- a/src/TestUtils/TestTrait.php +++ b/src/TestUtils/TestTrait.php @@ -50,7 +50,8 @@ private static function requireOneOfEnv($varNames) } self::markTestSkipped( - sprintf('Set the %s environment variable', + sprintf( + 'Set the %s environment variable', implode(' or ', (array) $varName) ) ); diff --git a/src/Utils/Flex/FlexExecCommand.php b/src/Utils/Flex/FlexExecCommand.php index 91da3c2..3d2163f 100644 --- a/src/Utils/Flex/FlexExecCommand.php +++ b/src/Utils/Flex/FlexExecCommand.php @@ -264,7 +264,7 @@ protected function detectLatestDeployedVersion( ] ); if (!empty($cmdOutput)) { - return preg_split('/\s+/', $cmdOutput[0])[0]; + return preg_split('/\s+/', $cmdOutput[0])[0]; } } } diff --git a/src/Utils/Project.php b/src/Utils/Project.php index a34c192..5b30d75 100644 --- a/src/Utils/Project.php +++ b/src/Utils/Project.php @@ -119,7 +119,9 @@ public function runComposer() chdir($this->dir); exec( 'composer update --no-interaction --no-progress --no-ansi', - $output, $ret); + $output, + $ret + ); $this->info = array_merge($this->info, $output); if ($ret !== 0) { $this->errors[] = 'Failed to run composer update in ' . $this->dir diff --git a/src/Utils/WordPress/Project.php b/src/Utils/WordPress/Project.php index 4cb3bb1..087973c 100644 --- a/src/Utils/WordPress/Project.php +++ b/src/Utils/WordPress/Project.php @@ -175,7 +175,8 @@ public function downloadBatcachePlugin() $this->output->writeln('Downloading the Batcache plugin...'); $dir = $this->getWordpressDir(); $this->downloadArchive( - 'Batcache plugin', self::LATEST_BATCACHE, + 'Batcache plugin', + self::LATEST_BATCACHE, $dir . '/wp-content/plugins' ); $this->report(); @@ -191,7 +192,8 @@ public function downloadMemcachedPlugin() $this->output->writeln('Downloading the Memcached plugin...'); $dir = $this->getWordpressDir(); $this->downloadArchive( - 'Memcached plugin', self::LATEST_MEMCACHED, + 'Memcached plugin', + self::LATEST_MEMCACHED, $dir . '/wp-content/plugins' ); $this->report(); @@ -207,7 +209,8 @@ public function downloadAppEnginePlugin() $this->output->writeln('Downloading the appengine-wordpress plugin...'); $dir = $this->getWordpressDir(); $this->downloadArchive( - 'App Engine WordPress plugin', self::LATEST_GAE_WP, + 'App Engine WordPress plugin', + self::LATEST_GAE_WP, $dir . '/wp-content/plugins' ); $this->report(); @@ -218,7 +221,8 @@ public function downloadGcsPlugin() $this->output->writeln('Downloading the GCS plugin...'); $dir = $this->getWordpressDir(); $this->downloadArchive( - 'GCS plugin', self::LATEST_GCS_PLUGIN, + 'GCS plugin', + self::LATEST_GCS_PLUGIN, $dir . '/wp-content/plugins' ); $this->report(); diff --git a/src/Utils/WordPress/files/wp-config.php b/src/Utils/WordPress/files/wp-config.php index 224132f..612936b 100644 --- a/src/Utils/WordPress/files/wp-config.php +++ b/src/Utils/WordPress/files/wp-config.php @@ -75,14 +75,14 @@ * * @since 2.6.0 */ -define('AUTH_KEY', 'YOUR_AUTH_KEY'); -define('SECURE_AUTH_KEY', 'YOUR_SECURE_AUTH_KEY'); -define('LOGGED_IN_KEY', 'YOUR_LOGGED_IN_KEY'); -define('NONCE_KEY', 'YOUR_NONCE_KEY'); -define('AUTH_SALT', 'YOUR_AUTH_SALT'); +define('AUTH_KEY', 'YOUR_AUTH_KEY'); +define('SECURE_AUTH_KEY', 'YOUR_SECURE_AUTH_KEY'); +define('LOGGED_IN_KEY', 'YOUR_LOGGED_IN_KEY'); +define('NONCE_KEY', 'YOUR_NONCE_KEY'); +define('AUTH_SALT', 'YOUR_AUTH_SALT'); define('SECURE_AUTH_SALT', 'YOUR_SECURE_AUTH_SALT'); -define('LOGGED_IN_SALT', 'YOUR_LOGGED_IN_SALT'); -define('NONCE_SALT', 'YOUR_NONCE_SALT'); +define('LOGGED_IN_SALT', 'YOUR_LOGGED_IN_SALT'); +define('NONCE_SALT', 'YOUR_NONCE_SALT'); /**#@-*/ /**