-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathphp-cs-fixer.php
More file actions
88 lines (76 loc) · 2.53 KB
/
php-cs-fixer.php
File metadata and controls
88 lines (76 loc) · 2.53 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/**
* This file is part of the contentful/contentful-management package.
*
* @copyright 2015-2026 Contentful GmbH
* @license MIT
*/
declare(strict_types=1);
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
return static function (string $packageName, bool $usePhp7, array $directories, array $exclude = []): Config {
$year = \date('Y');
$fileHeaderComment = <<<COMMENT
This file is part of the contentful/$packageName package.
@copyright 2015-$year Contentful GmbH
@license MIT
COMMENT;
$finder = Finder::create();
foreach ($directories as $directory) {
$finder = $finder->in($directory);
}
foreach ($exclude as $path) {
$finder = $finder->notPath($path);
}
$rules = [
'@Symfony' => true,
'@Symfony:risky' => true,
'@PHP80Migration' => true,
'array_syntax' => [
'syntax' => 'short',
],
'header_comment' => [
'comment_type' => 'PHPDoc',
'header' => $fileHeaderComment,
'location' => 'after_open',
'separate' => 'both',
],
'linebreak_after_opening_tag' => true,
'logical_operators' => true,
'mb_str_functions' => true,
'method_chaining_indentation' => true,
'multiline_whitespace_before_semicolons' => [
'strategy' => 'new_line_for_chained_calls',
],
'multiline_comment_opening_closing' => true,
'native_constant_invocation' => [
'exclude' => ['null', 'false', 'true'],
],
'native_function_invocation' => false,
'no_php4_constructor' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_imports' => true,
'php_unit_construct' => true,
'php_unit_dedicate_assert' => true,
'php_unit_strict' => true,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_order' => true,
'semicolon_after_instruction' => true,
'strict_comparison' => true,
'strict_param' => true,
];
if ($usePhp7) {
$rules['declare_strict_types'] = true;
$rules['ternary_to_null_coalescing'] = true;
$rules['assign_null_coalescing_to_coalesce_equal'] = false;
}
$cache = \tempnam(\sys_get_temp_dir(), $packageName).'-php_cs.cache';
return (new Config())
->setFinder($finder)
->setRiskyAllowed(true)
->setCacheFile($cache)
->setRules($rules)
;
};