Skip to content

Commit

Permalink
Fix property visibility and method docBlocks
Browse files Browse the repository at this point in the history
* Visibility of protected properties set to private where possible.
* Replaced method docBlock descriptions with inheritance.
  • Loading branch information
DigiLive committed Nov 19, 2020
1 parent 8e9735f commit 3bc0839
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 142 deletions.
37 changes: 12 additions & 25 deletions lib/jblond/Diff/Renderer/Html/Inline.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Inline extends MainRenderer implements SubRendererInterface
* - title1 Title of the 1st version of text.
* - title2 Title of the 2nd version of text.
*/
protected $subOptions = [
private $subOptions = [
'format' => 'html',
'insertMarkers' => ['<ins>', '</ins>'],
'deleteMarkers' => ['<del>', '</del>'],
Expand All @@ -43,7 +43,7 @@ class Inline extends MainRenderer implements SubRendererInterface
/**
* Inline constructor.
*
* @param array $options Custom defined options for the inline diff renderer.
* @param array $options Custom defined options for the inline diff renderer.
*
* @see Inline::$subOptions
*/
Expand All @@ -54,7 +54,7 @@ public function __construct(array $options = [])
}

/**
* Render and return a diff-view with changes between the two sequences displayed inline (under each other).
* @inheritDoc
*
* @return string|false The generated diff-view or false when there's no difference.
*/
Expand All @@ -66,8 +66,7 @@ public function render()
}

/**
* Generates a string representation of the opening of a table and its header with titles from the sub renderer's
* options.
* @inheritDoc
*
* @return string HTML code representation of a table's header.
*/
Expand All @@ -86,7 +85,7 @@ public function generateDiffHeader(): string
}

/**
* Generates a string representation of table rows with lines that are skipped.
* @inheritDoc
*
* @return string HTML code representation of skipped lines.
*/
Expand All @@ -102,9 +101,7 @@ public function generateSkippedLines(): string
}

/**
* Generate a string representation of table rows with lines without differences between both versions.
*
* @param array $changes Contains the op-codes about the changes between two blocks.
* @inheritDoc
*
* @return string HTML code representing table rows showing text without differences.
*/
Expand All @@ -129,9 +126,7 @@ public function generateLinesEqual(array $changes): string
}

/**
* Generates a string representation of table rows with lines that are added to the 2nd version.
*
* @param array $changes Contains the op-codes about the changes between two blocks of text.
* @inheritDoc
*
* @return string HTML code representing table rows showing with added text.
*/
Expand All @@ -158,9 +153,7 @@ public function generateLinesInsert(array $changes): string
}

/**
* Generates a string representation of table rows with lines that are removed from the 2nd version.
*
* @param array $changes Contains the op-codes about the changes between two blocks of text.
* @inheritDoc
*
* @return string HTML code representing table rows showing removed text.
*/
Expand All @@ -187,9 +180,7 @@ public function generateLinesDelete(array $changes): string
}

/**
* Generates a string representation of table rows with lines that are partially modified.
*
* @param array $changes Contains the op-codes about the changes between two blocks of text.
* @inheritDoc
*
* @return string Html code representing table rows showing modified text.
*/
Expand Down Expand Up @@ -229,9 +220,7 @@ public function generateLinesReplace(array $changes): string
}

/**
* Generate a string representation of the start of a block.
*
* @param array $changes Contains the op-codes about the changes between two blocks of text.
* @inheritDoc
*
* @return string Start of the block.
*/
Expand All @@ -241,9 +230,7 @@ public function generateBlockHeader(array $changes): string
}

/**
* Generate a string representation of the end of a block.
*
* @param array $changes Contains the op-codes about the changes between two blocks of text.
* @inheritDoc
*
* @return string End of the block.
*/
Expand All @@ -253,7 +240,7 @@ public function generateBlockFooter(array $changes): string
}

