Completed
Push — master ( 39c63d...c3f16a )
by John
27:19 queued 16s
created
lib/autoloader.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -77,20 +77,20 @@  discard block
 block discarded – undo
77 77
 			 * Remove "apps/" from inclusion path for smooth migration to multi app dir
78 78
 			 */
79 79
 			if (strpos(\OC::$CLASSPATH[$class], 'apps/') === 0) {
80
-				\OCP\Server::get(LoggerInterface::class)->debug('include path for class "' . $class . '" starts with "apps/"', ['app' => 'core']);
80
+				\OCP\Server::get(LoggerInterface::class)->debug('include path for class "'.$class.'" starts with "apps/"', ['app' => 'core']);
81 81
 				$paths[] = str_replace('apps/', '', \OC::$CLASSPATH[$class]);
82 82
 			}
83 83
 		} elseif (strpos($class, 'OC_') === 0) {
84
-			$paths[] = \OC::$SERVERROOT . '/lib/private/legacy/' . strtolower(str_replace('_', '/', substr($class, 3)) . '.php');
84
+			$paths[] = \OC::$SERVERROOT.'/lib/private/legacy/'.strtolower(str_replace('_', '/', substr($class, 3)).'.php');
85 85
 		} elseif (strpos($class, 'OCA\\') === 0) {
86 86
 			[, $app, $rest] = explode('\\', $class, 3);
87 87
 			$app = strtolower($app);
88 88
 			try {
89 89
 				$appPath = \OCP\Server::get(IAppManager::class)->getAppPath($app);
90 90
 				if (stream_resolve_include_path($appPath)) {
91
-					$paths[] = $appPath . '/' . strtolower(str_replace('\\', '/', $rest) . '.php');
91
+					$paths[] = $appPath.'/'.strtolower(str_replace('\\', '/', $rest).'.php');
92 92
 					// If not found in the root of the app directory, insert '/lib' after app id and try again.
93
-					$paths[] = $appPath . '/lib/' . strtolower(str_replace('\\', '/', $rest) . '.php');
93
+					$paths[] = $appPath.'/lib/'.strtolower(str_replace('\\', '/', $rest).'.php');
94 94
 				}
95 95
 			} catch (AppPathNotFoundException) {
96 96
 				// App not found, ignore
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	protected function isValidPath(string $fullPath): bool {
108 108
 		foreach ($this->validRoots as $root => $true) {
109
-			if (substr($fullPath, 0, strlen($root) + 1) === $root . '/') {
109
+			if (substr($fullPath, 0, strlen($root) + 1) === $root.'/') {
110 110
 				return true;
111 111
 			}
112 112
 		}
Please login to merge, or discard this patch.
lib/base.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -87,13 +87,13 @@  discard block
 block discarded – undo
87 87
 	 */
88 88
 	public static function initPaths(): void {
89 89
 		if (defined('PHPUNIT_CONFIG_DIR')) {
90
-			self::$configDir = OC::$SERVERROOT . '/' . PHPUNIT_CONFIG_DIR . '/';
91
-		} elseif (defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT . '/tests/config/')) {
92
-			self::$configDir = OC::$SERVERROOT . '/tests/config/';
90
+			self::$configDir = OC::$SERVERROOT.'/'.PHPUNIT_CONFIG_DIR.'/';
91
+		} elseif (defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT.'/tests/config/')) {
92
+			self::$configDir = OC::$SERVERROOT.'/tests/config/';
93 93
 		} elseif ($dir = getenv('NEXTCLOUD_CONFIG_DIR')) {
94
-			self::$configDir = rtrim($dir, '/') . '/';
94
+			self::$configDir = rtrim($dir, '/').'/';
95 95
 		} else {
96
-			self::$configDir = OC::$SERVERROOT . '/config/';
96
+			self::$configDir = OC::$SERVERROOT.'/config/';
97 97
 		}
98 98
 		self::$config = new \OC\Config(self::$configDir);
99 99
 
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 			//make sure suburi follows the same rules as scriptName
123 123
 			if (substr(OC::$SUBURI, -9) != 'index.php') {
124 124
 				if (substr(OC::$SUBURI, -1) != '/') {
125
-					OC::$SUBURI = OC::$SUBURI . '/';
125
+					OC::$SUBURI = OC::$SUBURI.'/';
126 126
 				}
127
-				OC::$SUBURI = OC::$SUBURI . 'index.php';
127
+				OC::$SUBURI = OC::$SUBURI.'index.php';
128 128
 			}
129 129
 		}
130 130
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 				OC::$WEBROOT = substr($scriptName, 0, 0 - strlen(OC::$SUBURI));
136 136
 
137 137
 				if (OC::$WEBROOT != '' && OC::$WEBROOT[0] !== '/') {
138
-					OC::$WEBROOT = '/' . OC::$WEBROOT;
138
+					OC::$WEBROOT = '/'.OC::$WEBROOT;
139 139
 				}
140 140
 			} else {
141 141
 				// The scriptName is not ending with OC::$SUBURI
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 			// slash which is required by URL generation.
150 150
 			if (isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'] === \OC::$WEBROOT &&
151 151
 					substr($_SERVER['REQUEST_URI'], -1) !== '/') {
152
-				header('Location: ' . \OC::$WEBROOT . '/');
152
+				header('Location: '.\OC::$WEBROOT.'/');
153 153
 				exit();
154 154
 			}
155 155
 		}
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
 					OC::$APPSROOTS[] = $paths;
165 165
 				}
