Skip to content

Commit 0f7dbcb

Browse files
style(phpcs): Upgrade to PHP CS Fixer v3
1 parent 41741c7 commit 0f7dbcb

File tree

6 files changed

+447
-380
lines changed

6 files changed

+447
-380
lines changed

.php_cs renamed to .php-cs-fixer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
exit(0);
55
}
66

7-
return PhpCsFixer\Config::create()
7+
$config = new PhpCsFixer\Config;
8+
return $config
89
->setRules([
910
'@Symfony' => true,
1011
'@Symfony:risky' => true,

docs/ddev.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,23 @@ Now, if you run the php script against the `1.2.3.4` IP:
216216
ddev exec php check-ip.php 1.2.3.4 <BOUNCER_KEY>
217217
```
218218

219-
LAPI will advise you to ban this IP as it's within the 1.2.3.4/30 range.
219+
LAPI will advise you to ban this IP as it's within the 1.2.3.4/30 range.
220+
221+
222+
### Coding standards
223+
224+
#### PHPCS
225+
226+
We are using the [PHP Coding Standards Fixer](https://cs.symfony.com/)
227+
228+
With ddev, you can do the following:
229+
230+
```command
231+
ddev composer update --working-dir=./my-own-modules/crowdsec-php-lib/tools/php-cs-fixer
232+
```
233+
And then:
234+
235+
```
236+
ddev exec PHP_CS_FIXER_IGNORE_ENV=1 ./my-own-modules/crowdsec-php-lib/tools/php-cs-fixer/vendor/bin/php-cs-fixer fix ./my-own-modules/crowdsec-php-lib
237+
238+
```

tests/TestHelpers.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@
1212

1313
class TestHelpers
1414
{
15-
const BAD_IP = '1.2.3.4';
16-
const CLEAN_IP = '2.3.4.5';
17-
const NEWLY_BAD_IP = '3.4.5.6';
18-
const IP_RANGE = '24';
19-
const LARGE_IPV4_RANGE = '23';
20-
const BAD_IPV6 = '2001:0db8:85a3:0000:0000:8a2e:0370:7334';
21-
const IPV6_RANGE = '64';
15+
public const BAD_IP = '1.2.3.4';
16+
public const CLEAN_IP = '2.3.4.5';
17+
public const NEWLY_BAD_IP = '3.4.5.6';
18+
public const IP_RANGE = '24';
19+
public const LARGE_IPV4_RANGE = '23';
20+
public const BAD_IPV6 = '2001:0db8:85a3:0000:0000:8a2e:0370:7334';
21+
public const IPV6_RANGE = '64';
2222

23-
const FS_CACHE_ADAPTER_DIR = __DIR__.'/../var/fs.cache';
24-
const PHP_FILES_CACHE_ADAPTER_DIR = __DIR__.'/../var/phpFiles.cache';
23+
public const FS_CACHE_ADAPTER_DIR = __DIR__.'/../var/fs.cache';
24+
public const PHP_FILES_CACHE_ADAPTER_DIR = __DIR__.'/../var/phpFiles.cache';
2525

26-
const WATCHER_LOGIN = 'PhpUnitTestMachine';
27-
const WATCHER_PASSWORD = 'PhpUnitTestMachinePassword';
26+
public const WATCHER_LOGIN = 'PhpUnitTestMachine';
27+
public const WATCHER_PASSWORD = 'PhpUnitTestMachinePassword';
2828

29-
const LOG_LEVEL = Logger::WARNING; // set to Logger::DEBUG to get high verbosity
29+
public const LOG_LEVEL = Logger::WARNING; // set to Logger::DEBUG to get high verbosity
3030

3131
public static function createLogger(): Logger
3232
{

tests/WatcherClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
class WatcherClient
1010
{
11-
const WATCHER_LOGIN = 'PhpUnitTestMachine';
12-
const WATCHER_PASSWORD = 'PhpUnitTestMachinePassword';
11+
public const WATCHER_LOGIN = 'PhpUnitTestMachine';
12+
public const WATCHER_PASSWORD = 'PhpUnitTestMachinePassword';
1313

1414
/** @var LoggerInterface */
1515
private $logger;

tools/php-cs-fixer/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"require": {
3-
"friendsofphp/php-cs-fixer": "^2.17"
3+
"friendsofphp/php-cs-fixer": "^3.5"
44
}
55
}

0 commit comments

Comments
 (0)