| @@ -16,12 +16,12 @@ discard block | ||
| 16 | 16 | // A class containing functions for computing diffs and formatting the output. | 
| 17 | 17 |  class Diff{ | 
| 18 | 18 | |
| 19 | - // define the constants | |
| 20 | - const UNMODIFIED = 0; | |
| 21 | - const DELETED = 1; | |
| 22 | - const INSERTED = 2; | |
| 19 | + // define the constants | |
| 20 | + const UNMODIFIED = 0; | |
| 21 | + const DELETED = 1; | |
| 22 | + const INSERTED = 2; | |
| 23 | 23 | |
| 24 | - /* Returns the diff for two strings. The return value is an array, each of | |
| 24 | + /* Returns the diff for two strings. The return value is an array, each of | |
| 25 | 25 | * whose values is an array containing two values: a line (or character, if | 
| 26 | 26 | * $compareCharacters is true), and one of the constants DIFF::UNMODIFIED (the | 
| 27 | 27 | * line or character is in both strings), DIFF::DELETED (the line or character | 
| @@ -33,34 +33,34 @@ discard block | ||
| 33 | 33 | * $compareCharacters - true to compare characters, and false to compare | 
| 34 | 34 | * lines; this optional parameter defaults to false | 
| 35 | 35 | */ | 
| 36 | - public static function compare( | |
| 37 | -      $string1, $string2, $compareCharacters = false){ | |
| 36 | + public static function compare( | |
| 37 | +        $string1, $string2, $compareCharacters = false){ | |
| 38 | 38 | |
| 39 | 39 | // initialise the sequences and comparison start and end positions | 
| 40 | 40 | $start = 0; | 
| 41 | 41 |      if ($compareCharacters){ | 
| 42 | - $sequence1 = $string1; | |
| 43 | - $sequence2 = $string2; | |
| 44 | - $end1 = strlen($string1) - 1; | |
| 45 | - $end2 = strlen($string2) - 1; | |
| 42 | + $sequence1 = $string1; | |
| 43 | + $sequence2 = $string2; | |
| 44 | + $end1 = strlen($string1) - 1; | |
| 45 | + $end2 = strlen($string2) - 1; | |
| 46 | 46 |      }else{ | 
| 47 | -      $sequence1 = preg_split('/\R/', $string1); | |
| 48 | -      $sequence2 = preg_split('/\R/', $string2); | |
| 49 | - $end1 = count($sequence1) - 1; | |
| 50 | - $end2 = count($sequence2) - 1; | |
| 47 | +        $sequence1 = preg_split('/\R/', $string1); | |
| 48 | +        $sequence2 = preg_split('/\R/', $string2); | |
| 49 | + $end1 = count($sequence1) - 1; | |
| 50 | + $end2 = count($sequence2) - 1; | |
| 51 | 51 | } | 
| 52 | 52 | |
| 53 | 53 | // skip any common prefix | 
| 54 | 54 | while ($start <= $end1 && $start <= $end2 | 
| 55 | 55 |          && $sequence1[$start] == $sequence2[$start]){ | 
| 56 | - $start ++; | |
| 56 | + $start ++; | |
| 57 | 57 | } | 
| 58 | 58 | |
| 59 | 59 | // skip any common suffix | 
| 60 | 60 | while ($end1 >= $start && $end2 >= $start | 
| 61 | 61 |          && $sequence1[$end1] == $sequence2[$end2]){ | 
| 62 | - $end1 --; | |
| 63 | - $end2 --; | |
| 62 | + $end1 --; | |
| 63 | + $end2 --; | |
| 64 | 64 | } | 
| 65 | 65 | |
| 66 | 66 | // compute the table of longest common subsequence lengths | 
| @@ -73,29 +73,29 @@ discard block | ||
| 73 | 73 | // generate the full diff | 
| 74 | 74 | $diff = array(); | 
| 75 | 75 |      for ($index = 0; $index < $start; $index ++){ | 
| 76 | - $diff[] = array($sequence1[$index], self::UNMODIFIED); | |
| 76 | + $diff[] = array($sequence1[$index], self::UNMODIFIED); | |
| 77 | 77 | } | 
| 78 | 78 | while (count($partialDiff) > 0) $diff[] = array_pop($partialDiff); | 
| 79 | 79 | for ($index = $end1 + 1; | 
| 80 | 80 | $index < ($compareCharacters ? strlen($sequence1) : count($sequence1)); | 
| 81 | 81 |          $index ++){ | 
| 82 | - $diff[] = array($sequence1[$index], self::UNMODIFIED); | |
| 82 | + $diff[] = array($sequence1[$index], self::UNMODIFIED); | |
| 83 | 83 | } | 
| 84 | 84 | |
| 85 | 85 | // return the diff | 
| 86 | 86 | return $diff; | 
| 87 | 87 | |
| 88 | - } | |
| 88 | + } | |
| 89 | 89 | |
| 90 | - /* Returns the diff for two files. The parameters are: | |
| 90 | + /* Returns the diff for two files. The parameters are: | |
| 91 | 91 | * | 
| 92 | 92 | * $file1 - the path to the first file | 
| 93 | 93 | * $file2 - the path to the second file | 
| 94 | 94 | * $compareCharacters - true to compare characters, and false to compare | 
| 95 | 95 | * lines; this optional parameter defaults to false | 
| 96 | 96 | */ | 
| 97 | - public static function compareFiles( | |
| 98 | -      $file1, $file2, $compareCharacters = false){ | |
| 97 | + public static function compareFiles( | |
| 98 | +        $file1, $file2, $compareCharacters = false){ | |
| 99 | 99 | |
| 100 | 100 | // return the diff of the files | 
| 101 | 101 | return self::compare( | 
| @@ -103,9 +103,9 @@ discard block | ||
| 103 | 103 | file_get_contents($file2), | 
| 104 | 104 | $compareCharacters); | 
| 105 | 105 | |
| 106 | - } | |
| 106 | + } | |
| 107 | 107 | |
| 108 | - /* Returns the table of longest common subsequence lengths for the specified | |
| 108 | + /* Returns the table of longest common subsequence lengths for the specified | |
| 109 | 109 | * sequences. The parameters are: | 
| 110 | 110 | * | 
| 111 | 111 | * $sequence1 - the first sequence | 
| @@ -114,8 +114,8 @@ discard block | ||
| 114 | 114 | * $end1 - the ending index for the first sequence | 
| 115 | 115 | * $end2 - the ending index for the second sequence | 
| 116 | 116 | */ | 
| 117 | - private static function computeTable( | |
| 118 | -      $sequence1, $sequence2, $start, $end1, $end2){ | |
| 117 | + private static function computeTable( | |
| 118 | +        $sequence1, $sequence2, $start, $end1, $end2){ | |
| 119 | 119 | |
| 120 | 120 | // determine the lengths to be compared | 
| 121 | 121 | $length1 = $end1 - $start + 1; | 
| @@ -127,30 +127,30 @@ discard block | ||
| 127 | 127 | // loop over the rows | 
| 128 | 128 |      for ($index1 = 1; $index1 <= $length1; $index1 ++){ | 
| 129 | 129 | |
| 130 | - // create the new row | |
| 131 | - $table[$index1] = array(0); | |
| 130 | + // create the new row | |
| 131 | + $table[$index1] = array(0); | |
| 132 | 132 | |
| 133 | - // loop over the columns | |
| 134 | -      for ($index2 = 1; $index2 <= $length2; $index2 ++){ | |
| 133 | + // loop over the columns | |
| 134 | +        for ($index2 = 1; $index2 <= $length2; $index2 ++){ | |
| 135 | 135 | |
| 136 | 136 | // store the longest common subsequence length | 
| 137 | 137 | if ($sequence1[$index1 + $start - 1] | 
| 138 | 138 |              == $sequence2[$index2 + $start - 1]){ | 
| 139 | - $table[$index1][$index2] = $table[$index1 - 1][$index2 - 1] + 1; | |
| 139 | + $table[$index1][$index2] = $table[$index1 - 1][$index2 - 1] + 1; | |
| 140 | 140 |          }else{ | 
| 141 | - $table[$index1][$index2] = | |
| 142 | - max($table[$index1 - 1][$index2], $table[$index1][$index2 - 1]); | |
| 141 | + $table[$index1][$index2] = | |
| 142 | + max($table[$index1 - 1][$index2], $table[$index1][$index2 - 1]); | |
| 143 | 143 | } | 
| 144 | 144 | |
| 145 | - } | |
| 145 | + } | |
| 146 | 146 | } | 
| 147 | 147 | |
| 148 | 148 | // return the table | 
| 149 | 149 | return $table; | 
| 150 | 150 | |
| 151 | - } | |
| 151 | + } | |
| 152 | 152 | |
| 153 | - /* Returns the partial diff for the specificed sequences, in reverse order. | |
| 153 | + /* Returns the partial diff for the specificed sequences, in reverse order. | |
| 154 | 154 | * The parameters are: | 
| 155 | 155 | * | 
| 156 | 156 | * $table - the table returned by the computeTable function | 
| @@ -158,8 +158,8 @@ discard block | ||
| 158 | 158 | * $sequence2 - the second sequence | 
| 159 | 159 | * $start - the starting index | 
| 160 | 160 | */ | 
| 161 | - private static function generatePartialDiff( | |
| 162 | -      $table, $sequence1, $sequence2, $start){ | |
| 161 | + private static function generatePartialDiff( | |
| 162 | +        $table, $sequence1, $sequence2, $start){ | |
| 163 | 163 | |
| 164 | 164 | // initialise the diff | 
| 165 | 165 | $diff = array(); | 
| @@ -171,39 +171,39 @@ discard block | ||
| 171 | 171 | // loop until there are no items remaining in either sequence | 
| 172 | 172 |      while ($index1 > 0 || $index2 > 0){ | 
| 173 | 173 | |
| 174 | - // check what has happened to the items at these indices | |
| 175 | - if ($index1 > 0 && $index2 > 0 | |
| 174 | + // check what has happened to the items at these indices | |
| 175 | + if ($index1 > 0 && $index2 > 0 | |
| 176 | 176 | && $sequence1[$index1 + $start - 1] | 
| 177 | -              == $sequence2[$index2 + $start - 1]){ | |
| 177 | +                == $sequence2[$index2 + $start - 1]){ | |
| 178 | 178 | |
| 179 | 179 | // update the diff and the indices | 
| 180 | 180 | $diff[] = array($sequence1[$index1 + $start - 1], self::UNMODIFIED); | 
| 181 | 181 | $index1 --; | 
| 182 | 182 | $index2 --; | 
| 183 | 183 | |
| 184 | - }elseif ($index2 > 0 | |
| 184 | + }elseif ($index2 > 0 | |
| 185 | 185 |            && $table[$index1][$index2] == $table[$index1][$index2 - 1]){ | 
| 186 | 186 | |
| 187 | 187 | // update the diff and the indices | 
| 188 | 188 | $diff[] = array($sequence2[$index2 + $start - 1], self::INSERTED); | 
| 189 | 189 | $index2 --; | 
| 190 | 190 | |
| 191 | -      }else{ | |
| 191 | +        }else{ | |
| 192 | 192 | |
| 193 | 193 | // update the diff and the indices | 
| 194 | 194 | $diff[] = array($sequence1[$index1 + $start - 1], self::DELETED); | 
| 195 | 195 | $index1 --; | 
| 196 | 196 | |
| 197 | - } | |
| 197 | + } | |
| 198 | 198 | |
| 199 | 199 | } | 
| 200 | 200 | |
| 201 | 201 | // return the diff | 
| 202 | 202 | return $diff; | 
| 203 | 203 | |
| 204 | - } | |
| 204 | + } | |
| 205 | 205 | |
| 206 | - /* Returns a diff as a string, where unmodified lines are prefixed by ' ', | |
| 206 | + /* Returns a diff as a string, where unmodified lines are prefixed by ' ', | |
| 207 | 207 | * deletions are prefixed by '- ', and insertions are prefixed by '+ '. The | 
| 208 | 208 | * parameters are: | 
| 209 | 209 | * | 
| @@ -211,7 +211,7 @@ discard block | ||
| 211 | 211 | * $separator - the separator between lines; this optional parameter defaults | 
| 212 | 212 | * to "\n" | 
| 213 | 213 | */ | 
| 214 | -  public static function toString($diff, $separator = "\n"){ | |
| 214 | +    public static function toString($diff, $separator = "\n"){ | |
| 215 | 215 | |
| 216 | 216 | // initialise the string | 
| 217 | 217 | $string = ''; | 
| @@ -219,24 +219,24 @@ discard block | ||
| 219 | 219 | // loop over the lines in the diff | 
| 220 | 220 |      foreach ($diff as $line){ | 
| 221 | 221 | |
| 222 | - // extend the string with the line | |
| 223 | -      switch ($line[1]){ | |
| 222 | + // extend the string with the line | |
| 223 | +        switch ($line[1]){ | |
| 224 | 224 | case self::UNMODIFIED : $string .= ' ' . $line[0];break; | 
| 225 | 225 | case self::DELETED : $string .= '- ' . $line[0];break; | 
| 226 | 226 | case self::INSERTED : $string .= '+ ' . $line[0];break; | 
| 227 | - } | |
| 227 | + } | |
| 228 | 228 | |
| 229 | - // extend the string with the separator | |
| 230 | - $string .= $separator; | |
| 229 | + // extend the string with the separator | |
| 230 | + $string .= $separator; | |
| 231 | 231 | |
| 232 | 232 | } | 
| 233 | 233 | |
| 234 | 234 | // return the string | 
| 235 | 235 | return $string; | 
| 236 | 236 | |
| 237 | - } | |
| 237 | + } | |
| 238 | 238 | |
| 239 | - /* Returns a diff as an HTML string, where unmodified lines are contained | |
| 239 | + /* Returns a diff as an HTML string, where unmodified lines are contained | |
| 240 | 240 | * within 'span' elements, deletions are contained within 'del' elements, and | 
| 241 | 241 | * insertions are contained within 'ins' elements. The parameters are: | 
| 242 | 242 | * | 
| @@ -244,7 +244,7 @@ discard block | ||
| 244 | 244 | * $separator - the separator between lines; this optional parameter defaults | 
| 245 | 245 | * to '<br>' | 
| 246 | 246 | */ | 
| 247 | -  public static function toHTML($diff, $separator = '<br>'){ | |
| 247 | +    public static function toHTML($diff, $separator = '<br>'){ | |
| 248 | 248 | |
| 249 | 249 | // initialise the HTML | 
| 250 | 250 | $html = ''; | 
| @@ -252,28 +252,28 @@ discard block | ||
| 252 | 252 | // loop over the lines in the diff | 
| 253 | 253 |      foreach ($diff as $line){ | 
| 254 | 254 | |
| 255 | - // extend the HTML with the line | |
| 256 | -      switch ($line[1]){ | |
| 255 | + // extend the HTML with the line | |
| 256 | +        switch ($line[1]){ | |
| 257 | 257 | case self::UNMODIFIED : $element = 'span'; break; | 
| 258 | 258 | case self::DELETED : $element = 'del'; break; | 
| 259 | 259 | case self::INSERTED : $element = 'ins'; break; | 
| 260 | - } | |
| 261 | - $html .= | |
| 262 | - '<' . $element . '>' | |
| 263 | - . htmlspecialchars($line[0]) | |
| 264 | - . '</' . $element . '>'; | |
| 260 | + } | |
| 261 | + $html .= | |
| 262 | + '<' . $element . '>' | |
| 263 | + . htmlspecialchars($line[0]) | |
| 264 | + . '</' . $element . '>'; | |
| 265 | 265 | |
| 266 | - // extend the HTML with the separator | |
| 267 | - $html .= $separator; | |
| 266 | + // extend the HTML with the separator | |
| 267 | + $html .= $separator; | |
| 268 | 268 | |
| 269 | 269 | } | 
| 270 | 270 | |
| 271 | 271 | // return the HTML | 
| 272 | 272 | return $html; | 
| 273 | 273 | |
| 274 | - } | |
| 274 | + } | |
| 275 | 275 | |
| 276 | - /* Returns a diff as an HTML table. The parameters are: | |
| 276 | + /* Returns a diff as an HTML table. The parameters are: | |
| 277 | 277 | * | 
| 278 | 278 | * $diff - the diff array | 
| 279 | 279 | * $indentation - indentation to add to every line of the generated HTML; this | 
| @@ -281,7 +281,7 @@ discard block | ||
| 281 | 281 | * $separator - the separator between lines; this optional parameter | 
| 282 | 282 | * defaults to '<br>' | 
| 283 | 283 | */ | 
| 284 | -  public static function toTable($diff, $indentation = '', $separator = '<br>'){ | |
| 284 | +    public static function toTable($diff, $indentation = '', $separator = '<br>'){ | |
| 285 | 285 | |
| 286 | 286 | // initialise the HTML | 
| 287 | 287 | $html = $indentation . "<table class=\"diff\">\n"; | 
| @@ -290,68 +290,68 @@ discard block | ||
| 290 | 290 | $index = 0; | 
| 291 | 291 |      while ($index < count($diff)){ | 
| 292 | 292 | |
| 293 | - // determine the line type | |
| 294 | -      switch ($diff[$index][1]){ | |
| 293 | + // determine the line type | |
| 294 | +        switch ($diff[$index][1]){ | |
| 295 | 295 | |
| 296 | 296 | // display the content on the left and right | 
| 297 | 297 | case self::UNMODIFIED: | 
| 298 | 298 | $leftCell = | 
| 299 | - self::getCellContent( | |
| 300 | - $diff, $indentation, $separator, $index, self::UNMODIFIED); | |
| 301 | - $rightCell = $leftCell; | |
| 302 | - break; | |
| 299 | + self::getCellContent( | |
| 300 | + $diff, $indentation, $separator, $index, self::UNMODIFIED); | |
| 301 | + $rightCell = $leftCell; | |
| 302 | + break; | |
| 303 | 303 | |
| 304 | 304 | // display the deleted on the left and inserted content on the right | 
| 305 | 305 | case self::DELETED: | 
| 306 | 306 | $leftCell = | 
| 307 | - self::getCellContent( | |
| 308 | - $diff, $indentation, $separator, $index, self::DELETED); | |
| 309 | - $rightCell = | |
| 310 | - self::getCellContent( | |
| 311 | - $diff, $indentation, $separator, $index, self::INSERTED); | |
| 312 | - break; | |
| 307 | + self::getCellContent( | |
| 308 | + $diff, $indentation, $separator, $index, self::DELETED); | |
| 309 | + $rightCell = | |
| 310 | + self::getCellContent( | |
| 311 | + $diff, $indentation, $separator, $index, self::INSERTED); | |
| 312 | + break; | |
| 313 | 313 | |
| 314 | 314 | // display the inserted content on the right | 
| 315 | 315 | case self::INSERTED: | 
| 316 | 316 | $leftCell = ''; | 
| 317 | - $rightCell = | |
| 318 | - self::getCellContent( | |
| 319 | - $diff, $indentation, $separator, $index, self::INSERTED); | |
| 320 | - break; | |
| 321 | - | |
| 322 | - } | |
| 323 | - | |
| 324 | - // extend the HTML with the new row | |
| 325 | - $html .= | |
| 326 | - $indentation | |
| 327 | - . " <tr>\n" | |
| 328 | - . $indentation | |
| 329 | - . ' <td class="diff' | |
| 330 | - . ($leftCell == $rightCell | |
| 317 | + $rightCell = | |
| 318 | + self::getCellContent( | |
| 319 | + $diff, $indentation, $separator, $index, self::INSERTED); | |
| 320 | + break; | |
| 321 | + | |
| 322 | + } | |
| 323 | + | |
| 324 | + // extend the HTML with the new row | |
| 325 | + $html .= | |
| 326 | + $indentation | |
| 327 | + . " <tr>\n" | |
| 328 | + . $indentation | |
| 329 | + . ' <td class="diff' | |
| 330 | + . ($leftCell == $rightCell | |
| 331 | 331 | ? 'Unmodified' | 
| 332 | 332 | : ($leftCell == '' ? 'Blank' : 'Deleted')) | 
| 333 | - . '">' | |
| 334 | - . $leftCell | |
| 335 | - . "</td>\n" | |
| 336 | - . $indentation | |
| 337 | - . ' <td class="diff' | |
| 338 | - . ($leftCell == $rightCell | |
| 333 | + . '">' | |
| 334 | + . $leftCell | |
| 335 | + . "</td>\n" | |
| 336 | + . $indentation | |
| 337 | + . ' <td class="diff' | |
| 338 | + . ($leftCell == $rightCell | |
| 339 | 339 | ? 'Unmodified' | 
| 340 | 340 | : ($rightCell == '' ? 'Blank' : 'Inserted')) | 
| 341 | - . '">' | |
| 342 | - . $rightCell | |
| 343 | - . "</td>\n" | |
| 344 | - . $indentation | |
| 345 | - . " </tr>\n"; | |
| 341 | + . '">' | |
| 342 | + . $rightCell | |
| 343 | + . "</td>\n" | |
| 344 | + . $indentation | |
| 345 | + . " </tr>\n"; | |
| 346 | 346 | |
| 347 | 347 | } | 
| 348 | 348 | |
| 349 | 349 | // return the HTML | 
| 350 | 350 | return $html . $indentation . "</table>\n"; | 
| 351 | 351 | |
| 352 | - } | |
| 352 | + } | |
| 353 | 353 | |
| 354 | - /* Returns the content of the cell, for use in the toTable function. The | |
| 354 | + /* Returns the content of the cell, for use in the toTable function. The | |
| 355 | 355 | * parameters are: | 
| 356 | 356 | * | 
| 357 | 357 | * $diff - the diff array | 
| @@ -360,25 +360,25 @@ discard block | ||
| 360 | 360 | * $index - the current index, passes by reference | 
| 361 | 361 | * $type - the type of line | 
| 362 | 362 | */ | 
| 363 | - private static function getCellContent( | |
| 364 | -      $diff, $indentation, $separator, &$index, $type){ | |
| 363 | + private static function getCellContent( | |
| 364 | +        $diff, $indentation, $separator, &$index, $type){ | |
| 365 | 365 | |
| 366 | 366 | // initialise the HTML | 
| 367 | 367 | $html = ''; | 
| 368 | 368 | |
| 369 | 369 | // loop over the matching lines, adding them to the HTML | 
| 370 | 370 |      while ($index < count($diff) && $diff[$index][1] == $type){ | 
| 371 | - $html .= | |
| 372 | - '<span>' | |
| 373 | - . htmlspecialchars($diff[$index][0]) | |
| 374 | - . '</span>' | |
| 375 | - . $separator; | |
| 376 | - $index ++; | |
| 371 | + $html .= | |
| 372 | + '<span>' | |
| 373 | + . htmlspecialchars($diff[$index][0]) | |
| 374 | + . '</span>' | |
| 375 | + . $separator; | |
| 376 | + $index ++; | |
| 377 | 377 | } | 
| 378 | 378 | |
| 379 | 379 | // return the HTML | 
| 380 | 380 | return $html; | 
| 381 | 381 | |
| 382 | - } | |
| 382 | + } | |
| 383 | 383 | |
| 384 | 384 | } | 
| @@ -43,7 +43,7 @@ discard block | ||
| 43 | 43 | $sequence2 = $string2; | 
| 44 | 44 | $end1 = strlen($string1) - 1; | 
| 45 | 45 | $end2 = strlen($string2) - 1; | 
| 46 | -    }else{ | |
| 46 | +    } else{ | |
| 47 | 47 |        $sequence1 = preg_split('/\R/', $string1); | 
| 48 | 48 |        $sequence2 = preg_split('/\R/', $string2); | 
| 49 | 49 | $end1 = count($sequence1) - 1; | 
| @@ -75,7 +75,9 @@ discard block | ||
| 75 | 75 |      for ($index = 0; $index < $start; $index ++){ | 
| 76 | 76 | $diff[] = array($sequence1[$index], self::UNMODIFIED); | 
| 77 | 77 | } | 
| 78 | - while (count($partialDiff) > 0) $diff[] = array_pop($partialDiff); | |
| 78 | +    while (count($partialDiff) > 0) { | |
| 79 | + $diff[] = array_pop($partialDiff); | |
| 80 | + } | |
| 79 | 81 | for ($index = $end1 + 1; | 
| 80 | 82 | $index < ($compareCharacters ? strlen($sequence1) : count($sequence1)); | 
| 81 | 83 |          $index ++){ | 
| @@ -137,7 +139,7 @@ discard block | ||
| 137 | 139 | if ($sequence1[$index1 + $start - 1] | 
| 138 | 140 |              == $sequence2[$index2 + $start - 1]){ | 
| 139 | 141 | $table[$index1][$index2] = $table[$index1 - 1][$index2 - 1] + 1; | 
| 140 | -        }else{ | |
| 142 | +        } else{ | |
| 141 | 143 | $table[$index1][$index2] = | 
| 142 | 144 | max($table[$index1 - 1][$index2], $table[$index1][$index2 - 1]); | 
| 143 | 145 | } | 
| @@ -181,14 +183,14 @@ discard block | ||
| 181 | 183 | $index1 --; | 
| 182 | 184 | $index2 --; | 
| 183 | 185 | |
| 184 | - }elseif ($index2 > 0 | |
| 186 | + } elseif ($index2 > 0 | |
| 185 | 187 |            && $table[$index1][$index2] == $table[$index1][$index2 - 1]){ | 
| 186 | 188 | |
| 187 | 189 | // update the diff and the indices | 
| 188 | 190 | $diff[] = array($sequence2[$index2 + $start - 1], self::INSERTED); | 
| 189 | 191 | $index2 --; | 
| 190 | 192 | |
| 191 | -      }else{ | |
| 193 | +      } else{ | |
| 192 | 194 | |
| 193 | 195 | // update the diff and the indices | 
| 194 | 196 | $diff[] = array($sequence1[$index1 + $start - 1], self::DELETED); | 
| @@ -9,19 +9,19 @@ | ||
| 9 | 9 | if ( | 
| 10 | 10 | ($prefix = substr($input, 0, 3)) == '../' || | 
| 11 | 11 | ($prefix = substr($input, 0, 2)) == './' | 
| 12 | -           ) { | |
| 12 | +            ) { | |
| 13 | 13 | $input = substr($input, strlen($prefix)); | 
| 14 | 14 | } else if ( | 
| 15 | 15 | ($prefix = substr($input, 0, 3)) == '/./' || | 
| 16 | 16 | ($prefix = $input) == '/.' | 
| 17 | -           ) { | |
| 17 | +            ) { | |
| 18 | 18 | $input = '/' . substr($input, strlen($prefix)); | 
| 19 | 19 | } else | 
| 20 | 20 | |
| 21 | 21 | if ( | 
| 22 | 22 | ($prefix = substr($input, 0, 4)) == '/../' || | 
| 23 | 23 | ($prefix = $input) == '/..' | 
| 24 | -           ) { | |
| 24 | +            ) { | |
| 25 | 25 | $input = '/' . substr($input, strlen($prefix)); | 
| 26 | 26 | $output = substr($output, 0, strrpos($output, '/')); | 
| 27 | 27 |          } else if ($input == '.' || $input == '..') { | 
| @@ -28,8 +28,12 @@ | ||
| 28 | 28 | $input = ''; | 
| 29 | 29 |          } else { | 
| 30 | 30 | $pos = strpos($input, '/'); | 
| 31 | - if ($pos === 0) $pos = strpos($input, '/', $pos+1); | |
| 32 | - if ($pos === false) $pos = strlen($input); | |
| 31 | +            if ($pos === 0) { | |
| 32 | + $pos = strpos($input, '/', $pos+1); | |
| 33 | + } | |
| 34 | +            if ($pos === false) { | |
| 35 | + $pos = strlen($input); | |
| 36 | + } | |
| 33 | 37 | $output .= substr($input, 0, $pos); | 
| 34 | 38 | $input = (string) substr($input, $pos); | 
| 35 | 39 | } | 
| @@ -7,16 +7,16 @@ | ||
| 7 | 7 | use mediators\AbstractMediator; | 
| 8 | 8 | |
| 9 | 9 | /** | 
| 10 | - * @property string FILENAME | |
| 11 | - * @property string $templatePath | |
| 12 | - * @property string $recycleBin - buffer to which be removed all langvars from actual content | |
| 13 | - * @property string $content | |
| 14 | - * @property Config $config | |
| 15 | - * @property AbstractMediator $mediator | |
| 16 | - * @property array $codes | |
| 17 | - * @property string $eol - end of line char | |
| 18 | - * @todo add all $codes supported by cs-cart | |
| 19 | - */ | |
| 10 | + * @property string FILENAME | |
| 11 | + * @property string $templatePath | |
| 12 | + * @property string $recycleBin - buffer to which be removed all langvars from actual content | |
| 13 | + * @property string $content | |
| 14 | + * @property Config $config | |
| 15 | + * @property AbstractMediator $mediator | |
| 16 | + * @property array $codes | |
| 17 | + * @property string $eol - end of line char | |
| 18 | + * @todo add all $codes supported by cs-cart | |
| 19 | + */ | |
| 20 | 20 | final class LanguageGenerator extends \generators\AbstractGenerator | 
| 21 | 21 |  { | 
| 22 | 22 |      const FILENAME = 'var/langs/${lang}/addons/${addon}.po'; | 
| @@ -6,10 +6,10 @@ | ||
| 6 | 6 | use mediators\AbstractMediator; | 
| 7 | 7 | |
| 8 | 8 | /** | 
| 9 | - * @property string FILENAME | |
| 10 | - * @property string $content | |
| 11 | - * @property Config $config | |
| 12 | - */ | |
| 9 | + * @property string FILENAME | |
| 10 | + * @property string $content | |
| 11 | + * @property Config $config | |
| 12 | + */ | |
| 13 | 13 | final class ReadmeGenerator extends \generators\AbstractGenerator | 
| 14 | 14 |  { | 
| 15 | 15 |      const FILENAME = 'app/addons/${addon}/README.md'; |