Skip to content

Development merge #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ example.php.

Requirements
-----------
PHP Multibyte String
- PHP 7.1 or greater
- PHP Multibyte String

Merge files using jQuery
------------------------
Expand All @@ -50,6 +51,7 @@ Contributors since I forked the repo.

- maxxer
- Creris
- jfcherng

License (BSD License)
---------------------
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}
],
"require": {
"php" : ">= 5.4",
"php" : ">= 7.1",
"ext-mbstring": "*"
},
"require-dev": {
Expand Down
9 changes: 5 additions & 4 deletions lib/jblond/Diff.php
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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions lib/jblond/Diff/Renderer/Html/HtmlArray.php
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;
Expand Down Expand Up @@ -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
*/

Expand Down Expand Up @@ -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('&#xA0; ', $div).str_repeat('&#xA0;', $mod);
}

$div = ($count / 2);
$div = (int) ($count / 2);
$mod = $count % 2;
return str_repeat('&#xA0; ', $div).str_repeat('&#xA0;', $mod);
}
Expand Down
17 changes: 9 additions & 8 deletions lib/jblond/Diff/Renderer/Html/Inline.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace jblond\Diff\Renderer\Html;

/**
Expand Down Expand Up @@ -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
*/

Expand All @@ -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 = '';
Expand Down Expand Up @@ -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>';
Expand All @@ -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>&hellip;</th>';
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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 = "";

Expand Down
17 changes: 9 additions & 8 deletions lib/jblond/Diff/Renderer/Html/SideBySide.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace jblond\Diff\Renderer\Html;

/**
Expand Down Expand Up @@ -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
*/

Expand All @@ -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();

Expand Down Expand Up @@ -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>';
Expand All @@ -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>&hellip;</th><td>&#xA0;</td>';
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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 = "";

Expand Down
3 changes: 2 additions & 1 deletion lib/jblond/Diff/Renderer/RendererAbstract.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace jblond\Diff\Renderer;

/**
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions lib/jblond/Diff/Renderer/Text/Context.php
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;
Expand Down Expand Up @@ -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
*/

Expand All @@ -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();
Expand Down
5 changes: 3 additions & 2 deletions lib/jblond/Diff/Renderer/Text/Unified.php
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;
Expand Down Expand Up @@ -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
*/

Expand All @@ -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();
Expand Down
Loading