Completed
Pull Request — master (#9705)
by Morris
49:01 queued 26:30
created
lib/private/Updater/ChangesCheck.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		try {
55 55
 			$version = $this->normalizeVersion($version);
56 56
 			$changesInfo = $this->mapper->getChanges($version);
57
-			if($changesInfo->getLastCheck() + 1800 > time()) {
57
+			if ($changesInfo->getLastCheck() + 1800 > time()) {
58 58
 				return json_decode($changesInfo->getData(), true);
59 59
 			}
60 60
 		} catch (DoesNotExistException $e) {
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 
64 64
 		$response = $this->queryChangesServer($uri, $changesInfo);
65 65
 
66
-		switch($this->evaluateResponse($response)) {
66
+		switch ($this->evaluateResponse($response)) {
67 67
 			case self::RESPONSE_NO_CONTENT:
68 68
 				return [];
69 69
 			case self::RESPONSE_USE_CACHE:
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 	}
81 81
 
82 82
 	protected function evaluateResponse(IResponse $response): int {
83
-		if($response->getStatusCode() === 304) {
83
+		if ($response->getStatusCode() === 304) {
84 84
 			return self::RESPONSE_USE_CACHE;
85
-		} else if($response->getStatusCode() === 404) {
85
+		} else if ($response->getStatusCode() === 404) {
86 86
 			return self::RESPONSE_NO_CONTENT;
87
-		} else if($response->getStatusCode() === 200) {
87
+		} else if ($response->getStatusCode() === 200) {
88 88
 			return self::RESPONSE_HAS_CONTENT;
89 89
 		}
90 90
 		$this->logger->debug('Unexpected return code {code} from changelog server', [
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	}
96 96
 
97 97
 	protected function cacheResult(ChangesResult $entry, string $version) {
98
-		if($entry->getVersion() === $version) {
98
+		if ($entry->getVersion() === $version) {
99 99
 			$this->mapper->update($entry);
100 100
 		} else {
101 101
 			$entry->setVersion($version);
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 */
109 109
 	protected function queryChangesServer(string $uri, ChangesResult $entry): IResponse {
110 110
 		$headers = [];
111
-		if($entry->getEtag() !== '') {
111
+		if ($entry->getEtag() !== '') {
112 112
 			$headers['If-None-Match'] = [$entry->getEtag()];
113 113
 		}
114 114
 
@@ -126,12 +126,12 @@  discard block
 block discarded – undo
126 126
 			$xml = @simplexml_load_string($body);
127 127
 			libxml_disable_entity_loader($loadEntities);
128 128
 			if ($xml !== false) {
129
-				$data['changelogURL'] = (string)$xml->changelog['href'];
129
+				$data['changelogURL'] = (string) $xml->changelog['href'];
130 130
 				$data['whatsNew'] = [];
131
-				foreach($xml->whatsNew as $infoSet) {
132
-					$data['whatsNew'][(string)$infoSet['lang']] = [
133
-						'regular' => (array)$infoSet->regular->item,
134
-						'admin' => (array)$infoSet->admin->item,
131
+				foreach ($xml->whatsNew as $infoSet) {
132
+					$data['whatsNew'][(string) $infoSet['lang']] = [
133
+						'regular' => (array) $infoSet->regular->item,
134
+						'admin' => (array) $infoSet->admin->item,
135 135
 					];
136 136
 				}
137 137
 			} else {
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	protected function normalizeVersion(string $version): string {
149 149
 		$versionNumbers = array_slice(explode('.', $version), 0, 3);
150 150
 		$versionNumbers[0] = $versionNumbers[0] ?: '0'; // deal with empty input
151
-		while(count($versionNumbers) < 3) {
151
+		while (count($versionNumbers) < 3) {
152 152
 			// changelog server expects x.y.z, pad 0 if it is too short
153 153
 			$versionNumbers[] = 0;
154 154
 		}
Please login to merge, or discard this patch.
lib/private/Updater/VersionCheck.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	public function check() {
57 57
 		// Look up the cache - it is invalidated all 30 minutes
58
-		if (((int)$this->config->getAppValue('core', 'lastupdatedat') + 1800) > time()) {
58
+		if (((int) $this->config->getAppValue('core', 'lastupdatedat') + 1800) > time()) {
59 59
 			return json_decode($this->config->getAppValue('core', 'lastupdateResult'), true);
60 60
 		}
61 61
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 		$versionString = implode('x', $version);
80 80
 
81 81
 		//fetch xml data from updater
82
-		$url = $updaterUrl . '?version=' . $versionString;
82
+		$url = $updaterUrl.'?version='.$versionString;
83 83
 
84 84
 		$tmp = [];
85 85
 		try {
@@ -93,13 +93,13 @@  discard block
 block discarded – undo
93 93
 			$data = @simplexml_load_string($xml);
94 94
 			libxml_disable_entity_loader($loadEntities);
95 95
 			if ($data !== false) {
96
-				$tmp['version'] = (string)$data->version;
97
-				$tmp['versionstring'] = (string)$data->versionstring;
98
-				$tmp['url'] = (string)$data->url;
99
-				$tmp['web'] = (string)$data->web;
100
-				$tmp['changes'] = isset($data->changes) ? (string)$data->changes : '';
101
-				$tmp['autoupdater'] = (string)$data->autoupdater;
102
-				$tmp['eol'] = isset($data->eol) ? (string)$data->eol : '0';
96
+				$tmp['version'] = (string) $data->version;
97
+				$tmp['versionstring'] = (string) $data->versionstring;
98
+				$tmp['url'] = (string) $data->url;
99
+				$tmp['web'] = (string) $data->web;
100
+				$tmp['changes'] = isset($data->changes) ? (string) $data->changes : '';
101
+				$tmp['autoupdater'] = (string) $data->autoupdater;
102
+				$tmp['eol'] = isset($data->eol) ? (string) $data->eol : '0';
103 103
 			} else {
104 104
 				libxml_clear_errors();
105 105
 			}
Please login to merge, or discard this patch.
apps/updatenotification/lib/Settings/Admin.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -116,40 +116,40 @@
 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
 		$isFirstCall = true;
127 127
 		do {
128 128
 			$lang = $this->l10nFactory->iterateLanguage($isFirstCall);
129
-			if($this->findWhatsNewTranslation($lang, $filtered, $changes['whatsNew'])) {
129
+			if ($this->findWhatsNewTranslation($lang, $filtered, $changes['whatsNew'])) {
130 130
 				return $filtered;
131 131
 			}
132 132
 			$isFirstCall = false;
133
-		} while($lang !== 'en');
133
+		} while ($lang !== 'en');
134 134
 
135 135
 		return $filtered;
136 136
 	}
137 137
 
138 138
 	protected function getLangTrunk(string $lang):string {
139 139
 		$pos = strpos($lang, '_');
140
-		if($pos !== false) {
140
+		if ($pos !== false) {
141 141
 			$lang = substr($lang, 0, $pos);
142 142
 		}
143 143
 		return $lang;
144 144
 	}
145 145
 
146 146
 	protected function findWhatsNewTranslation(string $lang, array &$result, array $whatsNew): bool {
147
-		if(isset($whatsNew[$lang])) {
147
+		if (isset($whatsNew[$lang])) {
148 148
 			$result['whatsNew'] = $whatsNew[$lang];
149 149
 			return true;
150 150
 		}
151 151
 		$trunkedLang = $this->getLangTrunk($lang);
152
-		if($trunkedLang !== $lang && isset($whatsNew[$trunkedLang])) {
152
+		if ($trunkedLang !== $lang && isset($whatsNew[$trunkedLang])) {
153 153
 			$result['whatsNew'] = $whatsNew[$trunkedLang];
154 154
 			return true;
155 155
 		}
Please login to merge, or discard this patch.
core/Migrations/Version14000Date20180626223656.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
 	public function changeSchema(\OCP\Migration\IOutput $output, \Closure $schemaClosure, array $options) {
32 32
 		/** @var ISchemaWrapper $schema */
33 33
 		$schema = $schemaClosure();
34
-		if(!$schema->hasTable('whats_new')) {
34
+		if (!$schema->hasTable('whats_new')) {
35 35
 			$table = $schema->createTable('whats_new');
36 36
 			$table->addColumn('id', 'integer', [
37 37
 				'autoincrement' => true,
Please login to merge, or discard this patch.
lib/private/L10N/Factory.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 		 * @link https://github.com/owncloud/core/issues/21955
165 165
 		 */
166 166
 		if ($this->config->getSystemValue('installed', false)) {
167
-			$userId = !is_null($this->userSession->getUser()) ? $this->userSession->getUser()->getUID() :  null;
167
+			$userId = !is_null($this->userSession->getUser()) ? $this->userSession->getUser()->getUID() : null;
168 168
 			if (!is_null($userId)) {
169 169
 				$userLang = $this->config->getUserValue($userId, 'core', 'lang', null);
170 170
 			} else {
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 		}
215 215
 
216 216
 		if ($this->config->getSystemValue('installed', false)) {
217
-			$userId = null !== $this->userSession->getUser() ? $this->userSession->getUser()->getUID() :  null;
217
+			$userId = null !== $this->userSession->getUser() ? $this->userSession->getUser()->getUID() : null;
218 218
 			$userLocale = null;
219 219
 			if (null !== $userId) {
220 220
 				$userLocale = $this->config->getUserValue($userId, 'core', 'locale', null);
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 		// merge with translations from theme
277 277
 		$theme = $this->config->getSystemValue('theme');
278 278
 		if (!empty($theme)) {
279
-			$themeDir = $this->serverRoot . '/themes/' . $theme . substr($dir, strlen($this->serverRoot));
279
+			$themeDir = $this->serverRoot.'/themes/'.$theme.substr($dir, strlen($this->serverRoot));
280 280
 
281 281
 			if (is_dir($themeDir)) {
282 282
 				$files = scandir($themeDir);
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 			return $this->availableLocales;
303 303
 		}
304 304
 
305
-		$localeData = file_get_contents(\OC::$SERVERROOT . '/resources/locales.json');
305
+		$localeData = file_get_contents(\OC::$SERVERROOT.'/resources/locales.json');
306 306
 		$this->availableLocales = \json_decode($localeData, true);
307 307
 
308 308
 		return $this->availableLocales;
@@ -324,24 +324,24 @@  discard block
 block discarded – undo
324 324
 
325 325
 	public function iterateLanguage(bool $reset = false): string {
326 326
 		static $i = 0;
327
-		if($reset) {
327
+		if ($reset) {
328 328
 			$i = 0;
329 329
 		}
330
-		switch($i) {
330
+		switch ($i) {
331 331
 			/** @noinspection PhpMissingBreakStatementInspection */
332 332
 			case 0:
333 333
 				$i++;
334 334
 				$forcedLang = $this->config->getSystemValue('force_language', false);
335
-				if(is_string($forcedLang)) {
335
+				if (is_string($forcedLang)) {
336 336
 					return $forcedLang;
337 337
 				}
338 338
 			/** @noinspection PhpMissingBreakStatementInspection */
339 339
 			case 1:
340 340
 				$i++;
341 341
 				$user = $this->userSession->getUser();
342
-				if($user instanceof IUser) {
342
+				if ($user instanceof IUser) {
343 343
 					$userLang = $this->config->getUserValue($user->getUID(), 'core', 'lang', null);
344
-					if(is_string($userLang)) {
344
+					if (is_string($userLang)) {
345 345
 						return $userLang;
346 346
 					}
347 347
 				}
@@ -465,12 +465,12 @@  discard block
 block discarded – undo
465 465
 		$languageFiles = [];
466 466
 
467 467
 		$i18nDir = $this->findL10nDir($app);
468
-		$transFile = strip_tags($i18nDir) . strip_tags($lang) . '.json';
468
+		$transFile = strip_tags($i18nDir).strip_tags($lang).'.json';
469 469
 
470
-		if (($this->isSubDirectory($transFile, $this->serverRoot . '/core/l10n/')
471
-				|| $this->isSubDirectory($transFile, $this->serverRoot . '/lib/l10n/')
472
-				|| $this->isSubDirectory($transFile, $this->serverRoot . '/settings/l10n/')
473
-				|| $this->isSubDirectory($transFile, \OC_App::getAppPath($app) . '/l10n/')
470
+		if (($this->isSubDirectory($transFile, $this->serverRoot.'/core/l10n/')
471
+				|| $this->isSubDirectory($transFile, $this->serverRoot.'/lib/l10n/')
472
+				|| $this->isSubDirectory($transFile, $this->serverRoot.'/settings/l10n/')
473
+				|| $this->isSubDirectory($transFile, \OC_App::getAppPath($app).'/l10n/')
474 474
 			)
475 475
 			&& file_exists($transFile)) {
476 476
 			// load the translations file
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 		// merge with translations from theme
481 481
 		$theme = $this->config->getSystemValue('theme');
482 482
 		if (!empty($theme)) {
483
-			$transFile = $this->serverRoot . '/themes/' . $theme . substr($transFile, strlen($this->serverRoot));
483
+			$transFile = $this->serverRoot.'/themes/'.$theme.substr($transFile, strlen($this->serverRoot));
484 484
 			if (file_exists($transFile)) {
485 485
 				$languageFiles[] = $transFile;
486 486
 			}
@@ -497,14 +497,14 @@  discard block
 block discarded – undo
497 497
 	 */
498 498
 	protected function findL10nDir($app = null) {
499 499
 		if (in_array($app, ['core', 'lib', 'settings'])) {
500
-			if (file_exists($this->serverRoot . '/' . $app . '/l10n/')) {
501
-				return $this->serverRoot . '/' . $app . '/l10n/';
500
+			if (file_exists($this->serverRoot.'/'.$app.'/l10n/')) {
501
+				return $this->serverRoot.'/'.$app.'/l10n/';
502 502
 			}
503 503
 		} else if ($app && \OC_App::getAppPath($app) !== false) {
504 504
 			// Check if the app is in the app folder
505
-			return \OC_App::getAppPath($app) . '/l10n/';
505
+			return \OC_App::getAppPath($app).'/l10n/';
506 506
 		}
507
-		return $this->serverRoot . '/core/l10n/';
507
+		return $this->serverRoot.'/core/l10n/';
508 508
 	}
509 509
 
510 510
 
@@ -521,15 +521,15 @@  discard block
 block discarded – undo
521 521
 			return $this->pluralFunctions[$string];
522 522
 		}
523 523
 
524
-		if (preg_match( '/^\s*nplurals\s*=\s*(\d+)\s*;\s*plural=(.*)$/u', $string, $matches)) {
524
+		if (preg_match('/^\s*nplurals\s*=\s*(\d+)\s*;\s*plural=(.*)$/u', $string, $matches)) {
525 525
 			// sanitize
526
-			$nplurals = preg_replace( '/[^0-9]/', '', $matches[1] );
527
-			$plural = preg_replace( '#[^n0-9:\(\)\?\|\&=!<>+*/\%-]#', '', $matches[2] );
526
+			$nplurals = preg_replace('/[^0-9]/', '', $matches[1]);
527
+			$plural = preg_replace('#[^n0-9:\(\)\?\|\&=!<>+*/\%-]#', '', $matches[2]);
528 528
 
529 529
 			$body = str_replace(
530
-				array( 'plural', 'n', '$n$plurals', ),
531
-				array( '$plural', '$n', '$nplurals', ),
532
-				'nplurals='. $nplurals . '; plural=' . $plural
530
+				array('plural', 'n', '$n$plurals',),
531
+				array('$plural', '$n', '$nplurals',),
532
+				'nplurals='.$nplurals.'; plural='.$plural
533 533
 			);
534 534
 
535 535
 			// add parents
@@ -538,9 +538,9 @@  discard block
 block discarded – undo
538 538
 			$res = '';
539 539
 			$p = 0;
540 540
 			$length = strlen($body);
541
-			for($i = 0; $i < $length; $i++) {
541
+			for ($i = 0; $i < $length; $i++) {
542 542
 				$ch = $body[$i];
543
-				switch ( $ch ) {
543
+				switch ($ch) {
544 544
 					case '?':
545 545
 						$res .= ' ? (';
546 546
 						$p++;
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 						$res .= ') : (';
550 550
 						break;
551 551
 					case ';':
552
-						$res .= str_repeat( ')', $p ) . ';';
552
+						$res .= str_repeat(')', $p).';';
553 553
 						$p = 0;
554 554
 						break;
555 555
 					default:
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 				}
558 558
 			}
559 559
 
560
-			$body = $res . 'return ($plural>=$nplurals?$nplurals-1:$plural);';
560
+			$body = $res.'return ($plural>=$nplurals?$nplurals-1:$plural);';
561 561
 			$function = create_function('$n', $body);
562 562
 			$this->pluralFunctions[$string] = $function;
563 563
 			return $function;
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 		$commonLanguages = [];
590 590
 		$languages = [];
591 591
 
592
-		foreach($languageCodes as $lang) {
592
+		foreach ($languageCodes as $lang) {
593 593
 			$l = $this->get('lib', $lang);
594 594
 			// TRANSLATORS this is the language name for the language switcher in the personal settings and should be the localized version
595 595
 			$potentialName = (string) $l->t('__language_name__');
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 		ksort($commonLanguages);
623 623
 
624 624
 		// sort now by displayed language not the iso-code
625
-		usort( $languages, function ($a, $b) {
625
+		usort($languages, function($a, $b) {
626 626
 			if ($a['code'] === $a['name'] && $b['code'] !== $b['name']) {
627 627
 				// If a doesn't have a name, but b does, list b before a
628 628
 				return 1;
Please login to merge, or discard this patch.