Skip to content

Commit 5330cd2

Browse files
committed
Uniform the term "base, changed" into "old, new"
Signed-off-by: Jack Cherng <jfcherng@gmail.com>
1 parent 347935c commit 5330cd2

File tree

3 files changed

+51
-51
lines changed

3 files changed

+51
-51
lines changed

src/Renderer/Html/AbstractHtml.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ public function getChanges(): array
8080
if (!empty($lines = \array_slice($old, $i1, ($i2 - $i1)))) {
8181
$formattedLines = $this->formatLines($lines);
8282

83-
$blocks[$lastBlock]['base']['lines'] += $formattedLines;
84-
$blocks[$lastBlock]['changed']['lines'] += $formattedLines;
83+
$blocks[$lastBlock]['old']['lines'] += $formattedLines;
84+
$blocks[$lastBlock]['new']['lines'] += $formattedLines;
8585
}
8686

8787
continue;
@@ -109,7 +109,7 @@ public function getChanges(): array
109109
$lines
110110
);
111111

112-
$blocks[$lastBlock]['base']['lines'] += $lines;
112+
$blocks[$lastBlock]['old']['lines'] += $lines;
113113
}
114114

115115
if (
@@ -124,7 +124,7 @@ public function getChanges(): array
124124
$lines
125125
);
126126

127-
$blocks[$lastBlock]['changed']['lines'] += $lines;
127+
$blocks[$lastBlock]['new']['lines'] += $lines;
128128
}
129129
}
130130

