Completed
Pull Request — master (#8096)
by Joas
21:24 queued 03:34
created
lib/private/Settings/Manager.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 			);
309 309
 			$forms[$form->getPriority()] = [$form];
310 310
 		}
311
-		if($section === 'security') {
311
+		if ($section === 'security') {
312 312
 			/** @var ISettings $form */
313 313
 			$form = new Personal\Security();
314 314
 			$forms[$form->getPriority()] = [$form];
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 		];
352 352
 
353 353
 		$legacyForms = \OC_App::getForms('personal');
354
-		if(!empty($legacyForms) && $this->hasLegacyPersonalSettingsToRender($legacyForms)) {
354
+		if (!empty($legacyForms) && $this->hasLegacyPersonalSettingsToRender($legacyForms)) {
355 355
 			$sections[98] = [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))];
356 356
 		}
357 357
 
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 	 */
378 378
 	private function hasLegacyPersonalSettingsToRender(array $forms): bool {
379 379
 		foreach ($forms as $form) {
380
-			if(trim($form) !== '') {
380
+			if (trim($form) !== '') {
381 381
 				return true;
382 382
 			}
383 383
 		}
Please login to merge, or discard this patch.
lib/public/Settings/IManager.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	/**
37 37
 	 * @since 9.1.0
38 38
 	 */
39
-	const KEY_ADMIN_SECTION  = 'admin-section';
39
+	const KEY_ADMIN_SECTION = 'admin-section';
40 40
 
41 41
 	/**
42 42
 	 * @since 13.0.0
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 * @since 13.0.0
48 48
 	 */
49
-	const KEY_PERSONAL_SECTION  = 'personal-section';
49
+	const KEY_PERSONAL_SECTION = 'personal-section';
50 50
 
51 51
 	/**
52 52
 	 * @param string $type 'admin' or 'personal'
Please login to merge, or discard this patch.
lib/base.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -122,14 +122,14 @@  discard block
 block discarded – undo
122 122
 	 * the app path list is empty or contains an invalid path
123 123
 	 */
124 124
 	public static function initPaths() {
125
-		if(defined('PHPUNIT_CONFIG_DIR')) {
126
-			self::$configDir = OC::$SERVERROOT . '/' . PHPUNIT_CONFIG_DIR . '/';
127
-		} elseif(defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT . '/tests/config/')) {
128
-			self::$configDir = OC::$SERVERROOT . '/tests/config/';
129
-		} elseif($dir = getenv('NEXTCLOUD_CONFIG_DIR')) {
130
-			self::$configDir = rtrim($dir, '/') . '/';
125
+		if (defined('PHPUNIT_CONFIG_DIR')) {
126
+			self::$configDir = OC::$SERVERROOT.'/'.PHPUNIT_CONFIG_DIR.'/';
127
+		} elseif (defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT.'/tests/config/')) {
128
+			self::$configDir = OC::$SERVERROOT.'/tests/config/';
129
+		} elseif ($dir = getenv('NEXTCLOUD_CONFIG_DIR')) {
130
+			self::$configDir = rtrim($dir, '/').'/';
131 131
 		} else {
132
-			self::$configDir = OC::$SERVERROOT . '/config/';
132
+			self::$configDir = OC::$SERVERROOT.'/config/';
133 133
 		}
134 134
 		self::$config = new \OC\Config(self::$configDir);
135 135
 
@@ -151,9 +151,9 @@  discard block
 block discarded – undo
151 151
 			//make sure suburi follows the same rules as scriptName
152 152
 			if (substr(OC::$SUBURI, -9) != 'index.php') {
153 153
 				if (substr(OC::$SUBURI, -1) != '/') {
154
-					OC::$SUBURI = OC::$SUBURI . '/';
154
+					OC::$SUBURI = OC::$SUBURI.'/';
155 155
 				}
156
-				OC::$SUBURI = OC::$SUBURI . 'index.php';
156
+				OC::$SUBURI = OC::$SUBURI.'index.php';
157 157
 			}
158 158
 		}
159 159
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 				OC::$WEBROOT = substr($scriptName, 0, 0 - strlen(OC::$SUBURI));
166 166
 
167 167
 				if (OC::$WEBROOT != '' && OC::$WEBROOT[0] !== '/') {
168
-					OC::$WEBROOT = '/' . OC::$WEBROOT;
168
+					OC::$WEBROOT = '/'.OC::$WEBROOT;
169 169
 				}
170 170
 			} else {
171 171
 				// The scriptName is not ending with OC::$SUBURI
@@ -194,11 +194,11 @@  discard block
 block discarded – undo
194 194
 					OC::$APPSROOTS[] = $paths;
195 195
 				}
196 196
 			}
197
-		} elseif (file_exists(OC::$SERVERROOT . '/apps')) {
198
-			OC::$APPSROOTS[] = array('path' => OC::$SERVERROOT . '/apps', 'url' => '/apps', 'writable' => true);
199
-		} elseif (file_exists(OC::$SERVERROOT . '/../apps')) {
197
+		} elseif (file_exists(OC::$SERVERROOT.'/apps')) {
198
+			OC::$APPSROOTS[] = array('path' => OC::$SERVERROOT.'/apps', 'url' => '/apps', 'writable' => true);
199
+		} elseif (file_exists(OC::$SERVERROOT.'/../apps')) {
200 200
 			OC::$APPSROOTS[] = array(
201
-				'path' => rtrim(dirname(OC::$SERVERROOT), '/') . '/apps',
201
+				'path' => rtrim(dirname(OC::$SERVERROOT), '/').'/apps',
202 202
 				'url' => '/apps',
203 203
 				'writable' => true
204 204
 			);
@@ -228,8 +228,8 @@  discard block
 block discarded – undo
228 228
 		$l = \OC::$server->getL10N('lib');
229 229
 
230 230
 		// Create config if it does not already exist
231
-		$configFilePath = self::$configDir .'/config.php';
232
-		if(!file_exists($configFilePath)) {
231
+		$configFilePath = self::$configDir.'/config.php';
232
+		if (!file_exists($configFilePath)) {
233 233
 			@touch($configFilePath);
234 234
 		}
235 235
 
@@ -244,13 +244,13 @@  discard block
 block discarded – undo
244 244
 				echo $l->t('Cannot write into "config" directory!')."\n";
245 245
 				echo $l->t('This can usually be fixed by giving the webserver write access to the config directory')."\n";
246 246
 				echo "\n";
247
-				echo $l->t('See %s', [ $urlGenerator->linkToDocs('admin-dir_permissions') ])."\n";
247
+				echo $l->t('See %s', [$urlGenerator->linkToDocs('admin-dir_permissions')])."\n";
248 248
 				exit;
249 249
 			} else {
250 250
 				OC_Template::printErrorPage(
251 251
 					$l->t('Cannot write into "config" directory!'),
252 252
 					$l->t('This can usually be fixed by giving the webserver write access to the config directory. See %s',
253
-					 [ $urlGenerator->linkToDocs('admin-dir_permissions') ])
253
+					 [$urlGenerator->linkToDocs('admin-dir_permissions')])
254 254
 				);
255 255
 			}
