49
loading...
This website collects cookies to deliver better user experience
#!/usr/bin/env bash
CSFIX="php-cs-fixer"
if [ ! -f "$CSFIX" ]; then
if ! type "php-cs-fixer" > /dev/null; then
clear
echo "☠️ You need PHP CS Fixer to run this command."
return
fi
fi
$CSFIX fix
if [[ `git status --porcelain` ]]; then
git add .
git commit -m "Apply PHP CS Fixer"
MESSAGE="🎉 Successfully complied with PSR-2"
else
MESSAGE="🎉 You already complied with PSR-2"
fi
echo $MESSAGE
chmod +x csfix
, then you can run on your current project.. ./csfix
scripts
section in your composer.json
file, add the following:{
"scripts": {
"csfix": [
"PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix",
"git add . && git commit -m '🎨 Apply PHP CS Fixer'"
]
}
}
PHP_CS_FIXER_IGNORE_ENV=1
if you are running on PHP8.1. At the moment, still unable to run PHP CS Fixer on PHP8.1.composer csfix
> PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix
PHP needs to be a minimum version of PHP 7.2.5 and maximum version of PHP 8.0.*.
Current PHP version: 8.1.0.
Ignoring environment requirements because `PHP_CS_FIXER_IGNORE_ENV` is set. Execution may be unstable.
Loaded config default from "/Users/nasrulhazim/Projects/2021/demo/.php-cs-fixer.php".
Using cache file ".php-cs-fixer.cache".
1) database/seeders/Mock/DemoSeeder.php
Fixed all files in 0.021 seconds, 18.000 MB memory used
> git add . && git commit -m '🎨 Apply PHP CS Fixer'
[develop 254c4d7] 🎨 Apply PHP CS Fixer
1 file changed, 1 insertion(+), 1 deletion(-)
composer csfix
.name: Check & fix styling
on: [push]
jobs:
php-cs-fixer:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Run PHP CS Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --config=.php_cs.dist.php --allow-risky=yes
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Fix styling