Skip to content

Commit

Permalink
ci(hooks): add phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
joelbeckmann committed Jan 21, 2025
1 parent 507e55e commit 2ae6b35
Showing 1 changed file with 9 additions and 26 deletions.
35 changes: 9 additions & 26 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -57,32 +57,15 @@ yarn markdownlint-cli2 '**/*.md' '#node_modules' '#vendor' '#tools' '#CHANGELOG.
echo ""
echo "Lint PHP Files..."

PHP_CS_FIXER="vendor/bin/php-cs-fixer"
HAS_PHP_CS_FIXER=false

if [ -x $PHP_CS_FIXER ]; then
HAS_PHP_CS_FIXER=true
fi

if $HAS_PHP_CS_FIXER; then
FILES=` git status --porcelain | grep -e '^[AM]\(.*\).php$' | cut -c 3- | tr '\n' ' '`
if [ -z "$FILES" ]
then
echo "No php files found in commit."
else
echo ${FILES}
$PHP_CS_FIXER fix --config .php-cs-fixer.dist.php --verbose ${FILES} --diff
git add ${FILES}
fi
else
echo ""
echo "Please install php-cs-fixer with"
echo ""
echo " composer install"
echo "or"
echo " composer require friendsofphp/php-cs-fixer"
echo ""
exit 1
FILES=` git status --porcelain | grep -e '^[AM]\(.*\).php$' | cut -c 3- | sed 's/config\/bundles.php//' | xargs`
if [ -z "$FILES" ]
then
echo "No php files found in commit."
else
echo ${FILES}
vendor/bin/phpstan analyse --configuration=phpstan.dist.neon ${FILES}
vendor/bin/php-cs-fixer fix --config .php-cs-fixer.dist.php --verbose ${FILES} --diff
git add ${FILES}
fi

echo ""

0 comments on commit 2ae6b35

Please sign in to comment.