@@ -37,12 +37,13 @@ class MainRenderer extends MainRendererAbstract
3737 *
3838 * This method is called by the renderers which extends this class.
3939 *
40- * @param array $changes Contains the op-codes about the differences between version1 and version2.
41- * @param object $subRenderer Renderer which is subClass of this class.
40+ * @param array $changes Contains the op-codes about the differences between version1 and
41+ * version2.
42+ * @param SubRendererInterface $subRenderer Renderer which is child class of this class.
4243 *
4344 * @return string|false String representation of the differences or false when versions are identical.
4445 */
45- public function renderOutput (array $ changes , object $ subRenderer )
46+ public function renderOutput (array $ changes , SubRendererInterface $ subRenderer )
4647 {
4748 if (!$ changes ) {
4849 //No changes between version1 and version2
@@ -51,13 +52,7 @@ public function renderOutput(array $changes, object $subRenderer)
5152
5253 $ output = $ subRenderer ->generateDiffHeader ();
5354
54- foreach ($ changes as $ iterator => $ blocks ) {
55- if ($ iterator > 0 ) {
56- // If this is a separate block, we're condensing code to indicate a significant portion of the code
57- // has been collapsed as it did not change.
58- $ output .= $ subRenderer ->generateSkippedLines ();
59- }
60-
55+ foreach ($ changes as $ blocks ) {
6156 $ this ->maxLineMarkerWidth = max (
6257 strlen ($ this ->options ['insertMarkers ' ][0 ]),
6358 strlen ($ this ->options ['deleteMarkers ' ][0 ]),
@@ -100,6 +95,10 @@ public function renderOutput(array $changes, object $subRenderer)
10095 // TODO: Keep backward compatible with renderers?
10196 $ output .= $ subRenderer ->generateLinesIgnore ($ change );
10297 break ;
98+ case 'outOfContext ' :
99+ // TODO: Keep backward compatible with renderers?
100+ $ output .= $ subRenderer ->generateLinesOutOfContext ($ change );
101+ break ;
103102 }
104103
105104 $ output .= $ subRenderer ->generateBlockFooter ($ change );
@@ -335,17 +334,15 @@ private function markOuterChange(array &$oldText, array &$newText, int $startOld
335334 // Changes between the lines exist.
336335 // Add markers around the changed character sequence in the old string.
337336 $ sequenceEnd = mb_strlen ($ oldString ) + $ end ;
338- $ oldString
339- = mb_substr ($ oldString , 0 , $ start ) . "\0" .
340- mb_substr ($ oldString , $ start , $ sequenceEnd - $ start ) . "\1" .
341- mb_substr ($ oldString , $ sequenceEnd );
337+ $ oldString = mb_substr ($ oldString , 0 , $ start ) . "\0" .
338+ mb_substr ($ oldString , $ start , $ sequenceEnd - $ start ) . "\1" .
339+ mb_substr ($ oldString , $ sequenceEnd );
342340
343341 // Add markers around the changed character sequence in the new string.
344342 $ sequenceEnd = mb_strlen ($ newString ) + $ end ;
345- $ newString
346- = mb_substr ($ newString , 0 , $ start ) . "\0" .
347- mb_substr ($ newString , $ start , $ sequenceEnd - $ start ) . "\1" .
348- mb_substr ($ newString , $ sequenceEnd );
343+ $ newString = mb_substr ($ newString , 0 , $ start ) . "\0" .
344+ mb_substr ($ newString , $ start , $ sequenceEnd - $ start ) . "\1" .
345+ mb_substr ($ newString , $ sequenceEnd );
349346
350347 // Overwrite the strings in the old and new text so the changed lines include the markers.
351348 $ oldText [$ startOld + $ iterator ] = $ oldString ;
@@ -397,7 +394,7 @@ private function getOuterChange(string $oldString, string $newString): array
397394
398395 /**
399396 * Helper function that will fill the changes-array for the renderer with default values.
400- * Every time an operation changes (specified by $tag) , a new element will be appended to this array.
397+ * Every time an operation changes (specified by $tag), a new element will be appended to this array.
401398 *
402399 * The index of the last element of the array is always returned.
403400 *
@@ -432,7 +429,7 @@ private function appendChangesArray(array &$blocks, string $tag, int $lineInOld,
432429 }
433430
434431 /**
435- * Format a series of strings which are suitable for output in a HTML rendered diff.
432+ * Format a series of strings which are suitable for output in an HTML rendered diff.
436433 *
437434 * This involves replacing tab characters with spaces, making the HTML safe for output by ensuring that double
438435 * spaces are replaced with etc.
0 commit comments