| @@ -14,7 +14,7 @@ discard block | ||
| 14 | 14 | */ | 
| 15 | 15 | |
| 16 | 16 | // A class containing functions for computing diffs and formatting the output. | 
| 17 | -class Diff{ | |
| 17 | +class Diff { | |
| 18 | 18 | |
| 19 | 19 | // define the constants | 
| 20 | 20 | const UNMODIFIED = 0; | 
| @@ -34,16 +34,16 @@ discard block | ||
| 34 | 34 | * lines; this optional parameter defaults to false | 
| 35 | 35 | */ | 
| 36 | 36 | public static function compare( | 
| 37 | -      $string1, $string2, $compareCharacters = false){ | |
| 37 | +      $string1, $string2, $compareCharacters = false) { | |
| 38 | 38 | |
| 39 | 39 | // initialise the sequences and comparison start and end positions | 
| 40 | 40 | $start = 0; | 
| 41 | -    if ($compareCharacters){ | |
| 41 | +    if ($compareCharacters) { | |
| 42 | 42 | $sequence1 = $string1; | 
| 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; | 
| @@ -52,15 +52,15 @@ discard block | ||
| 52 | 52 | |
| 53 | 53 | // skip any common prefix | 
| 54 | 54 | while ($start <= $end1 && $start <= $end2 | 
| 55 | -        && $sequence1[$start] == $sequence2[$start]){ | |
| 56 | - $start ++; | |
| 55 | +        && $sequence1[$start] == $sequence2[$start]) { | |
| 56 | + $start++; | |
| 57 | 57 | } | 
| 58 | 58 | |
| 59 | 59 | // skip any common suffix | 
| 60 | 60 | while ($end1 >= $start && $end2 >= $start | 
| 61 | -        && $sequence1[$end1] == $sequence2[$end2]){ | |
| 62 | - $end1 --; | |
| 63 | - $end2 --; | |
| 61 | +        && $sequence1[$end1] == $sequence2[$end2]) { | |
| 62 | + $end1--; | |
| 63 | + $end2--; | |
| 64 | 64 | } | 
| 65 | 65 | |
| 66 | 66 | // compute the table of longest common subsequence lengths | 
| @@ -72,13 +72,13 @@ discard block | ||
| 72 | 72 | |
| 73 | 73 | // generate the full diff | 
| 74 | 74 | $diff = array(); | 
| 75 | -    for ($index = 0; $index < $start; $index ++){ | |
| 75 | +    for ($index = 0; $index < $start; $index++) { | |
| 76 | 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 | -        $index ++){ | |
| 81 | +        $index++) { | |
| 82 | 82 | $diff[] = array($sequence1[$index], self::UNMODIFIED); | 
| 83 | 83 | } | 
| 84 | 84 | |
| @@ -95,7 +95,7 @@ discard block | ||
| 95 | 95 | * lines; this optional parameter defaults to false | 
| 96 | 96 | */ | 
| 97 | 97 | public static function compareFiles( | 
| 98 | -      $file1, $file2, $compareCharacters = false){ | |
| 98 | +      $file1, $file2, $compareCharacters = false) { | |
| 99 | 99 | |
| 100 | 100 | // return the diff of the files | 
| 101 | 101 | return self::compare( | 
| @@ -115,7 +115,7 @@ discard block | ||
| 115 | 115 | * $end2 - the ending index for the second sequence | 
| 116 | 116 | */ | 
| 117 | 117 | private static function computeTable( | 
| 118 | -      $sequence1, $sequence2, $start, $end1, $end2){ | |
| 118 | +      $sequence1, $sequence2, $start, $end1, $end2) { | |
| 119 | 119 | |
| 120 | 120 | // determine the lengths to be compared | 
| 121 | 121 | $length1 = $end1 - $start + 1; | 
| @@ -125,19 +125,19 @@ discard block | ||
| 125 | 125 | $table = array(array_fill(0, $length2 + 1, 0)); | 
| 126 | 126 | |
| 127 | 127 | // loop over the rows | 
| 128 | -    for ($index1 = 1; $index1 <= $length1; $index1 ++){ | |
| 128 | +    for ($index1 = 1; $index1 <= $length1; $index1++) { | |
| 129 | 129 | |
| 130 | 130 | // create the new row | 
| 131 | 131 | $table[$index1] = array(0); | 
| 132 | 132 | |
| 133 | 133 | // loop over the columns | 
| 134 | -      for ($index2 = 1; $index2 <= $length2; $index2 ++){ | |
| 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 | -            == $sequence2[$index2 + $start - 1]){ | |
| 138 | +            == $sequence2[$index2 + $start - 1]) { | |
| 139 | 139 | $table[$index1][$index2] = $table[$index1 - 1][$index2 - 1] + 1; | 
| 140 | -        }else{ | |
| 140 | +        } else { | |
| 141 | 141 | $table[$index1][$index2] = | 
| 142 | 142 | max($table[$index1 - 1][$index2], $table[$index1][$index2 - 1]); | 
| 143 | 143 | } | 
| @@ -159,7 +159,7 @@ discard block | ||
| 159 | 159 | * $start - the starting index | 
| 160 | 160 | */ | 
| 161 | 161 | private static function generatePartialDiff( | 
| 162 | -      $table, $sequence1, $sequence2, $start){ | |
| 162 | +      $table, $sequence1, $sequence2, $start) { | |
| 163 | 163 | |
| 164 | 164 | // initialise the diff | 
| 165 | 165 | $diff = array(); | 
| @@ -169,30 +169,30 @@ discard block | ||
| 169 | 169 | $index2 = count($table[0]) - 1; | 
| 170 | 170 | |
| 171 | 171 | // loop until there are no items remaining in either sequence | 
| 172 | -    while ($index1 > 0 || $index2 > 0){ | |
| 172 | +    while ($index1 > 0 || $index2 > 0) { | |
| 173 | 173 | |
| 174 | 174 | // check what has happened to the items at these indices | 
| 175 | 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 | - $index1 --; | |
| 182 | - $index2 --; | |
| 181 | + $index1--; | |
| 182 | + $index2--; | |
| 183 | 183 | |
| 184 | 184 | }elseif ($index2 > 0 | 
| 185 | -          && $table[$index1][$index2] == $table[$index1][$index2 - 1]){ | |
| 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 | - $index2 --; | |
| 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 | - $index1 --; | |
| 195 | + $index1--; | |
| 196 | 196 | |
| 197 | 197 | } | 
| 198 | 198 | |
| @@ -211,19 +211,19 @@ 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 = ''; | 
| 218 | 218 | |
| 219 | 219 | // loop over the lines in the diff | 
| 220 | -    foreach ($diff as $line){ | |
| 220 | +    foreach ($diff as $line) { | |
| 221 | 221 | |
| 222 | 222 | // extend the string with the line | 
| 223 | -      switch ($line[1]){ | |
| 224 | - case self::UNMODIFIED : $string .= ' ' . $line[0];break; | |
| 225 | - case self::DELETED : $string .= '- ' . $line[0];break; | |
| 226 | - case self::INSERTED : $string .= '+ ' . $line[0];break; | |
| 223 | +      switch ($line[1]) { | |
| 224 | + case self::UNMODIFIED : $string .= ' ' . $line[0]; break; | |
| 225 | + case self::DELETED : $string .= '- ' . $line[0]; break; | |
| 226 | + case self::INSERTED : $string .= '+ ' . $line[0]; break; | |
| 227 | 227 | } | 
| 228 | 228 | |
| 229 | 229 | // extend the string with the separator | 
| @@ -244,19 +244,19 @@ 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 = ''; | 
| 251 | 251 | |
| 252 | 252 | // loop over the lines in the diff | 
| 253 | -    foreach ($diff as $line){ | |
| 253 | +    foreach ($diff as $line) { | |
| 254 | 254 | |
| 255 | 255 | // extend the HTML with the line | 
| 256 | -      switch ($line[1]){ | |
| 256 | +      switch ($line[1]) { | |
| 257 | 257 | case self::UNMODIFIED : $element = 'span'; break; | 
| 258 | - case self::DELETED : $element = 'del'; break; | |
| 259 | - case self::INSERTED : $element = 'ins'; break; | |
| 258 | + case self::DELETED : $element = 'del'; break; | |
| 259 | + case self::INSERTED : $element = 'ins'; break; | |
| 260 | 260 | } | 
| 261 | 261 | $html .= | 
| 262 | 262 | '<' . $element . '>' | 
| @@ -281,17 +281,17 @@ 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"; | 
| 288 | 288 | |
| 289 | 289 | // loop over the lines in the diff | 
| 290 | 290 | $index = 0; | 
| 291 | -    while ($index < count($diff)){ | |
| 291 | +    while ($index < count($diff)) { | |
| 292 | 292 | |
| 293 | 293 | // determine the line type | 
| 294 | -      switch ($diff[$index][1]){ | |
| 294 | +      switch ($diff[$index][1]) { | |
| 295 | 295 | |
| 296 | 296 | // display the content on the left and right | 
| 297 | 297 | case self::UNMODIFIED: | 
| @@ -361,19 +361,19 @@ discard block | ||
| 361 | 361 | * $type - the type of line | 
| 362 | 362 | */ | 
| 363 | 363 | private static function getCellContent( | 
| 364 | -      $diff, $indentation, $separator, &$index, $type){ | |
| 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 | -    while ($index < count($diff) && $diff[$index][1] == $type){ | |
| 370 | +    while ($index < count($diff) && $diff[$index][1] == $type) { | |
| 371 | 371 | $html .= | 
| 372 | 372 | '<span>' | 
| 373 | 373 | . htmlspecialchars($diff[$index][0]) | 
| 374 | 374 | . '</span>' | 
| 375 | 375 | . $separator; | 
| 376 | - $index ++; | |
| 376 | + $index++; | |
| 377 | 377 | } | 
| 378 | 378 | |
| 379 | 379 | // return the HTML | 
| @@ -26,8 +26,8 @@ | ||
| 26 | 26 | $it = new \RecursiveDirectoryIterator($filename_clean, \RecursiveDirectoryIterator::SKIP_DOTS); | 
| 27 | 27 | $files = new \RecursiveIteratorIterator($it, | 
| 28 | 28 | \RecursiveIteratorIterator::CHILD_FIRST); | 
| 29 | -            foreach($files as $file) { | |
| 30 | -                if ($file->isDir()){ | |
| 29 | +            foreach ($files as $file) { | |
| 30 | +                if ($file->isDir()) { | |
| 31 | 31 | rmdir($file->getRealPath()); | 
| 32 | 32 |                  } else { | 
| 33 | 33 | unlink($file->getRealPath()); | 
| @@ -181,13 +181,13 @@ | ||
| 181 | 181 |  "Country-Code: ${country-code}\n" | 
| 182 | 182 | EOD; | 
| 183 | 183 | |
| 184 | -        $language_code          = $this->config->getOr('language', 'addon.default_language'); | |
| 184 | +        $language_code = $this->config->getOr('language', 'addon.default_language'); | |
| 185 | 185 | |
| 186 | 186 |          if (!$language_code) { | 
| 187 | 187 |              throw new \InvalidArgumentException('Nor language param and addon default_language are specified'); | 
| 188 | 188 | } | 
| 189 | 189 | |
| 190 | - $language_information = self::$codes[$language_code]; | |
| 190 | + $language_information = self::$codes[$language_code]; | |
| 191 | 191 | $po_heading = str_replace( | 
| 192 | 192 | [ | 
| 193 | 193 |                  '${code}', | 
| @@ -352,7 +352,7 @@ | ||
| 352 | 352 |              $settingItem->addChild('type', $type); | 
| 353 | 353 |              if ($variants) { | 
| 354 | 354 |                  $variantsElement = $settingItem->addChild('variants'); | 
| 355 | - foreach($variants as $variant) | |
| 355 | + foreach ($variants as $variant) | |
| 356 | 356 |                      { | 
| 357 | 357 |                          $variantElement = $variantsElement->addChild('item'); | 
| 358 | 358 |                              $variantElement->addAttribute('id', $variant); | 
| @@ -17,7 +17,7 @@ discard block | ||
| 17 | 17 | |
| 18 | 18 | public function addGenerator(AbstractGenerator $generator) | 
| 19 | 19 |      { | 
| 20 | - switch(get_class($generator)) | |
| 20 | + switch (get_class($generator)) | |
| 21 | 21 |          { | 
| 22 | 22 | case 'generators\AddonXml\AddonXmlGenerator': | 
| 23 | 23 | $this->addonXmlGenerator = $generator; | 
| @@ -107,7 +107,7 @@ discard block | ||
| 107 | 107 | ); | 
| 108 | 108 | |
| 109 | 109 |                  if (!empty($data['variants'])) { | 
| 110 | -                    foreach($data['variants'] as $variation) { | |
| 110 | +                    foreach ($data['variants'] as $variation) { | |
| 111 | 111 | $this->languageGenerator | 
| 112 | 112 | ->replaceLangvar( | 
| 113 | 113 | LanguageGenerator::getTranslationKey( | 
| @@ -18,7 +18,7 @@ discard block | ||
| 18 | 18 | $self->systemKeys[] = $key; | 
| 19 | 19 | }); | 
| 20 | 20 | |
| 21 | -        foreach($arguments as $key => $value) { | |
| 21 | +        foreach ($arguments as $key => $value) { | |
| 22 | 22 | $this->set($key, $value); | 
| 23 | 23 | } | 
| 24 | 24 | } | 
| @@ -40,7 +40,7 @@ discard block | ||
| 40 | 40 | |
| 41 | 41 | public function getOr(string ...$keys) | 
| 42 | 42 |      { | 
| 43 | -        foreach($keys as $key) { | |
| 43 | +        foreach ($keys as $key) { | |
| 44 | 44 | $value = $this->get($key); | 
| 45 | 45 | |
| 46 | 46 |              if ($value) { | 
| @@ -54,7 +54,7 @@ | ||
| 54 | 54 | $key = $matches[1]; | 
| 55 | 55 | $value = true; | 
| 56 | 56 | |
| 57 | -            switch(count($matches)) { | |
| 57 | +            switch (count($matches)) { | |
| 58 | 58 | case 4: | 
| 59 | 59 | case 5: | 
| 60 | 60 | $value = $matches[3]; | 
| @@ -28,7 +28,7 @@ | ||
| 28 | 28 | $input = ''; | 
| 29 | 29 |          } else { | 
| 30 | 30 | $pos = strpos($input, '/'); | 
| 31 | - if ($pos === 0) $pos = strpos($input, '/', $pos+1); | |
| 31 | + if ($pos === 0) $pos = strpos($input, '/', $pos + 1); | |
| 32 | 32 | if ($pos === false) $pos = strlen($input); | 
| 33 | 33 | $output .= substr($input, 0, $pos); | 
| 34 | 34 | $input = (string) substr($input, $pos); | 
| @@ -10,9 +10,9 @@ | ||
| 10 | 10 | /** | 
| 11 | 11 | * autoload | 
| 12 | 12 | */ | 
| 13 | -spl_autoload_register(function ($class) { | |
| 13 | +spl_autoload_register(function($class) { | |
| 14 | 14 |      $file = realpath(__DIR__ . '/' . 'app') . '/' . str_replace('\\', '/', $class) . '.php'; | 
| 15 | -    if(file_exists($file)) { | |
| 15 | +    if (file_exists($file)) { | |
| 16 | 16 | require_once($file); | 
| 17 | 17 | } | 
| 18 | 18 | }); |