Skip to content

Commit 524b457

Browse files
committed
codestyle
1 parent 22d82f2 commit 524b457

File tree

4 files changed

+140
-16
lines changed

4 files changed

+140
-16
lines changed

.php-cs-fixer.dist.php

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<?php
2+
$finder = PhpCsFixer\Finder::create()
3+
->exclude('*/vendor/*')
4+
->exclude('node_modules')
5+
->in(__DIR__)
6+
->notPath('lib/system/api');
7+
8+
return (new PhpCsFixer\Config())
9+
->setRiskyAllowed(true)
10+
->setRules([
11+
'@PSR1' => true,
12+
'@PSR2' => true,
13+
'@PSR12' => true,
14+
'@PER' => true,
15+
16+
'array_push' => true,
17+
'backtick_to_shell_exec' => true,
18+
'no_alias_language_construct_call' => true,
19+
'no_mixed_echo_print' => true,
20+
'pow_to_exponentiation' => true,
21+
'random_api_migration' => true,
22+
23+
'array_syntax' => ['syntax' => 'short'],
24+
'no_multiline_whitespace_around_double_arrow' => true,
25+
'no_trailing_comma_in_singleline_array' => true,
26+
'no_whitespace_before_comma_in_array' => true,
27+
'normalize_index_brace' => true,
28+
'whitespace_after_comma_in_array' => true,
29+
30+
'non_printable_character' => ['use_escape_sequences_in_strings' => true],
31+
32+
'magic_constant_casing' => true,
33+
'magic_method_casing' => true,
34+
'native_function_casing' => true,
35+
'native_function_type_declaration_casing' => true,
36+
37+
'cast_spaces' => ['space' => 'none'],
38+
'no_unset_cast' => true,
39+
40+
'class_attributes_separation' => true,
41+
'no_null_property_initialization' => true,
42+
'self_accessor' => true,
43+
'single_class_element_per_statement' => true,
44+
45+
'no_empty_comment' => true,
46+
'single_line_comment_style' => ['comment_types' => ['hash']],
47+
48+
'native_constant_invocation' => ['strict' => false],
49+
50+
'no_alternative_syntax' => true,
51+
'no_trailing_comma_in_list_call' => true,
52+
'no_unneeded_control_parentheses' => ['statements' => ['break', 'clone', 'continue', 'echo_print', 'return', 'switch_case', 'yield', 'yield_from']],
53+
'no_unneeded_curly_braces' => ['namespaces' => true],
54+
'switch_continue_to_break' => true,
55+
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
56+
57+
'function_typehint_space' => true,
58+
'lambda_not_used_import' => true,
59+
'native_function_invocation' => ['include' => ['@internal']],
60+
'no_unreachable_default_argument_value' => true,
61+
'nullable_type_declaration_for_default_null_value' => true,
62+
'static_lambda' => true,
63+
64+
'fully_qualified_strict_types' => true,
65+
'no_unused_imports' => true,
66+
67+
'dir_constant' => true,
68+
'explicit_indirect_variable' => true,
69+
'function_to_constant' => true,
70+
'is_null' => true,
71+
'no_unset_on_property' => true,
72+
73+
'list_syntax' => ['syntax' => 'short'],
74+
75+
'clean_namespace' => true,
76+
'no_leading_namespace_whitespace' => true,
77+
78+
'no_homoglyph_names' => true,
79+
80+
'binary_operator_spaces' => true,
81+
'concat_space' => ['spacing' => 'one'],
82+
'increment_style' => ['style' => 'post'],
83+
'logical_operators' => true,
84+
'object_operator_without_whitespace' => true,
85+
'operator_linebreak' => true,
86+
'standardize_increment' => true,
87+
'standardize_not_equals' => true,
88+
'ternary_to_elvis_operator' => true,
89+
'ternary_to_null_coalescing' => true,
90+
'unary_operator_spaces' => true,
91+
92+
'no_useless_return' => true,
93+
'return_assignment' => true,
94+
95+
'multiline_whitespace_before_semicolons' => true,
96+
'no_empty_statement' => true,
97+
'no_singleline_whitespace_before_semicolons' => true,
98+
'space_after_semicolon' => ['remove_in_empty_for_expressions' => true],
99+
100+
'escape_implicit_backslashes' => true,
101+
'explicit_string_variable' => true,
102+
'heredoc_to_nowdoc' => true,
103+
'no_binary_string' => true,
104+
'simple_to_complex_string_variable' => true,
105+
106+
'array_indentation' => true,
107+
'blank_line_before_statement' => ['statements' => ['return', 'exit']],
108+
'method_chaining_indentation' => true,
109+
'no_extra_blank_lines' => ['tokens' => ['case', 'continue', 'curly_brace_block', 'default', 'extra', 'parenthesis_brace_block', 'square_brace_block', 'switch', 'throw', 'use']],
110+
'no_spaces_around_offset' => true,
111+
112+
// SoftCreatR style
113+
'global_namespace_import' => [
114+
'import_classes' => true,
115+
'import_constants' => true,
116+
'import_functions' => false,
117+
],
118+
'ordered_imports' => [
119+
'imports_order' => ['class', 'function', 'const'],
120+
],
121+
])
122+
->setFinder($finder);

.phpcs.xml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?xml version="1.0"?>
2-
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
3-
<arg name="basepath" value="."/>
4-
<arg name="cache" value=".phpcs-cache"/>
5-
<arg name="colors"/>
6-
<arg name="extensions" value="php"/>
7-
<arg name="parallel" value="10"/>
2+
<ruleset>
3+
<file>files/</file>
4+
<exclude-pattern>lib/system/api/*</exclude-pattern>
5+
<exclude-pattern>node_modules/*</exclude-pattern>
6+
<arg name="extensions" value="php" />
7+
<arg value="p"/>
8+
<arg name="basepath" value="."/>
89

9-
<!-- Show progress -->
10-
<arg value="p"/>
11-
12-
<!-- Paths to check -->
13-
<file>files</file>
14-
15-
<!-- Include all rules from the Zend Coding Standard -->
16-
<rule ref="PSR12"/>
10+
<rule ref="PSR12">
11+
<!-- https://github.com/squizlabs/PHP_CodeSniffer/issues/3200 -->
12+
<exclude name="PSR12.Classes.AnonClassDeclaration.SpaceAfterKeyword"/>
13+
14+
<!-- We have a large number of comments between the closing brace of an `if` and the `else`. -->
15+
<exclude name="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace"/>
16+
</rule>
1717
</ruleset>

constants.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<?php
22

3-
define('CRONJOB_EXECUTE', 0);
3+
\define('CRONJOB_EXECUTE', 0);

files/lib/system/event/listener/CronjobDisableExecutionListener.class.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use wcf\system\WCF;
66

7+
use const CRONJOB_EXECUTE;
8+
79
/**
810
* disables automatic cronjob execution via page call
911
*
@@ -17,7 +19,7 @@ class CronjobDisableExecutionListener extends AbstractEventListener
1719
{
1820
public function onAssignVariables(): void
1921
{
20-
if (\CRONJOB_EXECUTE) {
22+
if (CRONJOB_EXECUTE) {
2123
return;
2224
}
2325

0 commit comments

Comments
 (0)