50 lines
2.4 KiB
PHP
50 lines
2.4 KiB
PHP
|
<?php
|
||
|
|
||
|
$finder = PhpCsFixer\Finder::create()
|
||
|
->in(__DIR__)
|
||
|
->name('*.php')
|
||
|
->notName('*.blade.php')
|
||
|
->exclude('vendor')
|
||
|
->exclude('storage');
|
||
|
|
||
|
return (new PhpCsFixer\Config())
|
||
|
->setRiskyAllowed(false) // Equivalent to "php-cs-fixer.allowRisky": false
|
||
|
->setIndent(" ") // Use four spaces for indentation
|
||
|
->setLineEnding("\n") // Ensure line endings are consistent
|
||
|
->setRules([
|
||
|
'@PSR12' => true, // Apply PSR-12 standard
|
||
|
'blank_line_after_namespace' => true, // Ensure there is a blank line after namespace declarations
|
||
|
'blank_line_after_opening_tag' => true, // Ensure there is a blank line after the opening PHP tag
|
||
|
'blank_line_before_statement' => [
|
||
|
'statements' => ['return'], // Ensure a blank line before return statements
|
||
|
],
|
||
|
'no_extra_blank_lines' => [
|
||
|
'tokens' => [
|
||
|
'curly_brace_block',
|
||
|
'extra',
|
||
|
'parenthesis_brace_block',
|
||
|
'square_brace_block',
|
||
|
'throw',
|
||
|
'use',
|
||
|
],
|
||
|
], // Remove extra blank lines
|
||
|
'no_whitespace_in_blank_line' => true, // Remove whitespace in blank lines
|
||
|
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'], // Ensure consistent method argument spacing
|
||
|
'trim_array_spaces' => true, // Remove spaces around array elements
|
||
|
'binary_operator_spaces' => ['default' => 'align'], // Align binary operators
|
||
|
'no_trailing_whitespace' => true, // Remove trailing whitespace
|
||
|
'no_trailing_whitespace_in_comment' => true, // Remove trailing whitespace in comments
|
||
|
'whitespace_after_comma_in_array' => true, // Ensure there is space after commas in arrays
|
||
|
'single_blank_line_at_eof' => true, // Ensure there is a single blank line at the end of the file
|
||
|
'single_class_element_per_statement' => ['elements' => ['property']], // Ensure single class element per statement
|
||
|
'class_attributes_separation' => [
|
||
|
'elements' => [
|
||
|
'method' => 'one', // Ensure one blank line between methods
|
||
|
'property' => 'one', // Ensure one blank line between properties
|
||
|
],
|
||
|
],
|
||
|
'space_after_semicolon' => ['remove_in_empty_for_expressions' => true], // Handle space after semicolons
|
||
|
'no_unused_imports' => true, // Remove unused use statements
|
||
|
])
|
||
|
->setFinder($finder);
|