256 256
 		}
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
 			if (OC::$CLI) {
266 266
 				throw new Exception('Not installed');
267 267
 			} else {
268
-				$url = OC::$WEBROOT . '/index.php';
269
-				header('Location: ' . $url);
268
+				$url = OC::$WEBROOT.'/index.php';
269
+				header('Location: '.$url);
270 270
 			}
271 271
 			exit();
272 272
 		}
@@ -372,14 +372,14 @@  discard block
 block discarded – undo
372 372
 		$incompatibleShippedApps = [];
373 373
 		foreach ($incompatibleApps as $appInfo) {
374 374
 			if ($appManager->isShipped($appInfo['id'])) {
375
-				$incompatibleShippedApps[] = $appInfo['name'] . ' (' . $appInfo['id'] . ')';
375
+				$incompatibleShippedApps[] = $appInfo['name'].' ('.$appInfo['id'].')';
376 376
 			}
377 377
 		}
378 378
 
379 379
 		if (!empty($incompatibleShippedApps)) {
380 380
 			$l = \OC::$server->getL10N('core');
381 381
 			$hint = $l->t('The files of the app %$1s were not replaced correctly. Make sure it is a version compatible with the server.', [implode(', ', $incompatibleShippedApps)]);
382
-			throw new \OC\HintException('The files of the app ' . implode(', ', $incompatibleShippedApps) . ' were not replaced correctly. Make sure it is a version compatible with the server.', $hint);
382
+			throw new \OC\HintException('The files of the app '.implode(', ', $incompatibleShippedApps).' were not replaced correctly. Make sure it is a version compatible with the server.', $hint);
383 383
 		}
384 384
 
385 385
 		$tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion));
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 	}
391 391
 
