Skip to content

Commit 3bc0839

Browse files
committed
Fix property visibility and method docBlocks
* Visibility of protected properties set to private where possible. * Replaced method docBlock descriptions with inheritance.
1 parent 8e9735f commit 3bc0839

File tree

6 files changed

+111
-142
lines changed

6 files changed

+111
-142
lines changed

lib/jblond/Diff/Renderer/Html/Inline.php

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Inline extends MainRenderer implements SubRendererInterface
3232
* - title1 Title of the 1st version of text.
3333
* - title2 Title of the 2nd version of text.
3434
*/
35-
protected $subOptions = [
35+
private $subOptions = [
3636
'format' => 'html',
3737
'insertMarkers' => ['<ins>', '</ins>'],
3838
'deleteMarkers' => ['<del>', '</del>'],
@@ -43,7 +43,7 @@ class Inline extends MainRenderer implements SubRendererInterface
4343
/**
4444
* Inline constructor.
4545
*
46-
* @param array $options Custom defined options for the inline diff renderer.
46+
* @param array $options Custom defined options for the inline diff renderer.
4747
*
4848
* @see Inline::$subOptions
4949
*/
@@ -54,7 +54,7 @@ public function __construct(array $options = [])
5454
}
5555

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

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

8887
/**
89-
* Generates a string representation of table rows with lines that are skipped.
88+
* @inheritDoc
9089
*
9190
* @return string HTML code representation of skipped lines.
9291
*/
@@ -102,9 +101,7 @@ public function generateSkippedLines(): string
102101
}
103102

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

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

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

189182
/**
190-
* Generates a string representation of table rows with lines that are partially modified.
191-
*
192-
* @param array $changes Contains the op-codes about the changes between two blocks of text.
183+
* @inheritDoc
193184
*
194185
* @return string Html code representing table rows showing modified text.
195186
*/
@@ -229,9 +220,7 @@ public function generateLinesReplace(array $changes): string
229220
}
230221

231222
/**
232-
* Generate a string representation of the start of a block.
233-
*
234-
* @param array $changes Contains the op-codes about the changes between two blocks of text.
223+
* @inheritDoc
235224
*
236225
* @return string Start of the block.
237226
*/
@@ -241,9 +230,7 @@ public function generateBlockHeader(array $changes): string
241230
}
242231

243232
/**
244-
* Generate a string representation of the end of a block.
245-
*
246-
* @param array $changes Contains the op-codes about the changes between two blocks of text.
233+
* @inheritDoc
247234
*
248235
* @return string End of the block.
249236
*/
@@ -253,7 +240,7 @@ public function generateBlockFooter(array $changes): string
253240
}
254241

255242
/**
256-
* Generate a string representation of the end of a diff view.
243+
* @inheritDoc
257244
*
258245
* @return string End of the diff view.
259246
*/

