Passed
Push — master ( 15b0e4...d4d33e )
by Roeland
14:38 queued 01:38
created
lib/base.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -138,13 +138,13 @@  discard block
 block discarded – undo
138 138
 	 */
139 139
 	public static function initPaths() {
140 140
 		if (defined('PHPUNIT_CONFIG_DIR')) {
141
-			self::$configDir = OC::$SERVERROOT . '/' . PHPUNIT_CONFIG_DIR . '/';
142
-		} elseif (defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT . '/tests/config/')) {
143
-			self::$configDir = OC::$SERVERROOT . '/tests/config/';
141
+			self::$configDir = OC::$SERVERROOT.'/'.PHPUNIT_CONFIG_DIR.'/';
142
+		} elseif (defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT.'/tests/config/')) {
143
+			self::$configDir = OC::$SERVERROOT.'/tests/config/';
144 144
 		} elseif ($dir = getenv('NEXTCLOUD_CONFIG_DIR')) {
145
-			self::$configDir = rtrim($dir, '/') . '/';
145
+			self::$configDir = rtrim($dir, '/').'/';
146 146
 		} else {
147
-			self::$configDir = OC::$SERVERROOT . '/config/';
147
+			self::$configDir = OC::$SERVERROOT.'/config/';
148 148
 		}
149 149
 		self::$config = new \OC\Config(self::$configDir);
150 150
 
@@ -166,9 +166,9 @@  discard block
 block discarded – undo
166 166
 			//make sure suburi follows the same rules as scriptName
167 167
 			if (substr(OC::$SUBURI, -9) != 'index.php') {
168 168
 				if (substr(OC::$SUBURI, -1) != '/') {
169
-					OC::$SUBURI = OC::$SUBURI . '/';
169
+					OC::$SUBURI = OC::$SUBURI.'/';
170 170
 				}
171
-				OC::$SUBURI = OC::$SUBURI . 'index.php';
171
+				OC::$SUBURI = OC::$SUBURI.'index.php';
172 172
 			}
173 173
 		}
174 174
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 				OC::$WEBROOT = substr($scriptName, 0, 0 - strlen(OC::$SUBURI));
181 181
 
182 182
 				if (OC::$WEBROOT != '' && OC::$WEBROOT[0] !== '/') {
183
-					OC::$WEBROOT = '/' . OC::$WEBROOT;
183
+					OC::$WEBROOT = '/'.OC::$WEBROOT;
184 184
 				}
185 185
 			} else {
186 186
 				// The scriptName is not ending with OC::$SUBURI
@@ -209,8 +209,8 @@  discard block
 block discarded – undo
209 209
 					OC::$APPSROOTS[] = $paths;
210 210
 				}
211 211
 			}
212
-		} elseif (file_exists(OC::$SERVERROOT . '/apps')) {
213
-			OC::$APPSROOTS[] = ['path' => OC::$SERVERROOT . '/apps', 'url' => '/apps', 'writable' => true];
212
+		} elseif (file_exists(OC::$SERVERROOT.'/apps')) {
213
+			OC::$APPSROOTS[] = ['path' => OC::$SERVERROOT.'/apps', 'url' => '/apps', 'writable' => true];
214 214
 		}
215 215
 
216 216
 		if (empty(OC::$APPSROOTS)) {
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 		$l = \OC::$server->getL10N('lib');
237 237
 
238 238
 		// Create config if it does not already exist
239
-		$configFilePath = self::$configDir .'/config.php';
239
+		$configFilePath = self::$configDir.'/config.php';
240 240
 		if (!file_exists($configFilePath)) {
241 241
 			@touch($configFilePath);
242 242
 		}
@@ -252,14 +252,14 @@  discard block
 block discarded – undo
252 252
 				echo $l->t('This can usually be fixed by giving the webserver write access to the config directory')."\n";
253 253
 				echo "\n";
254 254
 				echo $l->t('Or, if you prefer to keep config.php file read only, set the option "config_is_read_only" to true in it.')."\n";
255
-				echo $l->t('See %s', [ $urlGenerator->linkToDocs('admin-config') ])."\n";
255
+				echo $l->t('See %s', [$urlGenerator->linkToDocs('admin-config')])."\n";
256 256
 				exit;
257 257
 			} else {
258 258
 				OC_Template::printErrorPage(
259 259
 					$l->t('Cannot write into "config" directory!'),
260
-					$l->t('This can usually be fixed by giving the webserver write access to the config directory.') . '. '
260
+					$l->t('This can usually be fixed by giving the webserver write access to the config directory.').'. '
261 261
 					. $l->t('Or, if you prefer to keep config.php file read only, set the option "config_is_read_only" to true in it. See %s',
262
-					[ $urlGenerator->linkToDocs('admin-config') ]),
262
+					[$urlGenerator->linkToDocs('admin-config')]),
263 263
 					503
264 264
 				);
