Skip to content

Commit 83d3dc2

Browse files
committed
Code Style
1 parent 9ed3d96 commit 83d3dc2

File tree

2 files changed

+161
-96
lines changed

2 files changed

+161
-96
lines changed

.php_cs.dist

Lines changed: 149 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,153 @@
11
<?php
2-
3-
$finder = PhpCsFixer\Finder::create()
4-
->in(__DIR__.'\src')
5-
->in(__DIR__.'\tests')
6-
;
7-
2+
/*
3+
* This document has been generated with
4+
* https://mlocati.github.io/php-cs-fixer-configurator/#version:2.17.5|configurator
5+
* you can change this configuration by importing this file.
6+
*/
87
return PhpCsFixer\Config::create()
9-
->setIndent("\t")
10-
->setLineEnding("\r\n")
11-
->setRules([
12-
'array_syntax' => ['syntax' => 'short'],
13-
'blank_line_after_namespace' => true,
14-
'blank_line_after_opening_tag' => true,
15-
'blank_line_before_statement' => ['statements' => ['break', 'case', 'continue', 'declare', 'default', 'die', 'do', 'exit', 'for', 'foreach', 'goto', 'if', 'return', 'switch', 'throw', 'try', 'while', 'yield']],
16-
'combine_consecutive_issets' => true,
17-
'combine_consecutive_unsets' => true,
18-
'concat_space' => ['spacing' => 'one'],
19-
'declare_equal_normalize' => ['space' => 'single'],
20-
'dir_constant' => true,
21-
'elseif' => true,
22-
'ereg_to_preg' => true,
23-
'explicit_indirect_variable' => true,
24-
'explicit_string_variable' => true,
25-
'full_opening_tag' => true,
26-
'function_typehint_space' => true,
27-
'is_null' => true,
28-
'linebreak_after_opening_tag' => true,
29-
'list_syntax' => ['syntax' => 'short'],
30-
'logical_operators' => true,
31-
'lowercase_cast' => true,
32-
'lowercase_constants' => true,
33-
'lowercase_keywords' => true,
34-
'lowercase_static_reference' => true,
35-
'magic_constant_casing' => true,
36-
'magic_method_casing' => true,
37-
'method_chaining_indentation' => true,
38-
'modernize_types_casting' => true,
39-
'native_function_casing' => true,
40-
'native_function_invocation' => [],
41-
'new_with_braces' => true,
42-
'no_alias_functions' => ['sets' => ['@all']],
43-
'no_alternative_syntax' => true,
44-
'no_blank_lines_after_phpdoc' => true,
45-
'no_break_comment' => ['comment_text' => 'Intentionally fall through'],
46-
'no_closing_tag' => true,
47-
'no_empty_comment' => true,
48-
'no_empty_statement' => true,
49-
'no_leading_namespace_whitespace' => true,
50-
'no_spaces_inside_parenthesis' => true,
51-
'no_superfluous_phpdoc_tags' => true,
52-
'no_trailing_whitespace' => true,
53-
'no_trailing_whitespace_in_comment' => true,
54-
'no_unneeded_control_parentheses' => true,
55-
'no_unneeded_final_method' => true,
56-
'no_unreachable_default_argument_value' => true,
57-
'no_unset_cast' => true,
58-
'no_useless_return' => true,
59-
'no_whitespace_before_comma_in_array' => true,
60-
'no_whitespace_in_blank_line' => true,
61-
'non_printable_character' => ['use_escape_sequences_in_strings' => true],
62-
'normalize_index_brace' => true,
63-
'not_operator_with_successor_space' => true,
64-
'ordered_class_elements' => ['sortAlgorithm' => 'alpha',],
65-
'protected_to_private' => true,
66-
'psr0' => true,
67-
'return_type_declaration' => ['space_before' => 'one',],
68-
'semicolon_after_instruction' => true,
69-
'set_type_to_cast' => true,
70-
'short_scalar_cast' => true,
71-
'simple_to_complex_string_variable' => true,
72-
'simplified_null_return' => true,
73-
'single_blank_line_at_eof' => true,
74-
'single_blank_line_before_namespace' => true,
75-
'single_import_per_statement' => true,
76-
'single_line_after_imports' => true,
77-
'single_line_comment_style' => true,
78-
'single_quote' => true,
79-
'single_trait_insert_per_statement' => true,
80-
'standardize_not_equals' => true,
81-
'switch_case_semicolon_to_colon' => true,
82-
'switch_case_space' => true,
83-
'ternary_to_null_coalescing' => true,
84-
'void_return' => true,
85-
'yoda_style' => true,
86-
// 'braces' => ['position_after_control_structures' => 'next', 'position_after_functions_and_oop_constructs' => 'next', 'position_after_anonymous_constructs' => 'next',],
87-
// 'no_unneeded_curly_braces' => true,
8+
->setRiskyAllowed(true)
9+
->setIndent("\t")
10+
->setLineEnding("\r\n")
11+
->setRules([
12+
'align_multiline_comment' => ['comment_type'=>'all_multiline'],
13+
'array_indentation' => true,
14+
'array_push' => true,
15+
'array_syntax' => ['syntax'=>'short'],
16+
'backtick_to_shell_exec' => true,
17+
'binary_operator_spaces' => true,
18+
'blank_line_after_namespace' => true,
19+
'blank_line_after_opening_tag' => true,
20+
'blank_line_before_statement' => true,
21+
// 'braces' => ['position_after_anonymous_constructs'=>'next','position_after_control_structures'=>'next'],
22+
'cast_spaces' => ['space'=>'none'],
23+
'class_attributes_separation' => true,
24+
'class_definition' => true,
25+
'clean_namespace' => true,
26+
'combine_consecutive_issets' => true,
27+
'combine_consecutive_unsets' => true,
28+
'combine_nested_dirname' => true,
29+
'comment_to_phpdoc' => true,
30+
'compact_nullable_typehint' => true,
31+
'concat_space' => ['spacing'=>'one'],
32+
'constant_case' => true,
33+
'declare_equal_normalize' => true,
34+
'dir_constant' => true,
35+
'elseif' => true,
36+
'encoding' => true,
37+
'ereg_to_preg' => true,
38+
'explicit_indirect_variable' => true,
39+
'explicit_string_variable' => true,
40+
'fopen_flag_order' => true,
41+
'full_opening_tag' => true,
42+
'function_declaration' => ['closure_function_spacing'=>'none'],
43+
'function_to_constant' => true,
44+
'function_typehint_space' => true,
45+
'general_phpdoc_tag_rename' => true,
46+
'hash_to_slash_comment' => true,
47+
'implode_call' => true,
48+
'include' => true,
49+
'indentation_type' => true,
50+
'is_null' => true,
51+
'line_ending' => true,
52+
'linebreak_after_opening_tag' => true,
53+
'list_syntax' => ['syntax'=>'short'],
54+
'logical_operators' => true,
55+
'lowercase_cast' => true,
56+
'lowercase_constants' => true,
57+
'lowercase_keywords' => true,
58+
'lowercase_static_reference' => true,
59+
'magic_constant_casing' => true,
60+
'magic_method_casing' => true,
61+
'method_argument_space' => true,
62+
'method_chaining_indentation' => true,
63+
'modernize_types_casting' => true,
64+
'multiline_whitespace_before_semicolons' => true,
65+
'native_function_casing' => true,
66+
'native_function_invocation' => true,
67+
'native_function_type_declaration_casing' => true,
68+
'new_with_braces' => true,
69+
'no_alias_functions' => true,
70+
'no_alias_language_construct_call' => true,
71+
'no_alternative_syntax' => true,
72+
'no_blank_lines_after_phpdoc' => true,
73+
'no_break_comment' => ['comment_text'=>'Intentionally fall through'],
74+
'no_closing_tag' => true,
75+
'no_empty_comment' => true,
76+
'no_empty_phpdoc' => true,
77+
'no_empty_statement' => true,
78+
'no_homoglyph_names' => true,
79+
'no_leading_import_slash' => true,
80+
'no_leading_namespace_whitespace' => true,
81+
'no_mixed_echo_print' => true,
82+
'no_multiline_whitespace_around_double_arrow' => true,
83+
'no_multiline_whitespace_before_semicolons' => true,
84+
'no_php4_constructor' => true,
85+
'no_short_bool_cast' => true,
86+
'no_spaces_after_function_name' => true,
87+
'no_spaces_inside_parenthesis' => true,
88+
'no_superfluous_phpdoc_tags' => true,
89+
'no_trailing_whitespace' => true,
90+
'no_trailing_whitespace_in_comment' => true,
91+
'no_unneeded_control_parentheses' => true,
92+
'no_unneeded_final_method' => true,
93+
'no_unreachable_default_argument_value' => true,
94+
'no_unset_cast' => true,
95+
'no_unset_on_property' => true,
96+
'no_unused_imports' => true,
97+
'no_useless_else' => true,
98+
'no_useless_return' => true,
99+
'no_useless_sprintf' => true,
100+
'no_whitespace_before_comma_in_array' => true,
101+
'no_whitespace_in_blank_line' => true,
102+
'non_printable_character' => ['use_escape_sequences_in_strings'=>true],
103+
'normalize_index_brace' => true,
104+
'not_operator_with_successor_space' => true,
105+
'nullable_type_declaration_for_default_null_value' => true,
106+
'object_operator_without_whitespace' => true,
107+
'ordered_class_elements' => true,
108+
'ordered_imports' => true,
109+
'ordered_interfaces' => true,
110+
'ordered_traits' => true,
111+
'phpdoc_no_useless_inheritdoc' => true,
112+
'phpdoc_order' => true,
113+
'phpdoc_return_self_reference' => true,
114+
'phpdoc_scalar' => true,
115+
'phpdoc_tag_casing' => true,
116+
'protected_to_private' => true,
117+
'psr_autoloading' => true,
118+
'return_type_declaration' => ['space_before'=>'one'],
119+
'semicolon_after_instruction' => true,
120+
'set_type_to_cast' => true,
121+
'short_scalar_cast' => true,
122+
'simple_to_complex_string_variable' => true,
123+
'simplified_if_return' => true,
124+
'simplified_null_return' => true,
125+
'single_blank_line_at_eof' => true,
126+
'single_blank_line_before_namespace' => true,
127+
'single_class_element_per_statement' => true,
128+
'single_import_per_statement' => true,
129+
'single_line_after_imports' => true,
130+
'single_line_comment_style' => true,
131+
'single_quote' => true,
132+
'single_trait_insert_per_statement' => true,
133+
'standardize_not_equals' => true,
134+
'static_lambda' => true,
135+
'string_line_ending' => true,
136+
'switch_case_semicolon_to_colon' => true,
137+
'switch_case_space' => true,
138+
'switch_continue_to_break' => true,
139+
'ternary_operator_spaces' => true,
140+
'ternary_to_elvis_operator' => true,
141+
'ternary_to_null_coalescing' => true,
142+
'trailing_comma_in_multiline_array' => true,
143+
'trim_array_spaces' => true,
144+
'unary_operator_spaces' => true,
145+
'visibility_required' => true,
146+
'void_return' => true,
147+
'whitespace_after_comma_in_array' => true,
148+
'yoda_style' => true,
88149
])
89-
->setFinder($finder)
90-
;
150+
->setFinder(PhpCsFixer\Finder::create()
151+
->in(__DIR__.'\src')
152+
);
91153

src/PHPFUI/PHPUnitSyntaxCoverage/Extensions.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414

1515
class ClassFinder extends \PhpParser\NodeVisitorAbstract
1616
{
17-
1817
private $classes = [];
18+
1919
private $currentNamespace = '';
2020

2121
public function enterNode(\PhpParser\Node $node) : void
2222
{
2323
if ($node instanceof \PhpParser\Node\Stmt\Namespace_)
2424
{
25-
$this->currentNamespace = implode('\\', $node->name->parts);
25+
$this->currentNamespace = \implode('\\', $node->name->parts);
2626
}
2727
elseif ($node instanceof \PhpParser\Node\Stmt\Class_)
2828
{
@@ -34,13 +34,12 @@ public function getClasses() : array
3434
{
3535
return $this->classes;
3636
}
37-
3837
}
3938

4039
class Extensions extends \PHPUnit\Framework\TestCase implements \PHPUnit\Runner\Hook
4140
{
42-
4341
private static $parser = null;
42+
4443
private $skipDirectories = [];
4544

4645
public static function setUpBeforeClass() : void
@@ -117,26 +116,31 @@ public function assertValidPHPDirectory(string $directory, string $message = '',
117116
{
118117
$iterator = new \DirectoryIterator($directory);
119118
}
120-
$exts = array_flip($extensions);
119+
$exts = \array_flip($extensions);
121120

122121
foreach ($iterator as $item)
123122
{
124123
$type = $item->getType();
124+
125125
if ('file' == $type)
126126
{
127127
$file = $item->getPathname();
128-
$ext = strrchr($file, '.');
128+
$ext = \strrchr($file, '.');
129+
129130
if ($ext && isset($exts[$ext]))
130131
{
131132
$skip = false;
133+
132134
foreach ($this->skipDirectories as $directory)
133135
{
134-
if (stripos($file, $directory) !== false)
136+
if (false !== \stripos($file, $directory))
135137
{
136138
$skip = true;
139+
137140
break;
138141
}
139142
}
143+
140144
if (! $skip)
141145
{
142146
$this->assertValidPHPFile($file, $message . "\nFile: " . $file);
@@ -153,9 +157,8 @@ public function assertValidPHPFile(string $fileName, string $message = '') : voi
153157
{
154158
$this->assertFileExists($fileName, $message);
155159

156-
$code = file_get_contents($fileName);
160+
$code = \file_get_contents($fileName);
157161

158162
$this->assertValidPHP($code, $message);
159163
}
160-
161164
}

0 commit comments

Comments
 (0)