lib/jblond/Diff/Renderer/Html/Merged.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Merged extends MainRenderer implements SubRendererInterface
2828
* - title1 Title of the 1st version of text.
2929
* - title2 Title of the 2nd version of text.
3030
*/
31-
protected $subOptions = [
31+
private $subOptions = [
3232
'format' => 'html',
3333
'insertMarkers' => ['<ins>', '</ins>'],
3434
'deleteMarkers' => ['<del>', '</del>'],
@@ -38,11 +38,11 @@ class Merged extends MainRenderer implements SubRendererInterface
3838
/**
3939
* @var int Line offset to keep correct line number for merged diff.
4040
*/
41-
protected $lineOffset = 0;
41+
private $lineOffset = 0;
4242
/**
4343
* @var string last block of lines which where removed from version 2.
4444
*/
45-
protected $lastDeleted;
45+
private $lastDeleted;
4646

4747
/**
4848
* Merged constructor.
@@ -69,6 +69,8 @@ public function render()
6969

7070
/**
7171
* @inheritDoc
72+
*
73+
* @return string Start of the diff view.
7274
*/
7375
public function generateDiffHeader(): string
7476
{
@@ -84,6 +86,8 @@ public function generateDiffHeader(): string
8486

8587
/**
8688
* @inheritDoc
89+
*
90+
* @return string Start of the block.
8791
*/
8892
public function generateBlockHeader(array $changes): string
8993
{
@@ -92,6 +96,8 @@ public function generateBlockHeader(array $changes): string
9296

9397
/**
9498
* @inheritDoc
99+
*
100+
* @return string Representation of skipped lines.
95101
*/
96102
public function generateSkippedLines(): string
97103
{
@@ -114,6 +120,8 @@ public function generateSkippedLines(): string
114120

115121
/**
116122
* @inheritDoc
123+
*
124+
* @return string Text with no difference.
117125
*/
118126
public function generateLinesEqual(array $changes): string
119127
{
@@ -140,6 +148,8 @@ public function generateLinesEqual(array $changes): string
140148

141149
/**
142150
* @inheritDoc
151+
*
152+
* @return string Added text.
143153
*/
144154
public function generateLinesInsert(array $changes): string
145155
{
@@ -168,6 +178,8 @@ public function generateLinesInsert(array $changes): string
168178

169179
/**
170180
* @inheritDoc
181+
*
182+
* @return string Removed text.
171183
*/
172184
public function generateLinesDelete(array $changes): string
173185
{
@@ -191,6 +203,8 @@ public function generateLinesDelete(array $changes): string
191203

192204
/**
193205
* @inheritDoc
206+
*
207+
* @return string Modified text.
194208
*/
195209
public function generateLinesReplace(array $changes): string
196210
{
@@ -234,6 +248,8 @@ function ($removedParts) use ($addedParts) {
234248

235249
/**
236250
* @inheritDoc
251+
*
252+
* @return string End of the block.
237253
*/
238254
public function generateBlockFooter(array $changes): string
239255
{
@@ -242,6 +258,8 @@ public function generateBlockFooter(array $changes): string
242258

243259
/**
244260
* @inheritDoc
261+
*
262+
* @return string End of the diff view.
245263
*/
246264
public function generateDiffFooter(): string
247265
{

lib/jblond/Diff/Renderer/Html/SideBySide.php

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class SideBySide extends MainRenderer implements SubRendererInterface
3232
* - title1 Title of the 1st version of text.
3333
* - title2 Title of the 2nd version of text.
3434
*/
35-
protected $subOptions = [
35+
private $subOptions = [
3636
'format' => 'html',
3737
'insertMarkers' => ['<ins>', '</ins>'],
3838
'deleteMarkers' => ['<del>', '</del>'],
@@ -54,7 +54,7 @@ public function __construct(array $options = [])
5454
}
5555

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

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

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

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

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

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

196187
/**
197-
* Generates a string representation of table rows with lines that are partially modified.
198-
*
199-
* @param array $changes Contains the op-codes about the changes between two blocks of text.
188+
* @inheritDoc
200189
*
201190
* @return string Html code representing table rows showing modified text.
202191
*/
@@ -208,8 +197,8 @@ public function generateLinesReplace(array $changes): string
208197
if (count($changes['base']['lines']) >= count($changes['changed']['lines'])) {
209198
foreach ($changes['base']['lines'] as $lineNo => $line) {
210199
$fromLine = $changes['base']['offset'] + $lineNo + 1;
211-
$toLine = "&nbsp;";
212-
$changedLine = "&nbsp;";
200+
$toLine = '&nbsp;';
201+
$changedLine = '&nbsp;';
213202
if (isset($changes['changed']['lines'][$lineNo])) {
214203
$toLine = $changes['changed']['offset'] + $lineNo + 1;
215204
$changedLine = $changes['changed']['lines'][$lineNo];
@@ -237,8 +226,8 @@ public function generateLinesReplace(array $changes): string
237226

238227
foreach ($changes['changed']['lines'] as $lineNo => $changedLine) {
239228
$toLine = $changes['changed']['offset'] + $lineNo + 1;
240-
$fromLine = "&nbsp;";
241-
$line = "&nbsp;";
229+
$fromLine = '&nbsp;';
230+
$line = '&nbsp;';
242231
if (isset($changes['base']['lines'][$lineNo])) {
243232
$fromLine = $changes['base']['offset'] + $lineNo + 1;
244233
$line = $changes['base']['lines'][$lineNo];
@@ -265,9 +254,7 @@ public function generateLinesReplace(array $changes): string
265254
}
266255

267256
/**
268-
* Generate a string representation of the start of a block.
269-
*
270-
* @param array $changes Contains the op-codes about the changes between two blocks of text.
257+
* @inheritDoc
271258
*
272259
* @return string Start of the block.
273260
*/
@@ -277,9 +264,7 @@ public function generateBlockHeader(array $changes): string
277264
}
278265

279266
/**
280-
* Generate a string representation of the end of a block.
281-
*
282-
* @param array $changes Contains the op-codes about the changes between two blocks of text.
267+
* @inheritDoc
283268
*
284269
* @return string End of the block.
285270
*/
@@ -289,7 +274,7 @@ public function generateBlockFooter(array $changes): string
289274
}
290275

291276
/**
292-
* Generate a string representation of the end of a diff view.
277+
* @inheritDoc
293278
*
294279
* @return string End of the diff view.
295280
*/

0 commit comments

Comments
 (0)