forked from chrisboulton/php-diff
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from JBlond/development
Development merge
- Loading branch information
Showing
11 changed files
with
54 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
} | ||
], | ||
"require": { | ||
"php" : ">= 5.4", | ||
"php" : ">= 7.1", | ||
"ext-mbstring": "*" | ||
}, | ||
"require-dev": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
declare(strict_types=1); | ||
namespace jblond; | ||
|
||
use jblond\Diff\SequenceMatcher; | ||
|
@@ -43,7 +44,7 @@ | |
* @author Chris Boulton <[email protected]> | ||
* @copyright (c) 2009 Chris Boulton | ||
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php | ||
* @version 1.5 | ||
* @version 1.6 | ||
* @link https://github.com/JBlond/php-diff | ||
*/ | ||
class Diff | ||
|
@@ -121,7 +122,7 @@ public function render($renderer) | |
* @param int $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 getA($start = 0, $end = null) | ||
public function getA($start = 0, $end = null) : array | ||
{ | ||
if ($start == 0 && $end === null) { | ||
return $this->a; | ||
|
@@ -146,7 +147,7 @@ public function getA($start = 0, $end = null) | |
* @param int $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 getB($start = 0, $end = null) | ||
public function getB($start = 0, $end = null) : array | ||
{ | ||
if ($start == 0 && $end === null) { | ||
return $this->b; | ||
|
@@ -169,7 +170,7 @@ public function getB($start = 0, $end = null) | |
* | ||
* @return array Array of the grouped op codes for the generated diff. | ||
*/ | ||
public function getGroupedOpcodes() | ||
public function getGroupedOpcodes() : array | ||
{ | ||
if (!is_null($this->groupedCodes)) { | ||
return $this->groupedCodes; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
declare(strict_types=1); | ||
namespace jblond\Diff\Renderer\Html; | ||
|
||
use jblond\Diff\Renderer\RendererAbstract; | ||
|
@@ -40,7 +41,7 @@ | |
* @author Chris Boulton <[email protected]> | ||
* @copyright (c) 2009 Chris Boulton | ||
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php | ||
* @version 1.5 | ||
* @version 1.6 | ||
* @link https://github.com/JBlond/php-diff | ||
*/ | ||
|
||
|
@@ -254,12 +255,12 @@ protected function fixSpaces($matches) | |
if ($count == 0) { | ||
continue; | ||
} | ||
$div = ($count / 2); | ||
$div = (int) ($count / 2); | ||
$mod = $count % 2; | ||
$buffer .= str_repeat('  ', $div).str_repeat(' ', $mod); | ||
} | ||
|
||
$div = ($count / 2); | ||
$div = (int) ($count / 2); | ||
$mod = $count % 2; | ||
return str_repeat('  ', $div).str_repeat(' ', $mod); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
declare(strict_types=1); | ||
namespace jblond\Diff\Renderer\Html; | ||
|
||
/** | ||
|
@@ -38,7 +39,7 @@ | |
* @author Chris Boulton <[email protected]> | ||
* @copyright (c) 2009 Chris Boulton | ||
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php | ||
* @version 1.5 | ||
* @version 1.6 | ||
* @link https://github.com/JBlond/php-diff | ||
*/ | ||
|
||
|
@@ -53,7 +54,7 @@ class Inline extends HtmlArray | |
* | ||
* @return string The generated inline diff. | ||
*/ | ||
public function render() | ||
public function render() : string | ||
{ | ||
$changes = parent::render(); | ||
$html = ''; | ||
|
@@ -105,7 +106,7 @@ public function render() | |
* | ||
* @return string Html code representation of the table's header. | ||
*/ | ||
private function generateTableHeader() | ||
private function generateTableHeader() : string | ||
{ | ||
$html = '<table class="Differences DifferencesInline">'; | ||
$html .= '<thead>'; | ||
|
@@ -123,7 +124,7 @@ private function generateTableHeader() | |
* | ||
* @return string Html code representing empty table body. | ||
*/ | ||
private function generateSkippedTable() | ||
private function generateSkippedTable() : string | ||
{ | ||
$html = '<tbody class="Skipped">'; | ||
$html .= '<th>…</th>'; | ||
|
@@ -139,7 +140,7 @@ private function generateSkippedTable() | |
* @param array &$change Array with data about changes. | ||
* @return string Html code representing one or more rows of text with no difference. | ||
*/ | ||
private function generateTableRowsEqual(&$change) | ||
private function generateTableRowsEqual(&$change) : string | ||
{ | ||
$html = ""; | ||
foreach ($change['base']['lines'] as $no => $line) { | ||
|
@@ -160,7 +161,7 @@ private function generateTableRowsEqual(&$change) | |
* @param array &$change Array with data about changes. | ||
* @return string Html code representing one or more rows of added text. | ||
*/ | ||
private function generateTableRowsInsert(&$change) | ||
private function generateTableRowsInsert(&$change) : string | ||
{ | ||
$html = ""; | ||
foreach ($change['changed']['lines'] as $no => $line) { | ||
|
@@ -180,7 +181,7 @@ private function generateTableRowsInsert(&$change) | |
* @param array &$change Array with data about changes. | ||
* @return string Html code representing one or more rows of removed text. | ||
*/ | ||
private function generateTableRowsDelete(&$change) | ||
private function generateTableRowsDelete(&$change) : string | ||
{ | ||
$html = ""; | ||
foreach ($change['base']['lines'] as $no => $line) { | ||
|
@@ -200,7 +201,7 @@ private function generateTableRowsDelete(&$change) | |
* @param array &$change Array with data about changes. | ||
* @return string Html code representing one or more rows of modified. | ||
*/ | ||
private function generateTableRowsReplace(&$change) | ||
private function generateTableRowsReplace(&$change) : string | ||
{ | ||
$html = ""; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
declare(strict_types=1); | ||
namespace jblond\Diff\Renderer\Html; | ||
|
||
/** | ||
|
@@ -38,7 +39,7 @@ | |
* @author Chris Boulton <[email protected]> | ||
* @copyright (c) 2009 Chris Boulton | ||
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php | ||
* @version 1.5 | ||
* @version 1.6 | ||
* @link https://github.com/JBlond/php-diff | ||
*/ | ||
|
||
|
@@ -53,7 +54,7 @@ class SideBySide extends HtmlArray | |
* | ||
* @return string The generated side by side diff. | ||
*/ | ||
public function render() | ||
public function render() : string | ||
{ | ||
$changes = parent::render(); | ||
|
||
|
@@ -102,7 +103,7 @@ public function render() | |
* | ||
* @return string Html code representation of the table's header. | ||
*/ | ||
private function generateTableHeader() | ||
private function generateTableHeader() : string | ||
{ | ||
$html = '<table class="Differences DifferencesSideBySide">'; | ||
$html .= '<thead>'; | ||
|
@@ -119,7 +120,7 @@ private function generateTableHeader() | |
* | ||
* @return string Html code representing empty table body. | ||
*/ | ||
private function generateSkippedTable() | ||
private function generateSkippedTable() : string | ||
{ | ||
$html = '<tbody class="Skipped">'; | ||
$html .= '<th>…</th><td> </td>'; | ||
|
@@ -134,7 +135,7 @@ private function generateSkippedTable() | |
* @param array &$change Array with data about changes. | ||
* @return string Html code representing one or more rows of text with no difference. | ||
*/ | ||
private function generateTableRowsEqual(&$change) | ||
private function generateTableRowsEqual(&$change) : string | ||
{ | ||
$html = ""; | ||
foreach ($change['base']['lines'] as $no => $line) { | ||
|
@@ -156,7 +157,7 @@ private function generateTableRowsEqual(&$change) | |
* @param array &$change Array with data about changes. | ||
* @return string Html code representing one or more rows of added text. | ||
*/ | ||
private function generateTableRowsInsert(&$change) | ||
private function generateTableRowsInsert(&$change) : string | ||
{ | ||
$html = ""; | ||
foreach ($change['changed']['lines'] as $no => $line) { | ||
|
@@ -177,7 +178,7 @@ private function generateTableRowsInsert(&$change) | |
* @param array &$change Array with data about changes. | ||
* @return string Html code representing one or more rows of removed text. | ||
*/ | ||
private function generateTableRowsDelete(&$change) | ||
private function generateTableRowsDelete(&$change) : string | ||
{ | ||
$html = ""; | ||
foreach ($change['base']['lines'] as $no => $line) { | ||
|
@@ -198,7 +199,7 @@ private function generateTableRowsDelete(&$change) | |
* @param array &$change Array with data about changes. | ||
* @return string Html code representing one or more rows of modified. | ||
*/ | ||
private function generateTableRowsReplace(&$change) | ||
private function generateTableRowsReplace(&$change) : string | ||
{ | ||
$html = ""; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
declare(strict_types=1); | ||
namespace jblond\Diff\Renderer; | ||
|
||
/** | ||
|
@@ -38,7 +39,7 @@ | |
* @author Chris Boulton <[email protected]> | ||
* @copyright (c) 2009 Chris Boulton | ||
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php | ||
* @version 1.5 | ||
* @version 1.6 | ||
* @link https://github.com/JBlond/php-diff | ||
*/ | ||
abstract class RendererAbstract | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
declare(strict_types=1); | ||
namespace jblond\Diff\Renderer\Text; | ||
|
||
use jblond\Diff\Renderer\RendererAbstract; | ||
|
@@ -40,7 +41,7 @@ | |
* @author Chris Boulton <[email protected]> | ||
* @copyright (c) 2009 Chris Boulton | ||
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php | ||
* @version 1.5 | ||
* @version 1.6 | ||
* @link https://github.com/JBlond/php-diff | ||
*/ | ||
|
||
|
@@ -64,7 +65,7 @@ class Context extends RendererAbstract | |
* | ||
* @return string The generated context diff. | ||
*/ | ||
public function render() | ||
public function render() : string | ||
{ | ||
$diff = ''; | ||
$opCodes = $this->diff->getGroupedOpcodes(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
declare(strict_types=1); | ||
namespace jblond\Diff\Renderer\Text; | ||
|
||
use jblond\Diff\Renderer\RendererAbstract; | ||
|
@@ -40,7 +41,7 @@ | |
* @author Chris Boulton <[email protected]> | ||
* @copyright (c) 2009 Chris Boulton | ||
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php | ||
* @version 1.5 | ||
* @version 1.6 | ||
* @link https://github.com/JBlond/php-diff | ||
*/ | ||
|
||
|
@@ -54,7 +55,7 @@ class Unified extends RendererAbstract | |
* | ||
* @return string The unified diff. | ||
*/ | ||
public function render() | ||
public function render() : string | ||
{ | ||
$diff = ''; | ||
$opCodes = $this->diff->getGroupedOpcodes(); | ||
|
Oops, something went wrong.