Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-04-10 15:19:56 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-04-10 15:19:56 +0300
commitcaff1023ea72bb2ea94130e18a2a6e2ccf819e5f (patch)
tree186d494c2aea5dea7255d3584ef5d595fc6e6194 /apps/theming
parentedf8ce32cffdb920e8171207b342abbd7f1fbe73 (diff)
Format control structures, classes, methods and function
To continue this formatting madness, here's a tiny patch that adds unified formatting for control structures like if and loops as well as classes, their methods and anonymous functions. This basically forces the constructs to start on the same line. This is not exactly what PSR2 wants, but I think we can have a few exceptions with "our" style. The starting of braces on the same line is pracrically standard for our code. This also removes and empty lines from method/function bodies at the beginning and end. Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/theming')
-rw-r--r--apps/theming/lib/Controller/IconController.php4
-rw-r--r--apps/theming/lib/Controller/ThemingController.php2
-rw-r--r--apps/theming/lib/IconBuilder.php11
-rw-r--r--apps/theming/lib/ImageManager.php4
-rw-r--r--apps/theming/lib/Settings/Admin.php1
-rw-r--r--apps/theming/lib/ThemingDefaults.php19
-rw-r--r--apps/theming/lib/Util.php11
-rw-r--r--apps/theming/tests/CapabilitiesTest.php4
-rw-r--r--apps/theming/tests/Controller/IconControllerTest.php1
-rw-r--r--apps/theming/tests/Controller/ThemingControllerTest.php5
-rw-r--r--apps/theming/tests/IconBuilderTest.php2
-rw-r--r--apps/theming/tests/ImageManagerTest.php4
-rw-r--r--apps/theming/tests/ServicesTest.php2
-rw-r--r--apps/theming/tests/ThemingDefaultsTest.php1
-rw-r--r--apps/theming/tests/UtilTest.php3
15 files changed, 34 insertions, 40 deletions
diff --git a/apps/theming/lib/Controller/IconController.php b/apps/theming/lib/Controller/IconController.php
index 73d3606a3df..c0bc22de8ee 100644
--- a/apps/theming/lib/Controller/IconController.php
+++ b/apps/theming/lib/Controller/IconController.php
@@ -133,7 +133,7 @@ class IconController extends Controller {
$response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/x-icon']);
}
}
- if($response === null) {
+ if ($response === null) {
$fallbackLogo = \OC::$SERVERROOT . '/core/img/favicon.png';
$response = new DataDisplayResponse($this->fileAccessHelper->file_get_contents($fallbackLogo), Http::STATUS_OK, ['Content-Type' => 'image/x-icon']);
}
@@ -169,7 +169,7 @@ class IconController extends Controller {
$response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/png']);
}
}
- if($response === null) {
+ if ($response === null) {
$fallbackLogo = \OC::$SERVERROOT . '/core/img/favicon-touch.png';
$response = new DataDisplayResponse($this->fileAccessHelper->file_get_contents($fallbackLogo), Http::STATUS_OK, ['Content-Type' => 'image/png']);
}
diff --git a/apps/theming/lib/Controller/ThemingController.php b/apps/theming/lib/Controller/ThemingController.php
index e1fbb227774..6184796406d 100644
--- a/apps/theming/lib/Controller/ThemingController.php
+++ b/apps/theming/lib/Controller/ThemingController.php
@@ -414,7 +414,7 @@ class ThemingController extends Controller {
* since we need to add the cacheBuster value to the url
*/
$cssCached = $this->scssCacher->process($appPath, 'css/theming.scss', 'theming');
- if(!$cssCached) {
+ if (!$cssCached) {
return new NotFoundResponse();
}
diff --git a/apps/theming/lib/IconBuilder.php b/apps/theming/lib/IconBuilder.php
index 2380e960c70..77079851d69 100644
--- a/apps/theming/lib/IconBuilder.php
+++ b/apps/theming/lib/IconBuilder.php
@@ -127,7 +127,7 @@ class IconBuilder {
*/
public function renderAppIcon($app, $size) {
$appIcon = $this->util->getAppIcon($app);
- if($appIcon === false) {
+ if ($appIcon === false) {
return false;
}
if ($appIcon instanceof ISimpleFile) {
@@ -138,7 +138,7 @@ class IconBuilder {
$mime = mime_content_type($appIcon);
}
- if($appIconContent === false || $appIconContent === "") {
+ if ($appIconContent === false || $appIconContent === "") {
return false;
}
@@ -150,8 +150,8 @@ class IconBuilder {
'<rect x="0" y="0" rx="100" ry="100" width="512" height="512" style="fill:' . $color . ';" />' .
'</svg>';
// resize svg magic as this seems broken in Imagemagick
- if($mime === "image/svg+xml" || substr($appIconContent, 0, 4) === "<svg") {
- if(substr($appIconContent, 0, 5) !== "<?xml") {
+ if ($mime === "image/svg+xml" || substr($appIconContent, 0, 4) === "<svg") {
+ if (substr($appIconContent, 0, 5) !== "<?xml") {
$svg = "<?xml version=\"1.0\"?>".$appIconContent;
} else {
$svg = $appIconContent;
@@ -163,7 +163,7 @@ class IconBuilder {
$res = $tmp->getImageResolution();
$tmp->destroy();
- if($x>$y) {
+ if ($x>$y) {
$max = $x;
} else {
$max = $y;
@@ -237,5 +237,4 @@ class IconBuilder {
return false;
}
}
-
}
diff --git a/apps/theming/lib/ImageManager.php b/apps/theming/lib/ImageManager.php
index 53189181bfa..35a03c30c43 100644
--- a/apps/theming/lib/ImageManager.php
+++ b/apps/theming/lib/ImageManager.php
@@ -234,11 +234,11 @@ class ImageManager {
*/
public function shouldReplaceIcons() {
$cache = $this->cacheFactory->createDistributed('theming-' . $this->urlGenerator->getBaseUrl());
- if($value = $cache->get('shouldReplaceIcons')) {
+ if ($value = $cache->get('shouldReplaceIcons')) {
return (bool)$value;
}
$value = false;
- if(extension_loaded('imagick')) {
+ if (extension_loaded('imagick')) {
if (count(\Imagick::queryFormats('SVG')) >= 1) {
$value = true;
}
diff --git a/apps/theming/lib/Settings/Admin.php b/apps/theming/lib/Settings/Admin.php
index cd59b167365..518aace2c35 100644
--- a/apps/theming/lib/Settings/Admin.php
+++ b/apps/theming/lib/Settings/Admin.php
@@ -107,5 +107,4 @@ class Admin implements ISettings {
public function getPriority(): int {
return 5;
}
-
}
diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php
index 413e2a9e64f..059dc55cb99 100644
--- a/apps/theming/lib/ThemingDefaults.php
+++ b/apps/theming/lib/ThemingDefaults.php
@@ -188,9 +188,10 @@ class ThemingDefaults extends \OC_Defaults {
}, $navigation);
$links = array_merge($links, $guestNavigation);
- $legalLinks = ''; $divider = '';
- foreach($links as $link) {
- if($link['url'] !== ''
+ $legalLinks = '';
+ $divider = '';
+ foreach ($links as $link) {
+ if ($link['url'] !== ''
&& filter_var($link['url'], FILTER_VALIDATE_URL)
) {
$legalLinks .= $divider . '<a href="' . $link['url'] . '" class="legal" target="_blank"' .
@@ -198,7 +199,7 @@ class ThemingDefaults extends \OC_Defaults {
$divider = ' ยท ';
}
}
- if($legalLinks !== '') {
+ if ($legalLinks !== '') {
$footer .= '<br/>' . $legalLinks;
}
@@ -232,8 +233,8 @@ class ThemingDefaults extends \OC_Defaults {
$cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
- if(!$logo || !$logoExists) {
- if($useSvg) {
+ if (!$logo || !$logoExists) {
+ if ($useSvg) {
$logo = $this->urlGenerator->imagePath('core', 'logo/logo.svg');
} else {
$logo = $this->urlGenerator->imagePath('core', 'logo/logo.png');
@@ -309,7 +310,7 @@ class ThemingDefaults extends \OC_Defaults {
}
$variables['has-legal-links'] = 'false';
- if($this->getImprintUrl() !== '' || $this->getPrivacyUrl() !== '') {
+ if ($this->getImprintUrl() !== '' || $this->getPrivacyUrl() !== '') {
$variables['has-legal-links'] = 'true';
}
@@ -350,7 +351,8 @@ class ThemingDefaults extends \OC_Defaults {
if (file_exists($appPath . '/img/manifest.json')) {
return false;
}
- } catch (AppPathNotFoundException $e) {}
+ } catch (AppPathNotFoundException $e) {
+ }
$route = $this->urlGenerator->linkToRoute('theming.Theming.getManifest');
}
if (strpos($image, 'filetypes/') === 0 && file_exists(\OC::$SERVERROOT . '/core/img/' . $image)) {
@@ -372,7 +374,6 @@ class ThemingDefaults extends \OC_Defaults {
$this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1);
$this->cacheFactory->createDistributed('theming-')->clear();
$this->cacheFactory->createDistributed('imagePath')->clear();
-
}
/**
diff --git a/apps/theming/lib/Util.php b/apps/theming/lib/Util.php
index d66aeb3db2c..d3c0043b2a3 100644
--- a/apps/theming/lib/Util.php
+++ b/apps/theming/lib/Util.php
@@ -66,7 +66,7 @@ class Util {
*/
public function invertTextColor($color) {
$l = $this->calculateLuma($color);
- if($l>0.6) {
+ if ($l>0.6) {
return true;
} else {
return false;
@@ -81,7 +81,7 @@ class Util {
*/
public function elementColor($color) {
$l = $this->calculateLuminance($color);
- if($l>0.8) {
+ if ($l>0.8) {
return '#aaaaaa';
}
return $color;
@@ -153,7 +153,8 @@ class Util {
if (file_exists($icon)) {
return $icon;
}
- } catch (AppPathNotFoundException $e) {}
+ } catch (AppPathNotFoundException $e) {
+ }
if ($this->config->getAppValue('theming', 'logoMime', '') !== '') {
$logoFile = null;
@@ -162,7 +163,8 @@ class Util {
if ($folder !== null) {
return $folder->getFile('logo');
}
- } catch (NotFoundException $e) {}
+ } catch (NotFoundException $e) {
+ }
}
return \OC::$SERVERROOT . '/core/img/logo/logo.svg';
}
@@ -248,5 +250,4 @@ class Util {
}
return $backgroundLogo && $backgroundLogo !== 'backgroundColor' && $backgroundExists;
}
-
}
diff --git a/apps/theming/tests/CapabilitiesTest.php b/apps/theming/tests/CapabilitiesTest.php
index 1f871d101d8..6364f953c57 100644
--- a/apps/theming/tests/CapabilitiesTest.php
+++ b/apps/theming/tests/CapabilitiesTest.php
@@ -42,7 +42,7 @@ use Test\TestCase;
*
* @package OCA\Theming\Tests
*/
-class CapabilitiesTest extends TestCase {
+class CapabilitiesTest extends TestCase {
/** @var ThemingDefaults|\PHPUnit_Framework_MockObject_MockObject */
protected $theming;
@@ -175,7 +175,7 @@ class CapabilitiesTest extends TestCase {
->method('isBackgroundThemed')
->willReturn($backgroundThemed);
- if($background !== 'backgroundColor') {
+ if ($background !== 'backgroundColor') {
$this->theming->expects($this->once())
->method('getBackground')
->willReturn($background);
diff --git a/apps/theming/tests/Controller/IconControllerTest.php b/apps/theming/tests/Controller/IconControllerTest.php
index 59608f41a68..05b74c58e79 100644
--- a/apps/theming/tests/Controller/IconControllerTest.php
+++ b/apps/theming/tests/Controller/IconControllerTest.php
@@ -205,5 +205,4 @@ class IconControllerTest extends TestCase {
$expected->cacheFor(86400);
$this->assertEquals($expected, $this->iconController->getTouchIcon());
}
-
}
diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php
index d1890f7df5c..b9c291c9578 100644
--- a/apps/theming/tests/Controller/ThemingControllerTest.php
+++ b/apps/theming/tests/Controller/ThemingControllerTest.php
@@ -401,7 +401,7 @@ class ThemingControllerTest extends TestCase {
$file = $this->createMock(ISimpleFile::class);
$folder = $this->createMock(ISimpleFolder::class);
- if($folderExists) {
+ if ($folderExists) {
$this->appData
->expects($this->once())
->method('getFolder')
@@ -476,7 +476,7 @@ class ThemingControllerTest extends TestCase {
$file = $this->createMock(ISimpleFile::class);
$folder = $this->createMock(ISimpleFolder::class);
- if($folderExists) {
+ if ($folderExists) {
$this->appData
->expects($this->once())
->method('getFolder')
@@ -963,5 +963,4 @@ class ThemingControllerTest extends TestCase {
$response->cacheFor(3600);
$this->assertEquals($response, $this->themingController->getManifest('core'));
}
-
}
diff --git a/apps/theming/tests/IconBuilderTest.php b/apps/theming/tests/IconBuilderTest.php
index 1a05235e2dc..4d1a0daf3b1 100644
--- a/apps/theming/tests/IconBuilderTest.php
+++ b/apps/theming/tests/IconBuilderTest.php
@@ -68,7 +68,7 @@ class IconBuilderTest extends TestCase {
}
private function checkImagick() {
- if(!extension_loaded('imagick')) {
+ if (!extension_loaded('imagick')) {
$this->markTestSkipped('Imagemagick is required for dynamic icon generation.');
}
$checkImagick = new \Imagick();
diff --git a/apps/theming/tests/ImageManagerTest.php b/apps/theming/tests/ImageManagerTest.php
index 19896be21a2..4098c466da7 100644
--- a/apps/theming/tests/ImageManagerTest.php
+++ b/apps/theming/tests/ImageManagerTest.php
@@ -69,7 +69,7 @@ class ImageManagerTest extends TestCase {
}
private function checkImagick() {
- if(!extension_loaded('imagick')) {
+ if (!extension_loaded('imagick')) {
$this->markTestSkipped('Imagemagick is required for dynamic icon generation.');
}
$checkImagick = new \Imagick();
@@ -172,7 +172,6 @@ class ImageManagerTest extends TestCase {
->method('getAbsoluteUrl')
->willReturn('url-to-image-absolute?v=0');
$this->assertEquals('url-to-image-absolute?v=0', $this->imageManager->getImageUrlAbsolute('logo', false));
-
}
public function testGetImage() {
@@ -326,5 +325,4 @@ class ImageManagerTest extends TestCase {
->willReturn($folders[2]);
$this->imageManager->cleanup();
}
-
}
diff --git a/apps/theming/tests/ServicesTest.php b/apps/theming/tests/ServicesTest.php
index 62618abcd96..d530d321aeb 100644
--- a/apps/theming/tests/ServicesTest.php
+++ b/apps/theming/tests/ServicesTest.php
@@ -43,7 +43,7 @@ use Test\TestCase;
* @group DB
* @package OCA\Theming\Tests
*/
-class ServicesTest extends TestCase {
+class ServicesTest extends TestCase {
/** @var \OCA\Activity\AppInfo\Application */
protected $app;
diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php
index a06cdb8f7a8..e5b6fb72db0 100644
--- a/apps/theming/tests/ThemingDefaultsTest.php
+++ b/apps/theming/tests/ThemingDefaultsTest.php
@@ -777,5 +777,4 @@ class ThemingDefaultsTest extends TestCase {
->willReturn('themingRoute');
$this->assertEquals($result, $this->template->replaceImagePath($app, $image));
}
-
}
diff --git a/apps/theming/tests/UtilTest.php b/apps/theming/tests/UtilTest.php
index 969d35f7d27..51cb76f9559 100644
--- a/apps/theming/tests/UtilTest.php
+++ b/apps/theming/tests/UtilTest.php
@@ -165,7 +165,7 @@ class UtilTest extends TestCase {
* @dataProvider dataGetAppImage
*/
public function testGetAppImage($app, $image, $expected) {
- if($app !== 'core') {
+ if ($app !== 'core') {
$this->appManager->expects($this->once())
->method('getAppPath')
->with($app)
@@ -238,5 +238,4 @@ class UtilTest extends TestCase {
->willReturn($folder);
$this->assertEquals($expected, $this->util->isBackgroundThemed());
}
-
}