Skip to content

Instantly share code, notes, and snippets.

@lcdss
Last active January 14, 2019 12:05
Show Gist options
  • Save lcdss/c3da8184369b4caced871df6129daa1d to your computer and use it in GitHub Desktop.
Save lcdss/c3da8184369b4caced871df6129daa1d to your computer and use it in GitHub Desktop.
PHP CS Fixer
<?php
$finder = \PhpCsFixer\Finder::create()
->in('app')
// ->except(['vendor', 'storage', 'bootstrap'])
->name('*.php')
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true);
return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
// '@Symfony' => true,
'@PHP70Migration' => true,
'@PHP71Migration' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'fully_qualified_strict_types' => true,
'linebreak_after_opening_tag' => true,
'list_syntax' => ['syntax' => 'short'],
'logical_operators' => true,
'method_chaining_indentation' => true,
'phpdoc_no_empty_return' => false,
'ordered_class_elements' => true,
'ordered_imports' => ['sortAlgorithm' => 'length'],
])
->setFinder($finder);
{
"scripts": {
"format": "php-cs-fixer --ansi fix"
}
}
{
"devDependencies": {
"husky": "^1.1.3",
"lint-staged": "^8.0.4"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.php": ["composer format"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment