Skip to content

Commit 5e5cf20

Browse files
authored
Merge branch 'master' into php-diff-82
2 parents 280eb83 + 3f44195 commit 5e5cf20

22 files changed

+57
-50
lines changed

changelog.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Changelog
22

3-
## 2.3.2 (2021-03-27)
3+
## 2.3.3 (2021-08-23)
44

5-
* Bump library version ([6e42d96](https://github.com/JBlond/php-diff/commit/6e42d96))
5+
* Fix Autoload test classes only in development ([31b4222](https://github.com/JBlond/php-diff/commit/31b4222))
6+
7+
## v2.3.2 (2021-03-27)
8+
9+
* Bump library version und update Changelog ([8a83b39](https://github.com/JBlond/php-diff/commit/8a83b39))
610
* Fix [#90](https://github.com/JBlond/php-diff/issues/90) - Merged Diff shows result only partially ([acbfd7d](https://github.com/JBlond/php-diff/commit/acbfd7d))
711
* Fix colors ([7eba340](https://github.com/JBlond/php-diff/commit/7eba340))
812
* Fix repeating class assignment of line header ([fb32453](https://github.com/JBlond/php-diff/commit/fb32453))

composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@
4343
},
4444
"autoload": {
4545
"psr-4": {
46-
"jblond\\": "lib/jblond",
46+
"jblond\\": "lib/jblond"
47+
}
48+
},
49+
"autoload-dev": {
50+
"psr-4": {
4751
"Tests\\": "tests"
4852
}
4953
},

generateChangelog.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
require 'vendor/autoload.php';
66

77
$changelogOptions = [
8-
'headTagName' => '2.3.2',
9-
'headTagDate' => '2021-03-27',
8+
'headTagName' => '2.3.3',
9+
'headTagDate' => '2021-08-23',
1010
'titleOrder' => 'ASC',
1111
];
1212
$changelogLabels = ['Add', 'Cut', 'Fix', 'Bump', 'Document','Optimize'];

lib/jblond/Diff.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* @author Ferry Cools <[email protected]>
2525
* @copyright (c) 2020 Mario Brandt
2626
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
27-
* @version 2.3.2
27+
* @version 2.3.3
2828
* @link https://github.com/JBlond/php-diff
2929
*/
3030
class Diff implements ConstantsInterface
@@ -89,7 +89,7 @@ class Diff implements ConstantsInterface
8989
* The values can be of type string or array.
9090
* If the type is string, it's split into array elements by line-end characters.
9191
*
92-
* Options for comparison can be set by using the third parameter. The format of this value is expected to be a
92+
* Options for comparison can be set by using the third parameter. The format of this value is expected to be an
9393
* associative array where each key-value pair represents an option and its value (E.g. ['context' => 3], ...).
9494
* When a keyName matches the name of a default option, that option's value will be overridden by the key's value.
9595
* Any other keyName (and it's value) can be added as an option, but will not be used if not implemented.
@@ -112,7 +112,7 @@ public function __construct($version1, $version2, array $options = [])
112112
}
113113

114114
/**
115-
* Get the type of a variable.
115+
* Get the kind of variable.
116116
*
117117
* The return value depend on the type of variable:
118118
* 0 If the type is 'array'
@@ -202,11 +202,11 @@ public function render(object $renderer)
202202
* @param int|null $end The last element of the range to get.
203203
* If not supplied, only the element at start will be returned.
204204
*
205-
* @return array Array containing all of the elements of the specified range.
205+
* @return array Array containing all the elements of the specified range.
206206
* @throws OutOfRangeException When the value of start or end are invalid to define a range.
207207
*
208208
*/
209-
public function getArrayRange(array $array, int $start = 0, $end = null): array
209+
public function getArrayRange(array $array, int $start = 0, ?int $end = null): array
210210
{
211211
if ($start < 0 || $end < 0 || $end < $start) {
212212
throw new OutOfRangeException('Start parameter must be lower than End parameter while both are positive!');
@@ -276,7 +276,7 @@ public function getGroupedOpCodes(): array
276276
*
277277
* @return float Similarity ratio.
278278
*/
279-
public function getSimilarity($method = Similarity::CALC_DEFAULT): float
279+
public function getSimilarity(int $method = Similarity::CALC_DEFAULT): float
280280
{
281281
if ($this->similarity !== null) {
282282
return $this->similarity;

lib/jblond/Diff/DiffUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* @author Mario Brandt <[email protected]>
1212
* @copyright (c) 2020 Mario Brandt
1313
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
14-
* @version 2.3.2
14+
* @version 2.3.3
1515
* @link https://github.com/JBlond/php-diff
1616
*/
1717
class DiffUtils

lib/jblond/Diff/Renderer/Html/Merged.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
* @author Ferry Cools <[email protected]>
1515
* @copyright (c) 2020 Ferry Cools
1616
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
17-
* @version 2.3.2
17+
* @version 2.3.3
1818
* @link https://github.com/JBlond/php-diff
1919
*/
2020
class Merged extends MainRenderer implements SubRendererInterface
2121
{
2222
/**
2323
* @var array Associative array containing the default options available for this renderer and their default
2424
* value.
25-
* - format Format of the texts.
25+
* - format The Format of the texts.
2626
* - insertMarkers Markers for inserted text.
2727
* - deleteMarkers Markers for removed text.
2828
* - title1 Title of the 1st version of text.

lib/jblond/Diff/Renderer/Html/SideBySide.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
* @author Ferry Cools <[email protected]>
1919
* @copyright (c) 2009 Chris Boulton
2020
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
21-
* @version 2.3.2
21+
* @version 2.3.3
2222
* @link https://github.com/JBlond/php-diff
2323
*/
2424
class SideBySide extends MainRenderer implements SubRendererInterface
2525
{
2626
/**
2727
* @var array Associative array containing the default options available for this renderer and their default
2828
* value.
29-
* - format Format of the texts.
29+
* - format The Format of the texts.
3030
* - insertMarkers Markers for inserted text.
3131
* - deleteMarkers Markers for removed text.
3232
* - title1 Title of the 1st version of text.

lib/jblond/Diff/Renderer/Html/Unified.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
* @author Ferry Cools <[email protected]>
1919
* @copyright (c) 2009 Chris Boulton
2020
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
21-
* @version 2.3.2
21+
* @version 2.3.3
2222
* @link https://github.com/JBlond/php-diff
2323
*/
2424
class Unified extends MainRenderer implements SubRendererInterface
2525
{
2626
/**
2727
* @var array Associative array containing the default options available for this renderer and their default
2828
* value.
29-
* - format Format of the texts.
29+
* - format The Format of the texts.
3030
* - insertMarkers Markers for inserted text.
3131
* - deleteMarkers Markers for removed text.
3232
* - title1 Title of the 1st version of text.

lib/jblond/Diff/Renderer/MainRenderer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* @author Ferry Cools <[email protected]>
1818
* @copyright (c) 2009 Chris Boulton
1919
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
20-
* @version 2.3.2
20+
* @version 2.3.3
2121
* @link https://github.com/JBlond/php-diff
2222
*/
2323
class MainRenderer extends MainRendererAbstract
@@ -136,7 +136,7 @@ protected function renderSequences(): array
136136
foreach ($group as $code) {
137137
[$tag, $startOld, $endOld, $startNew, $endNew] = $code;
138138
/**
139-
* $code is an array describing a op-code which includes:
139+
* $code is an array describing an op-code which includes:
140140
* 0 - The type of tag (as described below) for the op code.
141141
* 1 - The beginning line in the first sequence.
142142
* 2 - The end line in the first sequence.
@@ -373,7 +373,7 @@ private function getOuterChange(string $oldString, string $newString): array
373373
$limit = min(mb_strlen($oldString), mb_strlen($newString));
374374

375375
// Find the position of the first character which is different between old and new.
376-
// Starts at the begin of the strings.
376+
// Starts at the beginning of the strings.
377377
// Stops at the end of the shortest string.
378378
while ($start < $limit && mb_substr($oldString, $start, 1) == mb_substr($newString, $start, 1)) {
379379
++$start;
@@ -397,7 +397,7 @@ private function getOuterChange(string $oldString, string $newString): array
397397

398398
/**
399399
* Helper function that will fill the changes-array for the renderer with default values.
400-
* Every time a operation changes (specified by $tag) , a new element will be appended to this array.
400+
* Every time an operation changes (specified by $tag) , a new element will be appended to this array.
401401
*
402402
* The index of the last element of the array is always returned.
403403
*

lib/jblond/Diff/Renderer/MainRendererAbstract.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* @author Ferry Cools <[email protected]>
1717
* @copyright (c) 2020 Ferry Cools
1818
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
19-
* @version 2.3.2
19+
* @version 2.3.3
2020
* @link https://github.com/JBlond/php-diff
2121
*/
2222
abstract class MainRendererAbstract

lib/jblond/Diff/Renderer/SubRendererInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* @author Ferry Cools <[email protected]>
1414
* @copyright (c) 2020 Ferry Cools
1515
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
16-
* @version 2.3.2
16+
* @version 2.3.3
1717
* @link https://github.com/JBlond/php-diff
1818
*/
1919
interface SubRendererInterface

lib/jblond/Diff/Renderer/Text/Context.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* @author Ferry Cools <[email protected]>
1818
* @copyright (c) 2009 Chris Boulton
1919
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
20-
* @version 2.3.2
20+
* @version 2.3.3
2121
* @link https://github.com/JBlond/php-diff
2222
*/
2323
class Context extends MainRendererAbstract

lib/jblond/Diff/Renderer/Text/InlineCli.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* @author Ferry Cools <[email protected]>
1818
* @copyright (c) 2020 Ferry Cools
1919
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
20-
* @version 2.3.2
20+
* @version 2.3.3
2121
* @link https://github.com/JBlond/php-diff
2222
*/
2323
class InlineCli extends MainRenderer implements SubRendererInterface
@@ -198,10 +198,6 @@ private function mergeChanges(
198198
max($this->maxLineMarkerWidth - strlen($this->options['equalityMarkers'][1]), 0)
199199
);
200200

201-
if ($this->options['cliColor']) {
202-
$colorize = new CliColors();
203-
}
204-
205201
foreach ($baseLines as $lineKey => $line) {
206202
$iterator = 0;
207203
$baselineParts = preg_split('/\x00(.*?)\x01/', $line, -1, PREG_SPLIT_DELIM_CAPTURE);
@@ -220,7 +216,7 @@ private function mergeChanges(
220216
}
221217

222218
if ($this->options['cliColor']) {
223-
// Colorize the changed part. $colorize is defined above.
219+
$colorize = new CliColors();
224220
$basePart = $colorize->getColoredString($basePart, ...$deleteColors);
225221
if (!empty($changedPart)) {
226222
$changedPart = $colorize->getColoredString($changedPart, ...$insertColors);

lib/jblond/Diff/Renderer/Text/Unified.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* @author Mario Brandt <[email protected]>
1717
* @copyright (c) 2020 Mario Brandt
1818
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
19-
* @version 2.3.2
19+
* @version 2.3.3
2020
* @link https://github.com/JBlond/php-diff
2121
*/
2222

lib/jblond/Diff/Renderer/Text/UnifiedCli.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* @author Mario Brandt <[email protected]>
1616
* @copyright (c) 2020 Mario Brandt
1717
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
18-
* @version 2.3.2
18+
* @version 2.3.3
1919
* @link https://github.com/JBlond/php-diff
2020
*/
2121
class UnifiedCli extends MainRendererAbstract
@@ -112,12 +112,12 @@ private function output(): string
112112
}
113113

114114
/**
115-
* @param $string
116-
* @param string $color
115+
* @param string $string
116+
* @param string $color
117117
*
118118
* @return string
119119
*/
120-
private function colorizeString($string, $color = ''): string
120+
private function colorizeString(string $string, string $color = ''): string
121121
{
122122
if ($this->options['cliColor']) {
123123
return $this->colors->getColoredString($string, $color);

lib/jblond/Diff/SequenceMatcher.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* @author Ferry Cools <[email protected]>
1818
* @copyright (c) 2020 Mario Brandt
1919
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
20-
* @version 2.3.2
20+
* @version 2.3.3
2121
* @link https://github.com/JBlond/php-diff
2222
*/
2323
class SequenceMatcher implements ConstantsInterface
@@ -80,8 +80,9 @@ class SequenceMatcher implements ConstantsInterface
8080
];
8181

8282
/**
83-
* The constructor. With the sequences being passed, they'll be set for the sequence matcher and it will perform a
84-
* basic cleanup & calculate junk elements.
83+
* The constructor. With the sequences being passed, they'll be set for the
84+
* sequence matcher, and it will perform a basic cleanup & calculate junk
85+
* elements.
8586
*
8687
* @param string|array $old A string or array containing the lines to compare against.
8788
* @param string|array $new A string or array containing the lines to compare.
@@ -222,7 +223,7 @@ private function chainB()
222223
* content of the different files but can still provide context as to where the
223224
* changes are.
224225
*
225-
* @return array Nested array of all of the grouped op codes.
226+
* @return array Nested array of all the grouped op codes.
226227
*/
227228
public function getGroupedOpCodes(): array
228229
{
@@ -302,7 +303,8 @@ public function getGroupedOpCodes(): array
302303
}
303304

304305
/**
305-
* Return a list of all of the op codes for the differences between the two strings.
306+
* Return a list of all the op codes for the differences between the
307+
* two strings.
306308
*
307309
* The nested array returned contains an array describing the op code which includes:
308310
* 0 - The type of tag (as described below) for the op code.
@@ -399,7 +401,8 @@ function (&$line) {
399401
}
400402

401403
/**
402-
* Return a nested set of arrays for all of the matching sub-sequences in compared strings $a and $b.
404+
* Return a nested set of arrays for all the matching sub-sequences
405+
* in the strings $a and $b.
403406
*
404407
* Each block contains the lower constraint of the block in $a, the lower constraint of the block in $b and finally
405408
* the number of lines that the block continues for.
@@ -510,7 +513,7 @@ function ($aArray, $bArray) {
510513
* lower and upper constraints for each sequence. (for the first sequence,
511514
* $alo - $ahi and for the second sequence, $blo - $bhi)
512515
*
513-
* Essentially, of all of the maximal matching blocks, return the one that
516+
* Essentially, of all the maximal matching blocks, return the one that
514517
* starts earliest in $a, and all of those maximal matching blocks that
515518
* start earliest in $a, return the one that starts earliest in $b.
516519
*

lib/jblond/Diff/Similarity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* @author Ferry Cools <[email protected]>
1717
* @copyright (c) 2020 Ferry Cools
1818
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
19-
* @version 2.3.2
19+
* @version 2.3.3
2020
* @link https://github.com/JBlond/php-diff
2121
*/
2222
class Similarity extends SequenceMatcher

tests/Diff/Renderer/Html/HtmlRenderersTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* @author Ferry Cools <[email protected]>
2121
* @copyright (c) 2020 Mario Brandt
2222
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
23-
* @version 2.3.2
23+
* @version 2.3.3
2424
* @link https://github.com/JBlond/php-diff
2525
*/
2626
class HtmlRenderersTest extends TestCase

tests/Diff/Renderer/MainRendererTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* @author Ferry Cools <[email protected]>
2323
* @copyright (c) 2009 Mario Brandt
2424
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
25-
* @version 2.3.2
25+
* @version 2.3.3
2626
* @link https://github.com/JBlond/php-diff
2727
*/
2828

tests/Diff/Renderer/Text/TextRenderersTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* @author Ferry Cools <[email protected]>
2020
* @copyright (c) 2019 Mario Brandt
2121
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
22-
* @version 2.3.2
22+
* @version 2.3.3
2323
* @link https://github.com/JBlond/php-diff
2424
*/
2525
class TextRenderersTest extends TestCase

tests/Diff/SequenceMatcherTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* @author Ferry Cools <[email protected]>
1616
* @copyright (c) 2009 Mario Brandt
1717
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
18-
* @version 2.3.2
18+
* @version 2.3.3
1919
* @link https://github.com/JBlond/php-diff
2020
*/
2121
class SequenceMatcherTest extends TestCase
@@ -73,7 +73,7 @@ public function testGetGroupedOpCodesIgnoreWhitespaceTrue()
7373
{
7474
// Test with ignoreWhitespace enabled. Both sequences are considered to be the same.
7575
// Note: The sequenceMatcher evaluates the string character by character. Option ignoreWhitespace will ignore
76-
// if the difference if the character is a tab in one sequence and a space in the other.
76+
// if the difference is the character or is a tab in one sequence and a space in the other.
7777
$sequenceMatcher = new SequenceMatcher(
7878
"\t54321ABXDE12345 ",
7979
" 54321ABXDE12345\t",

tests/Diff/SimilarityTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @author Ferry Cools <[email protected]>
1515
* @copyright (c) 2020 Ferry Cools
1616
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
17-
* @version 2.3.2
17+
* @version 2.3.3
1818
* @link https://github.com/JBlond/php-diff
1919
*/
2020
class SimilarityTest extends TestCase

0 commit comments

Comments
 (0)