Skip to content

Commit 3244941

Browse files
committed
Merge remote-tracking branch 'origin/development' into development
2 parents 7d22093 + 8b68a5d commit 3244941

File tree

8 files changed

+70
-67
lines changed

8 files changed

+70
-67
lines changed

lib/jblond/Diff.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
* @author Chris Boulton <chris.boulton@interspire.com>
4545
* @copyright (c) 2009 Chris Boulton
4646
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
47-
* @version 1.7
47+
* @version 1.9
4848
* @link https://github.com/JBlond/php-diff
4949
*/
5050
class Diff
@@ -87,7 +87,7 @@ class Diff
8787
* @param array $b Array containing the lines for the second string to compare.
8888
* @param array $options Array for the options
8989
*/
90-
public function __construct($a, $b, $options = array())
90+
public function __construct(array $a, array $b, array $options = array())
9191
{
9292
$this->a = $a;
9393
$this->b = $b;
@@ -119,10 +119,10 @@ public function render($renderer)
119119
* that line.
120120
*
121121
* @param int $start The starting number.
122-
* @param int $end The ending number. If not supplied, only the item in $start will be returned.
122+
* @param int|null $end The ending number. If not supplied, only the item in $start will be returned.
123123
* @return array Array of all of the lines between the specified range.
124124
*/
125-
public function getA($start = 0, $end = null) : array
125+
public function getA(int $start = 0, $end = null) : array
126126
{
127127
if ($start == 0 && $end === null) {
128128
return $this->a;
@@ -144,10 +144,10 @@ public function getA($start = 0, $end = null) : array
144144
* that line.
145145
*
146146
* @param int $start The starting number.
147-
* @param int $end The ending number. If not supplied, only the item in $start will be returned.
147+
* @param int|null $end The ending number. If not supplied, only the item in $start will be returned.
148148
* @return array Array of all of the lines between the specified range.
149149
*/
150-
public function getB($start = 0, $end = null) : array
150+
public function getB(int $start = 0, $end = null) : array
151151
{
152152
if ($start == 0 && $end === null) {
153153
return $this->b;

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* @author Chris Boulton <chris.boulton@interspire.com>
4242
* @copyright (c) 2009 Chris Boulton
4343
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
44-
* @version 1.7
44+
* @version 1.9
4545
* @link https://github.com/JBlond/php-diff
4646
*/
4747

@@ -61,18 +61,18 @@ class HtmlArray extends RendererAbstract
6161

6262
/**
6363
* From https://gist.github.com/stemar/8287074
64-
* @param mixed $string The input string.
65-
* @param mixed $replacement The replacement string.
66-
* @param mixed $start If start is positive, the replacing will begin at the start'th offset into string.
64+
* @param string $string The input string.
65+
* @param string $replacement The replacement string.
66+
* @param int $start If start is positive, the replacing will begin at the start'th offset into string.
6767
* If start is negative, the replacing will begin at the start'th character from the end of string.
68-
* @param mixed $length If given and is positive, it represents the length of the portion of string which is to
68+
* @param int|null $length If given and is positive, it represents the length of the portion of string which is to
6969
* be replaced. If it is negative, it represents the number of characters from the end of string at which to
7070
* stop replacing. If it is not given, then it will default to strlen( string ); i.e. end the replacing at the
7171
* end of string. Of course, if length is zero then this function will have the effect of inserting replacement
7272
* into string at the given start offset.
7373
* @return string|array The result string is returned. If string is an array then array is returned.
7474
*/
75-
public function mbSubstrReplace($string, $replacement, $start, $length = null)
75+
public function mbSubstrReplace(string $string, string $replacement, int $start, $length = null)
7676
{
7777
if (is_array($string)) {
7878
$num = count($string);
@@ -204,7 +204,7 @@ public function render()
204204
* @param string $toLine The second string.
205205
* @return array Array containing the starting position (0 by default) and the ending position (-1 by default)
206206
*/
207-
private function getChangeExtent($fromLine, $toLine)
207+
private function getChangeExtent(string $fromLine, string $toLine)
208208
{
209209
$start = 0;
210210
$limit = min(mb_strlen($fromLine), mb_strlen($toLine));
@@ -230,7 +230,7 @@ private function getChangeExtent($fromLine, $toLine)
230230
* @param array $lines Array of lines to format.
231231
* @return array Array of the formatted lines.
232232
*/
233-
protected function formatLines($lines)
233+
protected function formatLines(array $lines) : array
234234
{
235235
if ($this->options['tabSize'] !== false) {
236236
$lines = array_map(array($this, 'ExpandTabs'), $lines);
@@ -248,7 +248,7 @@ protected function formatLines($lines)
248248
* @param array $matches The string of spaces.
249249
* @return string The HTML representation of the string.
250250
*/
251-
protected function fixSpaces($matches)
251+
protected function fixSpaces(array $matches) : string
252252
{
253253
$buffer = '';
254254
$count = 0;
@@ -273,7 +273,7 @@ protected function fixSpaces($matches)
273273
* @param string $line The containing tabs to convert.
274274
* @return string The line with the tabs converted to spaces.
275275
*/
276-
private function expandTabs($line)
276+
private function expandTabs(string $line) : string
277277
{
278278
$tabSize = $this->options['tabSize'];
279279
while (($pos = strpos($line, "\t")) !== false) {
@@ -292,7 +292,7 @@ private function expandTabs($line)
292292
* @param string $string The string.
293293
* @return string The string with the HTML characters replaced by entities.
294294
*/
295-
private function htmlSafe($string)
295+
private function htmlSafe(string $string) : string
296296
{
297297
return htmlspecialchars($string, ENT_NOQUOTES, 'UTF-8');
298298
}
@@ -303,7 +303,7 @@ private function htmlSafe($string)
303303
* @param integer $j1
304304
* @return array
305305
*/
306-
private function getDefaultArray($tag, $i1, $j1)
306+
private function getDefaultArray(string $tag, int $i1, int $j1) : array
307307
{
308308
return array
309309
(

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
* @author Chris Boulton <chris.boulton@interspire.com>
4040
* @copyright (c) 2009 Chris Boulton
4141
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
42-
* @version 1.7
42+
* @version 1.9
4343
* @link https://github.com/JBlond/php-diff
4444
*/
4545

@@ -140,7 +140,7 @@ private function generateSkippedTable() : string
140140
* @param array &$change Array with data about changes.
141141
* @return string Html code representing one or more rows of text with no difference.
142142
*/
143-
private function generateTableRowsEqual(&$change) : string
143+
private function generateTableRowsEqual(array &$change) : string
144144
{
145145
$html = "";
146146
foreach ($change['base']['lines'] as $no => $line) {
@@ -161,7 +161,7 @@ private function generateTableRowsEqual(&$change) : string
161161
* @param array &$change Array with data about changes.
162162
* @return string Html code representing one or more rows of added text.
163163
*/
164-
private function generateTableRowsInsert(&$change) : string
164+
private function generateTableRowsInsert(array &$change) : string
165165
{
166166
$html = "";
167167
foreach ($change['changed']['lines'] as $no => $line) {
@@ -181,7 +181,7 @@ private function generateTableRowsInsert(&$change) : string
181181
* @param array &$change Array with data about changes.
182182
* @return string Html code representing one or more rows of removed text.
183183
*/
184-
private function generateTableRowsDelete(&$change) : string
184+
private function generateTableRowsDelete(array &$change) : string
185185
{
186186
$html = "";
187187
foreach ($change['base']['lines'] as $no => $line) {
@@ -201,7 +201,7 @@ private function generateTableRowsDelete(&$change) : string
201201
* @param array &$change Array with data about changes.
202202
* @return string Html code representing one or more rows of modified.
203203
*/
204-
private function generateTableRowsReplace(&$change) : string
204+
private function generateTableRowsReplace(array &$change) : string
205205
{
206206
$html = "";
207207

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
* @author Chris Boulton <chris.boulton@interspire.com>
4040
* @copyright (c) 2009 Chris Boulton
4141
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
42-
* @version 1.7
42+
* @version 1.9
4343
* @link https://github.com/JBlond/php-diff
4444
*/
4545

@@ -66,6 +66,9 @@ public function render() : string
6666
$html .= $this->generateTableHeader();
6767

6868
foreach ($changes as $i => $blocks) {
69+
// If this is a separate block, we're condensing code so output ...,
70+
// indicating a significant portion of the code has been collapsed as
71+
// it is the same
6972
if ($i > 0) {
7073
$html .= $this->generateSkippedTable();
7174
}
@@ -135,7 +138,7 @@ private function generateSkippedTable() : string
135138
* @param array &$change Array with data about changes.
136139
* @return string Html code representing one or more rows of text with no difference.
137140
*/
138-
private function generateTableRowsEqual(&$change) : string
141+
private function generateTableRowsEqual(array &$change) : string
139142
{
140143
$html = "";
141144
foreach ($change['base']['lines'] as $no => $line) {
@@ -157,7 +160,7 @@ private function generateTableRowsEqual(&$change) : string
157160
* @param array &$change Array with data about changes.
158161
* @return string Html code representing one or more rows of added text.
159162
*/
160-
private function generateTableRowsInsert(&$change) : string
163+
private function generateTableRowsInsert(array &$change) : string
161164
{
162165
$html = "";
163166
foreach ($change['changed']['lines'] as $no => $line) {
@@ -178,7 +181,7 @@ private function generateTableRowsInsert(&$change) : string
178181
* @param array &$change Array with data about changes.
179182
* @return string Html code representing one or more rows of removed text.
180183
*/
181-
private function generateTableRowsDelete(&$change) : string
184+
private function generateTableRowsDelete(array &$change) : string
182185
{
183186
$html = "";
184187
foreach ($change['base']['lines'] as $no => $line) {
@@ -199,7 +202,7 @@ private function generateTableRowsDelete(&$change) : string
199202
* @param array &$change Array with data about changes.
200203
* @return string Html code representing one or more rows of modified.
201204
*/
202-
private function generateTableRowsReplace(&$change) : string
205+
private function generateTableRowsReplace(array &$change) : string
203206
{
204207
$html = "";
205208

lib/jblond/Diff/Renderer/RendererAbstract.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
* @author Chris Boulton <chris.boulton@interspire.com>
4040
* @copyright (c) 2009 Chris Boulton
4141
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
42-
* @version 1.7
42+
* @version 1.9
4343
* @link https://github.com/JBlond/php-diff
4444
*/
4545
abstract class RendererAbstract

lib/jblond/Diff/Renderer/Text/Context.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* @author Chris Boulton <chris.boulton@interspire.com>
4242
* @copyright (c) 2009 Chris Boulton
4343
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
44-
* @version 1.7
44+
* @version 1.9
4545
* @link https://github.com/JBlond/php-diff
4646
*/
4747

lib/jblond/Diff/Renderer/Text/Unified.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* @author Chris Boulton <chris.boulton@interspire.com>
4242
* @copyright (c) 2009 Chris Boulton
4343
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
44-
* @version 1.7
44+
* @version 1.9
4545
* @link https://github.com/JBlond/php-diff
4646
*/
4747

0 commit comments

Comments
 (0)