392 392
 	public static function initSession() {
393
-		if(self::$server->getRequest()->getServerProtocol() === 'https') {
393
+		if (self::$server->getRequest()->getServerProtocol() === 'https') {
394 394
 			ini_set('session.cookie_secure', true);
395 395
 		}
396 396
 
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 		ini_set('session.cookie_httponly', 'true');
399 399
 
400 400
 		// set the cookie path to the Nextcloud directory
401
-		$cookie_path = OC::$WEBROOT ? : '/';
401
+		$cookie_path = OC::$WEBROOT ?: '/';
402 402
 		ini_set('session.cookie_path', $cookie_path);
403 403
 
404 404
 		// Let the session name be changed in the initSession Hook
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 		// session timeout
433 433
 		if ($session->exists('LAST_ACTIVITY') && (time() - $session->get('LAST_ACTIVITY') > $sessionLifeTime)) {
434 434
 			if (isset($_COOKIE[session_name()])) {
435
-				setcookie(session_name(), null, -1, self::$WEBROOT ? : '/');
435
+				setcookie(session_name(), null, -1, self::$WEBROOT ?: '/');
436 436
 			}
437 437
 			\OC::$server->getUserSession()->logout();
438 438
 		}
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 				continue;
455 455
 			}
456 456
 
457
-			$file = $appPath . '/appinfo/classpath.php';
457
+			$file = $appPath.'/appinfo/classpath.php';
458 458
 			if (file_exists($file)) {
459 459
 				require_once $file;
460 460
 			}
@@ -482,14 +482,14 @@  discard block
 block discarded – undo
482 482
 
483 483
 		// Append __Host to the cookie if it meets the requirements
484 484
 		$cookiePrefix = '';
485
-		if($cookieParams['secure'] === true && $cookieParams['path'] === '/') {
485
+		if ($cookieParams['secure'] === true && $cookieParams['path'] === '/') {
486 486
 			$cookiePrefix = '__Host-';
487 487
 		}
488 488
 
489
-		foreach($policies as $policy) {
489
+		foreach ($policies as $policy) {
490 490
 			header(
491 491
 				sprintf(
492
-					'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;' . $secureCookie . 'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s',
492
+					'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;'.$secureCookie.'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s',
493 493
 					$cookiePrefix,
494 494
 					$policy,
495 495
 					$cookieParams['path'],
@@ -520,31 +520,31 @@  discard block
 block discarded – undo
520 520
 			// OS X Finder
521 521
 			'/^WebDAVFS/',
522 522
 		];
523
-		if($request->isUserAgent($incompatibleUserAgents)) {
523
+		if ($request->isUserAgent($incompatibleUserAgents)) {
524 524
 			return;
525 525
 		}
526 526
 
527
-		if(count($_COOKIE) > 0) {
527
+		if (count($_COOKIE) > 0) {
528 528
 			$requestUri = $request->getScriptName();
529 529
 			$processingScript = explode('/', $requestUri);
530
-			$processingScript = $processingScript[count($processingScript)-1];
530
+			$processingScript = $processingScript[count($processingScript) - 1];
531 531
 
532 532
 			// index.php routes are handled in the middleware
533
-			if($processingScript === 'index.php') {
533
+			if ($processingScript === 'index.php') {
534 534
 				return;
535 535
 			}
536 536
 
537 537
 			// All other endpoints require the lax and the strict cookie
538
-			if(!$request->passesStrictCookieCheck()) {
538
+			if (!$request->passesStrictCookieCheck()) {
539 539
 				self::sendSameSiteCookies();
540 540
 				// Debug mode gets access to the resources without strict cookie
541 541
 				// due to the fact that the SabreDAV browser also lives there.
542
-				if(!\OC::$server->getConfig()->getSystemValue('debug', false)) {
542
+				if (!\OC::$server->getConfig()->getSystemValue('debug', false)) {
543 543
 					http_response_code(\OCP\AppFramework\Http::STATUS_SERVICE_UNAVAILABLE);
544 544
 					exit();
545 545
 				}
546 546
 			}
547
-		} elseif(!isset($_COOKIE['nc_sameSiteCookielax']) || !isset($_COOKIE['nc_sameSiteCookiestrict'])) {
547
+		} elseif (!isset($_COOKIE['nc_sameSiteCookielax']) || !isset($_COOKIE['nc_sameSiteCookiestrict'])) {
548 548
 			self::sendSameSiteCookies();
549 549
 		}
550 550
 	}
@@ -555,12 +555,12 @@  discard block
 block discarded – undo
555 555
 
556 556
 		// register autoloader
557 557
 		$loaderStart = microtime(true);
558
-		require_once __DIR__ . '/autoloader.php';
558
+		require_once __DIR__.'/autoloader.php';
559 559
 		self::$loader = new \OC\Autoloader([
560
-			OC::$SERVERROOT . '/lib/private/legacy',
560
+			OC::$SERVERROOT.'/lib/private/legacy',
561 561
 		]);
562 562
 		if (defined('PHPUNIT_RUN')) {
563
-			self::$loader->addValidRoot(OC::$SERVERROOT . '/tests');
563
+			self::$loader->addValidRoot(OC::$SERVERROOT.'/tests');
564 564
 		}
565 565
 		spl_autoload_register(array(self::$loader, 'load'));
566 566
 		$loaderEnd = microtime(true);
@@ -568,12 +568,12 @@  discard block
 block discarded – undo
568 568
 		self::$CLI = (php_sapi_name() == 'cli');
569 569
 
570 570
 		// Add default composer PSR-4 autoloader
571
-		self::$composerAutoloader = require_once OC::$SERVERROOT . '/lib/composer/autoload.php';
571
+		self::$composerAutoloader = require_once OC::$SERVERROOT.'/lib/composer/autoload.php';
572 572
 
573 573
 		try {
574 574
 			self::initPaths();
575 575
 			// setup 3rdparty autoloader
576
-			$vendorAutoLoad = OC::$SERVERROOT. '/3rdparty/autoload.php';
576
+			$vendorAutoLoad = OC::$SERVERROOT.'/3rdparty/autoload.php';
577 577
 			if (!file_exists($vendorAutoLoad)) {
578 578
 				throw new \RuntimeException('Composer autoloader not found, unable to continue. Check the folder "3rdparty". Running "git submodule update --init" will initialize the git submodule that handles the subfolder "3rdparty".');
579 579
 			}
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
 			if (!self::$CLI) {
584 584
 				$claimedProtocol = strtoupper($_SERVER['SERVER_PROTOCOL']);
585 585
 				$protocol = in_array($claimedProtocol, ['HTTP/1.0', 'HTTP/1.1', 'HTTP/2']) ? $claimedProtocol : 'HTTP/1.1';
586
-				header($protocol . ' ' . OC_Response::STATUS_SERVICE_UNAVAILABLE);
586
+				header($protocol.' '.OC_Response::STATUS_SERVICE_UNAVAILABLE);
587 587
 			}
588 588
 			// we can't use the template error page here, because this needs the
589 589
 			// DI container which isn't available yet
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 		@ini_set('display_errors', '0');
602 602
 		@ini_set('log_errors', '1');
603 603
 
604
-		if(!date_default_timezone_set('UTC')) {
604
+		if (!date_default_timezone_set('UTC')) {
605 605
 			throw new \RuntimeException('Could not set timezone to UTC');
606 606
 		}
607 607
 
@@ -655,11 +655,11 @@  discard block
 block discarded – undo
655 655
 					// Convert l10n string into regular string for usage in database
656 656
 					$staticErrors = [];
657 657
 					foreach ($errors as $error) {
658
-						echo $error['error'] . "\n";
659
-						echo $error['hint'] . "\n\n";
658
+						echo $error['error']."\n";
659
+						echo $error['hint']."\n\n";
660 660
 						$staticErrors[] = [
661
-							'error' => (string)$error['error'],
662
-							'hint' => (string)$error['hint'],
661
+							'error' => (string) $error['error'],
662
+							'hint' => (string) $error['hint'],
663 663
 						];
664 664
 					}
665 665
 
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
 		}
682 682
 		//try to set the session lifetime
683 683
 		$sessionLifeTime = self::getSessionLifeTime();
684
-		@ini_set('gc_maxlifetime', (string)$sessionLifeTime);
684
+		@ini_set('gc_maxlifetime', (string) $sessionLifeTime);
685 685
 
686 686
 		$systemConfig = \OC::$server->getSystemConfig();
687 687
 
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 		register_shutdown_function(array($lockProvider, 'releaseAll'));
727 727
 
728 728
 		// Check whether the sample configuration has been copied
729
-		if($systemConfig->getValue('copied_sample_config', false)) {
729
+		if ($systemConfig->getValue('copied_sample_config', false)) {
730 730
 			$l = \OC::$server->getL10N('lib');
731 731
 			header('HTTP/1.1 503 Service Temporarily Unavailable');
732 732
 			header('Status: 503 Service Temporarily Unavailable');
@@ -752,11 +752,11 @@  discard block
 block discarded – undo
752 752
 		) {
753 753
 			// Allow access to CSS resources
754 754
 			$isScssRequest = false;
755
-			if(strpos($request->getPathInfo(), '/css/') === 0) {
755
+			if (strpos($request->getPathInfo(), '/css/') === 0) {
756 756
 				$isScssRequest = true;
757 757
 			}
758 758
 
759
-			if(substr($request->getRequestUri(), -11) === '/status.php') {
759
+			if (substr($request->getRequestUri(), -11) === '/status.php') {
760 760
 				OC_Response::setStatus(\OC_Response::STATUS_BAD_REQUEST);
761 761
 				header('Status: 400 Bad Request');
762 762
 				header('Content-Type: application/json');
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
 
797 797
 			// NOTE: This will be replaced to use OCP
798 798
 			$userSession = self::$server->getUserSession();
799
-			$userSession->listen('\OC\User', 'postLogin', function () use ($userSession) {
799
+			$userSession->listen('\OC\User', 'postLogin', function() use ($userSession) {
800 800
 				if (!defined('PHPUNIT_RUN')) {
801 801
 					// reset brute force delay for this IP address and username
802 802
 					$uid = \OC::$server->getUserSession()->getUser()->getUID();
@@ -933,12 +933,12 @@  discard block
 block discarded – undo
933 933
 		// emergency app disabling
934 934
 		if ($requestPath === '/disableapp'
935 935
 			&& $request->getMethod() === 'POST'
936
-			&& ((array)$request->getParam('appid')) !== ''
936
+			&& ((array) $request->getParam('appid')) !== ''
937 937
 		) {
938 938
 			\OCP\JSON::callCheck();
939 939
 			\OCP\JSON::checkAdminUser();
940
-			$appIds = (array)$request->getParam('appid');
941
-			foreach($appIds as $appId) {
940
+			$appIds = (array) $request->getParam('appid');
941
+			foreach ($appIds as $appId) {
942 942
 				$appId = \OC_App::cleanAppId($appId);
943 943
 				\OC_App::disable($appId);
944 944
 			}
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
 		if (!\OCP\Util::needUpgrade()
954 954
 			&& !$systemConfig->getValue('maintenance', false)) {
955 955
 			// For logged-in users: Load everything
956
-			if(\OC::$server->getUserSession()->isLoggedIn()) {
956
+			if (\OC::$server->getUserSession()->isLoggedIn()) {
957 957
 				OC_App::loadApps();
958 958
 			} else {
959 959
 				// For guests: Load only filesystem and logging
Please login to merge, or discard this patch.
lib/private/legacy/app.php 1 patch
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 		$apps = self::getEnabledApps();
114 114
 
115 115
 		// Add each apps' folder as allowed class path
116
-		foreach($apps as $app) {
116
+		foreach ($apps as $app) {
117 117
 			$path = self::getAppPath($app);
118
-			if($path !== false) {
118
+			if ($path !== false) {
119 119
 				self::registerAutoloading($app, $path);
120 120
 			}
121 121
 		}
@@ -140,15 +140,15 @@  discard block
 block discarded – undo
140 140
 	public static function loadApp($app) {
141 141
 		self::$loadedApps[] = $app;
142 142
 		$appPath = self::getAppPath($app);
143
-		if($appPath === false) {
143
+		if ($appPath === false) {
144 144
 			return;
145 145
 		}
146 146
 
147 147
 		// in case someone calls loadApp() directly
148 148
 		self::registerAutoloading($app, $appPath);
149 149
 
150
-		if (is_file($appPath . '/appinfo/app.php')) {
151
-			\OC::$server->getEventLogger()->start('load_app_' . $app, 'Load app: ' . $app);
150
+		if (is_file($appPath.'/appinfo/app.php')) {
151
+			\OC::$server->getEventLogger()->start('load_app_'.$app, 'Load app: '.$app);
152 152
 			self::requireAppFile($app);
153 153
 			if (self::isType($app, array('authentication'))) {
154 154
 				// since authentication apps affect the "is app enabled for group" check,
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 				// enabled for groups
158 158
 				self::$enabledAppsCache = array();
159 159
 			}
160
-			\OC::$server->getEventLogger()->end('load_app_' . $app);
160
+			\OC::$server->getEventLogger()->end('load_app_'.$app);
161 161
 		}
162 162
 
163 163
 		$info = self::getAppInfo($app);
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 			$plugins = isset($info['collaboration']['plugins']['plugin']['@value']) ?
204 204
 				[$info['collaboration']['plugins']['plugin']] : $info['collaboration']['plugins']['plugin'];
205 205
 			foreach ($plugins as $plugin) {
206
-				if($plugin['@attributes']['type'] === 'collaborator-search') {
206
+				if ($plugin['@attributes']['type'] === 'collaborator-search') {
207 207
 					$pluginInfo = [
208 208
 						'shareType' => $plugin['@attributes']['share-type'],
209 209
 						'class' => $plugin['@value'],
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
 	 * @param string $path
223 223
 	 */
224 224
 	public static function registerAutoloading($app, $path) {
225
-		$key = $app . '-' . $path;
226
-		if(isset(self::$alreadyRegistered[$key])) {
225
+		$key = $app.'-'.$path;
226
+		if (isset(self::$alreadyRegistered[$key])) {
227 227
 			return;
228 228
 		}
229 229
 
@@ -233,17 +233,17 @@  discard block
 block discarded – undo
233 233
 		$appNamespace = \OC\AppFramework\App::buildAppNamespace($app);
234 234
 		\OC::$server->registerNamespace($app, $appNamespace);
235 235
 
236
-		if (file_exists($path . '/composer/autoload.php')) {
237
-			require_once $path . '/composer/autoload.php';
236
+		if (file_exists($path.'/composer/autoload.php')) {
237
+			require_once $path.'/composer/autoload.php';
238 238
 		} else {
239
-			\OC::$composerAutoloader->addPsr4($appNamespace . '\\', $path . '/lib/', true);
239
+			\OC::$composerAutoloader->addPsr4($appNamespace.'\\', $path.'/lib/', true);
240 240
 			// Register on legacy autoloader
241 241
 			\OC::$loader->addValidRoot($path);
242 242
 		}
243 243
 
244 244
 		// Register Test namespace only when testing
245 245
 		if (defined('PHPUNIT_RUN') || defined('CLI_TEST_RUN')) {
246
-			\OC::$composerAutoloader->addPsr4($appNamespace . '\\Tests\\', $path . '/tests/', true);
246
+			\OC::$composerAutoloader->addPsr4($appNamespace.'\\Tests\\', $path.'/tests/', true);
247 247
 		}
248 248
 	}
249 249
 
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 	private static function requireAppFile($app) {
256 256
 		try {
257 257
 			// encapsulated here to avoid variable scope conflicts
258
-			require_once $app . '/appinfo/app.php';
258
+			require_once $app.'/appinfo/app.php';
259 259
 		} catch (Error $ex) {
260 260
 			\OC::$server->getLogger()->logException($ex);
261 261
 			if (!\OC::$server->getAppManager()->isShipped($app)) {
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	 */
310 310
 	public static function setAppTypes($app) {
311 311
 		$appData = self::getAppInfo($app);
312
-		if(!is_array($appData)) {
312
+		if (!is_array($appData)) {
313 313
 			return;
314 314
 		}
315 315
 
@@ -361,8 +361,8 @@  discard block
 block discarded – undo
361 361
 		} else {
362 362
 			$apps = $appManager->getEnabledAppsForUser($user);
363 363
 		}
364
-		$apps = array_filter($apps, function ($app) {
365
-			return $app !== 'files';//we add this manually
364
+		$apps = array_filter($apps, function($app) {
365
+			return $app !== 'files'; //we add this manually
366 366
 		});
367 367
 		sort($apps);
368 368
 		array_unshift($apps, 'files');
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 		$installer = \OC::$server->query(Installer::class);
401 401
 		$isDownloaded = $installer->isDownloaded($appId);
402 402
 
403
-		if(!$isDownloaded) {
403
+		if (!$isDownloaded) {
404 404
 			$installer->downloadApp($appId);
405 405
 		}
406 406
 
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
 	 */
514 514
 	public static function findAppInDirectories($appId) {
515 515
 		$sanitizedAppId = self::cleanAppId($appId);
516
-		if($sanitizedAppId !== $appId) {
516
+		if ($sanitizedAppId !== $appId) {
517 517
 			return false;
518 518
 		}
519 519
 		static $app_dir = array();
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 
525 525
 		$possibleApps = array();
526 526
 		foreach (OC::$APPSROOTS as $dir) {
527
-			if (file_exists($dir['path'] . '/' . $appId)) {
527
+			if (file_exists($dir['path'].'/'.$appId)) {
528 528
 				$possibleApps[] = $dir;
529 529
 			}
530 530
 		}
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 		}
566 566
 
567 567
 		if (($dir = self::findAppInDirectories($appId)) != false) {
568
-			return $dir['path'] . '/' . $appId;
568
+			return $dir['path'].'/'.$appId;
569 569
 		}
570 570
 		return false;
571 571
 	}
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 	 */
580 580
 	public static function getAppWebPath($appId) {
581 581
 		if (($dir = self::findAppInDirectories($appId)) != false) {
582
-			return OC::$WEBROOT . $dir['url'] . '/' . $appId;
582
+			return OC::$WEBROOT.$dir['url'].'/'.$appId;
583 583
 		}
584 584
 		return false;
585 585
 	}
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 	 * @return string
593 593
 	 */
594 594
 	public static function getAppVersion($appId, $useCache = true) {
595
-		if($useCache && isset(self::$appVersion[$appId])) {
595
+		if ($useCache && isset(self::$appVersion[$appId])) {
596 596
 			return self::$appVersion[$appId];
597 597
 		}
598 598
 
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 	 * @return string
609 609
 	 */
610 610
 	public static function getAppVersionByPath($path) {
611
-		$infoFile = $path . '/appinfo/info.xml';
611
+		$infoFile = $path.'/appinfo/info.xml';
612 612
 		$appData = self::getAppInfo($infoFile, true);
613 613
 		return isset($appData['version']) ? $appData['version'] : '';
614 614
 	}
@@ -631,10 +631,10 @@  discard block
 block discarded – undo
631 631
 				return self::$appInfo[$appId];
632 632
 			}
633 633
 			$appPath = self::getAppPath($appId);
634
-			if($appPath === false) {
634
+			if ($appPath === false) {
635 635
 				return null;
636 636
 			}
637
-			$file = $appPath . '/appinfo/info.xml';
637
+			$file = $appPath.'/appinfo/info.xml';
638 638
 		}
639 639
 
640 640
 		$parser = new InfoParser(\OC::$server->getMemCacheFactory()->createLocal('core.appinfo'));
@@ -643,9 +643,9 @@  discard block
 block discarded – undo
643 643
 		if (is_array($data)) {
644 644
 			$data = OC_App::parseAppInfo($data, $lang);
645 645
 		}
646
-		if(isset($data['ocsid'])) {
646
+		if (isset($data['ocsid'])) {
647 647
 			$storedId = \OC::$server->getConfig()->getAppValue($appId, 'ocsid');
648
-			if($storedId !== '' && $storedId !== $data['ocsid']) {
648
+			if ($storedId !== '' && $storedId !== $data['ocsid']) {
649 649
 				$data['ocsid'] = $storedId;
650 650
 			}
651 651
 		}
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 	 * @param string $page
738 738
 	 */
739 739
 	public static function registerAdmin($app, $page) {
740
-		self::$adminForms[] = $app . '/' . $page . '.php';
740
+		self::$adminForms[] = $app.'/'.$page.'.php';
741 741
 	}
742 742
 
743 743
 	/**
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
 	 * @param string $page
747 747
 	 */
748 748
 	public static function registerPersonal($app, $page) {
749
-		self::$personalForms[] = $app . '/' . $page . '.php';
749
+		self::$personalForms[] = $app.'/'.$page.'.php';
750 750
 	}
751 751
 
752 752
 	/**
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
 
776 776
 		foreach (OC::$APPSROOTS as $apps_dir) {
777 777
 			if (!is_readable($apps_dir['path'])) {
778
-				\OCP\Util::writeLog('core', 'unable to read app folder : ' . $apps_dir['path'], \OCP\Util::WARN);
778
+				\OCP\Util::writeLog('core', 'unable to read app folder : '.$apps_dir['path'], \OCP\Util::WARN);
779 779
 				continue;
780 780
 			}
781 781
 			$dh = opendir($apps_dir['path']);
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
 			if (is_resource($dh)) {
784 784
 				while (($file = readdir($dh)) !== false) {
785 785
 
786
-					if ($file[0] != '.' and is_dir($apps_dir['path'] . '/' . $file) and is_file($apps_dir['path'] . '/' . $file . '/appinfo/info.xml')) {
786
+					if ($file[0] != '.' and is_dir($apps_dir['path'].'/'.$file) and is_file($apps_dir['path'].'/'.$file.'/appinfo/info.xml')) {
787 787
 
788 788
 						$apps[] = $file;
789 789
 					}
@@ -816,12 +816,12 @@  discard block
 block discarded – undo
816 816
 
817 817
 				$info = OC_App::getAppInfo($app, false, $langCode);
818 818
 				if (!is_array($info)) {
819
-					\OCP\Util::writeLog('core', 'Could not read app info file for app "' . $app . '"', \OCP\Util::ERROR);
819
+					\OCP\Util::writeLog('core', 'Could not read app info file for app "'.$app.'"', \OCP\Util::ERROR);
820 820
 					continue;
821 821
 				}
822 822
 
823 823
 				if (!isset($info['name'])) {
824
-					\OCP\Util::writeLog('core', 'App id "' . $app . '" has no name in appinfo', \OCP\Util::ERROR);
824
+					\OCP\Util::writeLog('core', 'App id "'.$app.'" has no name in appinfo', \OCP\Util::ERROR);
825 825
 					continue;
826 826
 				}
827 827
 
@@ -848,13 +848,13 @@  discard block
 block discarded – undo
848 848
 				}
849 849
 
850 850
 				$appPath = self::getAppPath($app);
851
-				if($appPath !== false) {
852
-					$appIcon = $appPath . '/img/' . $app . '.svg';
851
+				if ($appPath !== false) {
852
+					$appIcon = $appPath.'/img/'.$app.'.svg';
853 853
 					if (file_exists($appIcon)) {
854
-						$info['preview'] = $urlGenerator->imagePath($app, $app . '.svg');
854
+						$info['preview'] = $urlGenerator->imagePath($app, $app.'.svg');
855 855
 						$info['previewAsIcon'] = true;
856 856
 					} else {
857
-						$appIcon = $appPath . '/img/app.svg';
857
+						$appIcon = $appPath.'/img/app.svg';
858 858
 						if (file_exists($appIcon)) {
859 859
 							$info['preview'] = $urlGenerator->imagePath($app, 'app.svg');
860 860
 							$info['previewAsIcon'] = true;
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
 	public static function getAppVersions() {
980 980
 		static $versions;
981 981
 
982
-		if(!$versions) {
982
+		if (!$versions) {
983 983
 			$appConfig = \OC::$server->getAppConfig();
984 984
 			$versions = $appConfig->getValues(false, 'installed_version');
985 985
 		}
@@ -1001,7 +1001,7 @@  discard block
 block discarded – undo
1001 1001
 		if ($app !== false) {
1002 1002
 			// check if the app is compatible with this version of ownCloud
1003 1003
 			$info = self::getAppInfo($app);
1004
-			if(!is_array($info)) {
1004
+			if (!is_array($info)) {
1005 1005
 				throw new \Exception(
1006 1006
 					$l->t('App "%s" cannot be installed because appinfo file cannot be read.',
1007 1007
 						[$info['name']]
@@ -1026,14 +1026,14 @@  discard block
 block discarded – undo
1026 1026
 				$config->setAppValue($app, 'ocsid', $appData['id']);
1027 1027
 			}
1028 1028
 
1029
-			if(isset($info['settings']) && is_array($info['settings'])) {
1029
+			if (isset($info['settings']) && is_array($info['settings'])) {
1030 1030
 				$appPath = self::getAppPath($app);
1031 1031
 				self::registerAutoloading($app, $appPath);
1032 1032
 			}
1033 1033
 
1034 1034
 			\OC_Hook::emit('OC_App', 'post_enable', array('app' => $app));
1035 1035
 		} else {
1036
-			if(empty($appName) ) {
1036
+			if (empty($appName)) {
1037 1037
 				throw new \Exception($l->t("No app name specified"));
1038 1038
 			} else {
1039 1039
 				throw new \Exception($l->t("App '%s' could not be installed!", $appName));
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
 	 */
1052 1052
 	public static function updateApp($appId) {
1053 1053
 		$appPath = self::getAppPath($appId);
1054
-		if($appPath === false) {
1054
+		if ($appPath === false) {
1055 1055
 			return false;
1056 1056
 		}
1057 1057
 		self::registerAutoloading($appId, $appPath);
@@ -1059,8 +1059,8 @@  discard block
 block discarded – undo
1059 1059
 		$appData = self::getAppInfo($appId);
1060 1060
 		self::executeRepairSteps($appId, $appData['repair-steps']['pre-migration']);
1061 1061
 
1062
-		if (file_exists($appPath . '/appinfo/database.xml')) {
1063
-			OC_DB::updateDbFromStructure($appPath . '/appinfo/database.xml');
1062
+		if (file_exists($appPath.'/appinfo/database.xml')) {
1063
+			OC_DB::updateDbFromStructure($appPath.'/appinfo/database.xml');
1064 1064
 		} else {
1065 1065
 			$ms = new MigrationService($appId, \OC::$server->getDatabaseConnection());
1066 1066
 			$ms->migrate();
@@ -1071,23 +1071,23 @@  discard block
 block discarded – undo
1071 1071
 		unset(self::$appVersion[$appId]);
1072 1072
 
1073 1073
 		// run upgrade code
1074
-		if (file_exists($appPath . '/appinfo/update.php')) {
1074
+		if (file_exists($appPath.'/appinfo/update.php')) {
1075 1075
 			self::loadApp($appId);
1076
-			include $appPath . '/appinfo/update.php';
1076
+			include $appPath.'/appinfo/update.php';
1077 1077
 		}
1078 1078
 		self::setupBackgroundJobs($appData['background-jobs']);
1079 1079
 
1080 1080
 		//set remote/public handlers
1081 1081
 		if (array_key_exists('ocsid', $appData)) {
1082 1082
 			\OC::$server->getConfig()->setAppValue($appId, 'ocsid', $appData['ocsid']);
1083
-		} elseif(\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) {
1083
+		} elseif (\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) {
1084 1084
 			\OC::$server->getConfig()->deleteAppValue($appId, 'ocsid');
1085 1085
 		}
1086 1086
 		foreach ($appData['remote'] as $name => $path) {
1087
-			\OC::$server->getConfig()->setAppValue('core', 'remote_' . $name, $appId . '/' . $path);
1087
+			\OC::$server->getConfig()->setAppValue('core', 'remote_'.$name, $appId.'/'.$path);
1088 1088
 		}
1089 1089
 		foreach ($appData['public'] as $name => $path) {
1090
-			\OC::$server->getConfig()->setAppValue('core', 'public_' . $name, $appId . '/' . $path);
1090
+			\OC::$server->getConfig()->setAppValue('core', 'public_'.$name, $appId.'/'.$path);
1091 1091
 		}
1092 1092
 
1093 1093
 		self::setAppTypes($appId);
@@ -1157,17 +1157,17 @@  discard block
 block discarded – undo
1157 1157
 	public static function getStorage($appId) {
1158 1158
 		if (\OC::$server->getAppManager()->isEnabledForUser($appId)) { //sanity check
1159 1159
 			if (\OC::$server->getUserSession()->isLoggedIn()) {
1160
-				$view = new \OC\Files\View('/' . OC_User::getUser());
1160
+				$view = new \OC\Files\View('/'.OC_User::getUser());
1161 1161
 				if (!$view->file_exists($appId)) {
1162 1162
 					$view->mkdir($appId);
1163 1163
 				}
1164
-				return new \OC\Files\View('/' . OC_User::getUser() . '/' . $appId);
1164
+				return new \OC\Files\View('/'.OC_User::getUser().'/'.$appId);
1165 1165
 			} else {
1166
-				\OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ', user not logged in', \OCP\Util::ERROR);
1166
+				\OCP\Util::writeLog('core', 'Can\'t get app storage, app '.$appId.', user not logged in', \OCP\Util::ERROR);
1167 1167
 				return false;
1168 1168
 			}
1169 1169
 		} else {
1170
-			\OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ' not enabled', \OCP\Util::ERROR);
1170
+			\OCP\Util::writeLog('core', 'Can\'t get app storage, app '.$appId.' not enabled', \OCP\Util::ERROR);
1171 1171
 			return false;
1172 1172
 		}
1173 1173
 	}
@@ -1199,9 +1199,9 @@  discard block
 block discarded – undo
1199 1199
 
1200 1200
 				if ($attributeLang === $similarLang) {
1201 1201
 					$similarLangFallback = $option['@value'];
1202
-				} else if (strpos($attributeLang, $similarLang . '_') === 0) {
1202
+				} else if (strpos($attributeLang, $similarLang.'_') === 0) {
1203 1203
 					if ($similarLangFallback === false) {
1204
-						$similarLangFallback =  $option['@value'];
1204
+						$similarLangFallback = $option['@value'];
1205 1205
 					}
1206 1206
 				}
1207 1207
 			} else {
@@ -1236,7 +1236,7 @@  discard block
 block discarded – undo
1236 1236
 			$data['description'] = trim(self::findBestL10NOption($data['description'], $lang));
1237 1237
 		} else if (isset($data['description']) && is_string($data['description'])) {
1238 1238
 			$data['description'] = trim($data['description']);
1239
-		} else  {
1239
+		} else {
1240 1240
 			$data['description'] = '';
1241 1241
 		}
1242 1242
 
Please login to merge, or discard this patch.
lib/private/Installer.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	public function installApp($appId) {
102 102
 		$app = \OC_App::findAppInDirectories($appId);
103
-		if($app === false) {
103
+		if ($app === false) {
104 104
 			throw new \Exception('App not found in any app directory');
105 105
 		}
106 106
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 
110 110
 		$l = \OC::$server->getL10N('core');
111 111
 
112
-		if(!is_array($info)) {
112
+		if (!is_array($info)) {
113 113
 			throw new \Exception(
114 114
 				$l->t('App "%s" cannot be installed because appinfo file cannot be read.',
115 115
 					[$info['name']]
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 		\OC_App::registerAutoloading($appId, $basedir);
133 133
 
134 134
 		//install the database
135
-		if(is_file($basedir.'/appinfo/database.xml')) {
135
+		if (is_file($basedir.'/appinfo/database.xml')) {
136 136
 			if (\OC::$server->getConfig()->getAppValue($info['id'], 'installed_version') === null) {
137 137
 				OC_DB::createDbFromStructure($basedir.'/appinfo/database.xml');
138 138
 			} else {
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 		\OC_App::setupBackgroundJobs($info['background-jobs']);
147 147
 
148 148
 		//run appinfo/install.php
149
-		if(!isset($data['noinstall']) or $data['noinstall']==false) {
150
-			self::includeAppScript($basedir . '/appinfo/install.php');
149
+		if (!isset($data['noinstall']) or $data['noinstall'] == false) {
150
+			self::includeAppScript($basedir.'/appinfo/install.php');
151 151
 		}
152 152
 
153 153
 		$appData = OC_App::getAppInfo($appId);
@@ -158,10 +158,10 @@  discard block
 block discarded – undo
158 158
 		\OC::$server->getConfig()->setAppValue($info['id'], 'enabled', 'no');
159 159
 
160 160
 		//set remote/public handlers
161
-		foreach($info['remote'] as $name=>$path) {
161
+		foreach ($info['remote'] as $name=>$path) {
162 162
 			\OC::$server->getConfig()->setAppValue('core', 'remote_'.$name, $info['id'].'/'.$path);
163 163
 		}
164
-		foreach($info['public'] as $name=>$path) {
164
+		foreach ($info['public'] as $name=>$path) {
165 165
 			\OC::$server->getConfig()->setAppValue('core', 'public_'.$name, $info['id'].'/'.$path);
166 166
 		}
167 167
 
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 	 *
178 178
 	 * Checks whether or not an app is installed, i.e. registered in apps table.
179 179
 	 */
180
-	public static function isInstalled( $app ) {
180
+	public static function isInstalled($app) {
181 181
 		return (\OC::$server->getConfig()->getAppValue($app, "installed_version", null) !== null);
182 182
 	}
183 183
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	 * @return bool
189 189
 	 */
190 190
 	public function updateAppstoreApp($appId) {
191
-		if($this->isUpdateAvailable($appId)) {
191
+		if ($this->isUpdateAvailable($appId)) {
192 192
 			try {
193 193
 				$this->downloadApp($appId);
194 194
 			} catch (\Exception $e) {
@@ -215,18 +215,18 @@  discard block
 block discarded – undo
215 215
 		$appId = strtolower($appId);
216 216
 
217 217
 		$apps = $this->appFetcher->get();
218
-		foreach($apps as $app) {
219
-			if($app['id'] === $appId) {
218
+		foreach ($apps as $app) {
219
+			if ($app['id'] === $appId) {
220 220
 				// Load the certificate
221 221
 				$certificate = new X509();
222
-				$certificate->loadCA(file_get_contents(__DIR__ . '/../../resources/codesigning/root.crt'));
222
+				$certificate->loadCA(file_get_contents(__DIR__.'/../../resources/codesigning/root.crt'));
223 223
 				$loadedCertificate = $certificate->loadX509($app['certificate']);
224 224
 
225 225
 				// Verify if the certificate has been revoked
226 226
 				$crl = new X509();
227
-				$crl->loadCA(file_get_contents(__DIR__ . '/../../resources/codesigning/root.crt'));
228
-				$crl->loadCRL(file_get_contents(__DIR__ . '/../../resources/codesigning/root.crl'));
229
-				if($crl->validateSignature() !== true) {
227
+				$crl->loadCA(file_get_contents(__DIR__.'/../../resources/codesigning/root.crt'));
228
+				$crl->loadCRL(file_get_contents(__DIR__.'/../../resources/codesigning/root.crl'));
229
+				if ($crl->validateSignature() !== true) {
230 230
 					throw new \Exception('Could not validate CRL signature');
231 231
 				}
232 232
 				$csn = $loadedCertificate['tbsCertificate']['serialNumber']->toString();
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 				}
242 242
 
243 243
 				// Verify if the certificate has been issued by the Nextcloud Code Authority CA
244
-				if($certificate->validateSignature() !== true) {
244
+				if ($certificate->validateSignature() !== true) {
245 245
 					throw new \Exception(
246 246
 						sprintf(
247 247
 							'App with id %s has a certificate not issued by a trusted Code Signing Authority',
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 
253 253
 				// Verify if the certificate is issued for the requested app id
254 254
 				$certInfo = openssl_x509_parse($app['certificate']);
255
-				if(!isset($certInfo['subject']['CN'])) {
255
+				if (!isset($certInfo['subject']['CN'])) {
256 256
 					throw new \Exception(
257 257
 						sprintf(
258 258
 							'App with id %s has a cert with no CN',
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 						)
261 261
 					);
262 262
 				}
263
-				if($certInfo['subject']['CN'] !== $appId) {
263
+				if ($certInfo['subject']['CN'] !== $appId) {
264 264
 					throw new \Exception(
265 265
 						sprintf(
266 266
 							'App with id %s has a cert issued to %s',
@@ -277,15 +277,15 @@  discard block
 block discarded – undo
277 277
 
278 278
 				// Check if the signature actually matches the downloaded content
279 279
 				$certificate = openssl_get_publickey($app['certificate']);
280
-				$verified = (bool)openssl_verify(file_get_contents($tempFile), base64_decode($app['releases'][0]['signature']), $certificate, OPENSSL_ALGO_SHA512);
280
+				$verified = (bool) openssl_verify(file_get_contents($tempFile), base64_decode($app['releases'][0]['signature']), $certificate, OPENSSL_ALGO_SHA512);
281 281
 				openssl_free_key($certificate);
282 282
 
283
-				if($verified === true) {
283
+				if ($verified === true) {
284 284
 					// Seems to match, let's proceed
285 285
 					$extractDir = $this->tempManager->getTemporaryFolder();
286 286
 					$archive = new TAR($tempFile);
287 287
 
288
-					if($archive) {
288
+					if ($archive) {
289 289
 						if (!$archive->extract($extractDir)) {
290 290
 							throw new \Exception(
291 291
 								sprintf(
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 						$folders = array_diff($allFiles, ['.', '..']);
299 299
 						$folders = array_values($folders);
300 300
 
301
-						if(count($folders) > 1) {
301
+						if (count($folders) > 1) {
302 302
 							throw new \Exception(
303 303
 								sprintf(
304 304
 									'Extracted app %s has more than 1 folder',
@@ -309,22 +309,22 @@  discard block
 block discarded – undo
309 309
 
310 310
 						// Check if appinfo/info.xml has the same app ID as well
311 311
 						$loadEntities = libxml_disable_entity_loader(false);
312
-						$xml = simplexml_load_file($extractDir . '/' . $folders[0] . '/appinfo/info.xml');
312
+						$xml = simplexml_load_file($extractDir.'/'.$folders[0].'/appinfo/info.xml');
313 313
 						libxml_disable_entity_loader($loadEntities);
314
-						if((string)$xml->id !== $appId) {
314
+						if ((string) $xml->id !== $appId) {
315 315
 							throw new \Exception(
316 316
 								sprintf(
317 317
 									'App for id %s has a wrong app ID in info.xml: %s',
318 318
 									$appId,
319
-									(string)$xml->id
319
+									(string) $xml->id
320 320
 								)
321 321
 							);
322 322
 						}
323 323
 
324 324
 						// Check if the version is lower than before
325 325
 						$currentVersion = OC_App::getAppVersion($appId);
326
-						$newVersion = (string)$xml->version;
327
-						if(version_compare($currentVersion, $newVersion) === 1) {
326
+						$newVersion = (string) $xml->version;
327
+						if (version_compare($currentVersion, $newVersion) === 1) {
328 328
 							throw new \Exception(
329 329
 								sprintf(
330 330
 									'App for id %s has version %s and tried to update to lower version %s',
@@ -335,12 +335,12 @@  discard block
 block discarded – undo
335 335
 							);
336 336
 						}
337 337
 
338
-						$baseDir = OC_App::getInstallPath() . '/' . $appId;
338
+						$baseDir = OC_App::getInstallPath().'/'.$appId;
339 339
 						// Remove old app with the ID if existent
340 340
 						OC_Helper::rmdirr($baseDir);
341 341
 						// Move to app folder
342
-						if(@mkdir($baseDir)) {
343
-							$extractDir .= '/' . $folders[0];
342
+						if (@mkdir($baseDir)) {
343
+							$extractDir .= '/'.$folders[0];
344 344
 							OC_Helper::copyr($extractDir, $baseDir);
345 345
 						}
346 346
 						OC_Helper::copyr($extractDir, $baseDir);
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
 			$this->apps = $this->appFetcher->get();
404 404
 		}
405 405
 
406
-		foreach($this->apps as $app) {
407
-			if($app['id'] === $appId) {
406
+		foreach ($this->apps as $app) {
407
+			if ($app['id'] === $appId) {
408 408
 				$currentVersion = OC_App::getAppVersion($appId);
409 409
 				$newestVersion = $app['releases'][0]['version'];
410 410
 				if (version_compare($newestVersion, $currentVersion, '>')) {
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 	 */
428 428
 	private function isInstalledFromGit($appId) {
429 429
 		$app = \OC_App::findAppInDirectories($appId);
430
-		if($app === false) {
430
+		if ($app === false) {
431 431
 			return false;
432 432
 		}
433 433
 		$basedir = $app['path'].'/'.$appId;
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 	 * The function will check if the app is already downloaded in the apps repository
443 443
 	 */
444 444
 	public function isDownloaded($name) {
445
-		foreach(\OC::$APPSROOTS as $dir) {
445
+		foreach (\OC::$APPSROOTS as $dir) {
446 446
 			$dirToTest  = $dir['path'];
447 447
 			$dirToTest .= '/';
448 448
 			$dirToTest .= $name;
@@ -470,11 +470,11 @@  discard block
 block discarded – undo
470 470
 	 * this has to be done by the function oc_app_uninstall().
471 471
 	 */
472 472
 	public function removeApp($appId) {
473
-		if($this->isDownloaded( $appId )) {
474
-			$appDir = OC_App::getInstallPath() . '/' . $appId;
473
+		if ($this->isDownloaded($appId)) {
474
+			$appDir = OC_App::getInstallPath().'/'.$appId;
475 475
 			OC_Helper::rmdirr($appDir);
476 476
 			return true;
477
-		}else{
477
+		} else {
478 478
 			\OCP\Util::writeLog('core', 'can\'t remove app '.$appId.'. It is not installed.', \OCP\Util::ERROR);
479 479
 
480 480
 			return false;
@@ -490,8 +490,8 @@  discard block
 block discarded – undo
490 490
 	 */
491 491
 	public function installAppBundle(Bundle $bundle) {
492 492
 		$appIds = $bundle->getAppIdentifiers();
493
-		foreach($appIds as $appId) {
494
-			if(!$this->isDownloaded($appId)) {
493
+		foreach ($appIds as $appId) {
494
+			if (!$this->isDownloaded($appId)) {
495 495
 				$this->downloadApp($appId);
496 496
 			}
497 497
 			$this->installApp($appId);
@@ -513,13 +513,13 @@  discard block
 block discarded – undo
513 513
 	 */
514 514
 	public static function installShippedApps($softErrors = false) {
515 515
 		$errors = [];
516
-		foreach(\OC::$APPSROOTS as $app_dir) {
517
-			if($dir = opendir( $app_dir['path'] )) {
518
-				while( false !== ( $filename = readdir( $dir ))) {
519
-					if( $filename[0] !== '.' and is_dir($app_dir['path']."/$filename") ) {
520
-						if( file_exists( $app_dir['path']."/$filename/appinfo/info.xml" )) {
521
-							if(!Installer::isInstalled($filename)) {
522
-								$info=OC_App::getAppInfo($filename);
516
+		foreach (\OC::$APPSROOTS as $app_dir) {
517
+			if ($dir = opendir($app_dir['path'])) {
518
+				while (false !== ($filename = readdir($dir))) {
519
+					if ($filename[0] !== '.' and is_dir($app_dir['path']."/$filename")) {
520
+						if (file_exists($app_dir['path']."/$filename/appinfo/info.xml")) {
521
+							if (!Installer::isInstalled($filename)) {
522
+								$info = OC_App::getAppInfo($filename);
523 523
 								$enabled = isset($info['default_enable']);
524 524
 								if (($enabled || in_array($filename, \OC::$server->getAppManager()->getAlwaysEnabledApps()))
525 525
 									  && \OC::$server->getConfig()->getAppValue($filename, 'enabled') !== 'no') {
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 						}
543 543
 					}
544 544
 				}
545
-				closedir( $dir );
545
+				closedir($dir);
546 546
 			}
547 547
 		}
548 548
 
@@ -559,12 +559,12 @@  discard block
 block discarded – undo
559 559
 		$appPath = OC_App::getAppPath($app);
560 560
 		\OC_App::registerAutoloading($app, $appPath);
561 561
 
562
-		if(is_file("$appPath/appinfo/database.xml")) {
562
+		if (is_file("$appPath/appinfo/database.xml")) {
563 563
 			try {
564 564
 				OC_DB::createDbFromStructure("$appPath/appinfo/database.xml");
565 565
 			} catch (TableExistsException $e) {
566 566
 				throw new HintException(
567
-					'Failed to enable app ' . $app,
567
+					'Failed to enable app '.$app,
568 568
 					'Please ask for help via one of our <a href="https://nextcloud.com/support/" target="_blank" rel="noreferrer noopener">support channels</a>.',
569 569
 					0, $e
570 570
 				);
@@ -593,10 +593,10 @@  discard block
 block discarded – undo
593 593
 		}
594 594
 
595 595
 		//set remote/public handlers
596
-		foreach($info['remote'] as $name=>$path) {
596
+		foreach ($info['remote'] as $name=>$path) {
597 597
 			$config->setAppValue('core', 'remote_'.$name, $app.'/'.$path);
598 598
 		}
599
-		foreach($info['public'] as $name=>$path) {
599
+		foreach ($info['public'] as $name=>$path) {
600 600
 			$config->setAppValue('core', 'public_'.$name, $app.'/'.$path);
601 601
 		}
602 602
 
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
 	 * @param string $script
610 610
 	 */
611 611
 	private static function includeAppScript($script) {
612
-		if ( file_exists($script) ){
612
+		if (file_exists($script)) {
613 613
 			include $script;
614 614
 		}
615 615
 	}
Please login to merge, or discard this patch.