166 166
 			}
167
-		} elseif (file_exists(OC::$SERVERROOT . '/apps')) {
168
-			OC::$APPSROOTS[] = ['path' => OC::$SERVERROOT . '/apps', 'url' => '/apps', 'writable' => true];
167
+		} elseif (file_exists(OC::$SERVERROOT.'/apps')) {
168
+			OC::$APPSROOTS[] = ['path' => OC::$SERVERROOT.'/apps', 'url' => '/apps', 'writable' => true];
169 169
 		}
170 170
 
171 171
 		if (empty(OC::$APPSROOTS)) {
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 
190 190
 	public static function checkConfig(): void {
191 191
 		// Create config if it does not already exist
192
-		$configFilePath = self::$configDir . '/config.php';
192
+		$configFilePath = self::$configDir.'/config.php';
193 193
 		if (!file_exists($configFilePath)) {
194 194
 			@touch($configFilePath);
195 195
 		}
@@ -203,18 +203,18 @@  discard block
 block discarded – undo
203 203
 			$l = Server::get(\OCP\L10N\IFactory::class)->get('lib');
204 204
 
205 205
 			if (self::$CLI) {
206
-				echo $l->t('Cannot write into "config" directory!') . "\n";
207
-				echo $l->t('This can usually be fixed by giving the web server write access to the config directory.') . "\n";
206
+				echo $l->t('Cannot write into "config" directory!')."\n";
207
+				echo $l->t('This can usually be fixed by giving the web server write access to the config directory.')."\n";
208 208
 				echo "\n";
209
-				echo $l->t('But, if you prefer to keep config.php file read only, set the option "config_is_read_only" to true in it.') . "\n";
210
-				echo $l->t('See %s', [ $urlGenerator->linkToDocs('admin-config') ]) . "\n";
209
+				echo $l->t('But, if you prefer to keep config.php file read only, set the option "config_is_read_only" to true in it.')."\n";
210
+				echo $l->t('See %s', [$urlGenerator->linkToDocs('admin-config')])."\n";
211 211
 				exit;
212 212
 			} else {
213 213
 				Server::get(ITemplateManager::class)->printErrorPage(
214 214
 					$l->t('Cannot write into "config" directory!'),
215
-					$l->t('This can usually be fixed by giving the web server write access to the config directory.') . ' '
216
-					. $l->t('But, if you prefer to keep config.php file read only, set the option "config_is_read_only" to true in it.') . ' '
217
-					. $l->t('See %s', [ $urlGenerator->linkToDocs('admin-config') ]),
215
+					$l->t('This can usually be fixed by giving the web server write access to the config directory.').' '
216
+					. $l->t('But, if you prefer to keep config.php file read only, set the option "config_is_read_only" to true in it.').' '
217
+					. $l->t('See %s', [$urlGenerator->linkToDocs('admin-config')]),
218 218
 					503
219 219
 				);
220 220
 			}
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
 			if (OC::$CLI) {
231 231
 				throw new Exception('Not installed');
232 232
 			} else {
233
-				$url = OC::$WEBROOT . '/index.php';
234
-				header('Location: ' . $url);
233
+				$url = OC::$WEBROOT.'/index.php';
234
+				header('Location: '.$url);
235 235
 			}
236 236
 			exit();
237 237
 		}
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 
240 240
 	public static function checkMaintenanceMode(\OC\SystemConfig $systemConfig): void {
241 241
 		// Allow ajax update script to execute without being stopped
242
-		if (((bool)$systemConfig->getValue('maintenance', false)) && OC::$SUBURI != '/core/ajax/update.php') {
242
+		if (((bool) $systemConfig->getValue('maintenance', false)) && OC::$SUBURI != '/core/ajax/update.php') {
243 243
 			// send http status 503
244 244
 			http_response_code(503);
245 245
 			header('X-Nextcloud-Maintenance-Mode: 1');
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 		$incompatibleDisabledApps = [];
343 343
 		foreach ($incompatibleApps as $appInfo) {
344 344
 			if ($appManager->isShipped($appInfo['id'])) {
345
-				$incompatibleShippedApps[] = $appInfo['name'] . ' (' . $appInfo['id'] . ')';
345
+				$incompatibleShippedApps[] = $appInfo['name'].' ('.$appInfo['id'].')';
346 346
 			}
347 347
 			if (!in_array($appInfo['id'], $incompatibleOverwrites)) {
348 348
 				$incompatibleDisabledApps[] = $appInfo;
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 		if (!empty($incompatibleShippedApps)) {
353 353
 			$l = Server::get(\OCP\L10N\IFactory::class)->get('core');
354 354
 			$hint = $l->t('Application %1$s is not present or has a non-compatible version with this server. Please check the apps directory.', [implode(', ', $incompatibleShippedApps)]);
355
-			throw new \OCP\HintException('Application ' . implode(', ', $incompatibleShippedApps) . ' is not present or has a non-compatible version with this server. Please check the apps directory.', $hint);
355
+			throw new \OCP\HintException('Application '.implode(', ', $incompatibleShippedApps).' is not present or has a non-compatible version with this server. Please check the apps directory.', $hint);
356 356
 		}
357 357
 
358 358
 		$tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion));
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 		}
397 397
 
398 398
 		// set the cookie path to the Nextcloud directory
399
-		$cookie_path = OC::$WEBROOT ? : '/';
399
+		$cookie_path = OC::$WEBROOT ?: '/';
400 400
 		ini_set('session.cookie_path', $cookie_path);
401 401
 
402 402
 		// Let the session name be changed in the initSession Hook
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 
421 421
 			// if session can't be started break with http 500 error
422 422
 		} catch (Exception $e) {
423
-			Server::get(LoggerInterface::class)->error($e->getMessage(), ['app' => 'base','exception' => $e]);
423
+			Server::get(LoggerInterface::class)->error($e->getMessage(), ['app' => 'base', 'exception' => $e]);
424 424
 			//show the user a detailed error page
425 425
 			Server::get(ITemplateManager::class)->printExceptionErrorPage($e, 500);
426 426
 			die();
@@ -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(), '', -1, self::$WEBROOT ? : '/');
435
+				setcookie(session_name(), '', -1, self::$WEBROOT ?: '/');
436 436
 			}
437 437
 			Server::get(IUserSession::class)->logout();
438 438
 		}
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 		foreach ($policies as $policy) {
504 504
 			header(
505 505
 				sprintf(
506
-					'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;' . $secureCookie . 'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s',
506
+					'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;'.$secureCookie.'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s',
507 507
 					$cookiePrefix,
508 508
 					$policy,
509 509
 					$cookieParams['path'],
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
 		self::handleAuthHeaders();
584 584
 
585 585
 		// prevent any XML processing from loading external entities
586
-		libxml_set_external_entity_loader(static function () {
586
+		libxml_set_external_entity_loader(static function() {
587 587
 			return null;
588 588
 		});
589 589
 
@@ -597,9 +597,9 @@  discard block
 block discarded – undo
597 597
 
598 598
 		// register autoloader
599 599
 		$loaderStart = microtime(true);
600
-		require_once __DIR__ . '/autoloader.php';
600
+		require_once __DIR__.'/autoloader.php';
601 601
 		self::$loader = new \OC\Autoloader([
602
-			OC::$SERVERROOT . '/lib/private/legacy',
602
+			OC::$SERVERROOT.'/lib/private/legacy',
603 603
 		]);
604 604
 		spl_autoload_register([self::$loader, 'load']);
605 605
 		$loaderEnd = microtime(true);
@@ -607,14 +607,14 @@  discard block
 block discarded – undo
607 607
 		self::$CLI = (php_sapi_name() == 'cli');
608 608
 
609 609
 		// Add default composer PSR-4 autoloader, ensure apcu to be disabled
610
-		self::$composerAutoloader = require_once OC::$SERVERROOT . '/lib/composer/autoload.php';
610
+		self::$composerAutoloader = require_once OC::$SERVERROOT.'/lib/composer/autoload.php';
611 611
 		self::$composerAutoloader->setApcuPrefix(null);
612 612
 
613 613
 
614 614
 		try {
615 615
 			self::initPaths();
616 616
 			// setup 3rdparty autoloader
617
-			$vendorAutoLoad = OC::$SERVERROOT . '/3rdparty/autoload.php';
617
+			$vendorAutoLoad = OC::$SERVERROOT.'/3rdparty/autoload.php';
618 618
 			if (!file_exists($vendorAutoLoad)) {
619 619
 				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".');
620 620
 			}
@@ -640,10 +640,10 @@  discard block
 block discarded – undo
640 640
 			);
641 641
 			$profiler->start();
642 642
 		} catch (\Throwable $e) {
643
-			logger('core')->error('Failed to start profiler: ' . $e->getMessage(), ['app' => 'base']);
643
+			logger('core')->error('Failed to start profiler: '.$e->getMessage(), ['app' => 'base']);
644 644
 		}
645 645
 
646
-		if (self::$CLI && in_array('--' . \OCP\Console\ReservedOptions::DEBUG_LOG, $_SERVER['argv'])) {
646
+		if (self::$CLI && in_array('--'.\OCP\Console\ReservedOptions::DEBUG_LOG, $_SERVER['argv'])) {
647 647
 			\OC\Core\Listener\BeforeMessageLoggedEventListener::setup();
648 648
 		}
649 649
 
@@ -726,11 +726,11 @@  discard block
 block discarded – undo
726 726
 				// Convert l10n string into regular string for usage in database
727 727
 				$staticErrors = [];
728 728
 				foreach ($errors as $error) {
729
-					echo $error['error'] . "\n";
730
-					echo $error['hint'] . "\n\n";
729
+					echo $error['error']."\n";
730
+					echo $error['hint']."\n\n";
731 731
 					$staticErrors[] = [
732
-						'error' => (string)$error['error'],
733
-						'hint' => (string)$error['hint'],
732
+						'error' => (string) $error['error'],
733
+						'hint' => (string) $error['hint'],
734 734
 					];
735 735
 				}
736 736
 
@@ -850,11 +850,11 @@  discard block
 block discarded – undo
850 850
 		$eventLogger->log('init', 'OC::init', $loaderStart, microtime(true));
851 851
 		$eventLogger->start('runtime', 'Runtime');
852 852
 		$eventLogger->start('request', 'Full request after boot');
853
-		register_shutdown_function(function () use ($eventLogger) {
853
+		register_shutdown_function(function() use ($eventLogger) {
854 854
 			$eventLogger->end('request');
855 855
 		});
856 856
 
857
-		register_shutdown_function(function () {
857
+		register_shutdown_function(function() {
858 858
 			$memoryPeak = memory_get_peak_usage();
859 859
 			$logLevel = match (true) {
860 860
 				$memoryPeak > 500_000_000 => ILogger::FATAL,
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
 				default => null,
864 864
 			};
865 865
 			if ($logLevel !== null) {
866
-				$message = 'Request used more than 300 MB of RAM: ' . Util::humanFileSize($memoryPeak);
866
+				$message = 'Request used more than 300 MB of RAM: '.Util::humanFileSize($memoryPeak);
867 867
 				$logger = Server::get(LoggerInterface::class);
868 868
 				$logger->log($logLevel, $message, ['app' => 'core']);
869 869
 			}
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
 		if ($systemConfig->getValue('installed', false) && !\OCP\Util::needUpgrade()) {
879 879
 			// NOTE: This will be replaced to use OCP
880 880
 			$userSession = Server::get(\OC\User\Session::class);
881
-			$userSession->listen('\OC\User', 'postLogin', function () use ($userSession) {
881
+			$userSession->listen('\OC\User', 'postLogin', function() use ($userSession) {
882 882
 				if (!defined('PHPUNIT_RUN') && $userSession->isLoggedIn()) {
883 883
 					// reset brute force delay for this IP address and username
884 884
 					$uid = $userSession->getUser()->getUID();
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
 	private static function registerAppRestrictionsHooks(): void {
931 931
 		/** @var \OC\Group\Manager $groupManager */
932 932
 		$groupManager = Server::get(\OCP\IGroupManager::class);
933
-		$groupManager->listen('\OC\Group', 'postDelete', function (\OCP\IGroup $group) {
933
+		$groupManager->listen('\OC\Group', 'postDelete', function(\OCP\IGroup $group) {
934 934
 			$appManager = Server::get(\OCP\App\IAppManager::class);
935 935
 			$apps = $appManager->getEnabledAppsForGroup($group);
936 936
 			foreach ($apps as $appId) {
@@ -1019,7 +1019,7 @@  discard block
 block discarded – undo
1019 1019
 				if (function_exists('opcache_reset')) {
1020 1020
 					opcache_reset();
1021 1021
 				}
1022
-				if (!((bool)$systemConfig->getValue('maintenance', false))) {
1022
+				if (!((bool) $systemConfig->getValue('maintenance', false))) {
1023 1023
 					self::printUpgradePage($systemConfig);
1024 1024
 					exit();
1025 1025
 				}
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
 
1035 1035
 		// Load minimum set of apps
1036 1036
 		if (!\OCP\Util::needUpgrade()
1037
-			&& !((bool)$systemConfig->getValue('maintenance', false))) {
1037
+			&& !((bool) $systemConfig->getValue('maintenance', false))) {
1038 1038
 			// For logged-in users: Load everything
1039 1039
 			if (Server::get(IUserSession::class)->isLoggedIn()) {
1040 1040
 				$appManager->loadApps();
@@ -1096,10 +1096,10 @@  discard block
 block discarded – undo
1096 1096
 		if ($requestPath === '') {
1097 1097
 			// Someone is logged in
1098 1098
 			if (Server::get(IUserSession::class)->isLoggedIn()) {
1099
-				header('Location: ' . Server::get(IURLGenerator::class)->linkToDefaultPageUrl());
1099
+				header('Location: '.Server::get(IURLGenerator::class)->linkToDefaultPageUrl());
1100 1100
 			} else {
1101 1101
 				// Not handled and not logged in
1102
-				header('Location: ' . Server::get(IURLGenerator::class)->linkToRouteAbsolute('core.login.showLoginForm'));
1102
+				header('Location: '.Server::get(IURLGenerator::class)->linkToRouteAbsolute('core.login.showLoginForm'));
1103 1103
 			}
1104 1104
 			return;
1105 1105
 		}
@@ -1182,7 +1182,7 @@  discard block
 block discarded – undo
1182 1182
 		try {
1183 1183
 			$appAPIService = Server::get(OCA\AppAPI\Service\AppAPIService::class);
1184 1184
 			return $appAPIService->validateExAppRequestToNC($request);
1185
-		} catch (\Psr\Container\NotFoundExceptionInterface|\Psr\Container\ContainerExceptionInterface $e) {
1185
+		} catch (\Psr\Container\NotFoundExceptionInterface | \Psr\Container\ContainerExceptionInterface $e) {
1186 1186
 			return false;
1187 1187
 		}
1188 1188
 	}
Please login to merge, or discard this patch.
tests/lib/AutoLoaderTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@
 block discarded – undo
20 20
 
21 21
 	public function testLegacyPath(): void {
22 22
 		$this->assertEquals([
23
-			\OC::$SERVERROOT . '/lib/private/legacy/json.php',
23
+			\OC::$SERVERROOT.'/lib/private/legacy/json.php',
24 24
 		], $this->loader->findClass('OC_JSON'));
25 25
 	}
26 26
 
27 27
 	public function testLoadCore(): void {
28 28
 		$this->assertEquals([
29
-			\OC::$SERVERROOT . '/lib/private/legacy/foo/bar.php',
29
+			\OC::$SERVERROOT.'/lib/private/legacy/foo/bar.php',
30 30
 		], $this->loader->findClass('OC_Foo_Bar'));
31 31
 	}
32 32
 
Please login to merge, or discard this patch.