Skip to content

Commit 1da5da2

Browse files
committed
change to new array format
1 parent 2090f98 commit 1da5da2

File tree

3 files changed

+86
-86
lines changed

3 files changed

+86
-86
lines changed

lib/jblond/Diff/Renderer/RendererAbstract.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,23 @@ abstract class RendererAbstract
3030
/**
3131
* @var array Array of the default options that apply to this renderer.
3232
*/
33-
protected $defaultOptions = array(
33+
protected $defaultOptions = [
3434
'title1' => 'Version1',
3535
'title2' => 'Version2',
36-
);
36+
];
3737

3838
/**
3939
* @var array Array containing the user applied and merged default options for the renderer.
4040
*/
41-
protected $options = array();
41+
protected $options = [];
4242

4343
/**
4444
* The constructor. Instantiates the rendering engine and if options are passed,
4545
* sets the options for the renderer.
4646
*
4747
* @param array $options Optionally, an array of the options for the renderer.
4848
*/
49-
public function __construct(array $options = array())
49+
public function __construct(array $options = [])
5050
{
5151
$this->setOptions($options);
5252
}

lib/jblond/Diff/SequenceMatcher.php

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ class SequenceMatcher
6565
/**
6666
* @var array
6767
*/
68-
private $defaultOptions = array(
68+
private $defaultOptions = [
6969
'context' => 3,
7070
'trimEqual' => true,
7171
'ignoreWhitespace' => false,
7272
'ignoreCase' => false,
7373
'ignoreNewLines' => false,
74-
);
74+
];
7575

7676
/**
7777
* The constructor. With the sequences being passed, they'll be set for the
@@ -86,8 +86,8 @@ class SequenceMatcher
8686
*/
8787
public function __construct($old, $new, array $options = [], $junkCallback = null)
8888
{
89-
$this->old = array();
90-
$this->new = array();
89+
$this->old = [];
90+
$this->new = [];
9191
$this->junkCallback = $junkCallback;
9292
$this->setOptions($options);
9393
$this->setSequences($old, $new);
@@ -164,8 +164,8 @@ public function setSeq2($partB)
164164
private function chainB()
165165
{
166166
$length = count($this->new);
167-
$this->b2j = array();
168-
$popularDict = array();
167+
$this->b2j = [];
168+
$popularDict = [];
169169

170170
for ($i = 0; $i < $length; ++$i) {
171171
$char = $this->new[$i];
@@ -177,9 +177,9 @@ private function chainB()
177177
$this->b2j[$char][] = $i;
178178
}
179179
} else {
180-
$this->b2j[$char] = array(
180+
$this->b2j[$char] = [
181181
$i
182-
);
182+
];
183183
}
184184
}
185185

@@ -188,7 +188,7 @@ private function chainB()
188188
unset($this->b2j[$char]);
189189
}
190190