265 265
 			}
@@ -275,8 +275,8 @@  discard block
 block discarded – undo
275 275
 			if (OC::$CLI) {
276 276
 				throw new Exception('Not installed');
277 277
 			} else {
278
-				$url = OC::$WEBROOT . '/index.php';
279
-				header('Location: ' . $url);
278
+				$url = OC::$WEBROOT.'/index.php';
279
+				header('Location: '.$url);
280 280
 			}
281 281
 			exit();
282 282
 		}
@@ -380,14 +380,14 @@  discard block
 block discarded – undo
380 380
 		$incompatibleShippedApps = [];
381 381
 		foreach ($incompatibleApps as $appInfo) {
382 382
 			if ($appManager->isShipped($appInfo['id'])) {
383
-				$incompatibleShippedApps[] = $appInfo['name'] . ' (' . $appInfo['id'] . ')';
383
+				$incompatibleShippedApps[] = $appInfo['name'].' ('.$appInfo['id'].')';
384 384
 			}
385 385
 		}
386 386
 
387 387
 		if (!empty($incompatibleShippedApps)) {
388 388
 			$l = \OC::$server->getL10N('core');
389 389
 			$hint = $l->t('The files of the app %1$s were not replaced correctly. Make sure it is a version compatible with the server.', [implode(', ', $incompatibleShippedApps)]);
390
-			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);
390
+			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);
391 391
 		}
392 392
 
393 393
 		$tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion));
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 		ini_set('session.cookie_httponly', 'true');
407 407
 
408 408
 		// set the cookie path to the Nextcloud directory
409
-		$cookie_path = OC::$WEBROOT ? : '/';
409
+		$cookie_path = OC::$WEBROOT ?: '/';
410 410
 		ini_set('session.cookie_path', $cookie_path);
411 411
 
