@@ -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.', |
@@ -189,14 +189,14 @@ discard block |
||
189 | 189 | // skip any common prefix |
190 | 190 | while ($start <= $end1 && $start <= $end2 && $this->sequence1[$start] === $this->sequence2[$start]) |
191 | 191 | { |
192 | - $start ++; |
|
192 | + $start++; |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | // skip any common suffix |
196 | 196 | while ($end1 >= $start && $end2 >= $start && $this->sequence1[$end1] === $this->sequence2[$end2]) |
197 | 197 | { |
198 | - $end1 --; |
|
199 | - $end2 --; |
|
198 | + $end1--; |
|
199 | + $end2--; |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | // generate the partial diff |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | // generate the full diff |
206 | 206 | $diff = array(); |
207 | 207 | |
208 | - for ($index = 0; $index < $start; $index ++) |
|
208 | + for ($index = 0; $index < $start; $index++) |
|
209 | 209 | { |
210 | 210 | $diff[] = array($this->sequence1[$index], self::UNMODIFIED); |
211 | 211 | } |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | $diff[] = array_pop($partialDiff); |
216 | 216 | } |
217 | 217 | |
218 | - for ($index = $end1 + 1; $index < $totalSequence; $index ++) |
|
218 | + for ($index = $end1 + 1; $index < $totalSequence; $index++) |
|
219 | 219 | { |
220 | 220 | $diff[] = array($this->sequence1[$index], self::UNMODIFIED); |
221 | 221 | } |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | { |
239 | 239 | $split = preg_split('/\R/', $string); |
240 | 240 | |
241 | - if(is_array($split)) |
|
241 | + if (is_array($split)) |
|
242 | 242 | { |
243 | 243 | return $split; |
244 | 244 | } |
@@ -269,19 +269,19 @@ discard block |
||
269 | 269 | $table = array(array_fill(0, $length2 + 1, 0)); |
270 | 270 | |
271 | 271 | // loop over the rows |
272 | - for ($index1 = 1; $index1 <= $length1; $index1 ++){ |
|
272 | + for ($index1 = 1; $index1 <= $length1; $index1++) { |
|
273 | 273 | |
274 | 274 | // create the new row |
275 | 275 | $table[$index1] = array(0); |
276 | 276 | |
277 | 277 | // loop over the columns |
278 | - for ($index2 = 1; $index2 <= $length2; $index2 ++){ |
|
278 | + for ($index2 = 1; $index2 <= $length2; $index2++) { |
|
279 | 279 | |
280 | 280 | // store the longest common subsequence length |
281 | 281 | if ($this->sequence1[$index1 + $start - 1] |
282 | - === $this->sequence2[$index2 + $start - 1]){ |
|
282 | + === $this->sequence2[$index2 + $start - 1]) { |
|
283 | 283 | $table[$index1][$index2] = $table[$index1 - 1][$index2 - 1] + 1; |
284 | - }else{ |
|
284 | + } else { |
|
285 | 285 | $table[$index1][$index2] = |
286 | 286 | max($table[$index1 - 1][$index2], $table[$index1][$index2 - 1]); |
287 | 287 | } |
@@ -320,11 +320,11 @@ discard block |
||
320 | 320 | $index1 > 0 && $index2 > 0 |
321 | 321 | && $this->sequence1[$index1 + $start - 1] |
322 | 322 | === $this->sequence2[$index2 + $start - 1] |
323 | - ){ |
|
323 | + ) { |
|
324 | 324 | // update the diff and the indices |
325 | 325 | $diff[] = array($this->sequence1[$index1 + $start - 1], self::UNMODIFIED); |
326 | - $index1 --; |
|
327 | - $index2 --; |
|
326 | + $index1--; |
|
327 | + $index2--; |
|
328 | 328 | } |
329 | 329 | elseif ( |
330 | 330 | $index2 > 0 |
@@ -332,13 +332,13 @@ discard block |
||
332 | 332 | ) { |
333 | 333 | // update the diff and the indices |
334 | 334 | $diff[] = array($this->sequence2[$index2 + $start - 1], self::INSERTED); |
335 | - $index2 --; |
|
335 | + $index2--; |
|
336 | 336 | } |
337 | 337 | else |
338 | 338 | { |
339 | 339 | // update the diff and the indices |
340 | 340 | $diff[] = array($this->sequence1[$index1 + $start - 1], self::DELETED); |
341 | - $index1 --; |
|
341 | + $index1--; |
|
342 | 342 | } |
343 | 343 | } |
344 | 344 |
@@ -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 |