191-
$this->junkDict = array();
191+
$this->junkDict = [];
192192
if (is_callable($this->junkCallback)) {
193193
foreach (array_keys($popularDict) as $char) {
194194
if (call_user_func($this->junkCallback, $char)) {
@@ -251,11 +251,11 @@ public function findLongestMatch(int $alo, int $ahi, int $blo, int $bhi): array
251251
$bestJ = $blo;
252252
$bestSize = 0;
253253

254-
$j2Len = array();
255-
$nothing = array();
254+
$j2Len = [];
255+
$nothing = [];
256256

257257
for ($i = $alo; $i < $ahi; ++$i) {
258-
$newJ2Len = array();
258+
$newJ2Len = [];
259259
$jDict = $this->arrayGetDefault($this->b2j, $old[$i], $nothing);
260260
foreach ($jDict as $j) {
261261
if ($j < $blo) {
@@ -316,11 +316,11 @@ public function findLongestMatch(int $alo, int $ahi, int $blo, int $bhi): array
316316
++$bestSize;
317317
}
318318

319-
return array(
319+
return [
320320
$bestI,
321321
$bestJ,
322322
$bestSize
323-
);
323+
];
324324
}
325325

326326
/**
@@ -336,7 +336,7 @@ public function linesAreDifferent(int $aIndex, int $bIndex): bool
336336
$lineB = $this->new[$bIndex];
337337

338338
if ($this->options['ignoreWhitespace']) {
339-
$replace = array("\t", ' ');
339+
$replace = ["\t", ' '];
340340
$lineA = str_replace($replace, '', $lineA);
341341
$lineB = str_replace($replace, '', $lineB);
342342
}
@@ -372,38 +372,38 @@ public function getMatchingBlocks(): array
372372
$aLength = count($this->old);
373373
$bLength = count($this->new);
374374

375-
$queue = array(
376-
array(
375+
$queue = [
376+
[
377377
0,
378378
$aLength,
379379
0,
380380
$bLength
381-
)
382-
);
381+
]
382+
];
383383

384-
$matchingBlocks = array();
384+
$matchingBlocks = [];
385385
while (!empty($queue)) {
386386
[$alo, $ahi, $blo, $bhi] = array_pop($queue);
387387
$longestMatch = $this->findLongestMatch($alo, $ahi, $blo, $bhi);
388388
[$list1, $list2, $list3] = $longestMatch;
389389
if ($list3) {
390390
$matchingBlocks[] = $longestMatch;
391391
if ($alo < $list1 && $blo < $list2) {
392-
$queue[] = array(
392+
$queue[] = [
393393
$alo,
394394
$list1,
395395
$blo,
396396
$list2
397-
);
397+
];
398398
}
399399

400400
if ($list1 + $list3 < $ahi && $list2 + $list3 < $bhi) {
401-
$queue[] = array(
401+
$queue[] = [
402402
$list1 + $list3,
403403
$ahi,
404404
$list2 + $list3,
405405
$bhi
406-
);
406+
];
407407
}
408408
}
409409
}
@@ -418,17 +418,17 @@ function ($aArray, $bArray) {
418418
$i1 = 0;
419419
$j1 = 0;
420420
$k1 = 0;
421-
$nonAdjacent = array();
421+
$nonAdjacent = [];
422422
foreach ($matchingBlocks as [$list4, $list5, $list6]) {
423423
if ($i1 + $k1 == $list4 && $j1 + $k1 == $list5) {
424424
$k1 += $list6;
425425
} else {
426426
if ($k1) {
427-
$nonAdjacent[] = array(
427+
$nonAdjacent[] = [
428428
$i1,
429429
$j1,
430430
$k1
431-
);
431+
];
432432
}
433433

434434
$i1 = $list4;
@@ -438,18 +438,18 @@ function ($aArray, $bArray) {
438438
}
439439

440440
if ($k1) {
441-
$nonAdjacent[] = array(
441+
$nonAdjacent[] = [
442442
$i1,
443443
$j1,
444444
$k1
445-
);
445+
];
446446
}
447447

448-
$nonAdjacent[] = array(
448+
$nonAdjacent[] = [
449449
$aLength,
450450
$bLength,
451451
0
452-
);
452+
];
453453

454454
$this->matchingBlocks = $nonAdjacent;
455455
return $this->matchingBlocks;
@@ -485,7 +485,7 @@ public function getOpCodes(): array
485485

486486
$i = 0;
487487
$j = 0;
488-
$this->opCodes = array();
488+
$this->opCodes = [];
489489

490490
$blocks = $this->getMatchingBlocks();
491491
foreach ($blocks as [$ai, $bj, $size]) {
@@ -499,26 +499,26 @@ public function getOpCodes(): array
499499
}
500500

501501
if ($tag) {
502-
$this->opCodes[] = array(
502+
$this->opCodes[] = [
503503
$tag,
504504
$i,
505505
$ai,
506506
$j,
507507
$bj
508-
);
508+
];
509509
}
510510

511511
$i = $ai + $size;
512512
$j = $bj + $size;
513513

514514
if ($size) {
515-
$this->opCodes[] = array(
515+
$this->opCodes[] = [
516516
'equal',
517517
$ai,
518518
$i,
519519
$bj,
520520
$j
521-
);
521+
];
522522
}
523523
}
524524
return $this->opCodes;
@@ -541,69 +541,69 @@ public function getGroupedOpCodes(): array
541541
{
542542
$opCodes = $this->getOpCodes();
543543
if (empty($opCodes)) {
544-
$opCodes = array(
545-
array(
544+
$opCodes = [
545+
[
546546
'equal',
547547
0,
548548
1,
549549
0,
550550
1
551-
)
552-
);
551+
]
552+
];
553553
}
554554

555555
if ($this->options['trimEqual']) {
556556
if ($opCodes['0']['0'] == 'equal') {
557557
// Remove sequences at the start which are out of context.
558-
$opCodes['0'] = array(
558+
$opCodes['0'] = [
559559
$opCodes['0']['0'],
560560
max($opCodes['0']['1'], $opCodes['0']['2'] - $this->options['context']),
561561
$opCodes['0']['2'],
562562
max($opCodes['0']['3'], $opCodes['0']['4'] - $this->options['context']),
563563
$opCodes['0']['4']
564-
);
564+
];
565565
}
566566

567567
$lastItem = count($opCodes) - 1;
568568
if ($opCodes[$lastItem]['0'] == 'equal') {
569569
[$tag, $i1, $i2, $j1, $j2] = $opCodes[$lastItem];
570570
// Remove sequences at the end which are out of context.
571-
$opCodes[$lastItem] = array(
571+
$opCodes[$lastItem] = [
572572
$tag,
573573
$i1,
574574
min($i2, $i1 + $this->options['context']),
575575
$j1,
576576
min($j2, $j1 + $this->options['context'])
577-
);
577+
];
578578
}
579579
}
580580

581581
$maxRange = $this->options['context'] * 2;
582-
$groups = array();
583-
$group = array();
582+
$groups = [];
583+
$group = [];
584584

585585
foreach ($opCodes as [$tag, $i1, $i2, $j1, $j2]) {
586586
if ($tag == 'equal' && $i2 - $i1 > $maxRange) {
587-
$group[] = array(
587+
$group[] = [
588588
$tag,
589589
$i1,
590590
min($i2, $i1 + $this->options['context']),
591591
$j1,
592592
min($j2, $j1 + $this->options['context'])
593-
);
593+
];
594594
$groups[] = $group;
595-
$group = array();
595+
$group = [];
596596
$i1 = max($i1, $i2 - $this->options['context']);
597597
$j1 = max($j1, $j2 - $this->options['context']);
598598
}
599599

600-
$group[] = array(
600+
$group[] = [
601601
$tag,
602602
$i1,
603603
$i2,
604604
$j1,
605605
$j2
606-
);
606+
];
607607
}
608608

609609
if ($this->options['trimEqual'] || (!empty($group) && !(count($group) == 1 && $group[0][0] == 'equal'))) {

0 commit comments

Comments
 (0)