@@ -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 ;
0 commit comments