@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | { |
18 | 18 | public function testGetters(): void |
19 | 19 | { |
20 | - $diff = new RangeDifference(0, 1, 2, 3, 4, 5,6); |
|
20 | + $diff = new RangeDifference(0, 1, 2, 3, 4, 5, 6); |
|
21 | 21 | |
22 | 22 | $this->assertSame(0, $diff->getKind()); |
23 | 23 | $this->assertSame(1, $diff->getRightStart()); |
@@ -33,16 +33,16 @@ discard block |
||
33 | 33 | |
34 | 34 | public function testGetMaxLength(): void |
35 | 35 | { |
36 | - $diff = new RangeDifference(0, 1, 2, 3, 4, 5,6); |
|
36 | + $diff = new RangeDifference(0, 1, 2, 3, 4, 5, 6); |
|
37 | 37 | |
38 | 38 | $this->assertSame(6, $diff->getMaxLength()); |
39 | 39 | } |
40 | 40 | |
41 | 41 | public function testIsEqual(): void |
42 | 42 | { |
43 | - $diff1 = new RangeDifference(0, 1, 2, 3, 4, 5,6); |
|
44 | - $diff2 = new RangeDifference(0, 1, 2, 3, 4, 5,6); |
|
45 | - $diff3 = new RangeDifference(1, 1, 2, 3, 4, 5,6); |
|
43 | + $diff1 = new RangeDifference(0, 1, 2, 3, 4, 5, 6); |
|
44 | + $diff2 = new RangeDifference(0, 1, 2, 3, 4, 5, 6); |
|
45 | + $diff3 = new RangeDifference(1, 1, 2, 3, 4, 5, 6); |
|
46 | 46 | |
47 | 47 | $this->assertTrue($diff1->isEqual($diff2)); |
48 | 48 | $this->assertFalse($diff1->isEqual($diff3)); |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | { |
87 | 87 | $attrs = [ |
88 | 88 | 'class' => 'diff-tag-removed', |
89 | - 'id' => 'removed' . $this->removedId, |
|
90 | - 'title' => '#removed' . $this->removedId, |
|
89 | + 'id' => 'removed'.$this->removedId, |
|
90 | + 'title' => '#removed'.$this->removedId, |
|
91 | 91 | ]; |
92 | 92 | $this->removedId++; |
93 | 93 | |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | { |
104 | 104 | $attrs = [ |
105 | 105 | 'class' => 'diff-tag-added', |
106 | - 'id' => 'removed' . $this->addedId, |
|
107 | - 'title' => '#removed' . $this->addedId, |
|
106 | + 'id' => 'removed'.$this->addedId, |
|
107 | + 'title' => '#removed'.$this->addedId, |
|
108 | 108 | ]; |
109 | 109 | $this->addedId++; |
110 | 110 |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | $this->atoms[] = new TextAtom($currentWord); |
47 | 47 | } |
48 | 48 | |
49 | - $this->atoms[] = new TextAtom('' . $c); |
|
49 | + $this->atoms[] = new TextAtom(''.$c); |
|
50 | 50 | $currentWord = ''; |
51 | - } else if (DelimiterAtom::isValidDelimiter('' . $c)) { |
|
51 | + } else if (DelimiterAtom::isValidDelimiter(''.$c)) { |
|
52 | 52 | // A delimiter. |
53 | 53 | if (mb_strlen($currentWord) > 0) { |
54 | 54 | $this->atoms[] = new TextAtom($currentWord); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | public function getAtom(int $i): AtomInterface |
75 | 75 | { |
76 | 76 | if ($i < 0 || $i >= count($this->atoms)) { |
77 | - throw new OutOfBoundsException('There is no Atom with index ' . $i); |
|
77 | + throw new OutOfBoundsException('There is no Atom with index '.$i); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | return $this->atoms[$i]; |
@@ -153,7 +153,7 @@ |
||
153 | 153 | $begin = $end + 1; |
154 | 154 | $end = static::getEOL($text, $begin); |
155 | 155 | |
156 | - if ($end === $begin && "\r" === \mb_substr($text, $begin - 1, 1) && "\n" === \mb_substr($text, $begin, 1)) { |
|
156 | + if ($end === $begin && "\r" === \mb_substr($text, $begin - 1, 1) && "\n" === \mb_substr($text, $begin, 1)) { |
|
157 | 157 | // We have \r followed by \n, skip it. |
158 | 158 | $begin = $end + 1; |
159 | 159 | $end = static::getEOL($text, $begin); |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | return; |
56 | 56 | } |
57 | 57 | |
58 | - $this->maxDifferences = (int)(($length1 + $length2 + 1) / 2); |
|
58 | + $this->maxDifferences = (int) (($length1 + $length2 + 1) / 2); |
|
59 | 59 | |
60 | 60 | if ($length1 * $length2 > self::TOO_LONG) { |
61 | 61 | // Limit complexity to D^POW_LIMIT for long sequences. |
62 | - $this->maxDifferences = (int)\pow($this->maxDifferences, self::POW_LIMIT - 1.0); |
|
62 | + $this->maxDifferences = (int) \pow($this->maxDifferences, self::POW_LIMIT - 1.0); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | $this->initializeLcs($length1); |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | $delta = $N - $M; |
170 | 170 | $isEven = ($delta & 1) === 1 ? false : true; |
171 | 171 | |
172 | - $limit = \min($this->maxDifferences, (int)(($N + $M + 1) / 2)); |
|
172 | + $limit = \min($this->maxDifferences, (int) (($N + $M + 1) / 2)); |
|
173 | 173 | |
174 | 174 | // Offset to make it odd/even. |
175 | 175 | // a 0 or 1 that we add to the start offset to make it odd/even |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | |
317 | 317 | $maxProgress = array_fill( |
318 | 318 | 0, |
319 | - (int)(\max($forwardEndDiag - $forwardStartDiag, $backwardEndDiag - $backwardStartDiag) / 2 + 1), |
|
319 | + (int) (\max($forwardEndDiag - $forwardStartDiag, $backwardEndDiag - $backwardStartDiag) / 2 + 1), |
|
320 | 320 | [0, 0, 0]); |
321 | 321 | // The first entry is current, it is initialized with 0s. |
322 | 322 | $numProgress = 0; |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | } |
374 | 374 | } |
375 | 375 | |
376 | - return $maxProgress[(int)($numProgress / 2)]; |
|
376 | + return $maxProgress[(int) ($numProgress / 2)]; |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | /** |
@@ -245,8 +245,8 @@ |
||
245 | 245 | $N = 2; |
246 | 246 | $limit = 3; |
247 | 247 | $V = [ |
248 | - [0,0,1,1,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], |
|
249 | - [0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], |
|
248 | + [0, 0, 1, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], |
|
249 | + [0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], |
|
250 | 250 | ]; |
251 | 251 | |
252 | 252 | $refMethod = new \ReflectionMethod($lcs, 'findMostProgress'); |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | { |
21 | 21 | public function testLineAdditions(): void |
22 | 22 | { |
23 | - $s1 = 'abc' . PHP_EOL . 'def' . PHP_EOL . 'xyz'; |
|
24 | - $s2 = 'abc' . PHP_EOL . 'def' . PHP_EOL . '123' . PHP_EOL . 'xyz'; |
|
23 | + $s1 = 'abc'.PHP_EOL.'def'.PHP_EOL.'xyz'; |
|
24 | + $s2 = 'abc'.PHP_EOL.'def'.PHP_EOL.'123'.PHP_EOL.'xyz'; |
|
25 | 25 | |
26 | 26 | $l1 = TextLineLCS::getTextLines($s1); |
27 | 27 | $l2 = TextLineLCS::getTextLines($s2); |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | |
42 | 42 | public function testLineDeletion(): void |
43 | 43 | { |
44 | - $s1 = 'abc' . PHP_EOL . 'def' . PHP_EOL . '123' . PHP_EOL . 'xyz'; |
|
45 | - $s2 = 'abc' . PHP_EOL . 'def' . PHP_EOL . 'xyz'; |
|
44 | + $s1 = 'abc'.PHP_EOL.'def'.PHP_EOL.'123'.PHP_EOL.'xyz'; |
|
45 | + $s2 = 'abc'.PHP_EOL.'def'.PHP_EOL.'xyz'; |
|
46 | 46 | |
47 | 47 | $l1 = TextLineLCS::getTextLines($s1); |
48 | 48 | $l2 = TextLineLCS::getTextLines($s2); |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | |
69 | 69 | public function testLineAppendEnd(): void |
70 | 70 | { |
71 | - $s1 = 'abc' . PHP_EOL . 'def'; |
|
72 | - $s2 = 'abc' . PHP_EOL . 'def' . PHP_EOL . '123'; |
|
71 | + $s1 = 'abc'.PHP_EOL.'def'; |
|
72 | + $s2 = 'abc'.PHP_EOL.'def'.PHP_EOL.'123'; |
|
73 | 73 | |
74 | 74 | $l1 = TextLineLCS::getTextLines($s1); |
75 | 75 | $l2 = TextLineLCS::getTextLines($s2); |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | |
95 | 95 | public function testLineDeleteEnd(): void |
96 | 96 | { |
97 | - $s1 = 'abc' . PHP_EOL . 'def' . PHP_EOL . '123'; |
|
98 | - $s2 = 'abc' . PHP_EOL . 'def'; |
|
97 | + $s1 = 'abc'.PHP_EOL.'def'.PHP_EOL.'123'; |
|
98 | + $s2 = 'abc'.PHP_EOL.'def'; |
|
99 | 99 | |
100 | 100 | $l1 = TextLineLCS::getTextLines($s1); |
101 | 101 | $l2 = TextLineLCS::getTextLines($s2); |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | |
121 | 121 | public function testLineAppendStart(): void |
122 | 122 | { |
123 | - $s1 = 'abc' . PHP_EOL . 'def'; |
|
124 | - $s2 = '123' . PHP_EOL . 'abc' . PHP_EOL . 'def'; |
|
123 | + $s1 = 'abc'.PHP_EOL.'def'; |
|
124 | + $s2 = '123'.PHP_EOL.'abc'.PHP_EOL.'def'; |
|
125 | 125 | |
126 | 126 | $l1 = TextLineLCS::getTextLines($s1); |
127 | 127 | $l2 = TextLineLCS::getTextLines($s2); |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | |
147 | 147 | public function testLineDeleteStart(): void |
148 | 148 | { |
149 | - $s1 = '123' . PHP_EOL . 'abc' . PHP_EOL . 'def'; |
|
150 | - $s2 = 'abc' . PHP_EOL . 'def'; |
|
149 | + $s1 = '123'.PHP_EOL.'abc'.PHP_EOL.'def'; |
|
150 | + $s2 = 'abc'.PHP_EOL.'def'; |
|
151 | 151 | |
152 | 152 | $l1 = TextLineLCS::getTextLines($s1); |
153 | 153 | $l2 = TextLineLCS::getTextLines($s2); |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | |
182 | 182 | public function testLong(): void |
183 | 183 | { |
184 | - $s1 = str_repeat('a' . PHP_EOL, 100); |
|
184 | + $s1 = str_repeat('a'.PHP_EOL, 100); |
|
185 | 185 | $l1 = TextLineLCS::getTextLines($s1); |
186 | - $l2 = TextLineLCS::getTextLines($s1 . 'test'); |
|
186 | + $l2 = TextLineLCS::getTextLines($s1.'test'); |
|
187 | 187 | $lcs = new TextLineLCS($l1, $l2); |
188 | 188 | $lcs->longestCommonSubsequence(); |
189 | 189 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | |
193 | 193 | public function testOneDiff(): void |
194 | 194 | { |
195 | - $s1 = str_repeat('a' . PHP_EOL, 100); |
|
195 | + $s1 = str_repeat('a'.PHP_EOL, 100); |
|
196 | 196 | $l1 = TextLineLCS::getTextLines($s1); |
197 | 197 | $l2 = TextLineLCS::getTextLines($s1); |
198 | 198 | $l2[50] = new TextLine(50, 'diff'); |