Skip to content

Commit c416fcf

Browse files
Fix coding style issues using PHP-CS-Fixer
1 parent 5e02767 commit c416fcf

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ jobs:
3535
wget https://cs.symfony.com/download/php-cs-fixer-v3.phar -O php-cs-fixer.phar
3636
chmod +x php-cs-fixer.phar
3737
38-
# Run PHP-CS-Fixer (check coding standards)
38+
# Run PHP-CS-Fixer (fix coding standards)
3939
- name: Run PHP-CS-Fixer
40-
run: ./php-cs-fixer.phar fix --dry-run --diff --verbose . || [ $? -eq 8 ]
40+
run: ./php-cs-fixer.phar fix --verbose .
41+
42+
# Download PHP_CodeSniffer
43+
- name: Download PHP_CodeSniffer
44+
run: |
45+
wget https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar -O phpcs.phar
46+
chmod +x phpcs.phar
47+
48+
# Run PHP_CodeSniffer (check coding standards)
49+
- name: Run PHP_CodeSniffer
50+
run: ./phpcs.phar --standard=PSR12 .

php-cs-fixer.phar

Whitespace-only changes.

php-cs-fixer.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
return (new PhpCsFixer\Config())
4+
->setRules([
5+
'@PSR12' => true, // Use PSR-12 coding standard
6+
'array_syntax' => ['syntax' => 'short'], // Use short array syntax
7+
'no_unused_imports' => true, // Remove unused imports
8+
'binary_operator_spaces' => [ // Fix spacing around operators
9+
'operators' => [
10+
'.' => 'single_space', // Fix spacing around concatenation (.)
11+
'=>' => 'single_space', // Fix spacing around array arrows (=>)
12+
],
13+
],
14+
'no_whitespace_in_blank_line' => true, // Remove trailing whitespace
15+
'no_trailing_whitespace' => true, // Remove trailing whitespace
16+
'braces' => [ // Fix braces placement
17+
'allow_single_line_closure' => true,
18+
],
19+
])
20+
->setFinder(
21+
PhpCsFixer\Finder::create()
22+
->in(__DIR__) // Apply to the current directory
23+
->exclude('vendor') // Exclude the vendor directory
24+
);

0 commit comments

Comments
 (0)