Skip to content

Commit

Permalink
Merge pull request #193 from 5pm-HDH/php-cs-fixer
Browse files Browse the repository at this point in the history
PHP CS Fixer
  • Loading branch information
DumbergerL authored Jan 9, 2024
2 parents 165be32 + 46e98ed commit 0363586
Show file tree
Hide file tree
Showing 283 changed files with 2,227 additions and 1,064 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/php-coding-standards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: PHP coding standards

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Setup PHP8.1
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'

- uses: actions/checkout@v2

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress

- name: Composer dump-autoload to load all files
run: composer dump-autoload

- name: Run codefixer
run: composer run-script php-cs-fixer

- name: Check if code are already generated
uses: tj-actions/verify-changed-files@v8.8
id: verify-changed-files
with:
files: |
src
tests
- name: Run step only when files change.
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |
core.setFailed('Inconsistent coding standards. Please run `composer run-script php-cs-fixer` locally and commit style.')
10 changes: 10 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

$finder = (new PhpCsFixer\Finder())
->in([__DIR__ . '/src', __DIR__ . '/tests']);

return (new PhpCsFixer\Config())
->setRules([
'@PSR12' => true,
])
->setFinder($finder);
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added
- Retrieve, create and delete SongArrangement comments ([PR187](https://github.com/5pm-HDH/churchtools-api/pull/187))
- Get GroupTypes ([PR188](https://github.com/5pm-HDH/churchtools-api/pull/188))
- PHP coding standard ([PR193](https://github.com/5pm-HDH/churchtools-api/pull/193))

### Changed

Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
},
"require-dev": {
"phpunit/phpunit": "9.5.5",
"phpstan/phpstan": "^1.10"
"phpstan/phpstan": "^1.10",
"friendsofphp/php-cs-fixer": "^3.46"
},
"license": "MIT",
"authors": [
Expand All @@ -37,6 +38,7 @@
"test-coverage-w": "vendor\\bin\\phpunit.bat --coverage-html .phpunit.cache/coverage-report",
"phpstan": "./vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 1G",
"phpstan-w": "vendor\\bin\\phpstan.bat analyse -c phpstan.neon --memory-limit 1G",
"php-cs-fixer": "vendor/bin/php-cs-fixer fix",
"docs-generator": "php docs/src/DocGenerator.php"
}
}
Loading

0 comments on commit 0363586

Please sign in to comment.