@@ -71,10 +71,9 @@ |
||
71 | 71 | * The conflicting line changes from the first source. |
72 | 72 | * @param string[] $local |
73 | 73 | * The conflicting line changes from the second source. |
74 | - * @param int $line |
|
75 | - * The line number in the original text. |
|
76 | - * @param int $merged |
|
74 | + * @param integer $mergedLine |
|
77 | 75 | * The line number in the merged text. |
76 | + * @param integer $baseLine |
|
78 | 77 | */ |
79 | 78 | public function __construct($base, $remote, $local, $baseLine, $mergedLine) |
80 | 79 | { |
@@ -96,7 +96,7 @@ |
||
96 | 96 | * @param MergeConflict[] $conflicts |
97 | 97 | * The merge conflicts. |
98 | 98 | * |
99 | - * @return string[] |
|
99 | + * @return string |
|
100 | 100 | * The merged text. |
101 | 101 | */ |
102 | 102 | protected static function mergeHunks($base, $remote, $local, &$conflicts = []) |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | |
65 | 65 | $baseLines = Line::createArray( |
66 | 66 | array_map( |
67 | - function ($l) { |
|
67 | + function($l) { |
|
68 | 68 | return [$l, 0]; |
69 | 69 | }, |
70 | 70 | explode("\n", $base) |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $i = -1; |
113 | 113 | |
114 | 114 | // Loop over all indexes of the base and all hunks. |
115 | - while ($i < count($base) || $a->valid() || $b->valid()) { |
|
115 | + while ($i < count($base) || $a->valid() || $b->valid()) { |
|
116 | 116 | // Assure that $aa is the first hunk by swaping $a and $b |
117 | 117 | if ($a->valid() && $b->valid() && $a->current()->getStart() > $b->current()->getStart()) { |
118 | 118 | self::swap($a, $b, $flipped); |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $a->next(); |
161 | 161 | } else { |
162 | 162 | // Not dealing with a change, so return the line from the base. |
163 | - if ($i>=0) { |
|
163 | + if ($i >= 0) { |
|
164 | 164 | $merged[] = $base[$i]->getContent(); |
165 | 165 | } |
166 | 166 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | // So there might be a merge conflict. |
55 | 55 | $baseLines = $this->base = Line::createArray( |
56 | 56 | array_map( |
57 | - function ($l) { |
|
57 | + function($l) { |
|
58 | 58 | return [$l, 0]; |
59 | 59 | }, |
60 | 60 | explode("\n", $base) |
@@ -119,10 +119,10 @@ discard block |
||
119 | 119 | if (!$removed) { |
120 | 120 | $hunks[] = new Hunk($added, Hunk::ADDED, $matches[1], $matches[1]); |
121 | 121 | } elseif (!$added) { |
122 | - $hunks[] = new Hunk($removed, Hunk::REMOVED, $matches[1], $matches[1] + $matches[2] -1); |
|
122 | + $hunks[] = new Hunk($removed, Hunk::REMOVED, $matches[1], $matches[1] + $matches[2] - 1); |
|
123 | 123 | } else { |
124 | 124 | $combined = array_merge($removed, $added); |
125 | - $hunks[] = new Hunk($combined, Hunk::REPLACED, $matches[1], $matches[1] + $matches[2] -1); |
|
125 | + $hunks[] = new Hunk($combined, Hunk::REPLACED, $matches[1], $matches[1] + $matches[2] - 1); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | $i->next(); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | { |
63 | 63 | $this->start = $start; |
64 | 64 | if ($end === null) { |
65 | - $end= $start; |
|
65 | + $end = $start; |
|
66 | 66 | } |
67 | 67 | $this->end = $end; |
68 | 68 | if (!is_array($lines)) { |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | { |
203 | 203 | return array_values(array_filter( |
204 | 204 | $this->lines, |
205 | - function (Line $line) { |
|
205 | + function(Line $line) { |
|
206 | 206 | return $line->getType() == Line::REMOVED; |
207 | 207 | } |
208 | 208 | )); |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | { |
218 | 218 | return array_values(array_filter( |
219 | 219 | $this->lines, |
220 | - function (Line $line) { |
|
220 | + function(Line $line) { |
|
221 | 221 | return $line->getType() == Line::ADDED; |
222 | 222 | } |
223 | 223 | )); |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | public function getLinesContent() |
232 | 232 | { |
233 | 233 | return array_map( |
234 | - function (Line $line) { |
|
234 | + function(Line $line) { |
|
235 | 235 | return $line->getContent(); |
236 | 236 | }, |
237 | 237 | $this->getAddedLines() |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | protected static function preMergeAlter($text) |
298 | 298 | { |
299 | 299 | // Append new lines so that conflicts at the end of the text work. |
300 | - return $text . "\nthe\nend"; |
|
300 | + return $text."\nthe\nend"; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -334,11 +334,11 @@ discard block |
||
334 | 334 | if (!$this->dir) { |
335 | 335 | // Greate a temporary directory. |
336 | 336 | $tempfile = tempnam(sys_get_temp_dir(), ''); |
337 | - mkdir($tempfile . '.git'); |
|
337 | + mkdir($tempfile.'.git'); |
|
338 | 338 | if (file_exists($tempfile)) { |
339 | 339 | unlink($tempfile); |
340 | 340 | } |
341 | - $this->dir = $tempfile . '.git'; |
|
341 | + $this->dir = $tempfile.'.git'; |
|
342 | 342 | $this->git = $this->wrapper->init($this->dir); |
343 | 343 | } |
344 | 344 | $this->git->config('user.name', 'GitMerge') |