-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphp-cs-fixer.php
75 lines (68 loc) · 2.24 KB
/
php-cs-fixer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
declare(strict_types=1);
/**
* Derafu: Foundation - Base for Derafu's Projects.
*
* Copyright (c) 2025 Esteban De La Fuente Rubio / Derafu <https://www.derafu.org>
* Licensed under the MIT License.
* See LICENSE file for more details.
*/
/**
* Configuration file for PHP CS Fixer.
*/
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$dir = __DIR__;
$finder = Finder::create()
->in($dir)
->exclude('var')
;
return (new Config())
// Allow risky rules that may change code logic.
->setRiskyAllowed(true)
// Based on PSR-12, the latest style recommendation.
->setRules([
'@PSR12' => true,
// Add "declare(strict_types=1);" to files.
// This adds it like <?php declare(strict_types=1); however, it is
// recommended to edit or add it manually on separate lines.
'declare_strict_types' => true,
// Indent using spaces.
'indentation_type' => true,
// Sort "use" statements alphabetically.
'ordered_imports' => [
'sort_algorithm' => 'alpha',
],
// Remove unused imports.
'no_unused_imports' => true,
// One import per statement.
'single_import_per_statement' => true,
// Convert arrays to short syntax "[]".
'array_syntax' => [
'syntax' => 'short',
],
// Add trailing commas in multi-line arrays.
'trailing_comma_in_multiline' => true,
// Separate constants and properties.
'class_attributes_separation' => [
'elements' => [
'const' => 'one',
'property' => 'one',
'method' => 'one',
],
],
// Replace strpos with a boolean-returning function.
// Example: use str_contains().
'modernize_strpos' => true,
// Convert anonymous functions to arrow functions.
'use_arrow_functions' => true,
// Use PHPUnit constructors instead of factory methods.
'php_unit_construct' => true,
// Use stricter assertions in PHPUnit.
// Example: use assertSame() instead of assertEquals().
'php_unit_strict' => true,
])
->setLineEnding("\n")
->setCacheFile($dir . '/var/cache/php-cs-fixer.cache')
->setFinder($finder)
;