Skip to content

Commit 66750fc

Browse files
authored
Replace phpcs with php-cs-fixer (#1044)
1 parent f019a88 commit 66750fc

File tree

261 files changed

+6546
-6791
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

261 files changed

+6546
-6791
lines changed

.gitattributes

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
# Set the default behavior, in case people don't have core.autocrlf set.
22
* text eol=lf
3-
/.github export-ignore
4-
/benchmarks export-ignore
5-
/tests export-ignore
6-
/examples export-ignore
3+
4+
.github export-ignore
5+
benchmarks export-ignore
6+
tests export-ignore
7+
examples export-ignore
78
.codecov.yml export-ignore
89
.gitattributes export-ignore
910
.gitignore export-ignore
1011
CONTRIBUTING.md export-ignore
1112
generate-class-reference.php export-ignore
1213
mkdocs.yml export-ignore
1314
phpbench.json export-ignore
14-
phpcs.xml.dist export-ignore
15+
.php-cs-fixer.php export-ignore
1516
phpstan.neon.dist export-ignore
1617
phpstan-baseline.neon export-ignore
1718
phpunit.xml.dist export-ignore

.github/workflows/autoformat.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: "Autoformat"
2+
on:
3+
push:
4+
5+
jobs:
6+
composer-normalize:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
with:
11+
ref: ${{ github.head_ref }}
12+
13+
- uses: shivammathur/setup-php@v2
14+
with:
15+
coverage: none
16+
extensions: mbstring
17+
php-version: 7.4
18+
19+
- run: composer install --no-interaction --no-progress --no-suggest
20+
21+
- run: composer normalize
22+
23+
- uses: stefanzweifel/git-auto-commit-action@v4
24+
with:
25+
commit_message: Normalize composer.json
26+
27+
prettier:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v2
31+
with:
32+
ref: ${{ github.head_ref }}
33+
34+
- uses: creyD/[email protected]
35+
with:
36+
prettier_options: --write --tab-width=2 *.md **/*.md
37+
branch: ${{ github.head_ref }}
38+
commit_message: Prettify docs
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
42+
php-cs-fixer:
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v2
46+
with:
47+
ref: ${{ github.head_ref }}
48+
49+
- uses: shivammathur/setup-php@v2
50+
with:
51+
coverage: none
52+
extensions: mbstring
53+
php-version: 7.4
54+
55+
- run: composer install --no-interaction --no-progress --no-suggest
56+
57+
- run: vendor/bin/php-cs-fixer fix
58+
59+
- run: git pull
60+
61+
- uses: stefanzweifel/git-auto-commit-action@v4
62+
with:
63+
commit_message: Apply php-cs-fixer changes

.github/workflows/coding-standards.yml

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

.github/workflows/format.yml

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

.gitignore

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
.phpcs-cache
21
.phpunit.result.cache
2+
.php-cs-fixer.cache
33
composer.lock
44
composer.phar
5-
phpcs.xml
65
phpstan.neon
7-
vendor/
8-
/.idea
6+
vendor
7+
.idea

.php-cs-fixer.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php declare(strict_types=1);
2+
3+
use function MLL\PhpCsFixerConfig\config;
4+
5+
$finder = PhpCsFixer\Finder::create()
6+
->notPath('vendor')
7+
->in(__DIR__)
8+
->name('*.php')
9+
->ignoreDotFiles(true)
10+
->ignoreVCS(true);
11+
12+
return config($finder, [
13+
'no_superfluous_phpdoc_tags' => [
14+
'allow_mixed' => true,
15+
],
16+
]);

CONTRIBUTING.md

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,20 @@ we instead use [the PHP native `nowdoc` syntax](https://www.php.net/manual/en/la
4141
If the string contents are in a specific grammar, use an appropriate tag such as `GRAPHQL`, `PHP` or `JSON`:
4242

4343
```php
44-
self::assertSomePrintedOutputExactlyMatches(
45-
<<<'GRAPHQL'
46-
type Foo {
47-
bar: Baz
48-
}
49-
50-
GRAPHQL,
51-
$output
52-
);
44+
self::assertSomePrintedOutputExactlyMatches(
45+
<<<'GRAPHQL'
46+
type Foo {
47+
bar: Baz
48+
}
49+
50+
GRAPHQL,
51+
$output
52+
);
5353
```
5454

5555
## Coding Standard
5656

57-
We check and fix the coding standard with [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer).
58-
59-
Run the inspections:
60-
61-
```sh
62-
composer lint
63-
```
57+
We format the code automatically with [php-cs-fixer](https://github.com/friendsofphp/php-cs-fixer).
6458

6559
Apply automatic code style fixes:
6660

benchmarks/BuildSchemaBench.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace GraphQL\Benchmarks;
66

77
use GraphQL\Utils\BuildSchema;
8-
98
use function range;
109

1110
/**

benchmarks/HugeSchemaBench.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function setUp(): void
3737

3838
$this->schema = $this->schemaGenerator->buildSchema();
3939

40-
$queryBuilder = new QueryGenerator($this->schema, 0.05);
40+
$queryBuilder = new QueryGenerator($this->schema, 0.05);
4141
$this->smallQuery = $queryBuilder->buildQuery();
4242
}
4343

benchmarks/LexerBench.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ public function benchIntrospectionQuery(): void
3333

3434
do {
3535
$token = $lexer->advance();
36-
} while ($token->kind !== Token::EOF);
36+
} while (Token::EOF !== $token->kind);
3737
}
3838
}

0 commit comments

Comments
 (0)