Skip to content

Commit 1591373

Browse files
committed
Format code with PHP-CS-Fixer
1 parent 9cee1e1 commit 1591373

File tree

13 files changed

+3430
-898
lines changed

13 files changed

+3430
-898
lines changed

.github/workflows/php.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ jobs:
3434
- name: Perform static analysis
3535
run: composer analyze -- --error-format=github
3636
if: ${{ matrix.php == '8.4' }}
37+
38+
- name: Check Formatting
39+
run: vendor/bin/php-cs-fixer fix -v --dry-run --stop-on-violation --using-cache=no
40+
if: ${{ matrix.php == '8.3' }}

.php-cs-fixer.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->path([
5+
'src/',
6+
'tests/',
7+
])
8+
->notPath([
9+
'src/Parser.php',
10+
])
11+
->ignoreVCSIgnored(true)
12+
->append([__FILE__])
13+
->in(__DIR__);
14+
15+
$config = new PhpCsFixer\Config();
16+
return $config
17+
->setRules([
18+
'@PER-CS' => true,
19+
'align_multiline_comment' => true,
20+
'array_syntax' => true,
21+
'binary_operator_spaces' => true,
22+
'class_attributes_separation' => ['elements' => ['method' => 'one']],
23+
'class_reference_name_casing' => true,
24+
'clean_namespace' => true,
25+
'combine_consecutive_unsets' => true,
26+
'declare_parentheses' => true,
27+
'integer_literal_case' => true,
28+
'lambda_not_used_import' => true,
29+
'linebreak_after_opening_tag' => true,
30+
'method_chaining_indentation' => true,
31+
'multiline_comment_opening_closing' => true,
32+
'native_function_casing' => true,
33+
'no_alternative_syntax' => true,
34+
'no_blank_lines_after_phpdoc' => true,
35+
'no_empty_comment' => true,
36+
'no_empty_phpdoc' => true,
37+
'no_empty_statement' => true,
38+
'no_extra_blank_lines' => true,
39+
'no_spaces_around_offset' => true,
40+
'no_superfluous_phpdoc_tags' => true,
41+
'no_unneeded_control_parentheses' => true,
42+
'no_unused_imports' => true,
43+
'no_useless_return' => true,
44+
'no_whitespace_before_comma_in_array' => true,
45+
'object_operator_without_whitespace' => true,
46+
'ordered_imports' => ['sort_algorithm' => 'alpha'],
47+
'phpdoc_indent' => true,
48+
'phpdoc_no_empty_return' => true,
49+
'phpdoc_single_line_var_spacing' => true,
50+
'return_assignment' => true,
51+
'semicolon_after_instruction' => true,
52+
'single_class_element_per_statement' => true,
53+
'single_space_around_construct' => true,
54+
'space_after_semicolon' => true,
55+
'standardize_not_equals' => true,
56+
'trim_array_spaces' => true,
57+
'type_declaration_spaces' => true,
58+
'types_spaces' => true,
59+
'whitespace_after_comma_in_array' => ['ensure_single_space' => true],
60+
])
61+
->setFinder($finder);

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"php": ">=8.2"
2121
},
2222
"require-dev": {
23+
"friendsofphp/php-cs-fixer": "^3.75",
2324
"ircmaxell/php-yacc": "dev-master",
2425
"jbboehr/handlebars-spec": "dev-master",
2526
"phpstan/phpstan": "^2.1.14",
@@ -37,6 +38,7 @@
3738
},
3839
"scripts": {
3940
"analyze": "phpstan analyze",
41+
"cs-fix": "php-cs-fixer fix -v",
4042
"test": "vendor/bin/phpunit tests"
4143
},
4244
"config": {

0 commit comments

Comments
 (0)