Skip to content

Commit 7e900f2

Browse files
committed
Styling clean-up and additional docblocs
1 parent a81b56e commit 7e900f2

File tree

8 files changed

+45
-25
lines changed

8 files changed

+45
-25
lines changed

lib/Caxy/HtmlDiff/Table/AbstractTableElement.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ public function getInnerHtml()
6464
*
6565
* @return string
6666
*/
67-
public function getAttribute($name) {
67+
public function getAttribute($name)
68+
{
6869
return $this->domNode->getAttribute($name);
6970
}
7071

lib/Caxy/HtmlDiff/Table/DiffRowPosition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,4 +265,4 @@ public function getLesserColumnType()
265265

266266
return null;
267267
}
268-
}
268+
}

lib/Caxy/HtmlDiff/Table/RowMatch.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,18 @@ class RowMatch
2929
protected $endInOld;
3030

3131
/**
32-
* @var int|null
32+
* @var float|null
3333
*/
3434
protected $percentage;
3535

3636
/**
3737
* RowMatch constructor.
3838
*
39-
* @param $startInNew
40-
* @param $startInOld
41-
* @param $endInNew
42-
* @param $endInOld
39+
* @param int $startInNew
40+
* @param int $startInOld
41+
* @param int $endInNew
42+
* @param int $endInOld
43+
* @param float|null $percentage
4344
*/
4445
public function __construct($startInNew = 0, $startInOld = 0, $endInNew = 0, $endInOld = 0, $percentage = null)
4546
{
@@ -129,6 +130,4 @@ public function setEndInOld($endInOld)
129130

130131
return $this;
131132
}
132-
133-
134133
}

