@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * @param bool $compare |
| 81 | 81 | * @return Diff |
| 82 | 82 | */ |
| 83 | - public function setCompareCharacters(bool $compare=true) : Diff |
|
| 83 | + public function setCompareCharacters(bool $compare = true) : Diff |
|
| 84 | 84 | { |
| 85 | 85 | $this->compareCharacters = $compare; |
| 86 | 86 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | */ |
| 172 | 172 | public function toArray() : array |
| 173 | 173 | { |
| 174 | - if($this->disposed) |
|
| 174 | + if ($this->disposed) |
|
| 175 | 175 | { |
| 176 | 176 | throw new DiffException( |
| 177 | 177 | 'The diff has been disposed.', |
@@ -201,14 +201,14 @@ discard block |
||
| 201 | 201 | // skip any common prefix |
| 202 | 202 | while ($start <= $end1 && $start <= $end2 && $this->sequence1[$start] == $this->sequence2[$start]) |
| 203 | 203 | { |
| 204 | - $start ++; |
|
| 204 | + $start++; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | // skip any common suffix |
| 208 | 208 | while ($end1 >= $start && $end2 >= $start && $this->sequence1[$end1] == $this->sequence2[$end2]) |
| 209 | 209 | { |
| 210 | - $end1 --; |
|
| 211 | - $end2 --; |
|
| 210 | + $end1--; |
|
| 211 | + $end2--; |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | // compute the table of longest common subsequence lengths |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | // generate the full diff |
| 221 | 221 | $diff = array(); |
| 222 | 222 | |
| 223 | - for ($index = 0; $index < $start; $index ++) |
|
| 223 | + for ($index = 0; $index < $start; $index++) |
|
| 224 | 224 | { |
| 225 | 225 | $diff[] = array($this->sequence1[$index], self::UNMODIFIED); |
| 226 | 226 | } |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | |
| 233 | 233 | $max = ($this->compareCharacters ? strlen($this->sequence1) : count($this->sequence1)); |
| 234 | 234 | |
| 235 | - for ($index = $end1 + 1; $index < $max; $index ++) |
|
| 235 | + for ($index = $end1 + 1; $index < $max; $index++) |
|
| 236 | 236 | { |
| 237 | 237 | $diff[] = array($this->sequence1[$index], self::UNMODIFIED); |
| 238 | 238 | } |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | { |
| 255 | 255 | $split = preg_split('/\R/', $string); |
| 256 | 256 | |
| 257 | - if(is_array($split)) |
|
| 257 | + if (is_array($split)) |
|
| 258 | 258 | { |
| 259 | 259 | return $split; |
| 260 | 260 | } |
@@ -285,19 +285,19 @@ discard block |
||
| 285 | 285 | $table = array(array_fill(0, $length2 + 1, 0)); |
| 286 | 286 | |
| 287 | 287 | // loop over the rows |
| 288 | - for ($index1 = 1; $index1 <= $length1; $index1 ++){ |
|
| 288 | + for ($index1 = 1; $index1 <= $length1; $index1++) { |
|
| 289 | 289 | |
| 290 | 290 | // create the new row |
| 291 | 291 | $table[$index1] = array(0); |
| 292 | 292 | |
| 293 | 293 | // loop over the columns |
| 294 | - for ($index2 = 1; $index2 <= $length2; $index2 ++){ |
|
| 294 | + for ($index2 = 1; $index2 <= $length2; $index2++) { |
|
| 295 | 295 | |
| 296 | 296 | // store the longest common subsequence length |
| 297 | 297 | if ($this->sequence1[$index1 + $start - 1] |
| 298 | - == $this->sequence2[$index2 + $start - 1]){ |
|
| 298 | + == $this->sequence2[$index2 + $start - 1]) { |
|
| 299 | 299 | $table[$index1][$index2] = $table[$index1 - 1][$index2 - 1] + 1; |
| 300 | - }else{ |
|
| 300 | + } else { |
|
| 301 | 301 | $table[$index1][$index2] = |
| 302 | 302 | max($table[$index1 - 1][$index2], $table[$index1][$index2 - 1]); |
| 303 | 303 | } |
@@ -332,11 +332,11 @@ discard block |
||
| 332 | 332 | $index1 > 0 && $index2 > 0 |
| 333 | 333 | && $this->sequence1[$index1 + $start - 1] |
| 334 | 334 | == $this->sequence2[$index2 + $start - 1] |
| 335 | - ){ |
|
| 335 | + ) { |
|
| 336 | 336 | // update the diff and the indices |
| 337 | 337 | $diff[] = array($this->sequence1[$index1 + $start - 1], self::UNMODIFIED); |
| 338 | - $index1 --; |
|
| 339 | - $index2 --; |
|
| 338 | + $index1--; |
|
| 339 | + $index2--; |
|
| 340 | 340 | } |
| 341 | 341 | elseif ( |
| 342 | 342 | $index2 > 0 |
@@ -344,13 +344,13 @@ discard block |
||
| 344 | 344 | ) { |
| 345 | 345 | // update the diff and the indices |
| 346 | 346 | $diff[] = array($this->sequence2[$index2 + $start - 1], self::INSERTED); |
| 347 | - $index2 --; |
|
| 347 | + $index2--; |
|
| 348 | 348 | } |
| 349 | 349 | else |
| 350 | 350 | { |
| 351 | 351 | // update the diff and the indices |
| 352 | 352 | $diff[] = array($this->sequence1[$index1 + $start - 1], self::DELETED); |
| 353 | - $index1 --; |
|
| 353 | + $index1--; |
|
| 354 | 354 | } |
| 355 | 355 | } |
| 356 | 356 | |