diff --git a/composer.json b/composer.json
index c3ab7814..b7eec477 100644
--- a/composer.json
+++ b/composer.json
@@ -22,7 +22,7 @@
"ext-mbstring": "*"
},
"require-dev": {
- "phpunit/phpunit": "7.*",
+ "phpunit/phpunit": "8.*",
"squizlabs/php_codesniffer": "*"
},
"autoload": {
@@ -30,6 +30,9 @@
"jblond\\": "lib/jblond"
}
},
+ "config": {
+ "classmap-authoritative": true
+ },
"scripts": {
"phpunit": "phpunit ./tests/",
"php_src": "phpcs --standard=phpcs.xml -s -p --colors ./lib/",
diff --git a/lib/Autoloader.php b/lib/Autoloader.php
index 1341b1d6..0e42efe0 100644
--- a/lib/Autoloader.php
+++ b/lib/Autoloader.php
@@ -1,4 +1,5 @@
* @copyright (c) 2009 Chris Boulton
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
- * @version 1.12
+ * @version 1.13
* @link https://github.com/JBlond/php-diff
*/
class Diff
@@ -44,7 +46,7 @@ class Diff
'ignoreNewLines' => false,
'ignoreWhitespace' => false,
'ignoreCase' => false,
- 'labelDifferences'=>'Differences'
+ 'labelDifferences' => 'Differences'
);
/**
@@ -94,7 +96,7 @@ public function render($renderer)
* @param int|null $end The ending number. If not supplied, only the item in $start will be returned.
* @return array Array of all of the lines between the specified range.
*/
- public function getOld(int $start = 0, $end = null) : array
+ public function getOld(int $start = 0, $end = null): array
{
if ($start == 0 && $end === null) {
return $this->old;
@@ -118,7 +120,7 @@ public function getOld(int $start = 0, $end = null) : array
* @param int|null $end The ending number. If not supplied, only the item in $start will be returned.
* @return array Array of all of the lines between the specified range.
*/
- public function getNew(int $start = 0, $end = null) : array
+ public function getNew(int $start = 0, $end = null): array
{
if ($start == 0 && $end === null) {
return $this->new;
@@ -140,7 +142,7 @@ public function getNew(int $start = 0, $end = null) : array
*
* @return array Array of the grouped op codes for the generated diff.
*/
- public function getGroupedOpcodes() : array
+ public function getGroupedOpcodes(): array
{
if (!is_null($this->groupedCodes)) {
return $this->groupedCodes;
diff --git a/lib/jblond/Diff/Renderer/Html/HtmlArray.php b/lib/jblond/Diff/Renderer/Html/HtmlArray.php
index 696982d3..0dae8509 100644
--- a/lib/jblond/Diff/Renderer/Html/HtmlArray.php
+++ b/lib/jblond/Diff/Renderer/Html/HtmlArray.php
@@ -1,5 +1,7 @@
* @copyright (c) 2009 Chris Boulton
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
- * @version 1.12
+ * @version 1.13
* @link https://github.com/JBlond/php-diff
*/
class HtmlArray extends RendererAbstract
@@ -50,7 +52,7 @@ public function renderHtml($changes, $object)
}
foreach ($blocks as $change) {
- $html .= '
';
+ $html .= '';
switch ($change['tag']) {
// Equal changes should be shown on both sides of the diff
case 'equal':
@@ -125,7 +127,7 @@ public function render()
if ($tag != $lastTag) {
$blocks[] = $this->getDefaultArray($tag, $i1, $j1);
- $lastBlock = count($blocks)-1;
+ $lastBlock = count($blocks) - 1;
}
$lastTag = $tag;
@@ -190,7 +192,7 @@ private function getChangeExtent(string $fromLine, string $toLine)
* @param array $lines Array of lines to format.
* @return array Array of the formatted lines.
*/
- protected function formatLines(array $lines) : array
+ protected function formatLines(array $lines): array
{
if ($this->options['tabSize'] !== false) {
$lines = array_map(
@@ -218,7 +220,7 @@ function ($item) {
* @param array $matches The string of spaces.
* @return string The HTML representation of the string.
*/
- protected function fixSpaces(array $matches) : string
+ protected function fixSpaces(array $matches): string
{
$buffer = '';
$count = 0;
@@ -229,12 +231,12 @@ protected function fixSpaces(array $matches) : string
}
$div = (int) ($count / 2);
$mod = $count % 2;
- $buffer .= str_repeat(' ', $div).str_repeat(' ', $mod);
+ $buffer .= str_repeat(' ', $div) . str_repeat(' ', $mod);
}
$div = (int) ($count / 2);
$mod = $count % 2;
- return str_repeat(' ', $div).str_repeat(' ', $mod);
+ return str_repeat(' ', $div) . str_repeat(' ', $mod);
}
/**
@@ -243,7 +245,7 @@ protected function fixSpaces(array $matches) : string
* @param string $line The containing tabs to convert.
* @return string The line with the tabs converted to spaces.
*/
- private function expandTabs(string $line) : string
+ private function expandTabs(string $line): string
{
$tabSize = $this->options['tabSize'];
while (($pos = strpos($line, "\t")) !== false) {
@@ -262,7 +264,7 @@ private function expandTabs(string $line) : string
* @param string $string The string.
* @return string The string with the HTML characters replaced by entities.
*/
- private function htmlSafe(string $string) : string
+ private function htmlSafe(string $string): string
{
return htmlspecialchars($string, ENT_NOQUOTES, 'UTF-8');
}
@@ -273,7 +275,7 @@ private function htmlSafe(string $string) : string
* @param integer $j1
* @return array
*/
- private function getDefaultArray(string $tag, int $i1, int $j1) : array
+ private function getDefaultArray(string $tag, int $i1, int $j1): array
{
return array
(
diff --git a/lib/jblond/Diff/Renderer/Html/Inline.php b/lib/jblond/Diff/Renderer/Html/Inline.php
index a8cffc50..7696eb32 100644
--- a/lib/jblond/Diff/Renderer/Html/Inline.php
+++ b/lib/jblond/Diff/Renderer/Html/Inline.php
@@ -1,5 +1,7 @@
* @copyright (c) 2009 Chris Boulton
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
- * @version 1.12
+ * @version 1.13
* @link https://github.com/JBlond/php-diff
*/
class Inline extends HtmlArray
@@ -22,7 +24,7 @@ class Inline extends HtmlArray
*
* @return string The generated inline diff.
*/
- public function render() : string
+ public function render(): string
{
$changes = parent::render();
return parent::renderHtml($changes, $this);
@@ -35,7 +37,7 @@ public function render() : string
*
* @return string Html code representation of the table's header.
*/
- public function generateTableHeader() : string
+ public function generateTableHeader(): string
{
$html = '';
$html .= '';
@@ -53,7 +55,7 @@ public function generateTableHeader() : string
*
* @return string Html code representing empty table body.
*/
- public function generateSkippedTable() : string
+ public function generateSkippedTable(): string
{
$html = '';
$html .= '… | ';
@@ -69,16 +71,16 @@ public function generateSkippedTable() : string
* @param array &$change Array with data about changes.
* @return string Html code representing one or more rows of text with no difference.
*/
- public function generateTableRowsEqual(array &$change) : string
+ public function generateTableRowsEqual(array &$change): string
{
$html = "";
foreach ($change['base']['lines'] as $no => $line) {
$fromLine = $change['base']['offset'] + $no + 1;
$toLine = $change['changed']['offset'] + $no + 1;
$html .= '';
- $html .= ''.$fromLine.' | ';
- $html .= ''.$toLine.' | ';
- $html .= ''.$line.' | ';
+ $html .= '' . $fromLine . ' | ';
+ $html .= '' . $toLine . ' | ';
+ $html .= '' . $line . ' | ';
$html .= '
';
}
return $html;
@@ -90,15 +92,15 @@ public function generateTableRowsEqual(array &$change) : string
* @param array &$change Array with data about changes.
* @return string Html code representing one or more rows of added text.
*/
- public function generateTableRowsInsert(array &$change) : string
+ public function generateTableRowsInsert(array &$change): string
{
$html = "";
foreach ($change['changed']['lines'] as $no => $line) {
$toLine = $change['changed']['offset'] + $no + 1;
$html .= '';
$html .= ' | ';
- $html .= ''.$toLine.' | ';
- $html .= ''.$line.' | ';
+ $html .= '' . $toLine . ' | ';
+ $html .= '' . $line . ' | ';
$html .= '
';
}
return $html;
@@ -110,15 +112,15 @@ public function generateTableRowsInsert(array &$change) : string
* @param array &$change Array with data about changes.
* @return string Html code representing one or more rows of removed text.
*/
- public function generateTableRowsDelete(array &$change) : string
+ public function generateTableRowsDelete(array &$change): string
{
$html = "";
foreach ($change['base']['lines'] as $no => $line) {
$fromLine = $change['base']['offset'] + $no + 1;
$html .= '';
- $html .= ''.$fromLine.' | ';
+ $html .= '' . $fromLine . ' | ';
$html .= ' | ';
- $html .= ''.$line.' | ';
+ $html .= '' . $line . ' | ';
$html .= '
';
}
return $html;
@@ -130,16 +132,16 @@ public function generateTableRowsDelete(array &$change) : string
* @param array &$change Array with data about changes.
* @return string Html code representing one or more rows of modified.
*/
- public function generateTableRowsReplace(array &$change) : string
+ public function generateTableRowsReplace(array &$change): string
{
$html = "";
foreach ($change['base']['lines'] as $no => $line) {
$fromLine = $change['base']['offset'] + $no + 1;
$html .= '';
- $html .= ''.$fromLine.' | ';
+ $html .= '' . $fromLine . ' | ';
$html .= ' | ';
- $html .= ''.$line.' | ';
+ $html .= '' . $line . ' | ';
$html .= '
';
}
@@ -147,8 +149,8 @@ public function generateTableRowsReplace(array &$change) : string
$toLine = $change['changed']['offset'] + $no + 1;
$html .= '';
$html .= ' | ';
- $html .= ''.$toLine.' | ';
- $html .= ''.$line.' | ';
+ $html .= '' . $toLine . ' | ';
+ $html .= '' . $line . ' | ';
$html .= '
';
}
diff --git a/lib/jblond/Diff/Renderer/Html/SideBySide.php b/lib/jblond/Diff/Renderer/Html/SideBySide.php
index 44c2144d..acf2984a 100644
--- a/lib/jblond/Diff/Renderer/Html/SideBySide.php
+++ b/lib/jblond/Diff/Renderer/Html/SideBySide.php
@@ -1,5 +1,7 @@
* @copyright (c) 2009 Chris Boulton
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
- * @version 1.12
+ * @version 1.13
* @link https://github.com/JBlond/php-diff
*/
class SideBySide extends HtmlArray
@@ -22,7 +24,7 @@ class SideBySide extends HtmlArray
*
* @return string The generated side by side diff.
*/
- public function render() : string
+ public function render(): string
{
$changes = parent::render();
return parent::renderHtml($changes, $this);
@@ -34,13 +36,13 @@ public function render() : string
*
* @return string Html code representation of the table's header.
*/
- public function generateTableHeader() : string
+ public function generateTableHeader(): string
{
$html = '';
$html .= '';
$html .= '';
- $html .= ''.$this->options['title_a'].' | ';
- $html .= ''.$this->options['title_b'].' | ';
+ $html .= '' . $this->options['title_a'] . ' | ';
+ $html .= '' . $this->options['title_b'] . ' | ';
$html .= '
';
$html .= '';
return $html;
@@ -51,7 +53,7 @@ public function generateTableHeader() : string
*
* @return string Html code representing empty table body.
*/
- public function generateSkippedTable() : string
+ public function generateSkippedTable(): string
{
$html = '';
$html .= '… | | ';
@@ -66,17 +68,17 @@ public function generateSkippedTable() : string
* @param array &$change Array with data about changes.
* @return string Html code representing one or more rows of text with no difference.
*/
- public function generateTableRowsEqual(array &$change) : string
+ public function generateTableRowsEqual(array &$change): string
{
$html = "";
foreach ($change['base']['lines'] as $no => $line) {
$fromLine = $change['base']['offset'] + $no + 1;
$toLine = $change['changed']['offset'] + $no + 1;
$html .= '';
- $html .= ''.$fromLine.' | ';
- $html .= ''.$line.' | ';
- $html .= ''.$toLine.' | ';
- $html .= ''.$line.' | ';
+ $html .= '' . $fromLine . ' | ';
+ $html .= '' . $line . ' | ';
+ $html .= '' . $toLine . ' | ';
+ $html .= '' . $line . ' | ';
$html .= '
';
}
return $html;
@@ -88,7 +90,7 @@ public function generateTableRowsEqual(array &$change) : string
* @param array &$change Array with data about changes.
* @return string Html code representing one or more rows of added text.
*/
- public function generateTableRowsInsert(array &$change) : string
+ public function generateTableRowsInsert(array &$change): string
{
$html = "";
foreach ($change['changed']['lines'] as $no => $line) {
@@ -96,8 +98,8 @@ public function generateTableRowsInsert(array &$change) : string
$html .= '';
$html .= ' | ';
$html .= ' | ';
- $html .= ''.$toLine.' | ';
- $html .= ''.$line.' | ';
+ $html .= '' . $toLine . ' | ';
+ $html .= '' . $line . ' | ';
$html .= '
';
}
return $html;
@@ -109,14 +111,14 @@ public function generateTableRowsInsert(array &$change) : string
* @param array &$change Array with data about changes.
* @return string Html code representing one or more rows of removed text.
*/
- public function generateTableRowsDelete(array &$change) : string
+ public function generateTableRowsDelete(array &$change): string
{
$html = "";
foreach ($change['base']['lines'] as $no => $line) {
$fromLine = $change['base']['offset'] + $no + 1;
$html .= '';
- $html .= ''.$fromLine.' | ';
- $html .= ''.$line.' | ';
+ $html .= '' . $fromLine . ' | ';
+ $html .= '' . $line . ' | ';
$html .= ' | ';
$html .= ' | ';
$html .= '
';
@@ -130,7 +132,7 @@ public function generateTableRowsDelete(array &$change) : string
* @param array &$change Array with data about changes.
* @return string Html code representing one or more rows of modified.
*/
- public function generateTableRowsReplace(array &$change) : string
+ public function generateTableRowsReplace(array &$change): string
{
$html = "";
@@ -138,17 +140,17 @@ public function generateTableRowsReplace(array &$change) : string
foreach ($change['base']['lines'] as $no => $line) {
$fromLine = $change['base']['offset'] + $no + 1;
$html .= '';
- $html .= ''.$fromLine.' | ';
- $html .= ''.$line.' | ';
+ $html .= '' . $fromLine . ' | ';
+ $html .= '' . $line . ' | ';
if (!isset($change['changed']['lines'][$no])) {
$toLine = ' ';
$changedLine = ' ';
} else {
$toLine = $change['changed']['offset'] + $no + 1;
- $changedLine = ''.$change['changed']['lines'][$no].'';
+ $changedLine = '' . $change['changed']['lines'][$no] . '';
}
- $html .= ''.$toLine.' | ';
- $html .= ''.$changedLine.' | ';
+ $html .= '' . $toLine . ' | ';
+ $html .= '' . $changedLine . ' | ';
$html .= '
';
}
} else {
@@ -158,14 +160,14 @@ public function generateTableRowsReplace(array &$change) : string
$line = ' ';
} else {
$fromLine = $change['base']['offset'] + $no + 1;
- $line = ''.$change['base']['lines'][$no].'';
+ $line = '' . $change['base']['lines'][$no] . '';
}
$html .= '';
- $html .= ''.$fromLine.' | ';
- $html .= ''.$line.' | ';
+ $html .= '' . $fromLine . ' | ';
+ $html .= '' . $line . ' | ';
$toLine = $change['changed']['offset'] + $no + 1;
- $html .= ''.$toLine.' | ';
- $html .= ''.$changedLine.' | ';
+ $html .= '' . $toLine . ' | ';
+ $html .= '' . $changedLine . ' | ';
$html .= '
';
}
}
diff --git a/lib/jblond/Diff/Renderer/RendererAbstract.php b/lib/jblond/Diff/Renderer/RendererAbstract.php
index f3a0afc6..d04210f2 100644
--- a/lib/jblond/Diff/Renderer/RendererAbstract.php
+++ b/lib/jblond/Diff/Renderer/RendererAbstract.php
@@ -1,5 +1,7 @@
* @copyright (c) 2009 Chris Boulton
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
- * @version 1.12
+ * @version 1.13
* @link https://github.com/JBlond/php-diff
*/
abstract class RendererAbstract
diff --git a/lib/jblond/Diff/Renderer/Text/Context.php b/lib/jblond/Diff/Renderer/Text/Context.php
index 42d0b0a9..813e478e 100644
--- a/lib/jblond/Diff/Renderer/Text/Context.php
+++ b/lib/jblond/Diff/Renderer/Text/Context.php
@@ -1,5 +1,7 @@
* @copyright (c) 2009 Chris Boulton
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
- * @version 1.12
+ * @version 1.13
* @link https://github.com/JBlond/php-diff
*/
class Context extends RendererAbstract
@@ -33,28 +35,28 @@ class Context extends RendererAbstract
*
* @return string The generated context diff.
*/
- public function render() : string
+ public function render(): string
{
$diff = '';
$opCodes = $this->diff->getGroupedOpcodes();
foreach ($opCodes as $group) {
$diff .= "***************\n";
- $lastItem = count($group)-1;
+ $lastItem = count($group) - 1;
$i1 = $group['0']['1'];
$i2 = $group[$lastItem]['2'];
$j1 = $group['0']['3'];
$j2 = $group[$lastItem]['4'];
if ($i2 - $i1 >= 2) {
- $diff .= '*** '.($group['0']['1'] + 1).','.$i2." ****\n";
+ $diff .= '*** ' . ($group['0']['1'] + 1) . ',' . $i2 . " ****\n";
} else {
- $diff .= '*** '.$i2." ****\n";
+ $diff .= '*** ' . $i2 . " ****\n";
}
if ($j2 - $j1 >= 2) {
- $separator = '--- '.($j1 + 1).','.$j2." ----\n";
+ $separator = '--- ' . ($j1 + 1) . ',' . $j2 . " ----\n";
} else {
- $separator = '--- '.$j2." ----\n";
+ $separator = '--- ' . $j2 . " ----\n";
}
$hasVisible = false;
@@ -72,7 +74,7 @@ public function render() : string
continue;
}
$diff .= $this->tagMap[$tag] . ' ' .
- implode("\n" . $this->tagMap[$tag] .' ', $this->diff->getOld($i1, $i2)) . "\n";
+ implode("\n" . $this->tagMap[$tag] . ' ', $this->diff->getOld($i1, $i2)) . "\n";
}
}
@@ -93,7 +95,7 @@ public function render() : string
continue;
}
$diff .= $this->tagMap[$tag] . ' ' .
- implode("\n".$this->tagMap[$tag] . ' ', $this->diff->getNew($j1, $j2)) . "\n";
+ implode("\n" . $this->tagMap[$tag] . ' ', $this->diff->getNew($j1, $j2)) . "\n";
}
}
}
diff --git a/lib/jblond/Diff/Renderer/Text/Unified.php b/lib/jblond/Diff/Renderer/Text/Unified.php
index 33088c9e..bfeb05e9 100644
--- a/lib/jblond/Diff/Renderer/Text/Unified.php
+++ b/lib/jblond/Diff/Renderer/Text/Unified.php
@@ -1,5 +1,7 @@
* @copyright (c) 2009 Chris Boulton
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
- * @version 1.12
+ * @version 1.13
* @link https://github.com/JBlond/php-diff
*/
@@ -27,12 +29,12 @@ class Unified extends RendererAbstract
*
* @return string The unified diff.
*/
- public function render() : string
+ public function render(): string
{
$diff = '';
$opCodes = $this->diff->getGroupedOpcodes();
foreach ($opCodes as $group) {
- $lastItem = count($group)-1;
+ $lastItem = count($group) - 1;
$i1 = $group['0']['1'];
$i2 = $group[$lastItem]['2'];
$j1 = $group['0']['3'];
@@ -43,18 +45,18 @@ public function render() : string
$i2 = -1;
}
- $diff .= '@@ -'.($i1 + 1).','.($i2 - $i1).' +'.($j1 + 1).','.($j2 - $j1)." @@\n";
+ $diff .= '@@ -' . ($i1 + 1) . ',' . ($i2 - $i1) . ' +' . ($j1 + 1) . ',' . ($j2 - $j1) . " @@\n";
foreach ($group as $code) {
list($tag, $i1, $i2, $j1, $j2) = $code;
if ($tag == 'equal') {
- $diff .= ' '.implode("\n ", $this->diff->getOld($i1, $i2))."\n";
+ $diff .= ' ' . implode("\n ", $this->diff->getOld($i1, $i2)) . "\n";
} else {
if ($tag == 'replace' || $tag == 'delete') {
- $diff .= '-'.implode("\n-", $this->diff->getOld($i1, $i2))."\n";
+ $diff .= '-' . implode("\n-", $this->diff->getOld($i1, $i2)) . "\n";
}
if ($tag == 'replace' || $tag == 'insert') {
- $diff .= '+'.implode("\n+", $this->diff->getNew($j1, $j2))."\n";
+ $diff .= '+' . implode("\n+", $this->diff->getNew($j1, $j2)) . "\n";
}
}
}
diff --git a/lib/jblond/Diff/SequenceMatcher.php b/lib/jblond/Diff/SequenceMatcher.php
index 7c61b0e2..2f48466d 100644
--- a/lib/jblond/Diff/SequenceMatcher.php
+++ b/lib/jblond/Diff/SequenceMatcher.php
@@ -1,5 +1,7 @@
* @copyright (c) 2009 Chris Boulton
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
- * @version 1.12
+ * @version 1.13
* @link https://github.com/JBlond/php-diff
*/
class SequenceMatcher
@@ -209,7 +211,7 @@ private function chainB()
* @param string $bString
* @return bool $b True if the character is considered junk. False if not.
*/
- private function isBJunk(string $bString) : bool
+ private function isBJunk(string $bString): bool
{
if (isset($this->junkDict[$bString])) {
return true;
@@ -238,7 +240,7 @@ private function isBJunk(string $bString) : bool
* @return array Array containing the longest match that includes the starting position in $a,
* start in $b and the length/size.
*/
- public function findLongestMatch(int $alo, int $ahi, int $blo, int $bhi) : array
+ public function findLongestMatch(int $alo, int $ahi, int $blo, int $bhi): array
{
$old = $this->old;
$new = $this->new;
@@ -260,7 +262,7 @@ public function findLongestMatch(int $alo, int $ahi, int $blo, int $bhi) : array
break;
}
- $k = $this->arrayGetDefault($j2Len, $j -1, 0) + 1;
+ $k = $this->arrayGetDefault($j2Len, $j - 1, 0) + 1;
$newJ2Len[$j] = $k;
if ($k > $bestSize) {
$bestI = $i - $k + 1;
@@ -272,7 +274,8 @@ public function findLongestMatch(int $alo, int $ahi, int $blo, int $bhi) : array
$j2Len = $newJ2Len;
}
- while ($bestI > $alo &&
+ while (
+ $bestI > $alo &&
$bestJ > $blo &&
!$this->isBJunk($new[$bestJ - 1]) &&
!$this->linesAreDifferent($bestI - 1, $bestJ - 1)
@@ -282,14 +285,17 @@ public function findLongestMatch(int $alo, int $ahi, int $blo, int $bhi) : array
++$bestSize;
}
- while ($bestI + $bestSize < $ahi &&
+ while (
+ $bestI + $bestSize < $ahi &&
($bestJ + $bestSize) < $bhi &&
!$this->isBJunk($new[$bestJ + $bestSize]) &&
- !$this->linesAreDifferent($bestI + $bestSize, $bestJ + $bestSize)) {
+ !$this->linesAreDifferent($bestI + $bestSize, $bestJ + $bestSize)
+ ) {
++$bestSize;
}
- while ($bestI > $alo &&
+ while (
+ $bestI > $alo &&
$bestJ > $blo &&
$this->isBJunk($new[$bestJ - 1]) &&
!$this->linesAreDifferent($bestI - 1, $bestJ - 1)
@@ -299,7 +305,8 @@ public function findLongestMatch(int $alo, int $ahi, int $blo, int $bhi) : array
++$bestSize;
}
- while ($bestI + $bestSize < $ahi &&
+ while (
+ $bestI + $bestSize < $ahi &&
$bestJ + $bestSize < $bhi &&
$this->isBJunk($new[$bestJ + $bestSize]) &&
!$this->linesAreDifferent($bestI + $bestSize, $bestJ + $bestSize)
@@ -321,7 +328,7 @@ public function findLongestMatch(int $alo, int $ahi, int $blo, int $bhi) : array
* @param int $bIndex Line number to check against in b.
* @return bool True if the lines are different and false if not.
*/
- public function linesAreDifferent(int $aIndex, int $bIndex) : bool
+ public function linesAreDifferent(int $aIndex, int $bIndex): bool
{
$lineA = $this->old[$aIndex];
$lineB = $this->new[$bIndex];
@@ -354,7 +361,7 @@ public function linesAreDifferent(int $aIndex, int $bIndex) : bool
*
* @return array Nested array of the matching blocks, as described by the function.
*/
- public function getMatchingBlocks() : array
+ public function getMatchingBlocks(): array
{
if (!empty($this->matchingBlocks)) {
return $this->matchingBlocks;
@@ -469,7 +476,7 @@ function ($aArray, $bArray) {
*
* @return array Array of the opcodes describing the differences between the strings.
*/
- public function getOpCodes() : array
+ public function getOpCodes(): array
{
if (!empty($this->opCodes)) {
return $this->opCodes;
@@ -531,7 +538,7 @@ public function getOpCodes() : array
* @param int $context The number of lines of context to provide around the groups.
* @return array Nested array of all of the grouped op codes.
*/
- public function getGroupedOpcodes(int $context = 3) : array
+ public function getGroupedOpcodes(int $context = 3): array
{
$opCodes = $this->getOpCodes();
if (empty($opCodes)) {
@@ -628,7 +635,7 @@ private function arrayGetDefault(array $array, $key, $default)
* @param array $bArray Second array to compare.
* @return int -1, 0 or 1, as expected by the usort function.
*/
- private function tupleSort(array $aArray, array $bArray) : int
+ private function tupleSort(array $aArray, array $bArray): int
{
$max = max(count($aArray), count($bArray));
for ($counter = 0; $counter < $max; ++$counter) {
diff --git a/phpcs.xml b/phpcs.xml
index 3b6ba4eb..65305ff4 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -1,5 +1,7 @@
- php-diff
-
+ php-diff
+
+ lib
+ tests
diff --git a/tests/Diff/Renderer/ArrayTest.php b/tests/Diff/Renderer/ArrayTest.php
index da4df72b..3a5430c3 100644
--- a/tests/Diff/Renderer/ArrayTest.php
+++ b/tests/Diff/Renderer/ArrayTest.php
@@ -1,5 +1,7 @@