@@ -167,20 +167,20 @@ protected function renderChangedExtent(AbstractLineRenderer $lineRenderer, strin
167167
* Get the default block.
168168
*
169169
* @param string $tag the operation tag
170-
* @param int $i1 begin index of the diff of the source
171-
* @param int $j1 begin index of the diff of the destination
170+
* @param int $i1 begin index of the diff of the old array
171+
* @param int $j1 begin index of the diff of the new array
172172
*
173173
* @return array the default block
174174
*/
175175
protected function getDefaultBlock(string $tag, int $i1, int $j1): array
176176
{
177177
return [
178178
'tag' => $tag,
179-
'base' => [
179+
'old' => [
180180
'offset' => $i1,
181181
'lines' => [],
182182
],
183-
'changed' => [
183+
'new' => [
184184
'offset' => $j1,
185185
'lines' => [],
186186
],

src/Renderer/Html/Inline.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,14 @@ protected function renderTableEqual(array $change): string
124124
{
125125
$html = '';
126126

127-
foreach ($change['base']['lines'] as $no => $line) {
128-
$oldLineNum = $change['base']['offset'] + $no + 1;
129-
$newLineNum = $change['changed']['offset'] + $no + 1;
127+
foreach ($change['old']['lines'] as $no => $line) {
128+
$oldLineNum = $change['old']['offset'] + $no + 1;
129+
$newLineNum = $change['new']['offset'] + $no + 1;
130130

131131
$html .=
132132
'<tr data-type="=">' .
133-
'<th class="f-num">' . $oldLineNum . '</th>' .
134-
'<th class="t-num">' . $newLineNum . '</th>' .
133+
'<th class="n-old">' . $oldLineNum . '</th>' .
134+
'<th class="n-new">' . $newLineNum . '</th>' .
135135
'<th class="sign"></th>' .
136136
'<td class="old">' . $line . '</td>' .
137137
'</tr>';
@@ -151,13 +151,13 @@ protected function renderTableInsert(array $change): string
151151
{
152152
$html = '';
153153

154-
foreach ($change['changed']['lines'] as $no => $newLine) {
155-
$newLineNum = $change['changed']['offset'] + $no + 1;
154+
foreach ($change['new']['lines'] as $no => $newLine) {
155+
$newLineNum = $change['new']['offset'] + $no + 1;
156156

157157
$html .=
158158
'<tr data-type="+">' .
159159
'<th></th>' .
160-
'<th class="t-num">' . $newLineNum . '</th>' .
160+
'<th class="n-new">' . $newLineNum . '</th>' .
161161
'<th class="sign ins">+</th>' .
162162
'<td class="new">' . $newLine . '</td>' .
163163
'</tr>';
@@ -177,12 +177,12 @@ protected function renderTableDelete(array $change): string
177177
{
178178
$html = '';
179179

180-
foreach ($change['base']['lines'] as $no => $oldLine) {
181-
$oldLineNum = $change['base']['offset'] + $no + 1;
180+
foreach ($change['old']['lines'] as $no => $oldLine) {
181+
$oldLineNum = $change['old']['offset'] + $no + 1;
182182

183183
$html .=
184184
'<tr data-type="-">' .
185-
'<th class="f-num">' . $oldLineNum . '</th>' .
185+
'<th class="n-old">' . $oldLineNum . '</th>' .
186186
'<th></th>' .
187187
'<th class="sign del">-</th>' .
188188
'<td class="old">' . $oldLine . '</td>' .
@@ -203,25 +203,25 @@ protected function renderTableReplace(array $change): string
203203
{
204204
$html = '';
205205

206-
foreach ($change['base']['lines'] as $no => $oldLine) {
207-
$oldLineNum = $change['base']['offset'] + $no + 1;
206+
foreach ($change['old']['lines'] as $no => $oldLine) {
207+
$oldLineNum = $change['old']['offset'] + $no + 1;
208208

209209
$html .=
210210
'<tr data-type="-">' .
211-
'<th class="f-num">' . $oldLineNum . '</th>' .
211+
'<th class="n-old">' . $oldLineNum . '</th>' .
212212
'<th></th>' .
213213
'<th class="sign del">-</th>' .
214214
'<td class="old">' . $oldLine . '</td>' .
215215
'</tr>';
216216
}
217217

218-
foreach ($change['changed']['lines'] as $no => $newLine) {
219-
$newLineNum = $change['changed']['offset'] + $no + 1;
218+
foreach ($change['new']['lines'] as $no => $newLine) {
219+
$newLineNum = $change['new']['offset'] + $no + 1;
220220

221221
$html .=
222222
'<tr data-type="+">' .
223223
'<th></th>' .
224-
'<th class="t-num">' . $newLineNum . '</th>' .
224+
'<th class="n-new">' . $newLineNum . '</th>' .
225225
'<th class="sign ins">+</th>' .
226226
'<td class="new">' . $newLine . '</td>' .
227227
'</tr>';

src/Renderer/Html/SideBySide.php

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,15 @@ protected function renderTableEqual(array $change): string
122122
{
123123
$html = '';
124124

125-
foreach ($change['base']['lines'] as $no => $line) {
126-
$oldLineNum = $change['base']['offset'] + $no + 1;
127-
$newLine = $change['changed']['offset'] + $no + 1;
125+
foreach ($change['old']['lines'] as $no => $line) {
126+
$oldLineNum = $change['old']['offset'] + $no + 1;
127+
$newLine = $change['new']['offset'] + $no + 1;
128128

129129
$html .=
130130
'<tr>' .
131-
'<th class="f-num">' . $oldLineNum . '</th>' .
131+
'<th class="n-old">' . $oldLineNum . '</th>' .
132132
'<td class="old">' . $line . '</td>' .
133-
'<th class="t-num">' . $newLine . '</th>' .
133+
'<th class="n-new">' . $newLine . '</th>' .
134134
'<td class="new">' . $line . '</td>' .
135135
'</tr>';
136136
}
@@ -149,14 +149,14 @@ protected function renderTableInsert(array $change): string
149149
{
150150
$html = '';
151151

152-
foreach ($change['changed']['lines'] as $no => $newLine) {
153-
$newLineNum = $change['changed']['offset'] + $no + 1;
152+
foreach ($change['new']['lines'] as $no => $newLine) {
153+
$newLineNum = $change['new']['offset'] + $no + 1;
154154

155155
$html .=
156156
'<tr>' .
157157
'<th></th>' .
158158
'<td class="old"></td>' .
159-
'<th class="t-num">' . $newLineNum . '</th>' .
159+
'<th class="n-new">' . $newLineNum . '</th>' .
160160
'<td class="new">' . $newLine . '</td>' .
161161
'</tr>';
162162
}
@@ -175,12 +175,12 @@ protected function renderTableDelete(array $change): string
175175
{
176176
$html = '';
177177

178-
foreach ($change['base']['lines'] as $no => $oldLine) {
179-
$oldLineNum = $change['base']['offset'] + $no + 1;
178+
foreach ($change['old']['lines'] as $no => $oldLine) {
179+
$oldLineNum = $change['old']['offset'] + $no + 1;
180180

181181
$html .=
182182
'<tr>' .
183-
'<th class="f-num">' . $oldLineNum . '</th>' .
183+
'<th class="n-old">' . $oldLineNum . '</th>' .
184184
'<td class="old">' . $oldLine . '</td>' .
185185
'<th></th>' .
186186
'<td class="new"></td>' .
@@ -201,43 +201,43 @@ protected function renderTableReplace(array $change): string
201201
{
202202
$html = '';
203203

204-
if (\count($change['base']['lines']) >= \count($change['changed']['lines'])) {
205-
foreach ($change['base']['lines'] as $no => $oldLine) {
206-
$oldLineNum = $change['base']['offset'] + $no + 1;
204+
if (\count($change['old']['lines']) >= \count($change['new']['lines'])) {
205+
foreach ($change['old']['lines'] as $no => $oldLine) {
206+
$oldLineNum = $change['old']['offset'] + $no + 1;
207207

208-
if (isset($change['changed']['lines'][$no])) {
209-
$newLineNum = $change['base']['offset'] + $no + 1;
210-
$newLine = '<span>' . $change['changed']['lines'][$no] . '</span>';
208+
if (isset($change['new']['lines'][$no])) {
209+
$newLineNum = $change['old']['offset'] + $no + 1;
210+
$newLine = '<span>' . $change['new']['lines'][$no] . '</span>';
211211
} else {
212212
$newLineNum = '';
213213
$newLine = '';
214214
}
215215

216216
$html .=
217217
'<tr>' .
218-
'<th class="f-num">' . $oldLineNum . '</th>' .
218+
'<th class="n-old">' . $oldLineNum . '</th>' .
219219
'<td class="old"><span>' . $oldLine . '</span></td>' .
220-
'<th class="t-num">' . $newLineNum . '</th>' .
220+
'<th class="n-new">' . $newLineNum . '</th>' .
221221
'<td class="new">' . $newLine . '</td>' .
222222
'</tr>';
223223
}
224224
} else {
225-
foreach ($change['changed']['lines'] as $no => $newLine) {
226-
$newLineNum = $change['changed']['offset'] + $no + 1;
225+
foreach ($change['new']['lines'] as $no => $newLine) {
226+
$newLineNum = $change['new']['offset'] + $no + 1;
227227

228-
if (isset($change['base']['lines'][$no])) {
229-
$oldLineNum = $change['base']['offset'] + $no + 1;
230-
$oldLine = '<span>' . $change['base']['lines'][$no] . '</span>';
228+
if (isset($change['old']['lines'][$no])) {
229+
$oldLineNum = $change['old']['offset'] + $no + 1;
230+
$oldLine = '<span>' . $change['old']['lines'][$no] . '</span>';
231231
} else {
232232
$oldLineNum = '';
233233
$oldLine = '';
234234
}
235235

236236
$html .=
237237
'<tr>' .
238-
'<th class="f-num">' . $oldLineNum . '</th>' .
238+
'<th class="n-old">' . $oldLineNum . '</th>' .
239239
'<td class="old"><span>' . $oldLine . '</span></td>' .
240-
'<th class="t-num">' . $newLineNum . '</th>' .
240+
'<th class="n-new">' . $newLineNum . '</th>' .
241241
'<td class="new">' . $newLine . '</td>' .
242242
'</tr>';
243243
}

0 commit comments

Comments
 (0)