-
Notifications
You must be signed in to change notification settings - Fork 81
/
.php-cs-fixer.php
75 lines (71 loc) · 3.02 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
/**
* @package Joomla.Site
*
* @copyright (C) 2021 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
/**
* This is the configuration file for php-cs-fixer
*
* @link https://github.com/FriendsOfPHP/PHP-CS-Fixer
* @link https://mlocati.github.io/php-cs-fixer-configurator/#version:3.0
*
*
* If you would like to run the automated clean up, then open a command line and type one of the commands below
*
* To run a quick dry run to see the files that would be modified:
*
* ./libraries/vendor/bin/php-cs-fixer fix --dry-run
*
* To run a full check, with automated fixing of each problem :
*
* ./libraries/vendor/bin/php-cs-fixer fix
*
* You can run the clean up on a single file if you need to, this is faster
*
* ./libraries/vendor/bin/php-cs-fixer fix --dry-run administrator/index.php
* ./libraries/vendor/bin/php-cs-fixer fix administrator/index.php
*/
// Add all the core Joomla folders
$finder = PhpCsFixer\Finder::create()
->in(
[
__DIR__ . '/cli',
__DIR__ . '/src',
__DIR__ . '/tests',
]
);
$config = new PhpCsFixer\Config();
$config
->setRiskyAllowed(true)
->setHideProgress(false)
->setUsingCache(false)
->setRules(
[
// Basic ruleset is PSR 12
'@PSR12' => true,
// Short array syntax
'array_syntax' => ['syntax' => 'short'],
// List of values separated by a comma is contained on a single line should not have a trailing comma like [$foo, $bar,] = ...
'no_trailing_comma_in_singleline' => true,
// Arrays on multiline should have a trailing comma
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
// Align elements in multiline array and variable declarations on new lines below each other
'binary_operator_spaces' => ['operators' => ['=>' => 'align_single_space_minimal', '=' => 'align']],
// The "No break" comment in switch statements
'no_break_comment' => ['comment_text' => 'No break'],
// Remove unused imports
'no_unused_imports' => true,
// Classes from the global namespace should not be imported
'global_namespace_import' => ['import_classes' => false, 'import_constants' => false, 'import_functions' => false],
// Alpha order imports
'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'],
// There should not be useless else cases
'no_useless_else' => true,
// Native function invocation
'native_function_invocation' => ['include' => ['@compiler_optimized']],
]
)
->setFinder($finder);
return $config;