Skip to content

Commit 85fc60c

Browse files
Cleanup
1 parent bd8b5b8 commit 85fc60c

28 files changed

+336
-250
lines changed

.php_cs

Lines changed: 0 additions & 81 deletions
This file was deleted.

.php_cs.dist

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
<?php declare(strict_types=1);
2+
$header = <<<'EOF'
3+
This file is part of sebastian/diff.
4+
5+
(c) Sebastian Bergmann <[email protected]>
6+
7+
For the full copyright and license information, please view the LICENSE
8+
file that was distributed with this source code.
9+
EOF;
10+
11+
return PhpCsFixer\Config::create()
12+
->setRiskyAllowed(true)
13+
->setRules(
14+
[
15+
'array_syntax' => ['syntax' => 'short'],
16+
'binary_operator_spaces' => [
17+
'align_double_arrow' => true,
18+
'align_equals' => true
19+
],
20+
'blank_line_after_namespace' => true,
21+
'blank_line_before_statement' => [
22+
'statements' => [
23+
'break',
24+
'continue',
25+
'return',
26+
'throw',
27+
'try',
28+
],
29+
],
30+
'braces' => true,
31+
'cast_spaces' => true,
32+
'class_attributes_separation' => ['elements' => ['method']],
33+
'compact_nullable_typehint' => true,
34+
'concat_space' => ['spacing' => 'one'],
35+
'declare_equal_normalize' => ['space' => 'none'],
36+
'declare_strict_types' => true,
37+
'dir_constant' => true,
38+
'elseif' => true,
39+
'encoding' => true,
40+
'full_opening_tag' => true,
41+
'function_declaration' => true,
42+
'header_comment' => ['header' => $header, 'separate' => 'none'],
43+
'indentation_type' => true,
44+
'line_ending' => true,
45+
'list_syntax' => ['syntax' => 'short'],
46+
'lowercase_cast' => true,
47+
'lowercase_constants' => true,
48+
'lowercase_keywords' => true,
49+
'magic_constant_casing' => true,
50+
'method_argument_space' => ['ensure_fully_multiline' => true],
51+
'modernize_types_casting' => true,
52+
'native_function_casing' => true,
53+
'native_function_invocation' => true,
54+
'no_alias_functions' => true,
55+
'no_blank_lines_after_class_opening' => true,
56+
'no_blank_lines_after_phpdoc' => true,
57+
'no_closing_tag' => true,
58+
'no_empty_comment' => true,
59+
'no_empty_phpdoc' => true,
60+
'no_empty_statement' => true,
61+
'no_extra_consecutive_blank_lines' => true,
62+
'no_homoglyph_names' => true,
63+
'no_leading_import_slash' => true,
64+
'no_leading_namespace_whitespace' => true,
65+
'no_mixed_echo_print' => ['use' => 'print'],
66+
'no_null_property_initialization' => true,
67+
'no_short_bool_cast' => true,
68+
'no_short_echo_tag' => true,
69+
'no_singleline_whitespace_before_semicolons' => true,
70+
'no_spaces_after_function_name' => true,
71+
'no_spaces_inside_parenthesis' => true,
72+
'no_superfluous_elseif' => true,
73+
'no_trailing_comma_in_list_call' => true,
74+
'no_trailing_comma_in_singleline_array' => true,
75+
'no_trailing_whitespace' => true,
76+
'no_trailing_whitespace_in_comment' => true,
77+
'no_unneeded_control_parentheses' => true,
78+
'no_unneeded_curly_braces' => true,
79+
'no_unneeded_final_method' => true,
80+
'no_unreachable_default_argument_value' => true,
81+
'no_unused_imports' => true,
82+
'no_useless_else' => true,
83+
'no_whitespace_before_comma_in_array' => true,
84+
'no_whitespace_in_blank_line' => true,
85+
'non_printable_character' => true,
86+
'normalize_index_brace' => true,
87+
'object_operator_without_whitespace' => true,
88+
'ordered_class_elements' => [
89+
'order' => [
90+
'use_trait',
91+
'constant_public',
92+
'constant_protected',
93+
'constant_private',
94+
'property_public',
95+
'property_protected',
96+
'property_private',
97+
'construct',
98+
'destruct',
99+
'magic',
100+
'phpunit',
101+
'method_public',
102+
'method_protected',
103+
'method_private',
104+
],
105+
],
106+
'ordered_imports' => true,
107+
'phpdoc_add_missing_param_annotation' => true,
108+
'phpdoc_align' => true,
109+
'phpdoc_annotation_without_dot' => true,
110+
'phpdoc_indent' => true,
111+
'phpdoc_no_access' => true,
112+
'phpdoc_no_empty_return' => true,
113+
'phpdoc_no_package' => true,
114+
'phpdoc_order' => true,
115+
'phpdoc_return_self_reference' => true,
116+
'phpdoc_scalar' => true,
117+
'phpdoc_separation' => true,
118+
'phpdoc_single_line_var_spacing' => true,
119+
'phpdoc_to_comment' => true,
120+
'phpdoc_trim' => true,
121+
'phpdoc_types' => true,
122+
'phpdoc_types_order' => true,
123+
'phpdoc_var_without_name' => true,
124+
'pow_to_exponentiation' => true,
125+
'protected_to_private' => true,
126+
'return_type_declaration' => ['space_before' => 'none'],
127+
'self_accessor' => true,
128+
'short_scalar_cast' => true,
129+
'simplified_null_return' => true,
130+
'single_blank_line_at_eof' => true,
131+
'single_import_per_statement' => true,
132+
'single_line_after_imports' => true,
133+
'single_quote' => true,
134+
'standardize_not_equals' => true,
135+
'ternary_to_null_coalescing' => true,
136+
'trim_array_spaces' => true,
137+
'unary_operator_spaces' => true,
138+
'visibility_required' => true,
139+
'void_return' => true,
140+
'whitespace_after_comma_in_array' => true,
141+
]
142+
)
143+
->setFinder(
144+
PhpCsFixer\Finder::create()
145+
->files()
146+
->in(__DIR__ . '/src')
147+
->in(__DIR__ . '/tests')
148+
->name('*.php')
149+
);

