@@ -41,7 +41,7 @@ |
||
41 | 41 | $folder = sprintf(__DIR__.'/../../css/%s', $this->fileName); |
42 | 42 | $path = realpath($folder); |
43 | 43 | |
44 | - if($path === false) |
|
44 | + if ($path === false) |
|
45 | 45 | { |
46 | 46 | throw new DiffException( |
47 | 47 | 'Could not find the highlight CSS file', |
@@ -36,9 +36,9 @@ |
||
36 | 36 | // extend the string with the line |
37 | 37 | switch ($line[1]) |
38 | 38 | { |
39 | - case Diff::UNMODIFIED : $string .= ' ' . $line[0];break; |
|
40 | - case Diff::DELETED : $string .= '- ' . $line[0];break; |
|
41 | - case Diff::INSERTED : $string .= '+ ' . $line[0];break; |
|
39 | + case Diff::UNMODIFIED : $string .= ' '.$line[0]; break; |
|
40 | + case Diff::DELETED : $string .= '- '.$line[0]; break; |
|
41 | + case Diff::INSERTED : $string .= '+ '.$line[0]; break; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | // extend the string with the separator |
@@ -133,24 +133,24 @@ discard block |
||
133 | 133 | |
134 | 134 | // extend the HTML with the new row |
135 | 135 | $html .= |
136 | - $i2. "<tr>". $nl . |
|
137 | - $i3. '<td class="text-diff-'.$leftType. '">'. $leftCell . "</td>".$nl. |
|
138 | - $i3. '<td class="text-diff-'.$rightType. '">'. $rightCell . "</td>".$nl. |
|
139 | - $i2. "</tr>".$nl; |
|
136 | + $i2."<tr>".$nl. |
|
137 | + $i3.'<td class="text-diff-'.$leftType.'">'.$leftCell."</td>".$nl. |
|
138 | + $i3.'<td class="text-diff-'.$rightType.'">'.$rightCell."</td>".$nl. |
|
139 | + $i2."</tr>".$nl; |
|
140 | 140 | |
141 | 141 | } |
142 | 142 | |
143 | - return $i1. sprintf($this->container, $nl.$html).$nl; |
|
143 | + return $i1.sprintf($this->container, $nl.$html).$nl; |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | private function resolveLeftType(string $leftCell, string $rightCell) : string |
147 | 147 | { |
148 | - if(empty($leftCell)) |
|
148 | + if (empty($leftCell)) |
|
149 | 149 | { |
150 | 150 | return 'empty'; |
151 | 151 | } |
152 | 152 | |
153 | - if($leftCell !== $rightCell) |
|
153 | + if ($leftCell !== $rightCell) |
|
154 | 154 | { |
155 | 155 | return 'del'; |
156 | 156 | } |
@@ -160,12 +160,12 @@ discard block |
||
160 | 160 | |
161 | 161 | private function resolveRightType(string $leftCell, string $rightCell) : string |
162 | 162 | { |
163 | - if(empty($rightCell)) |
|
163 | + if (empty($rightCell)) |
|
164 | 164 | { |
165 | 165 | return 'empty'; |
166 | 166 | } |
167 | 167 | |
168 | - if($leftCell !== $rightCell) |
|
168 | + if ($leftCell !== $rightCell) |
|
169 | 169 | { |
170 | 170 | return 'ins'; |
171 | 171 | } |
@@ -192,11 +192,11 @@ discard block |
||
192 | 192 | $html .= sprintf( |
193 | 193 | '<%1$s>%2$s</%1$s>%3$s', |
194 | 194 | $tag, |
195 | - htmlspecialchars((string)$this->array[$index][0]), |
|
195 | + htmlspecialchars((string) $this->array[$index][0]), |
|
196 | 196 | $this->separator |
197 | 197 | ); |
198 | 198 | |
199 | - $index ++; |
|
199 | + $index++; |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | return $html; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | |
205 | 205 | private function resolveTag(int $type) : string |
206 | 206 | { |
207 | - switch($type) |
|
207 | + switch ($type) |
|
208 | 208 | { |
209 | 209 | case Diff::DELETED: return 'del'; |
210 | 210 | case Diff::INSERTED: return 'ins'; |
@@ -48,14 +48,14 @@ |
||
48 | 48 | switch ($line[1]) |
49 | 49 | { |
50 | 50 | case Diff::UNMODIFIED : $element = 'span'; break; |
51 | - case Diff::DELETED : $element = 'del'; break; |
|
52 | - case Diff::INSERTED : $element = 'ins'; break; |
|
51 | + case Diff::DELETED : $element = 'del'; break; |
|
52 | + case Diff::INSERTED : $element = 'ins'; break; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | $html .= sprintf( |
56 | 56 | '<%1$s>%2$s</%1$s>', |
57 | 57 | $element, |
58 | - htmlspecialchars((string)$line[0]) |
|
58 | + htmlspecialchars((string) $line[0]) |
|
59 | 59 | ); |
60 | 60 | |
61 | 61 | // extend the HTML with the separator |
@@ -173,8 +173,7 @@ discard block |
||
173 | 173 | { |
174 | 174 | $this->sequence1 = self::splitCharacters($this->string1); |
175 | 175 | $this->sequence2 = self::splitCharacters($this->string2); |
176 | - } |
|
177 | - else |
|
176 | + } else |
|
178 | 177 | { |
179 | 178 | $this->sequence1 = self::splitLines($this->string1); |
180 | 179 | $this->sequence2 = self::splitLines($this->string2); |
@@ -302,7 +301,7 @@ discard block |
||
302 | 301 | if ($this->sequence1[$index1 + $start - 1] |
303 | 302 | === $this->sequence2[$index2 + $start - 1]){ |
304 | 303 | $table[$index1][$index2] = $table[$index1 - 1][$index2 - 1] + 1; |
305 | - }else{ |
|
304 | + } else{ |
|
306 | 305 | $table[$index1][$index2] = |
307 | 306 | max($table[$index1 - 1][$index2], $table[$index1][$index2 - 1]); |
308 | 307 | } |
@@ -346,16 +345,14 @@ discard block |
||
346 | 345 | $diff[] = array($this->sequence1[$index1 + $start - 1], self::UNMODIFIED); |
347 | 346 | $index1 --; |
348 | 347 | $index2 --; |
349 | - } |
|
350 | - elseif ( |
|
348 | + } elseif ( |
|
351 | 349 | $index2 > 0 |
352 | 350 | && $table[$index1][$index2] === $table[$index1][$index2 - 1] |
353 | 351 | ) { |
354 | 352 | // update the diff and the indices |
355 | 353 | $diff[] = array($this->sequence2[$index2 + $start - 1], self::INSERTED); |
356 | 354 | $index2 --; |
357 | - } |
|
358 | - else |
|
355 | + } else |
|
359 | 356 | { |
360 | 357 | // update the diff and the indices |
361 | 358 | $diff[] = array($this->sequence1[$index1 + $start - 1], self::DELETED); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param bool $compare |
66 | 66 | * @return Diff |
67 | 67 | */ |
68 | - public function setCompareCharacters(bool $compare=true) : Diff |
|
68 | + public function setCompareCharacters(bool $compare = true) : Diff |
|
69 | 69 | { |
70 | 70 | $this->compareCharacters = $compare; |
71 | 71 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function toArray() : array |
159 | 159 | { |
160 | - if($this->disposed) |
|
160 | + if ($this->disposed) |
|
161 | 161 | { |
162 | 162 | throw new DiffException( |
163 | 163 | 'The diff has been disposed.', |
@@ -187,14 +187,14 @@ discard block |
||
187 | 187 | // skip any common prefix |
188 | 188 | while ($start <= $end1 && $start <= $end2 && $this->sequence1[$start] === $this->sequence2[$start]) |
189 | 189 | { |
190 | - $start ++; |
|
190 | + $start++; |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | // skip any common suffix |
194 | 194 | while ($end1 >= $start && $end2 >= $start && $this->sequence1[$end1] === $this->sequence2[$end2]) |
195 | 195 | { |
196 | - $end1 --; |
|
197 | - $end2 --; |
|
196 | + $end1--; |
|
197 | + $end2--; |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | // generate the partial diff |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | // generate the full diff |
204 | 204 | $diff = array(); |
205 | 205 | |
206 | - for ($index = 0; $index < $start; $index ++) |
|
206 | + for ($index = 0; $index < $start; $index++) |
|
207 | 207 | { |
208 | 208 | $diff[] = array($this->sequence1[$index], self::UNMODIFIED); |
209 | 209 | } |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | $diff[] = array_pop($partialDiff); |
214 | 214 | } |
215 | 215 | |
216 | - for ($index = $end1 + 1; $index < $totalSequence; $index ++) |
|
216 | + for ($index = $end1 + 1; $index < $totalSequence; $index++) |
|
217 | 217 | { |
218 | 218 | $diff[] = array($this->sequence1[$index], self::UNMODIFIED); |
219 | 219 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | { |
237 | 237 | $split = preg_split('/\R/u', $string); |
238 | 238 | |
239 | - if(is_array($split)) |
|
239 | + if (is_array($split)) |
|
240 | 240 | { |
241 | 241 | return $split; |
242 | 242 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | { |
260 | 260 | $split = mb_str_split($string); |
261 | 261 | |
262 | - if(is_array($split)) |
|
262 | + if (is_array($split)) |
|
263 | 263 | { |
264 | 264 | return $split; |
265 | 265 | } |
@@ -290,19 +290,19 @@ discard block |
||
290 | 290 | $table = array(array_fill(0, $length2 + 1, 0)); |
291 | 291 | |
292 | 292 | // loop over the rows |
293 | - for ($index1 = 1; $index1 <= $length1; $index1 ++){ |
|
293 | + for ($index1 = 1; $index1 <= $length1; $index1++) { |
|
294 | 294 | |
295 | 295 | // create the new row |
296 | 296 | $table[$index1] = array(0); |
297 | 297 | |
298 | 298 | // loop over the columns |
299 | - for ($index2 = 1; $index2 <= $length2; $index2 ++){ |
|
299 | + for ($index2 = 1; $index2 <= $length2; $index2++) { |
|
300 | 300 | |
301 | 301 | // store the longest common subsequence length |
302 | 302 | if ($this->sequence1[$index1 + $start - 1] |
303 | - === $this->sequence2[$index2 + $start - 1]){ |
|
303 | + === $this->sequence2[$index2 + $start - 1]) { |
|
304 | 304 | $table[$index1][$index2] = $table[$index1 - 1][$index2 - 1] + 1; |
305 | - }else{ |
|
305 | + } else { |
|
306 | 306 | $table[$index1][$index2] = |
307 | 307 | max($table[$index1 - 1][$index2], $table[$index1][$index2 - 1]); |
308 | 308 | } |
@@ -341,11 +341,11 @@ discard block |
||
341 | 341 | $index1 > 0 && $index2 > 0 |
342 | 342 | && $this->sequence1[$index1 + $start - 1] |
343 | 343 | === $this->sequence2[$index2 + $start - 1] |
344 | - ){ |
|
344 | + ) { |
|
345 | 345 | // update the diff and the indices |
346 | 346 | $diff[] = array($this->sequence1[$index1 + $start - 1], self::UNMODIFIED); |
347 | - $index1 --; |
|
348 | - $index2 --; |
|
347 | + $index1--; |
|
348 | + $index2--; |
|
349 | 349 | } |
350 | 350 | elseif ( |
351 | 351 | $index2 > 0 |
@@ -353,13 +353,13 @@ discard block |
||
353 | 353 | ) { |
354 | 354 | // update the diff and the indices |
355 | 355 | $diff[] = array($this->sequence2[$index2 + $start - 1], self::INSERTED); |
356 | - $index2 --; |
|
356 | + $index2--; |
|
357 | 357 | } |
358 | 358 | else |
359 | 359 | { |
360 | 360 | // update the diff and the indices |
361 | 361 | $diff[] = array($this->sequence1[$index1 + $start - 1], self::DELETED); |
362 | - $index1 --; |
|
362 | + $index1--; |
|
363 | 363 | } |
364 | 364 | } |
365 | 365 |