Skip to content

Commit 3f36b90

Browse files
authored
Merge pull request #1 from opositatest/2.0
Version 2.0
2 parents 4415dfb + 99253e2 commit 3f36b90

13 files changed

+154
-197
lines changed

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
.php_cs
2-
.php_cs.cache
3-
.phpunit.result.cache
41
composer.lock
52
phpunit.xml
63
vendor
7-
.idea
4+
.idea
5+
.php-cs-fixer.cache
6+
.phpunit.cache/
7+
.phpunit.result.cache

.php-cs-fixer.dist.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
use Opositatest\PhpCsFixerConfig\OpositatestConfig;
5+
6+
$config = new OpositatestConfig();
7+
$config->setCacheFile('.php-cs-fixer.cache');
8+
9+
$config->getFinder()
10+
->in(__DIR__ . "/src")
11+
->in(__DIR__ . "/tests");
12+
13+
return $config;

.php_cs.dist

Lines changed: 0 additions & 6 deletions
This file was deleted.

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
DOCKER_RUN = docker run --rm -v $(PWD):/app -w /app composer:latest
2+
3+
.PHONY: composer-install
4+
5+
composer-install:
6+
docker run --rm -v $(PWD):/app -w /app composer:latest composer update
7+
8+
test:
9+
docker run --rm -v $(PWD):/app -w /app php:8.3 vendor/bin/phpunit
10+
11+
cs-fix:
12+
docker run --rm -v $(PWD):/app -w /app php:8.3 vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Create a configuration file called `.php_cs.dist` in the project root with the f
1919
```php
2020
<?php
2121

22-
$config = new Opositatest\PhpCsFixerConfig\StrictConfig();
22+
$config = new Opositatest\PhpCsFixerConfig\OpositatestConfig();
2323
$config->getFinder()
2424
->in(__DIR__ . "/src")
2525
->in(__DIR__ . "/tests");
@@ -31,7 +31,7 @@ return $config;
3131
To execute the fixes manually, you must run the `php-cs-fixer` (usually located at `/vendor/bin` or `/bin`):
3232

3333
```
34-
$ ./vendor/bin/php-cs-fixer fix --config=.php_cs.dist
34+
$ ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php
3535
```
3636

3737
The `--verbose` and `--diff` options can be useful to see what changes are being actually made. To avoid applying changes automatically, the `--dry-run` option can be used:
@@ -41,7 +41,7 @@ $ ./vendor/bin/php-cs-fixer fix --config=.php_cs.dist --verbose --diff --dry-run
4141
```
4242
## Limiting scope
4343

44-
In large projects, the first time you run the tool you may end up with many changes, making it difficult to spot potential regressions. The tool makes use of the Symonfy Finder component, so you can use any of the filters provided by the component to limit by directory, file names, etc. For example:
44+
In large projects, the first time you run the tool you may end up with many changes, making it difficult to spot potential regressions. The tool makes use of the Symfony Finder component, so you can use any of the filters provided by the component to limit by directory, file names, etc. For example:
4545

4646
### Apply only to given subdirectory
4747

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
}
1111
],
1212
"require": {
13-
"php": ">=7.4",
14-
"friendsofphp/php-cs-fixer": "^2.16"
13+
"php": "^8.3",
14+
"friendsofphp/php-cs-fixer": "^3.54"
1515
},
1616
"require-dev": {
17-
"phpunit/phpunit": "^8.0"
17+
"phpunit/phpunit": "^11.0"
1818
},
1919
"autoload": {
2020
"psr-4": {

phpunit.xml.dist

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
32
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.0/phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.1/phpunit.xsd"
54
backupGlobals="false"
6-
backupStaticAttributes="false"
75
colors="true"
8-
convertErrorsToExceptions="true"
9-
convertNoticesToExceptions="true"
10-
convertWarningsToExceptions="true"
116
processIsolation="false"
127
stopOnFailure="false"
138
bootstrap="vendor/autoload.php"
9+
cacheDirectory=".phpunit.cache"
10+
backupStaticProperties="false"
1411
>
15-
<testsuite name="opositatest/php-cs-fixer-config Test Suite">
16-
<directory>./tests</directory>
17-
</testsuite>
1812

19-
<filter>
20-
<whitelist>
21-
<directory>./src/</directory>
22-
</whitelist>
23-
</filter>
24-
</phpunit>
13+
<testsuite name="opositatest/php-cs-fixer-config Test Suite">
14+
<directory>./tests</directory>
15+
</testsuite>
16+
17+
<source>
18+
<include>
19+
<directory>./src/</directory>
20+
</include>
21+
</source>
22+
23+
</phpunit>

src/OpositatestConfig.php

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Opositatest\PhpCsFixerConfig;
6+
7+
use PhpCsFixer\Config;
8+
9+
final class OpositatestConfig extends Config
10+
{
11+
public function __construct()
12+
{
13+
parent::__construct('Opositatest');
14+
$this->setRiskyAllowed(false);
15+
}
16+
17+
public function getRules(): array
18+
{
19+
return [
20+
// Symfony rule set
21+
'@Symfony' => true,
22+
23+
// additional configurations
24+
'attribute_empty_parentheses' => [
25+
'use_parentheses' => false,
26+
],
27+
'ordered_attributes' => [
28+
'sort_algorithm' => 'custom',
29+
'order' => [
30+
'Symfony\\Component\\Routing\\Annotation\\Route',
31+
'OpenApi\\Attributes\\Tag',
32+
'OpenApi\\Attributes\\Parameter',
33+
'OpenApi\\Attributes\\RequestBody',
34+
'OpenApi\\Attributes\\Response',
35+
'Symfony\\Component\\HttpKernel\\Attribute\\Cache'
36+
]
37+
],
38+
'array_syntax' => [
39+
'syntax' => 'short',
40+
],
41+
'general_phpdoc_annotation_remove' => [
42+
'annotations' => [
43+
'author', 'package', 'subpackage',
44+
],
45+
],
46+
'header_comment' => ['header' => ''],
47+
'heredoc_to_nowdoc' => true,
48+
'no_superfluous_elseif' => true,
49+
'no_useless_else' => true,
50+
'no_useless_return' => true,
51+
'ordered_class_elements' => true,
52+
'method_chaining_indentation' => true,
53+
'phpdoc_line_span' => [
54+
'const' => 'single',
55+
'property' => 'single',
56+
],
57+
'protected_to_private' => true,
58+
'self_static_accessor' => true,
59+
'simplified_if_return' => true,
60+
'assign_null_coalescing_to_coalesce_equal' => true,
61+
'ternary_to_null_coalescing' => true,
62+
'php_unit_attributes' => true,
63+
64+
// Symfony's ruleset overrides
65+
'blank_line_before_statement' => [
66+
'statements' => [
67+
'return',
68+
'try',
69+
],
70+
],
71+
'method_argument_space' => [
72+
'on_multiline' => 'ensure_fully_multiline',
73+
],
74+
];
75+
}
76+
}

src/SafeConfig.php

Lines changed: 0 additions & 77 deletions
This file was deleted.

src/StrictConfig.php

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)