412 412
 		// Let the session name be changed in the initSession Hook
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 		// session timeout
434 434
 		if ($session->exists('LAST_ACTIVITY') && (time() - $session->get('LAST_ACTIVITY') > $sessionLifeTime)) {
435 435
 			if (isset($_COOKIE[session_name()])) {
436
-				setcookie(session_name(), '', -1, self::$WEBROOT ? : '/');
436
+				setcookie(session_name(), '', -1, self::$WEBROOT ?: '/');
437 437
 			}
438 438
 			\OC::$server->getUserSession()->logout();
439 439
 		}
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 		foreach ($policies as $policy) {
477 477
 			header(
478 478
 				sprintf(
479
-					'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;' . $secureCookie . 'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s',
479
+					'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;'.$secureCookie.'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s',
480 480
 					$cookiePrefix,
481 481
 					$policy,
482 482
 					$cookieParams['path'],
@@ -550,12 +550,12 @@  discard block
 block discarded – undo
550 550
 
551 551
 		// register autoloader
552 552
 		$loaderStart = microtime(true);
553
-		require_once __DIR__ . '/autoloader.php';
553
+		require_once __DIR__.'/autoloader.php';
554 554
 		self::$loader = new \OC\Autoloader([
555
-			OC::$SERVERROOT . '/lib/private/legacy',
555
+			OC::$SERVERROOT.'/lib/private/legacy',
556 556
 		]);
557 557
 		if (defined('PHPUNIT_RUN')) {
558
-			self::$loader->addValidRoot(OC::$SERVERROOT . '/tests');
558
+			self::$loader->addValidRoot(OC::$SERVERROOT.'/tests');
559 559
 		}
560 560
 		spl_autoload_register([self::$loader, 'load']);
561 561
 		$loaderEnd = microtime(true);
@@ -563,12 +563,12 @@  discard block
 block discarded – undo
563 563
 		self::$CLI = (php_sapi_name() == 'cli');
564 564
 
565 565
 		// Add default composer PSR-4 autoloader
566
-		self::$composerAutoloader = require_once OC::$SERVERROOT . '/lib/composer/autoload.php';
566
+		self::$composerAutoloader = require_once OC::$SERVERROOT.'/lib/composer/autoload.php';
567 567
 
568 568
 		try {
569 569
 			self::initPaths();
570 570
 			// setup 3rdparty autoloader
571
-			$vendorAutoLoad = OC::$SERVERROOT. '/3rdparty/autoload.php';
571
+			$vendorAutoLoad = OC::$SERVERROOT.'/3rdparty/autoload.php';
572 572
 			if (!file_exists($vendorAutoLoad)) {
573 573
 				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".');
574 574
 			}
@@ -664,11 +664,11 @@  discard block
 block discarded – undo
664 664
 				// Convert l10n string into regular string for usage in database
665 665
 				$staticErrors = [];
666 666
 				foreach ($errors as $error) {
667
-					echo $error['error'] . "\n";
668
-					echo $error['hint'] . "\n\n";
667
+					echo $error['error']."\n";
668
+					echo $error['hint']."\n\n";
669 669
 					$staticErrors[] = [
670
-						'error' => (string)$error['error'],
671
-						'hint' => (string)$error['hint'],
670
+						'error' => (string) $error['error'],
671
+						'hint' => (string) $error['hint'],
672 672
 					];
673 673
 				}
674 674
 
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 		}
685 685
 		//try to set the session lifetime
686 686
 		$sessionLifeTime = self::getSessionLifeTime();
687
-		@ini_set('gc_maxlifetime', (string)$sessionLifeTime);
687
+		@ini_set('gc_maxlifetime', (string) $sessionLifeTime);
688 688
 
689 689
 		// User and Groups
690 690
 		if (!$systemConfig->getValue("installed", false)) {
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
 
795 795
 			// NOTE: This will be replaced to use OCP
796 796
 			$userSession = self::$server->getUserSession();
797
-			$userSession->listen('\OC\User', 'postLogin', function () use ($userSession) {
797
+			$userSession->listen('\OC\User', 'postLogin', function() use ($userSession) {
798 798
 				if (!defined('PHPUNIT_RUN') && $userSession->isLoggedIn()) {
799 799
 					// reset brute force delay for this IP address and username
800 800
 					$uid = \OC::$server->getUserSession()->getUser()->getUID();
@@ -845,7 +845,7 @@  discard block
 block discarded – undo
845 845
 	private static function registerAppRestrictionsHooks() {
846 846
 		/** @var \OC\Group\Manager $groupManager */
847 847
 		$groupManager = self::$server->query(\OCP\IGroupManager::class);
848
-		$groupManager->listen('\OC\Group', 'postDelete', function (\OCP\IGroup $group) {
848
+		$groupManager->listen('\OC\Group', 'postDelete', function(\OCP\IGroup $group) {
849 849
 			$appManager = self::$server->getAppManager();
850 850
 			$apps = $appManager->getEnabledAppsForGroup($group);
851 851
 			foreach ($apps as $appId) {
@@ -955,11 +955,11 @@  discard block
 block discarded – undo
955 955
 		// emergency app disabling
956 956
 		if ($requestPath === '/disableapp'
957 957
 			&& $request->getMethod() === 'POST'
958
-			&& ((array)$request->getParam('appid')) !== ''
958
+			&& ((array) $request->getParam('appid')) !== ''
959 959
 		) {
960 960
 			\OC_JSON::callCheck();
961 961
 			\OC_JSON::checkAdminUser();
962
-			$appIds = (array)$request->getParam('appid');
962
+			$appIds = (array) $request->getParam('appid');
963 963
 			foreach ($appIds as $appId) {
964 964
 				$appId = \OC_App::cleanAppId($appId);
965 965
 				\OC::$server->getAppManager()->disableApp($appId);
Please login to merge, or discard this patch.