Skip to content

Commit a49136e

Browse files
committed
CS-Fix
1 parent f3f637c commit a49136e

23 files changed

+515
-74
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/.idea/
2-
/docs/coverage/
32
/vendor/
3+
/tests/html/
44
/tests/clover.xml
5+
/tests/testdox.html
6+
.php_cs.cache
57
.phpunit.result.cache
68
composer.phar
79
composer.lock

.php_cs.dist

+236
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
<?php
2+
3+
/**
4+
* This file is part of coisa/error-handler.
5+
*
6+
* (c) Felipe Sayão Lobato Abreu <[email protected]>
7+
*
8+
* This source file is subject to the license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
$header = <<<'EOF'
15+
This file is part of coisa/error-handler.
16+
17+
(c) Felipe Sayão Lobato Abreu <[email protected]>
18+
19+
This source file is subject to the license that is bundled
20+
with this source code in the file LICENSE.
21+
EOF;
22+
23+
$finder = PhpCsFixer\Finder::create()
24+
->files()
25+
->in([__DIR__])
26+
->name('*.php')
27+
->append([__FILE__])
28+
->notPath('vendor/');
29+
30+
return PhpCsFixer\Config::create()
31+
->setRiskyAllowed(true)
32+
->setRules([
33+
'align_multiline_comment' => true,
34+
'array_syntax' => [
35+
'syntax' => 'short'
36+
],
37+
'binary_operator_spaces' => [
38+
'align_double_arrow' => true,
39+
'align_equals' => true
40+
],
41+
'blank_line_after_namespace' => true,
42+
'blank_line_after_opening_tag' => true,
43+
'blank_line_before_statement' => [
44+
'statements' => [
45+
'break',
46+
'continue',
47+
'declare',
48+
'return',
49+
'throw',
50+
'try',
51+
'yield',
52+
],
53+
],
54+
'braces' => true,
55+
'cast_spaces' => true,
56+
'class_attributes_separation' => [
57+
'elements' => [
58+
'const',
59+
'method',
60+
'property'
61+
]
62+
],
63+
'class_definition' => [
64+
'multi_line_extends_each_single_line' => false,
65+
'single_item_single_line' => false
66+
],
67+
'class_keyword_remove' => false,
68+
'combine_consecutive_issets' => true,
69+
'combine_consecutive_unsets' => true,
70+
'combine_nested_dirname' => true,
71+
'compact_nullable_typehint' => true,
72+
'concat_space' => [
73+
'spacing' => 'one'
74+
],
75+
'date_time_immutable' => false,
76+
'declare_equal_normalize' => [
77+
'space' => 'none'
78+
],
79+
'dir_constant' => true,
80+
'declare_strict_types' => true,
81+
'elseif' => true,
82+
'encoding' => true,
83+
'ereg_to_preg' => true,
84+
'error_suppression' => [
85+
'mute_deprecation_error' => false,
86+
'noise_remaining_usages' => false,
87+
'noise_remaining_usages_exclude' => []
88+
],
89+
'escape_implicit_backslashes' => [
90+
'double_quoted' => true,
91+
'heredoc_syntax' => true,
92+
'single_quoted' => false,
93+
],
94+
'explicit_indirect_variable' => true,
95+
'explicit_string_variable' => true,
96+
'final_internal_class' => false,
97+
'fopen_flag_order' => true,
98+
'fopen_flags' => [
99+
'b_mode' => true,
100+
],
101+
'full_opening_tag' => true,
102+
'fully_qualified_strict_types' => true,
103+
'function_declaration' => [
104+
'closure_function_spacing' => 'one'
105+
],
106+
'function_to_constant' => [
107+
'functions' => [
108+
'get_called_class',
109+
'get_class',
110+
'php_sapi_name',
111+
'phpversion',
112+
'pi'
113+
]
114+
],
115+
'function_typehint_space' => true,
116+
'general_phpdoc_annotation_remove' => [
117+
'annotations' => [
118+
'author'
119+
]
120+
],
121+
'header_comment' => [
122+
'commentType' => 'PHPDoc',
123+
'header' => $header,
124+
'location' => 'after_open',
125+
'separate' => 'both'
126+
],
127+
'heredoc_indentation' => false,
128+
'heredoc_to_nowdoc' => true,
129+
'indentation_type' => true,
130+
'line_ending' => true,
131+
'list_syntax' => [
132+
'syntax' => 'short'
133+
],
134+
'lowercase_cast' => true,
135+
'lowercase_constants' => true,
136+
'lowercase_keywords' => true,
137+
'magic_constant_casing' => true,
138+
'method_argument_space' => [
139+
'ensure_fully_multiline' => true
140+
],
141+
'modernize_types_casting' => true,
142+
'native_function_casing' => true,
143+
'native_function_invocation' => true,
144+
'no_alias_functions' => true,
145+
'no_blank_lines_after_class_opening' => true,
146+
'no_blank_lines_after_phpdoc' => true,
147+
'no_closing_tag' => true,
148+
'no_empty_comment' => true,
149+
'no_empty_phpdoc' => true,
150+
'no_empty_statement' => true,
151+
'no_extra_consecutive_blank_lines' => true,
152+
'no_homoglyph_names' => true,
153+
'no_leading_import_slash' => true,
154+
'no_leading_namespace_whitespace' => true,
155+
'no_mixed_echo_print' => [
156+
'use' => 'echo'
157+
],
158+
'no_null_property_initialization' => true,
159+
'no_short_bool_cast' => true,
160+
'no_short_echo_tag' => true,
161+
'no_singleline_whitespace_before_semicolons' => true,
162+
'no_spaces_after_function_name' => true,
163+
'no_spaces_inside_parenthesis' => true,
164+
'no_superfluous_elseif' => true,
165+
'no_trailing_comma_in_list_call' => true,
166+
'no_trailing_comma_in_singleline_array' => true,
167+
'no_trailing_whitespace' => true,
168+
'no_trailing_whitespace_in_comment' => true,
169+
'no_unneeded_control_parentheses' => true,
170+
'no_unneeded_curly_braces' => true,
171+
'no_unneeded_final_method' => true,
172+
'no_unreachable_default_argument_value' => true,
173+
'no_unused_imports' => true,
174+
'no_useless_else' => true,
175+
'no_whitespace_before_comma_in_array' => true,
176+
'no_whitespace_in_blank_line' => true,
177+
'non_printable_character' => true,
178+
'normalize_index_brace' => true,
179+
'object_operator_without_whitespace' => true,
180+
'ordered_class_elements' => [
181+
'order' => [
182+
'use_trait',
183+
'constant_public',
184+
'constant_protected',
185+
'constant_private',
186+
'property_public',
187+
'property_protected',
188+
'property_private',
189+
'construct',
190+
'destruct',
191+
'magic',
192+
'phpunit',
193+
'method_public',
194+
'method_protected',
195+
'method_private',
196+
],
197+
],
198+
'ordered_imports' => true,
199+
'phpdoc_add_missing_param_annotation' => true,
200+
'phpdoc_align' => true,
201+
'phpdoc_annotation_without_dot' => true,
202+
'phpdoc_indent' => true,
203+
'phpdoc_no_access' => true,
204+
'phpdoc_no_empty_return' => true,
205+
'phpdoc_no_package' => false,
206+
'phpdoc_order' => true,
207+
'phpdoc_return_self_reference' => true,
208+
'phpdoc_scalar' => true,
209+
'phpdoc_separation' => true,
210+
'phpdoc_single_line_var_spacing' => true,
211+
'phpdoc_to_comment' => true,
212+
'phpdoc_trim' => true,
213+
'phpdoc_types' => true,
214+
'phpdoc_types_order' => true,
215+
'phpdoc_var_without_name' => true,
216+
'pow_to_exponentiation' => true,
217+
'protected_to_private' => true,
218+
'return_type_declaration' => [
219+
'space_before' => 'none'
220+
],
221+
'self_accessor' => true,
222+
'short_scalar_cast' => true,
223+
'simplified_null_return' => true,
224+
'single_blank_line_at_eof' => true,
225+
'single_import_per_statement' => true,
226+
'single_line_after_imports' => true,
227+
'single_quote' => true,
228+
'standardize_not_equals' => true,
229+
'ternary_to_null_coalescing' => true,
230+
'trim_array_spaces' => true,
231+
'unary_operator_spaces' => true,
232+
'visibility_required' => true,
233+
'void_return' => true,
234+
'whitespace_after_comma_in_array' => true,
235+
])
236+
->setFinder($finder);

composer.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727
}
2828
},
2929
"require-dev": {
30-
"phpunit/phpunit": "^8.3"
30+
"phpunit/phpunit": "^8.3",
31+
"friendsofphp/php-cs-fixer": "^2.15"
32+
},
33+
"scripts": {
34+
"cs-check": "php-cs-fixer fix --dry-run --diff",
35+
"cs-fix": "php-cs-fixer fix",
36+
"test": "phpunit"
3137
}
3238
}

examples/index.php

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
<?php
2+
3+
/**
4+
* This file is part of coisa/error-handler.
5+
*
6+
* (c) Felipe Sayão Lobato Abreu <[email protected]>
7+
*
8+
* This source file is subject to the license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
12+
declare(strict_types=1);
213
require __DIR__ . '/../vendor/autoload.php';
314

415
use CoiSA\ErrorHandler\ErrorHandler;
516
use CoiSA\ErrorHandler\Handler\CallableThrowableHandler;
6-
use CoiSA\ErrorHandler\Handler\VarExportHandler;
717

8-
error_reporting(E_ALL);
9-
ini_set('display_errors', 1);
18+
\error_reporting(E_ALL);
19+
\ini_set('display_errors', 1);
1020

11-
$handler = new CallableThrowableHandler(function (\Throwable $throwable) {
21+
$handler = new CallableThrowableHandler(function (Throwable $throwable): void {
1222
echo 'Throwable error!' . "\n";
13-
var_dump($throwable);
23+
\var_dump($throwable);
1424
});
1525

1626
$errorHandler = new ErrorHandler($handler);

phpunit.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
</filter>
2323
<logging>
2424
<log type="coverage-clover" target="tests/clover.xml" lowUpperBound="35" highLowerBound="70"/>
25-
<log type="coverage-html" target="docs/coverage" lowUpperBound="35" highLowerBound="70"/>
25+
<log type="coverage-html" target="tests/html" lowUpperBound="35" highLowerBound="70"/>
2626
<log type="coverage-text" target="php://stdout" lowUpperBound="35" highLowerBound="70" />
27-
<log type="testdox-html" target="docs/coverage/testdox.html" lowUpperBound="35" highLowerBound="70"/>
27+
<log type="testdox-html" target="tests/testdox.html" lowUpperBound="35" highLowerBound="70"/>
2828
</logging>
2929
</phpunit>

src/ErrorHandler.php

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
<?php
2+
23
/**
3-
* @author Felipe Sayão Lobato Abreu <[email protected]>
4-
* @package CoiSA\ErrorHandler
5-
* @since 2017-07-24
4+
* This file is part of coisa/error-handler.
5+
*
6+
* (c) Felipe Sayão Lobato Abreu <[email protected]>
7+
*
8+
* This source file is subject to the license that is bundled
9+
* with this source code in the file LICENSE.
610
*/
711

