Skip to content

Commit 647f7f5

Browse files
committed
feat(codestyle): added phpcs to php tooling, added and applied new PER coding style, tweaked php-cs-fixer configuration accordingly
1 parent 0082ad8 commit 647f7f5

File tree

406 files changed

+5758
-4061
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

406 files changed

+5758
-4061
lines changed

.editorconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ insert_final_newline = false
1717
[*.{yml,yaml,json}]
1818
indent_size = 2
1919

20+
[*.{xml,xsd}]
21+
max_line_length=off
22+
indent_size=2
23+
tab_width=2
24+
2025
[composer.json]
2126
indent_size = 4
2227

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ Dockerfile.override
1313
ext
1414
!ext/.gitignore
1515
.env
16+
/.phpcs-cache

.php-cs-fixer.dist.php

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
$finder = PhpCsFixer\Finder::create()
66
->in([__DIR__])
77
->exclude([
8+
'.php-cs-fixer.dist.php',
89
'tests/Fixtures/Symfony/app/var',
910
'tests/Unit/Server/Php8',
1011
'vendor',
11-
'hack',
1212
'ext',
1313
]);
1414

@@ -17,27 +17,48 @@
1717
* @see https://github.com/FriendsOfPHP/PHP-CS-Fixer for rules
1818
*/
1919
return $config->setRules([
20-
'@Symfony' => true,
20+
'@PER-CS2.0' => true,
2121
'@PHP81Migration' => true,
22+
'array_indentation' => true,
2223
'array_syntax' => ['syntax' => 'short'],
24+
'blank_line_before_statement' => true,
25+
'braces_position' => ['classes_opening_brace' => 'next_line_unless_newline_at_signature_end'],
26+
'class_reference_name_casing' => false,
2327
'combine_consecutive_issets' => true,
2428
'combine_consecutive_unsets' => true,
2529
'compact_nullable_type_declaration' => true,
30+
'global_namespace_import' => [
31+
'import_classes' => true,
32+
],
2633
'linebreak_after_opening_tag' => true,
2734
'list_syntax' => ['syntax' => 'short'],
35+
'multiline_whitespace_before_semicolons' => ['strategy' => 'no_multi_line'],
36+
'native_constant_invocation' => [
37+
'fix_built_in' => false,
38+
'scope' => 'all',
39+
],
40+
'native_function_invocation' => [
41+
'include' => [],
42+
'exclude' => ['@all'],
43+
],
44+
'no_blank_lines_after_class_opening' => true,
2845
'no_null_property_initialization' => true,
29-
'nullable_type_declaration_for_default_null_value' => false,
3046
'no_useless_else' => true,
3147
'no_useless_return' => true,
32-
'ordered_imports' => ['sort_algorithm' => 'alpha'],
33-
'phpdoc_order' => true,
34-
'phpdoc_types_order' => true,
48+
'nullable_type_declaration_for_default_null_value' => false,
3549
'ordered_class_elements' => true,
36-
'array_indentation' => true,
37-
'multiline_whitespace_before_semicolons' => ['strategy' => 'new_line_for_chained_calls'],
38-
'no_blank_lines_after_class_opening' => true,
39-
'blank_line_before_statement' => true,
40-
'class_reference_name_casing' => false,
50+
'ordered_imports' => ['sort_algorithm' => 'alpha', 'imports_order' => ['class', 'function', 'const']],
51+
'phpdoc_order' => [
52+
'order' => ['param', 'return', 'throws'],
53+
],
54+
'phpdoc_types_order' => [
55+
'null_adjustment' => 'always_last',
56+
],
57+
'yoda_style' => [
58+
'equal' => false,
59+
'identical' => false,
60+
'less_and_greater' => false,
61+
],
4162
])
42-
->setRiskyAllowed(false)
63+
->setRiskyAllowed(true)
4364
->setFinder($finder);

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
"phpunit/phpunit": "^10.5",
7171
"pixelfederation/doctrine-resettable-em-bundle": "^7.0|^8.0",
7272
"ramsey/uuid": "^4.7",
73+
"slevomat/coding-standard": "^8.14",
74+
"squizlabs/php_codesniffer": "^3.8",
7375
"swoole-bundle/z-engine": "^8.1.1|^8.2.1|^8.3.0",
7476
"swoole/ide-helper": "^5.1.0",
7577
"symfony/debug-bundle": "^5.4.26|^6.4|^7.0",
@@ -182,7 +184,8 @@
182184
"allow-plugins": {
183185
"phpstan/extension-installer": true,
184186
"phpro/grumphp": false,
185-
"symfony/flex": true
187+
"symfony/flex": true,
188+
"dealerdirect/phpcodesniffer-composer-installer": false
186189
}
187190
}
188191
}

composer.lock

Lines changed: 224 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

grumphp.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ grumphp:
66
complete:
77
tasks:
88
- phpcsfixer
9+
- phpcs
910
- phpstan_src
1011
- phpstan_tests
1112
- phpunit_unit
@@ -15,6 +16,13 @@ grumphp:
1516
- phpunit_unit
1617
- phpunit_feature
1718
tasks:
19+
phpcs:
20+
standard: 'phpcs.xml'
21+
tab_width: 4
22+
whitelist_patterns: [ ]
23+
encoding: utf-8
24+
sniffs: [ ]
25+
triggered_by: [ php ]
1826
phpcsfixer:
1927
cache_file: '.php-cs-fixer.cache'
2028
allow_risky: true

0 commit comments

Comments
 (0)