Skip to content

Commit 7795e70

Browse files
authored
Merge pull request #7 from JBlond/development
Development merge
2 parents 5327190 + ea70fdf commit 7795e70

File tree

11 files changed

+54
-41
lines changed

11 files changed

+54
-41
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ example.php.
3030

3131
Requirements
3232
-----------
33-
PHP Multibyte String
33+
- PHP 7.1 or greater
34+
- PHP Multibyte String
3435

3536
Merge files using jQuery
3637
------------------------
@@ -50,6 +51,7 @@ Contributors since I forked the repo.
5051

5152
- maxxer
5253
- Creris
54+
- jfcherng
5355

5456
License (BSD License)
5557
---------------------

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
}
1919
],
2020
"require": {
21-
"php" : ">= 5.4",
21+
"php" : ">= 7.1",
2222
"ext-mbstring": "*"
2323
},
2424
"require-dev": {

lib/jblond/Diff.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types=1);
23
namespace jblond;
34

45
use jblond\Diff\SequenceMatcher;
@@ -43,7 +44,7 @@
4344
* @author Chris Boulton <[email protected]>
4445
* @copyright (c) 2009 Chris Boulton
4546
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
46-
* @version 1.5
47+
* @version 1.6
4748
* @link https://github.com/JBlond/php-diff
4849
*/
4950
class Diff
@@ -121,7 +122,7 @@ public function render($renderer)
121122
* @param int $end The ending number. If not supplied, only the item in $start will be returned.
122123
* @return array Array of all of the lines between the specified range.
123124
*/
124-
public function getA($start = 0, $end = null)
125+
public function getA($start = 0, $end = null) : array
125126
{
126127
if ($start == 0 && $end === null) {
127128
return $this->a;
@@ -146,7 +147,7 @@ public function getA($start = 0, $end = null)
146147
* @param int $end The ending number. If not supplied, only the item in $start will be returned.
147148
* @return array Array of all of the lines between the specified range.
148149
*/
149-
public function getB($start = 0, $end = null)
150+
public function getB($start = 0, $end = null) : array
150151
{
151152
if ($start == 0 && $end === null) {
152153
return $this->b;
@@ -169,7 +170,7 @@ public function getB($start = 0, $end = null)
169170
*
170171
* @return array Array of the grouped op codes for the generated diff.
171172
*/
172-
public function getGroupedOpcodes()
173+
public function getGroupedOpcodes() : array
173174
{
174175
if (!is_null($this->groupedCodes)) {
175176
return $this->groupedCodes;

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types=1);
23
namespace jblond\Diff\Renderer\Html;
34

45
use jblond\Diff\Renderer\RendererAbstract;
@@ -40,7 +41,7 @@
4041
* @author Chris Boulton <[email protected]>
4142
* @copyright (c) 2009 Chris Boulton
4243
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
43-
* @version 1.5
44+
* @version 1.6
4445
* @link https://github.com/JBlond/php-diff
4546
*/
4647

@@ -254,12 +255,12 @@ protected function fixSpaces($matches)
254255
if ($count == 0) {
255256
continue;
256257
}
257-
$div = ($count / 2);
258+
$div = (int) ($count / 2);
258259
$mod = $count % 2;
259260
$buffer .= str_repeat('&#xA0; ', $div).str_repeat('&#xA0;', $mod);
260261
}
261262

262-
$div = ($count / 2);
263+
$div = (int) ($count / 2);
263264
$mod = $count % 2;
264265
return str_repeat('&#xA0; ', $div).str_repeat('&#xA0;', $mod);
265266
}

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

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types=1);
23
namespace jblond\Diff\Renderer\Html;
34

45
/**
@@ -38,7 +39,7 @@
3839
* @author Chris Boulton <[email protected]>
3940
* @copyright (c) 2009 Chris Boulton
4041
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
41-
* @version 1.5
42+
* @version 1.6
4243
* @link https://github.com/JBlond/php-diff
4344
*/
4445

@@ -53,7 +54,7 @@ class Inline extends HtmlArray
5354
*
5455
* @return string The generated inline diff.
5556
*/
56-
public function render()
57+
public function render() : string
5758
{
5859
$changes = parent::render();
5960
$html = '';
@@ -105,7 +106,7 @@ public function render()
105106
*
106107
* @return string Html code representation of the table's header.
107108
*/
108-
private function generateTableHeader()
109+
private function generateTableHeader() : string
109110
{
110111
$html = '<table class="Differences DifferencesInline">';
111112
$html .= '<thead>';
@@ -123,7 +124,7 @@ private function generateTableHeader()
123124
*
124125
* @return string Html code representing empty table body.
125126
*/
126-
private function generateSkippedTable()
127+
private function generateSkippedTable() : string
127128
{
128129
$html = '<tbody class="Skipped">';
129130
$html .= '<th>&hellip;</th>';
@@ -139,7 +140,7 @@ private function generateSkippedTable()
139140
* @param array &$change Array with data about changes.
140141
* @return string Html code representing one or more rows of text with no difference.
141142
*/
142-
private function generateTableRowsEqual(&$change)
143+
private function generateTableRowsEqual(&$change) : string
143144
{
144145
$html = "";
145146
foreach ($change['base']['lines'] as $no => $line) {
@@ -160,7 +161,7 @@ private function generateTableRowsEqual(&$change)
160161
* @param array &$change Array with data about changes.
161162
* @return string Html code representing one or more rows of added text.
162163
*/
163-
private function generateTableRowsInsert(&$change)
164+
private function generateTableRowsInsert(&$change) : string
164165
{
165166
$html = "";
166167
foreach ($change['changed']['lines'] as $no => $line) {
@@ -180,7 +181,7 @@ private function generateTableRowsInsert(&$change)
180181
* @param array &$change Array with data about changes.
181182
* @return string Html code representing one or more rows of removed text.
182183
*/
183-
private function generateTableRowsDelete(&$change)
184+
private function generateTableRowsDelete(&$change) : string
184185
{
185186
$html = "";
186187
foreach ($change['base']['lines'] as $no => $line) {
@@ -200,7 +201,7 @@ private function generateTableRowsDelete(&$change)
200201
* @param array &$change Array with data about changes.
201202
* @return string Html code representing one or more rows of modified.
202203
*/
203-
private function generateTableRowsReplace(&$change)
204+
private function generateTableRowsReplace(&$change) : string
204205
{
205206
$html = "";
206207

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

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types=1);
23
namespace jblond\Diff\Renderer\Html;
34

45
/**
@@ -38,7 +39,7 @@
3839
* @author Chris Boulton <[email protected]>
3940
* @copyright (c) 2009 Chris Boulton
4041
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
41-
* @version 1.5
42+
* @version 1.6
4243
* @link https://github.com/JBlond/php-diff
4344
*/
4445

@@ -53,7 +54,7 @@ class SideBySide extends HtmlArray
5354
*
5455
* @return string The generated side by side diff.
5556
*/
56-
public function render()
57+
public function render() : string
5758
{
5859
$changes = parent::render();
5960

@@ -102,7 +103,7 @@ public function render()
102103
*
103104
* @return string Html code representation of the table's header.
104105
*/
105-
private function generateTableHeader()
106+
private function generateTableHeader() : string
106107
{
107108
$html = '<table class="Differences DifferencesSideBySide">';
108109
$html .= '<thead>';
@@ -119,7 +120,7 @@ private function generateTableHeader()
119120
*
120121
* @return string Html code representing empty table body.
121122
*/
122-
private function generateSkippedTable()
123+
private function generateSkippedTable() : string
123124
{
124125
$html = '<tbody class="Skipped">';
125126
$html .= '<th>&hellip;</th><td>&#xA0;</td>';
@@ -134,7 +135,7 @@ private function generateSkippedTable()
134135
* @param array &$change Array with data about changes.
135136
* @return string Html code representing one or more rows of text with no difference.
136137
*/
137-
private function generateTableRowsEqual(&$change)
138+
private function generateTableRowsEqual(&$change) : string
138139
{
139140
$html = "";
140141
foreach ($change['base']['lines'] as $no => $line) {
@@ -156,7 +157,7 @@ private function generateTableRowsEqual(&$change)
156157
* @param array &$change Array with data about changes.
157158
* @return string Html code representing one or more rows of added text.
158159
*/
159-
private function generateTableRowsInsert(&$change)
160+
private function generateTableRowsInsert(&$change) : string
160161
{
161162
$html = "";
162163
foreach ($change['changed']['lines'] as $no => $line) {
@@ -177,7 +178,7 @@ private function generateTableRowsInsert(&$change)
177178
* @param array &$change Array with data about changes.
178179
* @return string Html code representing one or more rows of removed text.
179180
*/
180-
private function generateTableRowsDelete(&$change)
181+
private function generateTableRowsDelete(&$change) : string
181182
{
182183
$html = "";
183184
foreach ($change['base']['lines'] as $no => $line) {
@@ -198,7 +199,7 @@ private function generateTableRowsDelete(&$change)
198199
* @param array &$change Array with data about changes.
199200
* @return string Html code representing one or more rows of modified.
200201
*/
201-
private function generateTableRowsReplace(&$change)
202+
private function generateTableRowsReplace(&$change) : string
202203
{
203204
$html = "";
204205

lib/jblond/Diff/Renderer/RendererAbstract.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types=1);
23
namespace jblond\Diff\Renderer;
34

45
/**
@@ -38,7 +39,7 @@
3839
* @author Chris Boulton <[email protected]>
3940
* @copyright (c) 2009 Chris Boulton
4041
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
41-
* @version 1.5
42+
* @version 1.6
4243
* @link https://github.com/JBlond/php-diff
4344
*/
4445
abstract class RendererAbstract

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types=1);
23
namespace jblond\Diff\Renderer\Text;
34

45
use jblond\Diff\Renderer\RendererAbstract;
@@ -40,7 +41,7 @@
4041
* @author Chris Boulton <[email protected]>
4142
* @copyright (c) 2009 Chris Boulton
4243
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
43-
* @version 1.5
44+
* @version 1.6
4445
* @link https://github.com/JBlond/php-diff
4546
*/
4647

@@ -64,7 +65,7 @@ class Context extends RendererAbstract
6465
*
6566
* @return string The generated context diff.
6667
*/
67-
public function render()
68+
public function render() : string
6869
{
6970
$diff = '';
7071
$opCodes = $this->diff->getGroupedOpcodes();

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types=1);
23
namespace jblond\Diff\Renderer\Text;
34

45
use jblond\Diff\Renderer\RendererAbstract;
@@ -40,7 +41,7 @@
4041
* @author Chris Boulton <[email protected]>
4142
* @copyright (c) 2009 Chris Boulton
4243
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
43-
* @version 1.5
44+
* @version 1.6
4445
* @link https://github.com/JBlond/php-diff
4546
*/
4647

@@ -54,7 +55,7 @@ class Unified extends RendererAbstract
5455
*
5556
* @return string The unified diff.
5657
*/
57-
public function render()
58+
public function render() : string
5859
{
5960
$diff = '';
6061
$opCodes = $this->diff->getGroupedOpcodes();

0 commit comments

Comments
 (0)