Skip to content

Commit 71b63a1

Browse files
committed
Code cleanup, bumped required PHP version to >= 7.2 and updated readme.
- Removed unreachable code from Diff::getArgumentType(). - Updated readme files to include the Unified HTML diff-view, PHP >= 7.2 requirement and DigiLive as contributor. - Updated PHP >= 7.2 requirement in file docBlocks.
1 parent 611dc21 commit 71b63a1

File tree

15 files changed

+60
-63
lines changed

15 files changed

+60
-63
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ rendered in all of the standard formats including:
1313
* Context
1414
* Inline HTML
1515
* Side by Side HTML
16+
* Unified HTML
1617

1718
The logic behind the core of the diff engine (ie, the sequence matcher)
1819
is primarily based on the Python difflib package. The reason for doing
@@ -36,21 +37,21 @@ require 'vendor/autoload.php';
3637
require dirname(__FILE__).'/../lib/Autoloader.php';
3738
new \jblond\Autoloader();
3839

39-
$a = explode("\n", file_get_contents(dirname(__FILE__).'/a.txt'));
40-
$b = explode("\n", file_get_contents(dirname(__FILE__).'/b.txt'));
40+
$a = file_get_contents(dirname(__FILE__).'/a.txt');
41+
$b = file_get_contents(dirname(__FILE__).'/b.txt');
4142
// Options for generating the diff
42-
$options = array(
43+
$options = [
4344
//'ignoreWhitespace' => true,
4445
//'ignoreCase' => true,
45-
);
46+
];
4647
// Initialize the diff class
4748
$diff = new \jblond\Diff($a, $b, $options);
4849

4950
//choose renderer
50-
$renderer = new \jblond\Diff\Renderer\Html\SideBySide(array(
51+
$renderer = new \jblond\Diff\Renderer\Html\SideBySide([
5152
'title_a' => 'Custom title for OLD version',
5253
'title_b' => 'Custom title for NEW version',
53-
));
54+
]);
5455

5556
//show it
5657
echo $diff->Render($renderer);
@@ -66,7 +67,7 @@ example.php.
6667

6768
## Requirements
6869

69-
- PHP 7.1 or greater
70+
- PHP 7.2 or greater
7071
- PHP Multibyte String
7172

7273
## Merge files using jQuery
@@ -86,6 +87,7 @@ Contributors since I forked the repo.
8687
- maxxer
8788
- Creris
8889
- jfcherng
90+
- DigiLive
8991

9092
### License (BSD License)
9193

composer.json

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,39 @@
11
{
2-
"name": "jblond/php-diff",
3-
"type": "library",
4-
"description": "A comprehensive library for generating differences between two hashable objects (strings or arrays).",
5-
"license": "BSD-3-Clause",
6-
"keywords": [
7-
"php",
8-
"diff"
9-
],
10-
"authors": [
11-
{
12-
"name": "Mario",
13-
"email": "leet31337@web.de"
14-
},
15-
{
16-
"name": "Chris Boulton",
17-
"email": "chris.boulton@interspire.com"
18-
}
19-
],
20-
"require": {
21-
"php" : ">= 7.1",
22-
"ext-mbstring": "*"
23-
},
24-
"require-dev": {
25-
"phpunit/phpunit": "8.*",
26-
"squizlabs/php_codesniffer": "*"
27-
},
28-
"autoload": {
29-
"psr-4": {
30-
"jblond\\": "lib/jblond"
31-
}
32-
},
33-
"config": {
34-
"classmap-authoritative": true
35-
},
36-
"scripts": {
37-
"phpunit": "phpunit ./tests/",
38-
"php_src": "phpcs --standard=phpcs.xml -s -p --colors ./lib/",
39-
"php_test": "phpcs --standard=phpcs.xml -s -p --colors ./tests/"
40-
}
41-
}
2+
"name" : "jblond/php-diff",
3+
"type" : "library",
4+
"description" : "A comprehensive library for generating differences between two hashable objects (strings or arrays).",
5+
"license" : "BSD-3-Clause",
6+
"keywords" : [
7+
"php",
8+
"diff"
9+
],
10+
"authors" : [{
11+
"name" : "Mario",
12+
"email" : "leet31337@web.de"
13+
}, {
14+
"name" : "Chris Boulton",
15+
"email" : "chris.boulton@interspire.com"
16+
}
17+
],
18+
"require" : {
19+
"php" : ">= 7.2",
20+
"ext-mbstring" : "*"
21+
},
22+
"require-dev" : {
23+
"phpunit/phpunit" : "8.*",
24+
"squizlabs/php_codesniffer" : "*"
25+
},
26+
"autoload" : {
27+
"psr-4" : {
28+
"jblond\\" : "lib/jblond"
29+
}
30+
},
31+
"config" : {
32+
"classmap-authoritative" : true
33+
},
34+
"scripts" : {
35+
"phpunit" : "phpunit ./tests/",
36+
"php_src" : "phpcs --standard=phpcs.xml -s -p --colors ./lib/",
37+
"php_test" : "phpcs --standard=phpcs.xml -s -p --colors ./tests/"
38+
}
39+
}

composer.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/Autoloader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Library to automatically include required files when a script calls a class.
99
*
10-
* PHP version 7.1 or greater
10+
* PHP version 7.2 or greater
1111
*
1212
* @package jblond
1313
* @author Chris Boulton <chris.boulton@interspire.com>

lib/jblond/Diff.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* A comprehensive library for comparing two strings and generating the differences between them in multiple formats.
1313
* (unified, side by side, inline, HTML, etc.)
1414
*
15-
* PHP version 7.1 or greater
15+
* PHP version 7.2 or greater
1616
*
1717
* @package jblond
1818
* @author Chris Boulton <chris.boulton@interspire.com>
@@ -201,9 +201,6 @@ public function getArgumentType($var): int
201201
default:
202202
throw new \InvalidArgumentException('Invalid argument type! Argument must be of type array or string.');
203203
}
204-
205-
$length = $end - $start;
206-
return array_slice($this->new, $start, $length);
207204
}
208205

209206
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/**
1010
* Base renderer for rendering HTML based diffs for PHP DiffLib.
1111
*
12-
* PHP version 7.1 or greater
12+
* PHP version 7.2 or greater
1313
*
1414
* @package jblond\Diff\Renderer\Html
1515
* @author Chris Boulton <chris.boulton@interspire.com>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
* Inline HTML diff generator for PHP DiffLib.
99
*
10-
* PHP version 7.1 or greater
10+
* PHP version 7.2 or greater
1111
*
1212
* @package jblond\Diff\Renderer\Html
1313
* @author Chris Boulton <chris.boulton@interspire.com>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
* Side by Side HTML diff generator for PHP DiffLib.
99
*
10-
* PHP version 7.1 or greater
10+
* PHP version 7.2 or greater
1111
*
1212
* @package jblond\Diff\Renderer\Html
1313
* @author Chris Boulton <chris.boulton@interspire.com>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
* Unified HTML diff generator for PHP DiffLib.
99
*
10-
* PHP version 7.1 or greater
10+
* PHP version 7.2 or greater
1111
*
1212
* @package jblond\Diff\Renderer\Html
1313
* @author Chris Boulton <chris.boulton@interspire.com>

lib/jblond/Diff/Renderer/RendererAbstract.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/**
1010
* Abstract class for diff renderers in PHP DiffLib.
1111
*
12-
* PHP version 7.1 or greater
12+
* PHP version 7.2 or greater
1313
*
1414
* @package jblond\Diff\Renderer
1515
* @author Chris Boulton <chris.boulton@interspire.com>

0 commit comments

Comments
 (0)