@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @return bool |
100 | 100 | */ |
101 | 101 | public function isCodeCheckEnforced(): bool { |
102 | - $notSignedChannels = [ '', 'git']; |
|
102 | + $notSignedChannels = ['', 'git']; |
|
103 | 103 | if (\in_array($this->environmentHelper->getChannel(), $notSignedChannels, true)) { |
104 | 104 | return false; |
105 | 105 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $folderToIterate, |
134 | 134 | \RecursiveDirectoryIterator::SKIP_DOTS |
135 | 135 | ); |
136 | - if($root === '') { |
|
136 | + if ($root === '') { |
|
137 | 137 | $root = \OC::$SERVERROOT; |
138 | 138 | } |
139 | 139 | $root = rtrim($root, '/'); |
@@ -162,9 +162,9 @@ discard block |
||
162 | 162 | $tmpFolder = ''; |
163 | 163 | |
164 | 164 | $baseDirectoryLength = \strlen($path); |
165 | - foreach($iterator as $filename => $data) { |
|
165 | + foreach ($iterator as $filename => $data) { |
|
166 | 166 | /** @var \DirectoryIterator $data */ |
167 | - if($data->isDir()) { |
|
167 | + if ($data->isDir()) { |
|
168 | 168 | continue; |
169 | 169 | } |
170 | 170 | |
@@ -172,11 +172,11 @@ discard block |
||
172 | 172 | $relativeFileName = ltrim($relativeFileName, '/'); |
173 | 173 | |
174 | 174 | // Exclude signature.json files in the appinfo and root folder |
175 | - if($relativeFileName === 'appinfo/signature.json') { |
|
175 | + if ($relativeFileName === 'appinfo/signature.json') { |
|
176 | 176 | continue; |
177 | 177 | } |
178 | 178 | // Exclude signature.json files in the appinfo and core folder |
179 | - if($relativeFileName === 'core/signature.json') { |
|
179 | + if ($relativeFileName === 'core/signature.json') { |
|
180 | 180 | continue; |
181 | 181 | } |
182 | 182 | |
@@ -185,18 +185,18 @@ discard block |
||
185 | 185 | // to ensure that this will not lead to false positives this will |
186 | 186 | // copy the file to a temporary folder and reset it to the default |
187 | 187 | // values. |
188 | - if($filename === $this->environmentHelper->getServerRoot() . '/.htaccess' |
|
189 | - || $filename === $this->environmentHelper->getServerRoot() . '/.user.ini') { |
|
188 | + if ($filename === $this->environmentHelper->getServerRoot().'/.htaccess' |
|
189 | + || $filename === $this->environmentHelper->getServerRoot().'/.user.ini') { |
|
190 | 190 | |
191 | - if(!$copiedWebserverSettingFiles) { |
|
191 | + if (!$copiedWebserverSettingFiles) { |
|
192 | 192 | $tmpFolder = rtrim($this->tempManager->getTemporaryFolder(), '/'); |
193 | - copy($this->environmentHelper->getServerRoot() . '/.htaccess', $tmpFolder . '/.htaccess'); |
|
194 | - copy($this->environmentHelper->getServerRoot() . '/.user.ini', $tmpFolder . '/.user.ini'); |
|
193 | + copy($this->environmentHelper->getServerRoot().'/.htaccess', $tmpFolder.'/.htaccess'); |
|
194 | + copy($this->environmentHelper->getServerRoot().'/.user.ini', $tmpFolder.'/.user.ini'); |
|
195 | 195 | \OC_Files::setUploadLimit( |
196 | 196 | \OCP\Util::computerFileSize('511MB'), |
197 | 197 | [ |
198 | - '.htaccess' => $tmpFolder . '/.htaccess', |
|
199 | - '.user.ini' => $tmpFolder . '/.user.ini', |
|
198 | + '.htaccess' => $tmpFolder.'/.htaccess', |
|
199 | + '.user.ini' => $tmpFolder.'/.user.ini', |
|
200 | 200 | ] |
201 | 201 | ); |
202 | 202 | } |
@@ -204,8 +204,8 @@ discard block |
||
204 | 204 | |
205 | 205 | // The .user.ini file can contain custom modifications to the file size |
206 | 206 | // as well. |
207 | - if($filename === $this->environmentHelper->getServerRoot() . '/.user.ini') { |
|
208 | - $fileContent = file_get_contents($tmpFolder . '/.user.ini'); |
|
207 | + if ($filename === $this->environmentHelper->getServerRoot().'/.user.ini') { |
|
208 | + $fileContent = file_get_contents($tmpFolder.'/.user.ini'); |
|
209 | 209 | $hashes[$relativeFileName] = hash('sha512', $fileContent); |
210 | 210 | continue; |
211 | 211 | } |
@@ -217,10 +217,10 @@ discard block |
||
217 | 217 | // Thus we ignore everything below the first occurrence of |
218 | 218 | // "#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####" and have the |
219 | 219 | // hash generated based on this. |
220 | - if($filename === $this->environmentHelper->getServerRoot() . '/.htaccess') { |
|
221 | - $fileContent = file_get_contents($tmpFolder . '/.htaccess'); |
|
220 | + if ($filename === $this->environmentHelper->getServerRoot().'/.htaccess') { |
|
221 | + $fileContent = file_get_contents($tmpFolder.'/.htaccess'); |
|
222 | 222 | $explodedArray = explode('#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####', $fileContent); |
223 | - if(\count($explodedArray) === 2) { |
|
223 | + if (\count($explodedArray) === 2) { |
|
224 | 224 | $hashes[$relativeFileName] = hash('sha512', $explodedArray[0]); |
225 | 225 | continue; |
226 | 226 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | public function writeAppSignature($path, |
270 | 270 | X509 $certificate, |
271 | 271 | RSA $privateKey) { |
272 | - $appInfoDir = $path . '/appinfo'; |
|
272 | + $appInfoDir = $path.'/appinfo'; |
|
273 | 273 | try { |
274 | 274 | $this->fileAccessHelper->assertDirectoryExists($appInfoDir); |
275 | 275 | |
@@ -277,12 +277,12 @@ discard block |
||
277 | 277 | $hashes = $this->generateHashes($iterator, $path); |
278 | 278 | $signature = $this->createSignatureData($hashes, $certificate, $privateKey); |
279 | 279 | $this->fileAccessHelper->file_put_contents( |
280 | - $appInfoDir . '/signature.json', |
|
280 | + $appInfoDir.'/signature.json', |
|
281 | 281 | json_encode($signature, JSON_PRETTY_PRINT) |
282 | 282 | ); |
283 | - } catch (\Exception $e){ |
|
283 | + } catch (\Exception $e) { |
|
284 | 284 | if (!$this->fileAccessHelper->is_writable($appInfoDir)) { |
285 | - throw new \Exception($appInfoDir . ' is not writable'); |
|
285 | + throw new \Exception($appInfoDir.' is not writable'); |
|
286 | 286 | } |
287 | 287 | throw $e; |
288 | 288 | } |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | public function writeCoreSignature(X509 $certificate, |
300 | 300 | RSA $rsa, |
301 | 301 | $path) { |
302 | - $coreDir = $path . '/core'; |
|
302 | + $coreDir = $path.'/core'; |
|
303 | 303 | try { |
304 | 304 | |
305 | 305 | $this->fileAccessHelper->assertDirectoryExists($coreDir); |
@@ -307,12 +307,12 @@ discard block |
||
307 | 307 | $hashes = $this->generateHashes($iterator, $path); |
308 | 308 | $signatureData = $this->createSignatureData($hashes, $certificate, $rsa); |
309 | 309 | $this->fileAccessHelper->file_put_contents( |
310 | - $coreDir . '/signature.json', |
|
310 | + $coreDir.'/signature.json', |
|
311 | 311 | json_encode($signatureData, JSON_PRETTY_PRINT) |
312 | 312 | ); |
313 | - } catch (\Exception $e){ |
|
313 | + } catch (\Exception $e) { |
|
314 | 314 | if (!$this->fileAccessHelper->is_writable($coreDir)) { |
315 | - throw new \Exception($coreDir . ' is not writable'); |
|
315 | + throw new \Exception($coreDir.' is not writable'); |
|
316 | 316 | } |
317 | 317 | throw $e; |
318 | 318 | } |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | * @throws \Exception |
330 | 330 | */ |
331 | 331 | private function verify(string $signaturePath, string $basePath, string $certificateCN): array { |
332 | - if(!$this->isCodeCheckEnforced()) { |
|
332 | + if (!$this->isCodeCheckEnforced()) { |
|
333 | 333 | return []; |
334 | 334 | } |
335 | 335 | |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | if (\is_string($content)) { |
340 | 340 | $signatureData = json_decode($content, true); |
341 | 341 | } |
342 | - if(!\is_array($signatureData)) { |
|
342 | + if (!\is_array($signatureData)) { |
|
343 | 343 | throw new InvalidSignatureException('Signature data not found.'); |
344 | 344 | } |
345 | 345 | |
@@ -353,11 +353,11 @@ discard block |
||
353 | 353 | $rootCertificatePublicKey = $this->fileAccessHelper->file_get_contents($this->environmentHelper->getServerRoot().'/resources/codesigning/root.crt'); |
354 | 354 | $x509->loadCA($rootCertificatePublicKey); |
355 | 355 | $x509->loadX509($certificate); |
356 | - if(!$x509->validateSignature()) { |
|
356 | + if (!$x509->validateSignature()) { |
|
357 | 357 | throw new InvalidSignatureException('Certificate is not valid.'); |
358 | 358 | } |
359 | 359 | // Verify if certificate has proper CN. "core" CN is always trusted. |
360 | - if($x509->getDN(X509::DN_OPENSSL)['CN'] !== $certificateCN && $x509->getDN(X509::DN_OPENSSL)['CN'] !== 'core') { |
|
360 | + if ($x509->getDN(X509::DN_OPENSSL)['CN'] !== $certificateCN && $x509->getDN(X509::DN_OPENSSL)['CN'] !== 'core') { |
|
361 | 361 | throw new InvalidSignatureException( |
362 | 362 | sprintf('Certificate is not valid for required scope. (Requested: %s, current: CN=%s)', $certificateCN, $x509->getDN(true)['CN']) |
363 | 363 | ); |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | $rsa->setMGFHash('sha512'); |
371 | 371 | // See https://tools.ietf.org/html/rfc3447#page-38 |
372 | 372 | $rsa->setSaltLength(0); |
373 | - if(!$rsa->verify(json_encode($expectedHashes), $signature)) { |
|
373 | + if (!$rsa->verify(json_encode($expectedHashes), $signature)) { |
|
374 | 374 | throw new InvalidSignatureException('Signature could not get verified.'); |
375 | 375 | } |
376 | 376 | |
@@ -379,9 +379,9 @@ discard block |
||
379 | 379 | // |
380 | 380 | // Due to this reason we exclude the whole updater/ folder from the code |
381 | 381 | // integrity check. |
382 | - if($basePath === $this->environmentHelper->getServerRoot()) { |
|
383 | - foreach($expectedHashes as $fileName => $hash) { |
|
384 | - if(strpos($fileName, 'updater/') === 0) { |
|
382 | + if ($basePath === $this->environmentHelper->getServerRoot()) { |
|
383 | + foreach ($expectedHashes as $fileName => $hash) { |
|
384 | + if (strpos($fileName, 'updater/') === 0) { |
|
385 | 385 | unset($expectedHashes[$fileName]); |
386 | 386 | } |
387 | 387 | } |
@@ -393,23 +393,23 @@ discard block |
||
393 | 393 | $differencesB = array_diff($currentInstanceHashes, $expectedHashes); |
394 | 394 | $differences = array_unique(array_merge($differencesA, $differencesB)); |
395 | 395 | $differenceArray = []; |
396 | - foreach($differences as $filename => $hash) { |
|
396 | + foreach ($differences as $filename => $hash) { |
|
397 | 397 | // Check if file should not exist in the new signature table |
398 | - if(!array_key_exists($filename, $expectedHashes)) { |
|
398 | + if (!array_key_exists($filename, $expectedHashes)) { |
|
399 | 399 | $differenceArray['EXTRA_FILE'][$filename]['expected'] = ''; |
400 | 400 | $differenceArray['EXTRA_FILE'][$filename]['current'] = $hash; |
401 | 401 | continue; |
402 | 402 | } |
403 | 403 | |
404 | 404 | // Check if file is missing |
405 | - if(!array_key_exists($filename, $currentInstanceHashes)) { |
|
405 | + if (!array_key_exists($filename, $currentInstanceHashes)) { |
|
406 | 406 | $differenceArray['FILE_MISSING'][$filename]['expected'] = $expectedHashes[$filename]; |
407 | 407 | $differenceArray['FILE_MISSING'][$filename]['current'] = ''; |
408 | 408 | continue; |
409 | 409 | } |
410 | 410 | |
411 | 411 | // Check if hash does mismatch |
412 | - if($expectedHashes[$filename] !== $currentInstanceHashes[$filename]) { |
|
412 | + if ($expectedHashes[$filename] !== $currentInstanceHashes[$filename]) { |
|
413 | 413 | $differenceArray['INVALID_HASH'][$filename]['expected'] = $expectedHashes[$filename]; |
414 | 414 | $differenceArray['INVALID_HASH'][$filename]['current'] = $currentInstanceHashes[$filename]; |
415 | 415 | continue; |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | */ |
430 | 430 | public function hasPassedCheck(): bool { |
431 | 431 | $results = $this->getResults(); |
432 | - if(empty($results)) { |
|
432 | + if (empty($results)) { |
|
433 | 433 | return true; |
434 | 434 | } |
435 | 435 | |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | */ |
442 | 442 | public function getResults(): array { |
443 | 443 | $cachedResults = $this->cache->get(self::CACHE_KEY); |
444 | - if(!\is_null($cachedResults)) { |
|
444 | + if (!\is_null($cachedResults)) { |
|
445 | 445 | return json_decode($cachedResults, true); |
446 | 446 | } |
447 | 447 | |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | private function storeResults(string $scope, array $result) { |
461 | 461 | $resultArray = $this->getResults(); |
462 | 462 | unset($resultArray[$scope]); |
463 | - if(!empty($result)) { |
|
463 | + if (!empty($result)) { |
|
464 | 464 | $resultArray[$scope] = $result; |
465 | 465 | } |
466 | 466 | if ($this->config !== null) { |
@@ -512,11 +512,11 @@ discard block |
||
512 | 512 | */ |
513 | 513 | public function verifyAppSignature(string $appId, string $path = ''): array { |
514 | 514 | try { |
515 | - if($path === '') { |
|
515 | + if ($path === '') { |
|
516 | 516 | $path = $this->appLocator->getAppPath($appId); |
517 | 517 | } |
518 | 518 | $result = $this->verify( |
519 | - $path . '/appinfo/signature.json', |
|
519 | + $path.'/appinfo/signature.json', |
|
520 | 520 | $path, |
521 | 521 | $appId |
522 | 522 | ); |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | public function verifyCoreSignature(): array { |
567 | 567 | try { |
568 | 568 | $result = $this->verify( |
569 | - $this->environmentHelper->getServerRoot() . '/core/signature.json', |
|
569 | + $this->environmentHelper->getServerRoot().'/core/signature.json', |
|
570 | 570 | $this->environmentHelper->getServerRoot(), |
571 | 571 | 'core' |
572 | 572 | ); |
@@ -591,18 +591,18 @@ discard block |
||
591 | 591 | $this->cleanResults(); |
592 | 592 | $this->verifyCoreSignature(); |
593 | 593 | $appIds = $this->appLocator->getAllApps(); |
594 | - foreach($appIds as $appId) { |
|
594 | + foreach ($appIds as $appId) { |
|
595 | 595 | // If an application is shipped a valid signature is required |
596 | 596 | $isShipped = $this->appManager->isShipped($appId); |
597 | 597 | $appNeedsToBeChecked = false; |
598 | 598 | if ($isShipped) { |
599 | 599 | $appNeedsToBeChecked = true; |
600 | - } elseif ($this->fileAccessHelper->file_exists($this->appLocator->getAppPath($appId) . '/appinfo/signature.json')) { |
|
600 | + } elseif ($this->fileAccessHelper->file_exists($this->appLocator->getAppPath($appId).'/appinfo/signature.json')) { |
|
601 | 601 | // Otherwise only if the application explicitly ships a signature.json file |
602 | 602 | $appNeedsToBeChecked = true; |
603 | 603 | } |
604 | 604 | |
605 | - if($appNeedsToBeChecked) { |
|
605 | + if ($appNeedsToBeChecked) { |
|
606 | 606 | $this->verifyAppSignature($appId); |
607 | 607 | } |
608 | 608 | } |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function file_put_contents(string $filename, string $data): int { |
63 | 63 | $bytesWritten = @file_put_contents($filename, $data); |
64 | - if ($bytesWritten === false || $bytesWritten !== \strlen($data)){ |
|
65 | - throw new \Exception('Failed to write into ' . $filename); |
|
64 | + if ($bytesWritten === false || $bytesWritten !== \strlen($data)) { |
|
65 | + throw new \Exception('Failed to write into '.$filename); |
|
66 | 66 | } |
67 | 67 | return $bytesWritten; |
68 | 68 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function assertDirectoryExists(string $path) { |
83 | 83 | if (!is_dir($path)) { |
84 | - throw new \Exception('Directory ' . $path . ' does not exist.'); |
|
84 | + throw new \Exception('Directory '.$path.' does not exist.'); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | } |
@@ -40,7 +40,7 @@ |
||
40 | 40 | */ |
41 | 41 | public function getAppPath(string $appId): string { |
42 | 42 | $path = \OC_App::getAppPath($appId); |
43 | - if($path === false) { |
|
43 | + if ($path === false) { |
|
44 | 44 | |
45 | 45 | throw new \Exception('App not found'); |
46 | 46 | } |
@@ -163,7 +163,7 @@ |
||
163 | 163 | $data = strtotime($data); |
164 | 164 | $value->setTimestamp($data); |
165 | 165 | } else if ($data !== null) { |
166 | - $data = (int)$data; |
|
166 | + $data = (int) $data; |
|
167 | 167 | $value->setTimestamp($data); |
168 | 168 | } |
169 | 169 |
@@ -139,14 +139,14 @@ discard block |
||
139 | 139 | ->from(self::TAG_TABLE); |
140 | 140 | |
141 | 141 | if (!\is_null($visibilityFilter)) { |
142 | - $query->andWhere($query->expr()->eq('visibility', $query->createNamedParameter((int)$visibilityFilter))); |
|
142 | + $query->andWhere($query->expr()->eq('visibility', $query->createNamedParameter((int) $visibilityFilter))); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | if (!empty($nameSearchPattern)) { |
146 | 146 | $query->andWhere( |
147 | 147 | $query->expr()->like( |
148 | 148 | 'name', |
149 | - $query->createNamedParameter('%' . $this->connection->escapeLikeParameter($nameSearchPattern). '%') |
|
149 | + $query->createNamedParameter('%'.$this->connection->escapeLikeParameter($nameSearchPattern).'%') |
|
150 | 150 | ) |
151 | 151 | ); |
152 | 152 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $result->closeCursor(); |
181 | 181 | if (!$row) { |
182 | 182 | throw new TagNotFoundException( |
183 | - 'Tag ("' . $tagName . '", '. $userVisible . ', ' . $userAssignable . ') does not exist' |
|
183 | + 'Tag ("'.$tagName.'", '.$userVisible.', '.$userAssignable.') does not exist' |
|
184 | 184 | ); |
185 | 185 | } |
186 | 186 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | $query->execute(); |
204 | 204 | } catch (UniqueConstraintViolationException $e) { |
205 | 205 | throw new TagAlreadyExistsException( |
206 | - 'Tag ("' . $tagName . '", '. $userVisible . ', ' . $userAssignable . ') already exists', |
|
206 | + 'Tag ("'.$tagName.'", '.$userVisible.', '.$userAssignable.') already exists', |
|
207 | 207 | 0, |
208 | 208 | $e |
209 | 209 | ); |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $tagId = $query->getLastInsertId(); |
213 | 213 | |
214 | 214 | $tag = new SystemTag( |
215 | - (string)$tagId, |
|
215 | + (string) $tagId, |
|
216 | 216 | $tagName, |
217 | 217 | $userVisible, |
218 | 218 | $userAssignable |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | } |
265 | 265 | } catch (UniqueConstraintViolationException $e) { |
266 | 266 | throw new TagAlreadyExistsException( |
267 | - 'Tag ("' . $tagName . '", '. $userVisible . ', ' . $userAssignable . ') already exists', |
|
267 | + 'Tag ("'.$tagName.'", '.$userVisible.', '.$userAssignable.') already exists', |
|
268 | 268 | 0, |
269 | 269 | $e |
270 | 270 | ); |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | } |
372 | 372 | |
373 | 373 | private function createSystemTagFromRow($row) { |
374 | - return new SystemTag((string)$row['id'], $row['name'], (bool)$row['visibility'], (bool)$row['editable']); |
|
374 | + return new SystemTag((string) $row['id'], $row['name'], (bool) $row['visibility'], (bool) $row['editable']); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | /** |
@@ -233,7 +233,7 @@ |
||
233 | 233 | $result->closeCursor(); |
234 | 234 | |
235 | 235 | if ($all) { |
236 | - return ((int)$row[0] === \count($objIds)); |
|
236 | + return ((int) $row[0] === \count($objIds)); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | return (bool) $row; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | public function __destruct() { |
70 | 70 | try { |
71 | 71 | $this->close(); |
72 | - } catch (SessionNotAvailableException $e){ |
|
72 | + } catch (SessionNotAvailableException $e) { |
|
73 | 73 | // This exception can occur if session is already closed |
74 | 74 | // So it is safe to ignore it and let the garbage collector to proceed |
75 | 75 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @return string|null Either the value or null |
106 | 106 | */ |
107 | 107 | public function get(string $key) { |
108 | - if(isset($this->sessionValues[$key])) { |
|
108 | + if (isset($this->sessionValues[$key])) { |
|
109 | 109 | return $this->sessionValues[$key]; |
110 | 110 | } |
111 | 111 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | * Close the session and release the lock, also writes all changed data in batch |
172 | 172 | */ |
173 | 173 | public function close() { |
174 | - if($this->isModified) { |
|
174 | + if ($this->isModified) { |
|
175 | 175 | $encryptedValue = $this->crypto->encrypt(json_encode($this->sessionValues), $this->passphrase); |
176 | 176 | $this->session->set(self::encryptedSessionName, $encryptedValue); |
177 | 177 | $this->isModified = false; |
@@ -170,12 +170,12 @@ |
||
170 | 170 | */ |
171 | 171 | private function invoke(string $functionName, array $parameters = [], bool $silence = false) { |
172 | 172 | try { |
173 | - if($silence) { |
|
173 | + if ($silence) { |
|
174 | 174 | return @call_user_func_array($functionName, $parameters); |
175 | 175 | } else { |
176 | 176 | return call_user_func_array($functionName, $parameters); |
177 | 177 | } |
178 | - } catch(\Error $e) { |
|
178 | + } catch (\Error $e) { |
|
179 | 179 | $this->trapError($e->getCode(), $e->getMessage()); |
180 | 180 | } |
181 | 181 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function getDefaultPolicy(): ContentSecurityPolicy { |
46 | 46 | $defaultPolicy = new \OC\Security\CSP\ContentSecurityPolicy(); |
47 | - foreach($this->policies as $policy) { |
|
47 | + foreach ($this->policies as $policy) { |
|
48 | 48 | $defaultPolicy = $this->mergePolicies($defaultPolicy, $policy); |
49 | 49 | } |
50 | 50 | return $defaultPolicy; |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function mergePolicies(ContentSecurityPolicy $defaultPolicy, |
61 | 61 | EmptyContentSecurityPolicy $originalPolicy): ContentSecurityPolicy { |
62 | - foreach((object)(array)$originalPolicy as $name => $value) { |
|
62 | + foreach ((object) (array) $originalPolicy as $name => $value) { |
|
63 | 63 | $setter = 'set'.ucfirst($name); |
64 | - if(\is_array($value)) { |
|
64 | + if (\is_array($value)) { |
|
65 | 65 | $getter = 'get'.ucfirst($name); |
66 | 66 | $currentValues = \is_array($defaultPolicy->$getter()) ? $defaultPolicy->$getter() : []; |
67 | 67 | $defaultPolicy->$setter(array_values(array_unique(array_merge($currentValues, $value)))); |