lib/Caxy/HtmlDiff/Table/Table.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
class Table extends AbstractTableElement
1010
{
1111
/**
12-
* @var array
12+
* @var TableRow[]
1313
*/
1414
protected $rows = array();
1515

1616
/**
17-
* @return array
17+
* @return TableRow[]
1818
*/
1919
public function getRows()
2020
{

lib/Caxy/HtmlDiff/Table/TableDiff.php

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class TableDiff extends AbstractDiff
2323
protected $newTable = null;
2424

2525
/**
26-
* @var null|Table
26+
* @var null|\DOMElement
2727
*/
2828
protected $diffTable = null;
2929

@@ -205,8 +205,12 @@ protected function diffTableRowsWithMatches($oldRows, $newRows, $matches)
205205
* @param array $appliedRowSpans
206206
* @param bool $forceExpansion
207207
*/
208-
protected function processInsertOperation(Operation $operation, $newRows, &$appliedRowSpans, $forceExpansion = false)
209-
{
208+
protected function processInsertOperation(
209+
Operation $operation,
210+
$newRows,
211+
&$appliedRowSpans,
212+
$forceExpansion = false
213+
) {
210214
$targetRows = array_slice($newRows, $operation->startInNew, $operation->endInNew - $operation->startInNew);
211215
foreach ($targetRows as $row) {
212216
$this->diffAndAppendRows(null, $row, $appliedRowSpans, $forceExpansion);
@@ -219,8 +223,12 @@ protected function processInsertOperation(Operation $operation, $newRows, &$appl
219223
* @param array $appliedRowSpans
220224
* @param bool $forceExpansion
221225
*/
222-
protected function processDeleteOperation(Operation $operation, $oldRows, &$appliedRowSpans, $forceExpansion = false)
223-
{
226+
protected function processDeleteOperation(
227+
Operation $operation,
228+
$oldRows,
229+
&$appliedRowSpans,
230+
$forceExpansion = false
231+
) {
224232
$targetRows = array_slice($oldRows, $operation->startInOld, $operation->endInOld - $operation->startInOld);
225233
foreach ($targetRows as $row) {
226234
$this->diffAndAppendRows($row, null, $appliedRowSpans, $forceExpansion);
@@ -235,8 +243,12 @@ protected function processDeleteOperation(Operation $operation, $oldRows, &$appl
235243
*/
236244
protected function processEqualOperation(Operation $operation, $oldRows, $newRows, &$appliedRowSpans)
237245
{
238-
$targetOldRows = array_values(array_slice($oldRows, $operation->startInOld, $operation->endInOld - $operation->startInOld));
239-
$targetNewRows = array_values(array_slice($newRows, $operation->startInNew, $operation->endInNew - $operation->startInNew));
246+
$targetOldRows = array_values(
247+
array_slice($oldRows, $operation->startInOld, $operation->endInOld - $operation->startInOld)
248+
);
249+
$targetNewRows = array_values(
250+
array_slice($newRows, $operation->startInNew, $operation->endInNew - $operation->startInNew)
251+
);
240252

241253
foreach ($targetNewRows as $index => $newRow) {
242254
if (!isset($targetOldRows[$index])) {
@@ -382,12 +394,13 @@ protected function findRowMatch($newMatchData, $startInOld, $endInOld, $startInN
382394
* @param array $appliedRowSpans
383395
* @param bool $forceExpansion
384396
*
385-
* @return \DOMNode
397+
* @return array
386398
*/
387399
protected function diffRows($oldRow, $newRow, array &$appliedRowSpans, $forceExpansion = false)
388400
{
389401
// create tr dom element
390402
$rowToClone = $newRow ?: $oldRow;
403+
/* @var $diffRow \DOMElement */
391404
$diffRow = $this->diffDom->importNode($rowToClone->getDomNode()->cloneNode(false), false);
392405

393406
$oldCells = $oldRow ? $oldRow->getCells() : array();
@@ -397,7 +410,9 @@ protected function diffRows($oldRow, $newRow, array &$appliedRowSpans, $forceExp
397410

398411
$extraRow = null;
399412

413+
/* @var $expandCells \DOMElement[] */
400414
$expandCells = array();
415+
/* @var $cellsWithMultipleRows \DOMElement[] */
401416
$cellsWithMultipleRows = array();
402417

403418
$newCellCount = count($newCells);
@@ -425,6 +440,7 @@ protected function diffRows($oldRow, $newRow, array &$appliedRowSpans, $forceExp
425440

426441
if ($oldCell && $newCell->getColspan() != $oldCell->getColspan()) {
427442
if (null === $extraRow) {
443+
/* @var $extraRow \DOMElement */
428444
$extraRow = $this->diffDom->importNode($rowToClone->getDomNode()->cloneNode(false), false);
429445
}
430446

@@ -475,14 +491,17 @@ protected function diffRows($oldRow, $newRow, array &$appliedRowSpans, $forceExp
475491

476492
if ($extraRow) {
477493
foreach ($expandCells as $expandCell) {
478-
$expandCell->setAttribute('rowspan', $expandCell->getAttribute('rowspan') + 1);
494+
$rowspan = $expandCell->getAttribute('rowspan') ?: 1;
495+
$expandCell->setAttribute('rowspan', 1 + $rowspan);
479496
}
480497
}
481498

482499
if ($extraRow || $forceExpansion) {
483500
foreach ($appliedRowSpans as $rowSpanCells) {
501+
/* @var $rowSpanCells \DOMElement[] */
484502
foreach ($rowSpanCells as $extendCell) {
485-
$extendCell->setAttribute('rowspan', $extendCell->getAttribute('rowspan') + 1);
503+
$rowspan = $extendCell->getAttribute('rowspan') ?: 1;
504+
$extendCell->setAttribute('rowspan', 1 + $rowspan);
486505
}
487506
}
488507
}
@@ -513,6 +532,7 @@ protected function getNewCellNode(TableCell $oldCell = null, TableCell $newCell
513532
$oldNode = $oldCell->getDomNode();
514533
$newNode = $newCell->getDomNode();
515534

535+
/* @var $clone \DOMElement */
516536
$clone = $newNode->cloneNode(false);
517537

518538
$oldRowspan = $oldNode->getAttribute('rowspan') ?: 1;

lib/Caxy/HtmlDiff/Table/TableMatch.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Class TableMatch
77
* @package Caxy\HtmlDiff\Table
88
*/
9-
class TableMatch extends AbstractTableElement
9+
class TableMatch
1010
{
1111
/**
1212
* @var int

lib/Caxy/HtmlDiff/Table/TablePosition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Class TablePosition
77
* @package Caxy\HtmlDiff\Table
88
*/
9-
class TablePosition extends AbstractTableElement
9+
class TablePosition
1010
{
1111
/**
1212
* @var int

lib/Caxy/HtmlDiff/Table/TableRow.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class TableRow extends AbstractTableElement
1414
protected $table;
1515

1616
/**
17-
* @var array
17+
* @var TableCell[]
1818
*/
1919
protected $cells = array();
2020

@@ -43,7 +43,7 @@ public function setTable(Table $table = null)
4343
}
4444

4545
/**
46-
* @return array
46+
* @return TableCell[]
4747
*/
4848
public function getCells()
4949
{

0 commit comments

Comments
 (0)