Skip to content

Commit 4bb9e2b

Browse files
committed
Updating Drone setup to use PSR-12
1 parent 91eb17b commit 4bb9e2b

File tree

5 files changed

+541
-526
lines changed

5 files changed

+541
-526
lines changed

.drone.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ steps:
1919
failure: ignore
2020
commands:
2121
- echo $(date)
22-
- ./vendor/bin/phpcs --config-set installed_paths vendor/joomla/coding-standards
22+
- ./vendor/bin/php-cs-fixer fix -vvv --dry-run --diff
2323
- ./vendor/bin/phpcs --extensions=php -p --standard=ruleset.xml .
2424
- echo $(date)
2525

@@ -77,6 +77,6 @@ volumes:
7777

7878
---
7979
kind: signature
80-
hmac: 68a338fe9dd102f1d86b2437c48b8cdf14a113efe5624ac1814f7da6dae3fd91
80+
hmac: 59007ec8408b9665b23c6160cac1b13045cbecd68c8305d7d7ea97b6ea2332b2
8181

8282
...

.php-cs-fixer.php

+75-97
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,75 @@
1-
<?php
2-
3-
$mainFinder = PhpCsFixer\Finder::create()
4-
->in(
5-
[
6-
__DIR__ . '/cli',
7-
__DIR__ . '/src',
8-
__DIR__ . '/tests',
9-
]
10-
);
11-
12-
return (new PhpCsFixer\Config)
13-
->setRules(
14-
[
15-
// psr-1
16-
'encoding' => true,
17-
'full_opening_tag' => true,
18-
// psr-2
19-
'blank_line_after_namespace' => true,
20-
'braces' => [
21-
'allow_single_line_closure' => false,
22-
'position_after_anonymous_constructs' => 'next',
23-
'position_after_control_structures' => 'next',
24-
'position_after_functions_and_oop_constructs' => 'next',
25-
],
26-
'elseif' => true,
27-
'function_declaration' => true,
28-
'line_ending' => true,
29-
'constant_case' => true,
30-
'lowercase_keywords' => true,
31-
'method_argument_space' => true,
32-
'no_spaces_after_function_name' => true,
33-
'no_spaces_inside_parenthesis' => true,
34-
'no_trailing_whitespace' => true,
35-
'ordered_imports' => true,
36-
'single_blank_line_at_eof' => true,
37-
'single_import_per_statement' => true,
38-
'single_line_after_imports' => true,
39-
'switch_case_semicolon_to_colon' => true,
40-
'visibility_required' => true,
41-
// symfony
42-
'binary_operator_spaces' => ['operators' => ['=>' => 'align', '=' => 'align']],
43-
'blank_line_before_statement' => [
44-
'statements' => [
45-
'break', 'case', 'continue', 'declare', 'for', 'foreach', 'if', 'return', 'switch', 'throw', 'try',
46-
],
47-
],
48-
'cast_spaces' => true,
49-
'concat_space' => ['spacing' => 'one'],
50-
'dir_constant' => true,
51-
'function_to_constant' => true,
52-
'function_typehint_space' => true,
53-
'include' => true,
54-
'increment_style' => ['style' => 'post'],
55-
'is_null' => true,
56-
'lowercase_static_reference' => true,
57-
'magic_constant_casing' => true,
58-
'modernize_types_casting' => true,
59-
'native_function_casing' => true,
60-
'no_alias_functions' => true,
61-
'no_blank_lines_after_class_opening' => true,
62-
'no_blank_lines_after_phpdoc' => true,
63-
'no_empty_statement' => true,
64-
'no_extra_blank_lines' => true,
65-
'no_trailing_comma_in_list_call' => true,
66-
'no_trailing_comma_in_singleline_array' => true,
67-
'no_unneeded_control_parentheses' => true,
68-
'no_unused_imports' => true,
69-
'no_whitespace_before_comma_in_array' => true,
70-
'no_whitespace_in_blank_line' => true,
71-
'phpdoc_trim' => true,
72-
'return_type_declaration' => true,
73-
'self_accessor' => true,
74-
'simplified_null_return' => true,
75-
'single_blank_line_before_namespace' => true,
76-
'single_quote' => true,
77-
'trailing_comma_in_multiline' => true,
78-
'whitespace_after_comma_in_array' => true,
79-
'yoda_style' => ['equal' => false, 'identical' => false],
80-
// misc
81-
'array_indentation' => true,
82-
'array_syntax' => ['syntax' => 'short'],
83-
'combine_consecutive_issets' => true,
84-
'combine_consecutive_unsets' => true,
85-
'linebreak_after_opening_tag' => true,
86-
'logical_operators' => true,
87-
'native_function_invocation' => ['include' => ['@compiler_optimized']],
88-
'no_null_property_initialization' => true,
89-
'no_superfluous_elseif' => true,
90-
'no_useless_else' => true,
91-
'no_useless_return' => true,
92-
'ternary_to_null_coalescing' => true,
93-
]
94-
)
95-
->setRiskyAllowed(true)
96-
->setIndent("\t")
97-
->setFinder($mainFinder);
1+
<?php
2+
/**
3+
* @package Joomla.Site
4+
*
5+
* @copyright (C) 2021 Open Source Matters, Inc. <https://www.joomla.org>
6+
* @license GNU General Public License version 2 or later; see LICENSE.txt
7+
*/
8+
9+
/**
10+
* This is the configuration file for php-cs-fixer
11+
*
12+
* @link https://github.com/FriendsOfPHP/PHP-CS-Fixer
13+
* @link https://mlocati.github.io/php-cs-fixer-configurator/#version:3.0
14+
*
15+
*
16+
* If you would like to run the automated clean up, then open a command line and type one of the commands below
17+
*
18+
* To run a quick dry run to see the files that would be modified:
19+
*
20+
* ./libraries/vendor/bin/php-cs-fixer fix --dry-run
21+
*
22+
* To run a full check, with automated fixing of each problem :
23+
*
24+
* ./libraries/vendor/bin/php-cs-fixer fix
25+
*
26+
* You can run the clean up on a single file if you need to, this is faster
27+
*
28+
* ./libraries/vendor/bin/php-cs-fixer fix --dry-run administrator/index.php
29+
* ./libraries/vendor/bin/php-cs-fixer fix administrator/index.php
30+
*/
31+
32+
// Add all the core Joomla folders
33+
$finder = PhpCsFixer\Finder::create()
34+
->in(
35+
[
36+
__DIR__ . '/cli',
37+
__DIR__ . '/src',
38+
__DIR__ . '/tests',
39+
]
40+
);
41+
42+
$config = new PhpCsFixer\Config();
43+
$config
44+
->setRiskyAllowed(true)
45+
->setHideProgress(false)
46+
->setUsingCache(false)
47+
->setRules(
48+
[
49+
// Basic ruleset is PSR 12
50+
'@PSR12' => true,
51+
// Short array syntax
52+
'array_syntax' => ['syntax' => 'short'],
53+
// List of values separated by a comma is contained on a single line should not have a trailing comma like [$foo, $bar,] = ...
54+
'no_trailing_comma_in_singleline' => true,
55+
// Arrays on multiline should have a trailing comma
56+
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
57+
// Align elements in multiline array and variable declarations on new lines below each other
58+
'binary_operator_spaces' => ['operators' => ['=>' => 'align_single_space_minimal', '=' => 'align']],
59+
// The "No break" comment in switch statements
60+
'no_break_comment' => ['comment_text' => 'No break'],
61+
// Remove unused imports
62+
'no_unused_imports' => true,
63+
// Classes from the global namespace should not be imported
64+
'global_namespace_import' => ['import_classes' => false, 'import_constants' => false, 'import_functions' => false],
65+
// Alpha order imports
66+
'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'],
67+
// There should not be useless else cases
68+
'no_useless_else' => true,
69+
// Native function invocation
70+
'native_function_invocation' => ['include' => ['@compiler_optimized']],
71+
]
72+
)
73+
->setFinder($finder);
74+
75+
return $config;

