Skip to content

Commit

Permalink
feat: add php-cs-fixer and git hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
gaelreyrol committed Jul 22, 2019
1 parent 5a01751 commit 1689a16
Show file tree
Hide file tree
Showing 15 changed files with 1,686 additions and 338 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ composer.phar
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock
tests/Credentials.php
report
coverage
.php_cs.cache
23 changes: 23 additions & 0 deletions .php_cs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

$finder = \PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude([
'bootstrap',
'storage',
'vendor'
])
->name('*.php')
->notName('*.blade.php')
->notName('_ide_helper*.php')
->ignoreDotFiles(true)
->ignoreVCS(true);

return \PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
'no_unused_imports' => true,
])
->setFinder($finder);
16 changes: 13 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,20 @@
"php": "^7.0"
},
"require-dev": {
"phpunit/phpunit": "^7.5",
"nesbot/carbon": "^2.10"
"phpunit/phpunit": "^8.2",
"nesbot/carbon": "^2.20",
"friendsofphp/php-cs-fixer": "^2.15",
"brainmaestro/composer-git-hooks": "^2.7"
},
"scripts": {
"test": "vendor/bin/phpunit"
"test": "@php vendor/bin/phpunit",
"coverage": "@php vendor/bin/phpunit --coverage-html coverage",
"format": "@php vendor/bin/php-cs-fixer fix --config .php_cs.php"
},
"extra": {
"hooks": {
"pre-commit": "composer format",
"pre-push": "composer format"
}
}
}
Loading

0 comments on commit 1689a16

Please sign in to comment.