Skip to content

Commit fe51dc2

Browse files
authored
chore: better cs fixer rules (#149)
1 parent 4a48388 commit fe51dc2

File tree

8 files changed

+44
-22
lines changed

8 files changed

+44
-22
lines changed

.github/workflows/code-standards.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,14 @@ on:
1919
"@PSR2": true,
2020
"array_syntax": {"syntax":"short"},
2121
"concat_space": {"spacing":"one"},
22+
"new_with_parentheses": true,
2223
"no_unused_imports": true,
2324
"ordered_imports": true,
24-
"new_with_parentheses": true,
25-
"whitespace_after_comma_in_array": true,
26-
"method_argument_space": {
27-
"keep_multiple_spaces_after_comma": true,
28-
"on_multiline": "ignore"
29-
},
3025
"return_type_declaration": {"space_before": "none"},
31-
"single_quote": true
26+
"single_quote": true,
27+
"single_space_around_construct": true,
28+
"cast_spaces": true,
29+
"whitespace_after_comma_in_array": true
3230
}
3331
3432
permissions:

.php-cs-fixer.default.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
require __DIR__ . '/vendor/autoload.php';
4+
5+
use Symfony\Component\Yaml\Yaml;
6+
7+
$workflow = Yaml::parse(file_get_contents(__DIR__ . '/.github/workflows/code-standards.yml'));
8+
$rules = json_decode($workflow['on']['workflow_call']['inputs']['rules']['default'], true);
9+
10+
return (new PhpCsFixer\Config())
11+
->setRules($rules)
12+
->setFinder(
13+
PhpCsFixer\Finder::create()
14+
->in(__DIR__)
15+
)
16+
;

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"friendsofphp/php-cs-fixer": "^3.62",
4444
"google/cloud-dlp": "^1.10",
4545
"google/cloud-storage": "^1.33",
46-
"google/cloud-secret-manager": "^1.12"
46+
"google/cloud-secret-manager": "^1.12",
47+
"symfony/yaml": "^5"
4748
}
4849
}

src/TestUtils/TestTrait.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ private static function requireOneOfEnv($varNames)
5050
}
5151

5252
self::markTestSkipped(
53-
sprintf('Set the %s environment variable',
53+
sprintf(
54+
'Set the %s environment variable',
5455
implode(' or ', (array) $varName)
5556
)
5657
);

src/Utils/Flex/FlexExecCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ protected function detectLatestDeployedVersion(
264264
]
265265
);
266266
if (!empty($cmdOutput)) {
267-
return preg_split('/\s+/', $cmdOutput[0])[0];
267+
return preg_split('/\s+/', $cmdOutput[0])[0];
268268
}
269269
}
270270
}

src/Utils/Project.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ public function runComposer()
119119
chdir($this->dir);
120120
exec(
121121
'composer update --no-interaction --no-progress --no-ansi',
122-
$output, $ret);
122+
$output,
123+
$ret
124+
);
123125
$this->info = array_merge($this->info, $output);
124126
if ($ret !== 0) {
125127
$this->errors[] = 'Failed to run composer update in ' . $this->dir

src/Utils/WordPress/Project.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ public function downloadBatcachePlugin()
175175
$this->output->writeln('Downloading the Batcache plugin...');
176176
$dir = $this->getWordpressDir();
177177
$this->downloadArchive(
178-
'Batcache plugin', self::LATEST_BATCACHE,
178+
'Batcache plugin',
179+
self::LATEST_BATCACHE,
179180
$dir . '/wp-content/plugins'
180181
);
181182
$this->report();
@@ -191,7 +192,8 @@ public function downloadMemcachedPlugin()
191192
$this->output->writeln('Downloading the Memcached plugin...');
192193
$dir = $this->getWordpressDir();
193194
$this->downloadArchive(
194-
'Memcached plugin', self::LATEST_MEMCACHED,
195+
'Memcached plugin',
196+
self::LATEST_MEMCACHED,
195197
$dir . '/wp-content/plugins'
196198
);
197199
$this->report();
@@ -207,7 +209,8 @@ public function downloadAppEnginePlugin()
207209
$this->output->writeln('Downloading the appengine-wordpress plugin...');
208210
$dir = $this->getWordpressDir();
209211
$this->downloadArchive(
210-
'App Engine WordPress plugin', self::LATEST_GAE_WP,
212+
'App Engine WordPress plugin',
213+
self::LATEST_GAE_WP,
211214
$dir . '/wp-content/plugins'
212215
);
213216
$this->report();
@@ -218,7 +221,8 @@ public function downloadGcsPlugin()
218221
$this->output->writeln('Downloading the GCS plugin...');
219222
$dir = $this->getWordpressDir();
220223
$this->downloadArchive(
221-
'GCS plugin', self::LATEST_GCS_PLUGIN,
224+
'GCS plugin',
225+
self::LATEST_GCS_PLUGIN,
222226
$dir . '/wp-content/plugins'
223227
);
224228
$this->report();

src/Utils/WordPress/files/wp-config.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@
7575
*
7676
* @since 2.6.0
7777
*/
78-
define('AUTH_KEY', 'YOUR_AUTH_KEY');
79-
define('SECURE_AUTH_KEY', 'YOUR_SECURE_AUTH_KEY');
80-
define('LOGGED_IN_KEY', 'YOUR_LOGGED_IN_KEY');
81-
define('NONCE_KEY', 'YOUR_NONCE_KEY');
82-
define('AUTH_SALT', 'YOUR_AUTH_SALT');
78+
define('AUTH_KEY', 'YOUR_AUTH_KEY');
79+
define('SECURE_AUTH_KEY', 'YOUR_SECURE_AUTH_KEY');
80+
define('LOGGED_IN_KEY', 'YOUR_LOGGED_IN_KEY');
81+
define('NONCE_KEY', 'YOUR_NONCE_KEY');
82+
define('AUTH_SALT', 'YOUR_AUTH_SALT');
8383
define('SECURE_AUTH_SALT', 'YOUR_SECURE_AUTH_SALT');
84-
define('LOGGED_IN_SALT', 'YOUR_LOGGED_IN_SALT');
85-
define('NONCE_SALT', 'YOUR_NONCE_SALT');
84+
define('LOGGED_IN_SALT', 'YOUR_LOGGED_IN_SALT');
85+
define('NONCE_SALT', 'YOUR_NONCE_SALT');
8686

8787
/**#@-*/
8888
/**

0 commit comments

Comments
 (0)