Skip to content

Commit 3baaeaa

Browse files
author
n.gnato
committed
Initial commit
0 parents  commit 3baaeaa

File tree

4 files changed

+106
-0
lines changed

4 files changed

+106
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.idea/
2+
/vendor/
3+
/composer.lock

composer.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "studservis/php-cs-fixer-ruleset",
3+
"description": "StudService shared PHP style rules for PHP-CS-Fixer",
4+
"license": "MIT",
5+
"require": {
6+
"friendsofphp/php-cs-fixer": "^3.0"
7+
},
8+
"autoload": {
9+
"files": [
10+
"./src/config_builder.php"
11+
]
12+
}
13+
}

src/config_builder.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace StudService\PhpCsFixer;
4+
5+
use PhpCsFixer\Config;
6+
use PhpCsFixer\ConfigInterface;
7+
8+
function build_config(iterable $finder, array $rules): ConfigInterface
9+
{
10+
$rules = array_merge(require __DIR__.'/rules.php', $rules);
11+
12+
return (new Config())
13+
->setFinder($finder)
14+
->setRules($rules);
15+
}

src/rules.php

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
return [
4+
'@PHP80Migration' => true,
5+
'@PHP81Migration' => true,
6+
'@PhpCsFixer' => true,
7+
'@PSR12' => true,
8+
'binary_operator_spaces' => [
9+
'operators' => [
10+
'=>' => 'align_by_scope',
11+
],
12+
],
13+
'blank_line_before_statement' => [
14+
'statements' => [
15+
'continue',
16+
'declare',
17+
'default',
18+
'return',
19+
'throw',
20+
'try',
21+
'while',
22+
],
23+
],
24+
25+
'blank_line_between_import_groups' => false,
26+
'braces' => [
27+
'allow_single_line_anonymous_class_with_empty_body' => true,
28+
'allow_single_line_closure' => true,
29+
],
30+
'concat_space' => [
31+
'spacing' => 'one',
32+
],
33+
'global_namespace_import' => [
34+
'import_constants' => false,
35+
'import_functions' => false,
36+
'import_classes' => false,
37+
],
38+
'method_chaining_indentation' => false,
39+
'no_break_comment' => false,
40+
'no_superfluous_phpdoc_tags' => true,
41+
'nullable_type_declaration_for_default_null_value' => true,
42+
'ordered_class_elements' => ['order' => [
43+
'use_trait',
44+
'case',
45+
'constant_public',
46+
'constant_protected',
47+
'constant_private',
48+
'property_public_static',
49+
'property_protected_static',
50+
'property_private_static',
51+
'property_public',
52+
'property_protected',
53+
'property_private',
54+
'construct',
55+
]],
56+
'ordered_imports' => [
57+
'imports_order' => [
58+
'class',
59+
'function',
60+
'const',
61+
],
62+
],
63+
'trailing_comma_in_multiline' => [
64+
'after_heredoc' => true,
65+
'elements' => [
66+
'arrays',
67+
'arguments',
68+
],
69+
],
70+
'yoda_style' => [
71+
'equal' => false,
72+
'identical' => false,
73+
'less_and_greater' => false,
74+
],
75+
];

0 commit comments

Comments
 (0)