Skip to content

Commit

Permalink
addded php-cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
sreichel committed Jan 13, 2025
1 parent a20c2f2 commit 60ec8a9
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
34 changes: 34 additions & 0 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: PHP-CS-Fixer

on: [push, pull_request]

jobs:
php-cs-fixer:
name: Validation
runs-on: [ubuntu-latest]

steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4

- name: Checkout code
uses: actions/checkout@v4

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-*

- name: PHP-CS-Fixer
run: php bin/php-cs-fixer fix --diff --dry-run
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
/.idea
/vendor
.php-cs-fixer.cache
composer.lock
22 changes: 22 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

$config = new PhpCsFixer\Config();
return $config
->setRiskyAllowed(true)
->setRules([
'@PER-CS2.0' => true,
'logical_operators' => true,
'modernize_types_casting' => true,
'nullable_type_declaration_for_default_null_value' => true,
'single_quote' => true,
'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['arguments', 'array_destructuring', 'arrays']],
])
->setFinder(
PhpCsFixer\Finder::create()
->in([
__DIR__ . '/src',
])
->name('*.php')
->ignoreDotFiles(true)
->ignoreVCS(true)
);
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"symfony/finder": "*"
},
"require-dev": {
"composer/composer": "^2.7"
"composer/composer": "^2.7",
"friendsofphp/php-cs-fixer": "^3.67"
},
"extra": {
"class": "OpenMage\\ComposerPlugin\\Plugin"
Expand Down

0 comments on commit 60ec8a9

Please sign in to comment.