/**
* Generate a string representation of the end of a diff view.
* @inheritDoc
*
* @return string End of the diff view.
*/
Expand Down
24 changes: 21 additions & 3 deletions lib/jblond/Diff/Renderer/Html/Merged.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Merged extends MainRenderer implements SubRendererInterface
* - title1 Title of the 1st version of text.
* - title2 Title of the 2nd version of text.
*/
protected $subOptions = [
private $subOptions = [
'format' => 'html',
'insertMarkers' => ['<ins>', '</ins>'],
'deleteMarkers' => ['<del>', '</del>'],
Expand All @@ -38,11 +38,11 @@ class Merged extends MainRenderer implements SubRendererInterface
/**
* @var int Line offset to keep correct line number for merged diff.
*/
protected $lineOffset = 0;
private $lineOffset = 0;
/**
* @var string last block of lines which where removed from version 2.
*/
protected $lastDeleted;
private $lastDeleted;

/**
* Merged constructor.
Expand All @@ -69,6 +69,8 @@ public function render()

/**
* @inheritDoc
*
* @return string Start of the diff view.
*/
public function generateDiffHeader(): string
{
Expand All @@ -84,6 +86,8 @@ public function generateDiffHeader(): string

/**
* @inheritDoc
*
* @return string Start of the block.
*/
public function generateBlockHeader(array $changes): string
{
Expand All @@ -92,6 +96,8 @@ public function generateBlockHeader(array $changes): string

/**
* @inheritDoc
*
* @return string Representation of skipped lines.
*/
public function generateSkippedLines(): string
{
Expand All @@ -114,6 +120,8 @@ public function generateSkippedLines(): string

/**
* @inheritDoc
*
* @return string Text with no difference.
*/
public function generateLinesEqual(array $changes): string
{
Expand All @@ -140,6 +148,8 @@ public function generateLinesEqual(array $changes): string

/**
* @inheritDoc
*
* @return string Added text.
*/
public function generateLinesInsert(array $changes): string
{
Expand Down Expand Up @@ -168,6 +178,8 @@ public function generateLinesInsert(array $changes): string

/**
* @inheritDoc
*
* @return string Removed text.
*/
public function generateLinesDelete(array $changes): string
{
Expand All @@ -191,6 +203,8 @@ public function generateLinesDelete(array $changes): string

/**
* @inheritDoc
*
* @return string Modified text.
*/
public function generateLinesReplace(array $changes): string
{
Expand Down Expand Up @@ -234,6 +248,8 @@ function ($removedParts) use ($addedParts) {

/**
* @inheritDoc
*
* @return string End of the block.
*/
public function generateBlockFooter(array $changes): string
{
Expand All @@ -242,6 +258,8 @@ public function generateBlockFooter(array $changes): string

/**
* @inheritDoc
*
* @return string End of the diff view.
*/
public function generateDiffFooter(): string
{
Expand Down
45 changes: 15 additions & 30 deletions lib/jblond/Diff/Renderer/Html/SideBySide.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class SideBySide extends MainRenderer implements SubRendererInterface
* - title1 Title of the 1st version of text.
* - title2 Title of the 2nd version of text.
*/
protected $subOptions = [
private $subOptions = [
'format' => 'html',
'insertMarkers' => ['<ins>', '</ins>'],
'deleteMarkers' => ['<del>', '</del>'],
Expand All @@ -54,7 +54,7 @@ public function __construct(array $options = [])
}

/**
* Render a and return diff-view with changes between the two sequences displayed side by side.
* @inheritDoc
*
* @return string|false The generated diff-view or false when there's no difference.
*/
Expand All @@ -66,7 +66,7 @@ public function render()
}

/**
* Generates a string representation of the opening of a predefined table and its header with titles from options.
* @inheritDoc
*
* @return string HTML code representation of a table's header.
*/
Expand All @@ -84,7 +84,7 @@ public function generateDiffHeader(): string
}

/**
* Generates a string representation of table rows with lines that are skipped.
* @inheritDoc
*
* @return string HTML code representation of a table's header.
*/
Expand All @@ -101,12 +101,7 @@ public function generateSkippedLines(): string
}

/**
* Generate a string representation of table rows with lines without differences between both versions.
*
* Note: Depending on the options, lines can be marked as being equal, while the contents actually differ.
* (E.g. ignoreWhitespace and ignoreCase)
*
* @param array $changes Contains the op-codes about the changes between two blocks.
* @inheritDoc
*
* @return string HTML code representing table rows showing text with no difference.
*/
Expand Down Expand Up @@ -136,9 +131,7 @@ public function generateLinesEqual(array $changes): string
}

/**
* Generates a string representation of table rows with lines that are added to the 2nd version.
*
* @param array $changes Contains the op-codes about the changes between two blocks of text.
* @inheritDoc
*
* @return string HTML code representing table rows showing with added text.
*/
Expand All @@ -165,9 +158,7 @@ public function generateLinesInsert(array $changes): string
}

/**
* Generates a string representation of table rows with lines that are removed from the 2nd version.
*
* @param array $changes Contains the op-codes about the changes between two blocks of text.
* @inheritDoc
*
* @return string HTML code representing table rows showing removed text.
*/
Expand All @@ -194,9 +185,7 @@ public function generateLinesDelete(array $changes): string
}

/**
* Generates a string representation of table rows with lines that are partially modified.
*
* @param array $changes Contains the op-codes about the changes between two blocks of text.
* @inheritDoc
*
* @return string Html code representing table rows showing modified text.
*/
Expand All @@ -208,8 +197,8 @@ public function generateLinesReplace(array $changes): string
if (count($changes['base']['lines']) >= count($changes['changed']['lines'])) {
foreach ($changes['base']['lines'] as $lineNo => $line) {
$fromLine = $changes['base']['offset'] + $lineNo + 1;
$toLine = "&nbsp;";
$changedLine = "&nbsp;";
$toLine = '&nbsp;';
$changedLine = '&nbsp;';
if (isset($changes['changed']['lines'][$lineNo])) {
$toLine = $changes['changed']['offset'] + $lineNo + 1;
$changedLine = $changes['changed']['lines'][$lineNo];
Expand Down Expand Up @@ -237,8 +226,8 @@ public function generateLinesReplace(array $changes): string

foreach ($changes['changed']['lines'] as $lineNo => $changedLine) {
$toLine = $changes['changed']['offset'] + $lineNo + 1;
$fromLine = "&nbsp;";
$line = "&nbsp;";
$fromLine = '&nbsp;';
$line = '&nbsp;';
if (isset($changes['base']['lines'][$lineNo])) {
$fromLine = $changes['base']['offset'] + $lineNo + 1;
$line = $changes['base']['lines'][$lineNo];
Expand All @@ -265,9 +254,7 @@ public function generateLinesReplace(array $changes): string
}

/**
* Generate a string representation of the start of a block.
*
* @param array $changes Contains the op-codes about the changes between two blocks of text.
* @inheritDoc
*
* @return string Start of the block.
*/
Expand All @@ -277,9 +264,7 @@ public function generateBlockHeader(array $changes): string
}

/**
* Generate a string representation of the end of a block.
*
* @param array $changes Contains the op-codes about the changes between two blocks of text.
* @inheritDoc
*
* @return string End of the block.
*/
Expand All @@ -289,7 +274,7 @@ public function generateBlockFooter(array $changes): string
}

/**
* Generate a string representation of the end of a diff view.
* @inheritDoc
*
* @return string End of the diff view.
*/
Expand Down
Loading

0 comments on commit 3bc0839

Please sign in to comment.