Skip to content

Commit 1438833

Browse files
Merge pull request #666 from tighten/jbk/php-cs-fixer
Re-configure and run PHP-CS-Fixer
2 parents fdf6db6 + 308d7a3 commit 1438833

Some content is hidden

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

65 files changed

+331
-281
lines changed

.editorconfig

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
; This file is for unifying the coding style for different editors and IDEs.
2-
; More information at https://editorconfig.org
3-
41
root = true
52

63
[*]
@@ -15,4 +12,4 @@ trim_trailing_whitespace = true
1512
trim_trailing_whitespace = false
1613

1714
[*.yml]
18-
indent_size = 2
15+
indent_size = 2

.git-blame-ignore-revs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,9 @@
66

77
# Move dotenv file snapshot test
88
a2f33e083680337ba53704e4daf8c2d9ed2ac2f8
9+
10+
# Format
11+
ec8c6c07e290fa3c85fd7a1975d1bee0f0d417b9
12+
13+
# Format
14+
12148101ebd2a945d581bf17a7d3c7ed139250cb

.github/workflows/format.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Format
2+
on:
3+
pull_request:
4+
paths: ['**.php']
5+
jobs:
6+
php-cs-fixer:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
with:
11+
fetch-depth: 0
12+
ref: ${{ github.event.pull_request.head.ref }}
13+
- uses: shivammathur/setup-php@v2
14+
with:
15+
php-version: 8.1
16+
- uses: ramsey/composer-install@v2
17+
- name: Run PHP-CS-Fixer
18+
id: format
19+
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
20+
run: |
21+
delimiter=$RANDOM
22+
echo "summary<<${delimiter}" >> $GITHUB_OUTPUT
23+
composer format >> $GITHUB_OUTPUT
24+
echo $delimiter >> $GITHUB_OUTPUT
25+
- name: Check for fixed files
26+
run: echo "changed=$(git diff --quiet && echo false || echo true)" >> $GITHUB_ENV
27+
- name: Commit changes
28+
if: ${{ env.changed == 'true' }}
29+
run: |
30+
git config --global user.name github-actions
31+
git config --global user.email github-actions[bot]@users.noreply.github.com
32+
# awk trims leading and trailing whitespace from each line, sed removes the last two lines
33+
git commit -a -m "Format" -m "$(echo '${{ steps.format.outputs.summary }})' | awk '{$1=$1};1' | sed '$d' | sed '$d')"
34+
git push

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches: [main, ci]
66
jobs:
7-
test:
7+
phpunit:
88
name: PHP ${{ matrix.php }}, ${{ matrix.dependencies }}
99
runs-on: ubuntu-latest
1010
continue-on-error: ${{ matrix.php == '8.2' }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
vendor/
2+
.php-cs-fixer.cache
23
.phpunit.result.cache
3-
.php_cs.cache
44
composer.lock

.php-cs-fixer.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
return (new PhpCsFixer\Config)
4+
->setFinder(PhpCsFixer\Finder::create()->in(__DIR__)->exclude('tests/snapshots'))
5+
->setRiskyAllowed(true)
6+
->setRules([
7+
'@PSR2' => true,
8+
'@Symfony' => true,
9+
'align_multiline_comment' => [
10+
'comment_type' => 'all_multiline',
11+
],
12+
'binary_operator_spaces' => [
13+
'operators' => [
14+
'|' => 'single_space', // Doesn't apply to union types
15+
],
16+
],
17+
'blank_line_after_namespace' => true,
18+
'blank_line_after_opening_tag' => true,
19+
'blank_line_before_statement' => [
20+
'statements' => ['return', 'throw'],
21+
],
22+
'concat_space' => [
23+
'spacing' => 'one',
24+
],
25+
'get_class_to_class_keyword' => true,
26+
'global_namespace_import' => [
27+
'import_classes' => true,
28+
],
29+
'new_with_braces' => false,
30+
'no_empty_comment' => false,
31+
'no_useless_else' => true,
32+
'not_operator_with_successor_space' => true,
33+
'php_unit_method_casing' => false,
34+
'phpdoc_annotation_without_dot' => false,
35+
'phpdoc_to_comment' => [
36+
'ignored_tags' => ['var'],
37+
],
38+
'phpdoc_separation' => [
39+
'groups' => [
40+
['test', 'group', 'dataProvider', 'doesNotPerformAssertions'],
41+
],
42+
],
43+
'phpdoc_var_annotation_correct_order' => true,
44+
'trailing_comma_in_multiline' => [
45+
'after_heredoc' => true,
46+
'elements' => ['arrays', 'arguments', 'parameters'],
47+
],
48+
'yoda_style' => false,
49+
]);

.php_cs

Lines changed: 0 additions & 23 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)