ChangeLog.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@
22

33
All notable changes are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
44

5-
## [2.1.0] - 2017-MM-DD
5+
## [3.0.0] - 2018-MM-DD
6+
7+
* The `StrictUnifiedDiffOutputBuilder` implementation of the `DiffOutputBuilderInterface` was added
8+
9+
### Changed
10+
11+
* The default `DiffOutputBuilderInterface` implementation now generates context lines (unchanged lines)
12+
13+
### Removed
14+
15+
* Removed support for PHP 7.0
616

717
### Fixed
818

@@ -24,6 +34,6 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
2434

2535
* This component is no longer supported on PHP 5.6
2636

27-
[2.1.0]: https://github.com/sebastianbergmann/diff/compare/2.0...2.1.0
37+
[3.0.0]: https://github.com/sebastianbergmann/diff/compare/2.0...3.0.0
2838
[2.0.1]: https://github.com/sebastianbergmann/diff/compare/c341c98ce083db77f896a0aa64f5ee7652915970...2.0.1
2939
[2.0.0]: https://github.com/sebastianbergmann/diff/compare/1.4...c341c98ce083db77f896a0aa64f5ee7652915970

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
sebastian/diff
22

3-
Copyright (c) 2002-2017, Sebastian Bergmann <[email protected]>.
3+
Copyright (c) 2002-2018, Sebastian Bergmann <[email protected]>.
44
All rights reserved.
55

66
Redistribution and use in source and binary forms, with or without

src/Chunk.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function getLines(): array
7171
return $this->lines;
7272
}
7373

74-
public function setLines(array $lines)
74+
public function setLines(array $lines): void
7575
{
7676
$this->lines = $lines;
7777
}

src/Diff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function getChunks(): array
6060
/**
6161
* @param Chunk[] $chunks
6262
*/
63-
public function setChunks(array $chunks)
63+
public function setChunks(array $chunks): void
6464
{
6565
$this->chunks = $chunks;
6666
}

src/Differ.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function __construct($outputBuilder = null)
6060
*
6161
* @param array|string $from
6262
* @param array|string $to
63-
* @param LongestCommonSubsequenceCalculator|null $lcs
63+
* @param null|LongestCommonSubsequenceCalculator $lcs
6464
*
6565
* @return string
6666
*/
@@ -75,22 +75,6 @@ public function diff($from, $to, LongestCommonSubsequenceCalculator $lcs = null)
7575
return $this->outputBuilder->getDiff($diff);
7676
}
7777

78-
/**
79-
* Casts variable to string if it is not a string or array.
80-
*
81-
* @param mixed $input
82-
*
83-
* @return string|array
84-
*/
85-
private function normalizeDiffInput($input)
86-
{
87-
if (!\is_array($input) && !\is_string($input)) {
88-
return (string) $input;
89-
}
90-
91-
return $input;
92-
}
93-
9478
/**
9579
* Returns the diff between two arrays or strings as array.
9680
*
@@ -122,7 +106,7 @@ public function diffToArray($from, $to, LongestCommonSubsequenceCalculator $lcs
122106
throw new InvalidArgumentException('"to" must be an array or string.');
123107
}
124108

125-
list($from, $to, $start, $end) = self::getArrayDiffParted($from, $to);
109+
[$from, $to, $start, $end] = self::getArrayDiffParted($from, $to);
126110

127111
if ($lcs === null) {
128112
$lcs = $this->selectLcsImplementation($from, $to);
@@ -172,6 +156,22 @@ public function diffToArray($from, $to, LongestCommonSubsequenceCalculator $lcs
172156
return $diff;
173157
}
174158

159+
/**
160+
* Casts variable to string if it is not a string or array.
161+
*
162+
* @param mixed $input
163+
*
164+
* @return array|string
165+
*/
166+
private function normalizeDiffInput($input)
167+
{
168+
if (!\is_array($input) && !\is_string($input)) {
169+
return (string) $input;
170+
}
171+
172+
return $input;
173+
}
174+
175175
/**
176176
* Checks if input is string, if so it will split it line-by-line.
177177
*
@@ -211,7 +211,7 @@ private function selectLcsImplementation(array $from, array $to): LongestCommonS
211211
* @param array $from
212212
* @param array $to
213213
*
214-
* @return int|float
214+
* @return float|int
215215
*/
216216
private function calculateEstimatedFootprint(array $from, array $to)
217217
{

src/Exception/ConfigurationException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ final class ConfigurationException extends InvalidArgumentException
1717
* @param string $expected
1818
* @param mixed $value
1919
* @param int $code
20-
* @param \Exception|null $previous
20+
* @param null|\Exception $previous
2121
*/
2222
public function __construct(
2323
string $option,

src/Output/StrictUnifiedDiffOutputBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function getDiff(array $diff): string
129129
;
130130
}
131131

132-
private function writeDiffHunks($output, array $diff)
132+
private function writeDiffHunks($output, array $diff): void
133133
{
134134
// detect "No newline at end of file" and insert into `$diff` if needed
135135

@@ -278,7 +278,7 @@ private function writeHunk(
278278
int $toStart,
279279
int $toRange,
280280
$output
281-
) {
281+
): void {
282282
\fwrite($output, '@@ -' . $fromStart);
283283

284284
if (!$this->collapseRanges || 1 !== $fromRange) {

0 commit comments

Comments
 (0)