composer.json

+7-5
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,14 @@
4444
"laminas/laminas-diactoros": "^2.24"
4545
},
4646
"require-dev": {
47-
"friendsofphp/php-cs-fixer": "^3.0.2",
48-
"joomla/coding-standards": "2.0-rc4",
47+
"friendsofphp/php-cs-fixer": "^3.51.0",
48+
"squizlabs/php_codesniffer": "^3.9.0",
49+
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.2",
4950
"phpunit/phpunit": "^9.6.11",
50-
"squizlabs/php_codesniffer": "^2.9.2",
5151
"phpstan/extension-installer": "^1.2",
5252
"phpstan/phpstan": "1.10.63",
53-
"phpstan/phpstan-phpunit": "1.3.16"
53+
"phpstan/phpstan-phpunit": "1.3.16",
54+
"phpstan/phpstan-deprecation-rules": "^1.1"
5455
},
5556
"replace": {
5657
"paragonie/random_compat": "*",
@@ -75,7 +76,8 @@
7576
"php": "8.1.24"
7677
},
7778
"allow-plugins": {
78-
"phpstan/extension-installer": true
79+
"phpstan/extension-installer": true,
80+
"dealerdirect/phpcodesniffer-composer-installer": true
7981
}
8082
}
8183
}

0 commit comments

Comments
 (0)