12+
declare(strict_types=1);
13+
814
namespace CoiSA\ErrorHandler;
915

1016
use CoiSA\ErrorHandler\Handler\PhpErrorHandlerInterface;
@@ -18,7 +24,8 @@
1824
*
1925
* @package CoiSA\ErrorHandler
2026
*/
21-
class ErrorHandler implements ErrorHandlerInterface,
27+
class ErrorHandler implements
28+
ErrorHandlerInterface,
2229
ThrowableHandlerInterface,
2330
PhpErrorHandlerInterface,
2431
ShutdownHandlerInterface
@@ -46,9 +53,9 @@ class ErrorHandler implements ErrorHandlerInterface,
4653
/**
4754
* ErrorHandler constructor.
4855
*
49-
* @param ThrowableHandlerInterface $throwableHandler
50-
* @param PhpErrorHandlerInterface|null $phpErrorHandler
51-
* @param ShutdownHandlerInterface|null $shutdownHandler
56+
* @param ThrowableHandlerInterface $throwableHandler
57+
* @param null|PhpErrorHandlerInterface $phpErrorHandler
58+
* @param null|ShutdownHandlerInterface $shutdownHandler
5259
*/
5360
public function __construct(
5461
ThrowableHandlerInterface $throwableHandler,
@@ -100,10 +107,10 @@ public function handleThrowable(\Throwable $throwable): void
100107
}
101108

102109
/**
103-
* @param int $code
110+
* @param int $code
104111
* @param string $message
105112
* @param string $filename
106-
* @param int $line
113+
* @param int $line
107114
*
108115
* @throws \ErrorException
109116
*/

src/ErrorHandlerInterface.php

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
<?php
2+
23
/**
3-
* @author Felipe Sayão Lobato Abreu <[email protected]>
4-
* @package CoiSA\ErrorHandler\Handler
5-
* @since 2017-07-24
4+
* This file is part of coisa/error-handler.
5+
*
6+
* (c) Felipe Sayão Lobato Abreu <[email protected]>
7+
*
8+
* This source file is subject to the license that is bundled
9+
* with this source code in the file LICENSE.
610
*/
711

12+
declare(strict_types=1);
13+
814
namespace CoiSA\ErrorHandler;
915

1016
/**
1117
* Interface ErrorHandlerInterface
18+
*
1219
* @package CoiSA\ErrorHandler
1320
*/
1421
interface ErrorHandlerInterface

0 commit comments

Comments
 (0)