@@ -40,8 +40,7 @@ |
||
40 | 40 | { |
41 | 41 | $configuration = new Configuration(); |
42 | 42 | $configuration->exchangeArray($array); |
43 | - } |
|
44 | - catch (\InvalidArgumentException $exception) |
|
43 | + } catch (\InvalidArgumentException $exception) |
|
45 | 44 | { |
46 | 45 | throw new ConfigurationException("In file {$configurationFilePath}", 0, $exception); |
47 | 46 | } |
@@ -229,8 +229,7 @@ |
||
229 | 229 | $vaultConfig = new VaultConfiguration($this); |
230 | 230 | $vaultConfig->exchangeArray($val); |
231 | 231 | } |
232 | - } |
|
233 | - else |
|
232 | + } else |
|
234 | 233 | { |
235 | 234 | // using setter to prevent skipping validation |
236 | 235 | call_user_func([$this, 'set' . ucfirst($key)], $value); |
@@ -34,16 +34,13 @@ discard block |
||
34 | 34 | |
35 | 35 | return 0; |
36 | 36 | } |
37 | - } |
|
38 | - elseif ($revision === 'local') |
|
37 | + } elseif ($revision === 'local') |
|
39 | 38 | { |
40 | 39 | $index = $storeman->getLocalIndex(); |
41 | - } |
|
42 | - elseif (ctype_digit($revision)) |
|
40 | + } elseif (ctype_digit($revision)) |
|
43 | 41 | { |
44 | 42 | $revision = intval($revision); |
45 | - } |
|
46 | - else |
|
43 | + } else |
|
47 | 44 | { |
48 | 45 | $this->consoleStyle->error("Argument 'revision' invalid."); |
49 | 46 | |
@@ -72,8 +69,7 @@ discard block |
||
72 | 69 | /** @var DisplayIndexHelper $displayIndexHelper */ |
73 | 70 | $displayIndexHelper = $this->getHelper('displayIndex'); |
74 | 71 | $displayIndexHelper->displayIndex($index, $output); |
75 | - } |
|
76 | - else |
|
72 | + } else |
|
77 | 73 | { |
78 | 74 | $this->consoleStyle->writeln("(Empty index)"); |
79 | 75 | } |
@@ -56,12 +56,10 @@ discard block |
||
56 | 56 | $this->consoleStyle->error("Invalid argument compareTo given."); |
57 | 57 | |
58 | 58 | return 1; |
59 | - } |
|
60 | - elseif ($compareTo === null) |
|
59 | + } elseif ($compareTo === null) |
|
61 | 60 | { |
62 | 61 | $compareToIndex = $storeman->getLocalIndex(); |
63 | - } |
|
64 | - else |
|
62 | + } else |
|
65 | 63 | { |
66 | 64 | $vault = $vaults->getPrioritizedVault($vaults->getVaultsHavingRevision($compareTo)); |
67 | 65 | |
@@ -88,9 +86,7 @@ discard block |
||
88 | 86 | /** @var DisplayIndexComparisonHelper $helper */ |
89 | 87 | $helper = $this->getHelper('displayIndexComparison'); |
90 | 88 | $helper->displayIndexComparison($diff, $output, "r{$revision}", $compareTo ? "r{$compareTo}" : "local"); |
91 | - } |
|
92 | - |
|
93 | - else |
|
89 | + } else |
|
94 | 90 | { |
95 | 91 | $output->writeln("No differences found."); |
96 | 92 | } |
@@ -59,8 +59,7 @@ |
||
59 | 59 | "blobId: " . ($indexObject->getBlobId() ?: '-'), |
60 | 60 | "hash(es):" . ($indexObject->getHashes() && $indexObject->getHashes()->count() ? ("\n" . str_replace(', ', "\n", $indexObject->getHashes()->__toString())) : ' -'), |
61 | 61 | ]); |
62 | - } |
|
63 | - elseif ($indexObject->isLink()) |
|
62 | + } elseif ($indexObject->isLink()) |
|
64 | 63 | { |
65 | 64 | $parts = array_merge($parts, [ |
66 | 65 | "target: {$indexObject->getLinkTarget()}" |
@@ -275,6 +275,10 @@ |
||
275 | 275 | return $remoteObject->getBlobId() !== $lastLocalObject->getBlobId(); |
276 | 276 | } |
277 | 277 | |
278 | + /** |
|
279 | + * @param IndexObject $localObject |
|
280 | + * @param IndexObject $lastLocalObject |
|
281 | + */ |
|
278 | 282 | protected function resolveConflict(ConflictHandlerInterface $conflictHandler, IndexObject $remoteObject, ?IndexObject $localObject, ?IndexObject $lastLocalObject): IndexObject |
279 | 283 | { |
280 | 284 | $this->logger->notice("Resolving conflict at {$remoteObject->getRelativePath()}..."); |
@@ -100,38 +100,32 @@ discard block |
||
100 | 100 | { |
101 | 101 | // locally and remotely deleted |
102 | 102 | return null; |
103 | - } |
|
104 | - elseif ($lastLocalObject === null) |
|
103 | + } elseif ($lastLocalObject === null) |
|
105 | 104 | { |
106 | 105 | if ($remoteObject === null) |
107 | 106 | { |
108 | 107 | // locally created |
109 | 108 | return clone $localObject; |
110 | - } |
|
111 | - elseif ($localObject === null) |
|
109 | + } elseif ($localObject === null) |
|
112 | 110 | { |
113 | 111 | // remotely created |
114 | 112 | return clone $remoteObject; |
115 | - } |
|
116 | - elseif ($remoteObject !== null && $localObject !== null) |
|
113 | + } elseif ($remoteObject !== null && $localObject !== null) |
|
117 | 114 | { |
118 | 115 | // remotely and locally created |
119 | 116 | return $this->resolveConflict($conflictHandler, $remoteObject, $localObject, $lastLocalObject); |
120 | 117 | } |
121 | - } |
|
122 | - elseif ($remoteObject === null) |
|
118 | + } elseif ($remoteObject === null) |
|
123 | 119 | { |
124 | 120 | // remotely deleted and locally changed |
125 | 121 | return $this->resolveConflict($conflictHandler, $remoteObject, $localObject, $lastLocalObject); |
126 | - } |
|
127 | - elseif ($localObject === null) |
|
122 | + } elseif ($localObject === null) |
|
128 | 123 | { |
129 | 124 | if ($remoteObject->equals($lastLocalObject)) |
130 | 125 | { |
131 | 126 | // locally deleted |
132 | 127 | return null; |
133 | - } |
|
134 | - else |
|
128 | + } else |
|
135 | 129 | { |
136 | 130 | // remotely changed and locally deleted |
137 | 131 | return $this->resolveConflict($conflictHandler, $remoteObject, $localObject, $lastLocalObject); |
@@ -183,8 +177,7 @@ discard block |
||
183 | 177 | if ($modifiedRemote || !$modifiedLocal) |
184 | 178 | { |
185 | 179 | $attributes[$attribute] = $remoteObject[$attribute]; |
186 | - } |
|
187 | - else |
|
180 | + } else |
|
188 | 181 | { |
189 | 182 | $attributes[$attribute] = $localObject[$attribute]; |
190 | 183 | } |
@@ -210,8 +203,7 @@ discard block |
||
210 | 203 | $attributes['size'] = $remoteObject->getSize(); |
211 | 204 | $attributes['blobId'] = $remoteObject->getBlobId(); |
212 | 205 | $attributes['hashes'] = clone $remoteObject->getHashes(); |
213 | - } |
|
214 | - else |
|
206 | + } else |
|
215 | 207 | { |
216 | 208 | $attributes['size'] = $localObject->getSize(); |
217 | 209 | $attributes['inode'] = $localObject->getInode(); |
@@ -63,9 +63,7 @@ discard block |
||
63 | 63 | $toSetMtime[$mergedIndexObject->getRelativePath()] = $mergedIndexObject; |
64 | 64 | } |
65 | 65 | } |
66 | - } |
|
67 | - |
|
68 | - elseif ($mergedIndexObject->isFile()) |
|
66 | + } elseif ($mergedIndexObject->isFile()) |
|
69 | 67 | { |
70 | 68 | // local file did not exist, hasn't been a file before or has outdated content |
71 | 69 | $doDownloadFile = $localObject === null || !$localObject->isFile() || $mergedIndexObject->getBlobId() !== $localObject->getBlobId(); |
@@ -78,9 +76,7 @@ discard block |
||
78 | 76 | |
79 | 77 | $modifiedPaths[] = $mergedIndexObject->getRelativePath(); |
80 | 78 | } |
81 | - } |
|
82 | - |
|
83 | - elseif ($mergedIndexObject->isLink()) |
|
79 | + } elseif ($mergedIndexObject->isLink()) |
|
84 | 80 | { |
85 | 81 | if ($localObject !== null && $localObject->getLinkTarget() !== $mergedIndexObject->getLinkTarget()) |
86 | 82 | { |
@@ -89,9 +85,7 @@ discard block |
||
89 | 85 | |
90 | 86 | $modifiedPaths[] = $mergedIndexObject->getRelativePath(); |
91 | 87 | } |
92 | - } |
|
93 | - |
|
94 | - else |
|
88 | + } else |
|
95 | 89 | { |
96 | 90 | // unknown/invalid object type |
97 | 91 | throw new Exception(); |
@@ -284,8 +284,7 @@ |
||
284 | 284 | "size: {$this->size} B", |
285 | 285 | "blobId: {$blobId}", |
286 | 286 | ]); |
287 | - } |
|
288 | - elseif ($this->isLink()) |
|
287 | + } elseif ($this->isLink()) |
|
289 | 288 | { |
290 | 289 | $parts = array_merge($parts, [ |
291 | 290 | "target: {$this->linkTarget}", |