Skip to content

Instantly share code, notes, and snippets.

@tumainimosha
Last active August 9, 2018 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tumainimosha/53029908dfb36e333425382b0ffebd03 to your computer and use it in GitHub Desktop.
Save tumainimosha/53029908dfb36e333425382b0ffebd03 to your computer and use it in GitHub Desktop.
<?php
/**
* Example .phpcs file for Laravel app
*
* Usage:
* - install php-cs-fixer to your project using composer
* `composer require friendsofphp/php-cs-fixer --dev`
* - create file name `.phpcs` in ROOT directory of your project
* and copy contents of this file into it.
* - run php-cs-fixer to format your code
* `./vendor/bin/php-cs-fixer fix .`
* - You can add a git pre-commit hook to automatically run above
* command before each commit.
*/
$finder = PhpCsFixer\Finder::create()
->exclude(['vendor', 'storage', 'bootstrap'])
->in(__DIR__)
->name('*.php')
->ignoreDotFiles(true)
->ignoreVCS(true);
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
/**
* symfony
*/
// Ensure there is no code on the same line as the PHP open tag and it is followed by a blankline.
'blank_line_after_opening_tag' => true,
// Remove duplicated semicolons.
'no_empty_statement' => true,
// PHP multi-line arrays should have a trailing comma.
'trailing_comma_in_multiline_array' => true,
// There should be no empty lines after class opening brace.
'no_blank_lines_after_class_opening' => true,
// There should not be blank lines between docblock and the documented element.
'no_blank_lines_after_phpdoc' => true,
// Phpdocs short descriptions should end in either a full stop, exclamation mark, or question mark.
'phpdoc_summary' => true,
// Phpdocs should start and end with content, excluding the very first and last line of the docblocks.
'phpdoc_trim' => true,
// Removes line breaks between use statements.
'no_extra_consecutive_blank_lines' => ['use'],
// An empty line feed should precede a return statement.
'blank_line_before_return' => true,
// There should be exactly one blank line before a namespace declaration.
'single_blank_line_before_namespace' => true,
// Convert double quotes to single quotes for simple strings.
'single_quote' => true,
// Unused use statements must be removed.
'no_unused_imports' => true,
// Methods must be separated with one blank line.
'class_attributes_separation' => true,
// Binary operators should be surrounded by at least one space.
'binary_operator_spaces' => ['align_double_arrow' => false],
// A single space should be between cast and variable.
'cast_spaces' => true,
/**
* contrib
*/
// Concatenation should be used with at least one whitespace around.
'concat_space' => ['spacing' => 'one'],
// Ordering use statements.
'ordered_imports' => true,
// PHP arrays should be declared using the configured syntax.
'array_syntax' => ['syntax' => 'short']
])
->setFinder($finder)
->setUsingCache(true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment