Completed
Push — master ( 1801e4...143145 )
by Morris
19:04 queued 02:13
created
core/Controller/WhatsNewController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -74,13 +74,13 @@  discard block
 block discarded – undo
74 74
 	 */
75 75
 	public function get():DataResponse {
76 76
 		$user = $this->userSession->getUser();
77
-		if($user === null) {
77
+		if ($user === null) {
78 78
 			throw new \RuntimeException("Acting user cannot be resolved");
79 79
 		}
80 80
 		$lastRead = $this->config->getUserValue($user->getUID(), 'core', 'whatsNewLastRead', 0);
81 81
 		$currentVersion = $this->whatsNewService->normalizeVersion($this->config->getSystemValue('version'));
82 82
 
83
-		if(version_compare($lastRead, $currentVersion, '>=')) {
83
+		if (version_compare($lastRead, $currentVersion, '>=')) {
84 84
 			return new DataResponse([], Http::STATUS_NO_CONTENT);
85 85
 		}
86 86
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 			];
95 95
 			do {
96 96
 				$lang = $iterator->current();
97
-				if(isset($whatsNew['whatsNew'][$lang])) {
97
+				if (isset($whatsNew['whatsNew'][$lang])) {
98 98
 					$resultData['whatsNew'] = $whatsNew['whatsNew'][$lang];
99 99
 					break;
100 100
 				}
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	public function dismiss(string $version):DataResponse {
116 116
 		$user = $this->userSession->getUser();
117
-		if($user === null) {
117
+		if ($user === null) {
118 118
 			throw new \RuntimeException("Acting user cannot be resolved");
119 119
 		}
120 120
 		$version = $this->whatsNewService->normalizeVersion($version);
Please login to merge, or discard this patch.
lib/private/L10N/Factory.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 		 * @link https://github.com/owncloud/core/issues/21955
166 166
 		 */
167 167
 		if ($this->config->getSystemValue('installed', false)) {
168
-			$userId = !is_null($this->userSession->getUser()) ? $this->userSession->getUser()->getUID() :  null;
168
+			$userId = !is_null($this->userSession->getUser()) ? $this->userSession->getUser()->getUID() : null;
169 169
 			if (!is_null($userId)) {
170 170
 				$userLang = $this->config->getUserValue($userId, 'core', 'lang', null);
171 171
 			} else {
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 		}
216 216
 
217 217
 		if ($this->config->getSystemValue('installed', false)) {
218
-			$userId = null !== $this->userSession->getUser() ? $this->userSession->getUser()->getUID() :  null;
218
+			$userId = null !== $this->userSession->getUser() ? $this->userSession->getUser()->getUID() : null;
219 219
 			$userLocale = null;
220 220
 			if (null !== $userId) {
221 221
 				$userLocale = $this->config->getUserValue($userId, 'core', 'locale', null);
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 		// merge with translations from theme
278 278
 		$theme = $this->config->getSystemValue('theme');
279 279
 		if (!empty($theme)) {
280
-			$themeDir = $this->serverRoot . '/themes/' . $theme . substr($dir, strlen($this->serverRoot));
280
+			$themeDir = $this->serverRoot.'/themes/'.$theme.substr($dir, strlen($this->serverRoot));
281 281
 
282 282
 			if (is_dir($themeDir)) {
283 283
 				$files = scandir($themeDir);
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 			return $this->availableLocales;
304 304
 		}
305 305
 
306
-		$localeData = file_get_contents(\OC::$SERVERROOT . '/resources/locales.json');
306
+		$localeData = file_get_contents(\OC::$SERVERROOT.'/resources/locales.json');
307 307
 		$this->availableLocales = \json_decode($localeData, true);
308 308
 
309 309
 		return $this->availableLocales;
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 
326 326
 	public function getLanguageIterator(IUser $user = null): ILanguageIterator {
327 327
 		$user = $user ?? $this->userSession->getUser();
328
-		if($user === null) {
328
+		if ($user === null) {
329 329
 			throw new \RuntimeException('Failed to get an IUser instance');
330 330
 		}
331 331
 		return new LanguageIterator($user, $this->config);
@@ -443,12 +443,12 @@  discard block
 block discarded – undo
443 443
 		$languageFiles = [];
444 444
 
445 445
 		$i18nDir = $this->findL10nDir($app);
446
-		$transFile = strip_tags($i18nDir) . strip_tags($lang) . '.json';
446
+		$transFile = strip_tags($i18nDir).strip_tags($lang).'.json';
447 447
 
448
-		if (($this->isSubDirectory($transFile, $this->serverRoot . '/core/l10n/')
449
-				|| $this->isSubDirectory($transFile, $this->serverRoot . '/lib/l10n/')
450
-				|| $this->isSubDirectory($transFile, $this->serverRoot . '/settings/l10n/')
451
-				|| $this->isSubDirectory($transFile, \OC_App::getAppPath($app) . '/l10n/')
448
+		if (($this->isSubDirectory($transFile, $this->serverRoot.'/core/l10n/')
449
+				|| $this->isSubDirectory($transFile, $this->serverRoot.'/lib/l10n/')
450
+				|| $this->isSubDirectory($transFile, $this->serverRoot.'/settings/l10n/')
451
+				|| $this->isSubDirectory($transFile, \OC_App::getAppPath($app).'/l10n/')
452 452
 			)
453 453
 			&& file_exists($transFile)) {
454 454
 			// load the translations file
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
 		// merge with translations from theme
459 459
 		$theme = $this->config->getSystemValue('theme');
460 460
 		if (!empty($theme)) {
461
-			$transFile = $this->serverRoot . '/themes/' . $theme . substr($transFile, strlen($this->serverRoot));
461
+			$transFile = $this->serverRoot.'/themes/'.$theme.substr($transFile, strlen($this->serverRoot));
462 462
 			if (file_exists($transFile)) {
463 463
 				$languageFiles[] = $transFile;
464 464
 			}
@@ -475,14 +475,14 @@  discard block
 block discarded – undo
475 475
 	 */
476 476
 	protected function findL10nDir($app = null) {
477 477
 		if (in_array($app, ['core', 'lib', 'settings'])) {
478
-			if (file_exists($this->serverRoot . '/' . $app . '/l10n/')) {
479
-				return $this->serverRoot . '/' . $app . '/l10n/';
478
+			if (file_exists($this->serverRoot.'/'.$app.'/l10n/')) {
479
+				return $this->serverRoot.'/'.$app.'/l10n/';
480 480
 			}
481 481
 		} else if ($app && \OC_App::getAppPath($app) !== false) {
482 482
 			// Check if the app is in the app folder
483
-			return \OC_App::getAppPath($app) . '/l10n/';
483
+			return \OC_App::getAppPath($app).'/l10n/';
484 484
 		}
485
-		return $this->serverRoot . '/core/l10n/';
485
+		return $this->serverRoot.'/core/l10n/';
486 486
 	}
487 487
 
488 488
 
@@ -499,15 +499,15 @@  discard block
 block discarded – undo
499 499
 			return $this->pluralFunctions[$string];
500 500
 		}
501 501
 
502
-		if (preg_match( '/^\s*nplurals\s*=\s*(\d+)\s*;\s*plural=(.*)$/u', $string, $matches)) {
502
+		if (preg_match('/^\s*nplurals\s*=\s*(\d+)\s*;\s*plural=(.*)$/u', $string, $matches)) {
503 503
 			// sanitize
504
-			$nplurals = preg_replace( '/[^0-9]/', '', $matches[1] );
505
-			$plural = preg_replace( '#[^n0-9:\(\)\?\|\&=!<>+*/\%-]#', '', $matches[2] );
504
+			$nplurals = preg_replace('/[^0-9]/', '', $matches[1]);
505
+			$plural = preg_replace('#[^n0-9:\(\)\?\|\&=!<>+*/\%-]#', '', $matches[2]);
506 506
 
507 507
 			$body = str_replace(
508
-				array( 'plural', 'n', '$n$plurals', ),
509
-				array( '$plural', '$n', '$nplurals', ),
510
-				'nplurals='. $nplurals . '; plural=' . $plural
508
+				array('plural', 'n', '$n$plurals',),
509
+				array('$plural', '$n', '$nplurals',),
510
+				'nplurals='.$nplurals.'; plural='.$plural
511 511
 			);
512 512
 
513 513
 			// add parents
@@ -516,9 +516,9 @@  discard block
 block discarded – undo
516 516
 			$res = '';
517 517
 			$p = 0;
518 518
 			$length = strlen($body);
519
-			for($i = 0; $i < $length; $i++) {
519
+			for ($i = 0; $i < $length; $i++) {
520 520
 				$ch = $body[$i];
521
-				switch ( $ch ) {
521
+				switch ($ch) {
522 522
 					case '?':
523 523
 						$res .= ' ? (';
524 524
 						$p++;
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 						$res .= ') : (';
528 528
 						break;
529 529
 					case ';':
530
-						$res .= str_repeat( ')', $p ) . ';';
530
+						$res .= str_repeat(')', $p).';';
531 531
 						$p = 0;
532 532
 						break;
533 533
 					default:
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
 				}
536 536
 			}
537 537
 
538
-			$body = $res . 'return ($plural>=$nplurals?$nplurals-1:$plural);';
538
+			$body = $res.'return ($plural>=$nplurals?$nplurals-1:$plural);';
539 539
 			$function = create_function('$n', $body);
540 540
 			$this->pluralFunctions[$string] = $function;
541 541
 			return $function;
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 		$commonLanguages = [];
568 568
 		$languages = [];
569 569
 
570
-		foreach($languageCodes as $lang) {
570
+		foreach ($languageCodes as $lang) {
571 571
 			$l = $this->get('lib', $lang);
572 572
 			// TRANSLATORS this is the language name for the language switcher in the personal settings and should be the localized version
573 573
 			$potentialName = (string) $l->t('__language_name__');
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 		ksort($commonLanguages);
601 601
 
602 602
 		// sort now by displayed language not the iso-code
603
-		usort( $languages, function ($a, $b) {
603
+		usort($languages, function($a, $b) {
604 604
 			if ($a['code'] === $a['name'] && $b['code'] !== $b['name']) {
605 605
 				// If a doesn't have a name, but b does, list b before a
606 606
 				return 1;
Please login to merge, or discard this patch.
lib/private/L10N/LanguageIterator.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -53,18 +53,18 @@  discard block
 block discarded – undo
53 53
 	 * @since 14.0.0
54 54
 	 */
55 55
 	public function current(): string {
56
-		switch($this->i) {
56
+		switch ($this->i) {
57 57
 			/** @noinspection PhpMissingBreakStatementInspection */
58 58
 			case 0:
59 59
 				$forcedLang = $this->config->getSystemValue('force_language', false);
60
-				if(is_string($forcedLang)) {
60
+				if (is_string($forcedLang)) {
61 61
 					return $forcedLang;
62 62
 				}
63 63
 				$this->next();
64 64
 			/** @noinspection PhpMissingBreakStatementInspection */
65 65
 			case 1:
66 66
 				$forcedLang = $this->config->getSystemValue('force_language', false);
67
-				if(is_string($forcedLang)
67
+				if (is_string($forcedLang)
68 68
 					&& ($truncated = $this->getTruncatedLanguage($forcedLang)) !== $forcedLang
69 69
 				) {
70 70
 					return $truncated;
@@ -73,14 +73,14 @@  discard block
 block discarded – undo
73 73
 			/** @noinspection PhpMissingBreakStatementInspection */
74 74
 			case 2:
75 75
 				$userLang = $this->config->getUserValue($this->user->getUID(), 'core', 'lang', null);
76
-				if(is_string($userLang)) {
76
+				if (is_string($userLang)) {
77 77
 					return $userLang;
78 78
 				}
79 79
 				$this->next();
80 80
 			/** @noinspection PhpMissingBreakStatementInspection */
81 81
 			case 3:
82 82
 				$userLang = $this->config->getUserValue($this->user->getUID(), 'core', 'lang', null);
83
-				if(is_string($userLang)
83
+				if (is_string($userLang)
84 84
 					&& ($truncated = $this->getTruncatedLanguage($userLang)) !== $userLang
85 85
 				) {
86 86
 					return $truncated;
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 			/** @noinspection PhpMissingBreakStatementInspection */
92 92
 			case 5:
93 93
 				$defaultLang = $this->config->getSystemValue('default_language', 'en');
94
-				if(($truncated = $this->getTruncatedLanguage($defaultLang)) !== $defaultLang) {
94
+				if (($truncated = $this->getTruncatedLanguage($defaultLang)) !== $defaultLang) {
95 95
 					return $truncated;
96 96
 				}
97 97
 				$this->next();
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 
130 130
 	protected function getTruncatedLanguage(string $lang):string {
131 131
 		$pos = strpos($lang, '_');
132
-		if($pos !== false) {
132
+		if ($pos !== false) {
133 133
 			$lang = substr($lang, 0, $pos);
134 134
 		}
135 135
 		return $lang;
Please login to merge, or discard this patch.
lib/private/Updater/ChangesCheck.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 		try {
64 64
 			$version = $this->normalizeVersion($version);
65 65
 			$changesInfo = $this->mapper->getChanges($version);
66
-			if($changesInfo->getLastCheck() + 1800 > time()) {
66
+			if ($changesInfo->getLastCheck() + 1800 > time()) {
67 67
 				return json_decode($changesInfo->getData(), true);
68 68
 			}
69 69
 		} catch (DoesNotExistException $e) {
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
 		$response = $this->queryChangesServer($uri, $changesInfo);
74 74
 
75
-		switch($this->evaluateResponse($response)) {
75
+		switch ($this->evaluateResponse($response)) {
76 76
 			case self::RESPONSE_NO_CONTENT:
77 77
 				return [];
78 78
 			case self::RESPONSE_USE_CACHE:
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
 	}
90 90
 
91 91
 	protected function evaluateResponse(IResponse $response): int {
92
-		if($response->getStatusCode() === 304) {
92
+		if ($response->getStatusCode() === 304) {
93 93
 			return self::RESPONSE_USE_CACHE;
94
-		} else if($response->getStatusCode() === 404) {
94
+		} else if ($response->getStatusCode() === 404) {
95 95
 			return self::RESPONSE_NO_CONTENT;
96
-		} else if($response->getStatusCode() === 200) {
96
+		} else if ($response->getStatusCode() === 200) {
97 97
 			return self::RESPONSE_HAS_CONTENT;
98 98
 		}
99 99
 		$this->logger->debug('Unexpected return code {code} from changelog server', [
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	}
105 105
 
106 106
 	protected function cacheResult(ChangesResult $entry, string $version) {
107
-		if($entry->getVersion() === $version) {
107
+		if ($entry->getVersion() === $version) {
108 108
 			$this->mapper->update($entry);
109 109
 		} else {
110 110
 			$entry->setVersion($version);
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	protected function queryChangesServer(string $uri, ChangesResult $entry): IResponse {
119 119
 		$headers = [];
120
-		if($entry->getEtag() !== '') {
120
+		if ($entry->getEtag() !== '') {
121 121
 			$headers['If-None-Match'] = [$entry->getEtag()];
122 122
 		}
123 123
 
@@ -135,12 +135,12 @@  discard block
 block discarded – undo
135 135
 			$xml = @simplexml_load_string($body);
136 136
 			libxml_disable_entity_loader($loadEntities);
137 137
 			if ($xml !== false) {
138
-				$data['changelogURL'] = (string)$xml->changelog['href'];
138
+				$data['changelogURL'] = (string) $xml->changelog['href'];
139 139
 				$data['whatsNew'] = [];
140
-				foreach($xml->whatsNew as $infoSet) {
141
-					$data['whatsNew'][(string)$infoSet['lang']] = [
142
-						'regular' => (array)$infoSet->regular->item,
143
-						'admin' => (array)$infoSet->admin->item,
140
+				foreach ($xml->whatsNew as $infoSet) {
141
+					$data['whatsNew'][(string) $infoSet['lang']] = [
142
+						'regular' => (array) $infoSet->regular->item,
143
+						'admin' => (array) $infoSet->admin->item,
144 144
 					];
145 145
 				}
146 146
 			} else {
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	public function normalizeVersion(string $version): string {
158 158
 		$versionNumbers = array_slice(explode('.', $version), 0, 3);
159 159
 		$versionNumbers[0] = $versionNumbers[0] ?: '0'; // deal with empty input
160
-		while(count($versionNumbers) < 3) {
160
+		while (count($versionNumbers) < 3) {
161 161
 			// changelog server expects x.y.z, pad 0 if it is too short
162 162
 			$versionNumbers[] = 0;
163 163
 		}
Please login to merge, or discard this patch.
apps/updatenotification/lib/Settings/Admin.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -116,21 +116,21 @@
 block discarded – undo
116 116
 
117 117
 	protected function filterChanges(array $changes) {
118 118
 		$filtered = [];
119
-		if(isset($changes['changelogURL'])) {
119
+		if (isset($changes['changelogURL'])) {
120 120
 			$filtered['changelogURL'] = $changes['changelogURL'];
121 121
 		}
122
-		if(!isset($changes['whatsNew'])) {
122
+		if (!isset($changes['whatsNew'])) {
123 123
 			return $filtered;
124 124
 		}
125 125
 
126 126
 		$iterator = $this->l10nFactory->getLanguageIterator();
127 127
 		do {
128 128
 			$lang = $iterator->current();
129
-			if(isset($changes['whatsNew'][$lang])) {
129
+			if (isset($changes['whatsNew'][$lang])) {
130 130
 				return $filtered['whatsNew'][$lang];
131 131
 			}
132 132
 			$iterator->next();
133
-		} while($lang !== 'en' && $iterator->valid());
133
+		} while ($lang !== 'en' && $iterator->valid());
134 134
 
135 135
 		return $filtered;
136 136
 	}
Please login to merge, or discard this patch.