Merge branch 'develop' of https://github.com/friendica/friendica into develop
[friendica.git/.git] / .php-cs-fixer.dist.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2024, the Friendica project
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  */
20
21 declare(strict_types=1);
22
23 $finder = PhpCsFixer\Finder::create()
24         ->in(__DIR__)
25         ->notPath('addon')
26         ->notPath('bin/dev')
27         ->notPath('config')
28         ->notPath('doc')
29         ->notPath('images')
30         ->notPath('mods')
31         ->notPath('spec')
32         ->notPath('vendor')
33         ->notPath('view/asset')
34         ->notPath('lang')
35         ->notPath('view/smarty3/compiled');
36
37 $config = new PhpCsFixer\Config();
38 return $config
39         ->setRules([
40                 '@PSR1'                   => true,
41                 '@PSR2'                   => true,
42                 '@PSR12'                  => true,
43                 'align_multiline_comment' => true,
44                 'array_indentation'       => true,
45                 'array_syntax'            => [
46                         'syntax' => 'short',
47                 ],
48                 'binary_operator_spaces' => [
49                         'default'   => 'single_space',
50                         'operators' => [
51                                 '=>' => 'align_single_space_minimal',
52                                 '='  => 'align_single_space_minimal',
53                                 '??' => 'align_single_space_minimal',
54                         ],
55                 ],
56                 'blank_line_after_namespace'   => true,
57                 'braces'                       => [
58                         'position_after_anonymous_constructs'         => 'same',
59                         'position_after_control_structures'           => 'same',
60                         'position_after_functions_and_oop_constructs' => 'next',
61                 ],
62                 'elseif'               => true,
63                 'encoding'             => true,
64                 'full_opening_tag'     => true,
65                 'function_declaration' => [
66                         'closure_function_spacing' => 'one',
67                 ],
68                 'indentation_type' => true,
69                 'line_ending'      => true,
70                 'list_syntax'      => [
71                         'syntax' => 'long',
72                 ],
73                 'lowercase_keywords'                 => true,
74                 'method_argument_space'              => [],
75                 'no_closing_tag'                     => true,
76                 'no_spaces_after_function_name'      => true,
77                 'no_spaces_inside_parenthesis'       => true,
78                 'no_trailing_whitespace'             => true,
79                 'no_trailing_whitespace_in_comment'  => true,
80                 'no_unused_imports'                  => true,
81                 'single_blank_line_at_eof'           => true,
82                 'single_class_element_per_statement' => true,
83                 'single_import_per_statement'        => true,
84                 'single_line_after_imports'          => true,
85                 'switch_case_space'                  => true,
86                 'ternary_operator_spaces'            => false,
87                 'visibility_required'                => [
88                         'elements' => ['property', 'method']
89                 ],
90                 'new_with_braces' => true,
91         ])
92         ->setFinder($finder)
93         ->setIndent("\t");