Some more strict_types

Signed-off-by: J0WI <J0WI@users.noreply.github.com>
This commit is contained in:
J0WI 2021-04-26 12:33:36 +02:00
parent 8f3a0705d4
commit efc5c57a79
7 changed files with 51 additions and 33 deletions

View File

@ -68,7 +68,7 @@ class Autoloader {
* *
* @param string $root * @param string $root
*/ */
public function addValidRoot(string $root) { public function addValidRoot(string $root): void {
$root = stream_resolve_include_path($root); $root = stream_resolve_include_path($root);
$this->validRoots[$root] = true; $this->validRoots[$root] = true;
} }
@ -76,14 +76,14 @@ class Autoloader {
/** /**
* disable the usage of the global classpath \OC::$CLASSPATH * disable the usage of the global classpath \OC::$CLASSPATH
*/ */
public function disableGlobalClassPath() { public function disableGlobalClassPath(): void {
$this->useGlobalClassPath = false; $this->useGlobalClassPath = false;
} }
/** /**
* enable the usage of the global classpath \OC::$CLASSPATH * enable the usage of the global classpath \OC::$CLASSPATH
*/ */
public function enableGlobalClassPath() { public function enableGlobalClassPath(): void {
$this->useGlobalClassPath = true; $this->useGlobalClassPath = true;
} }
@ -184,7 +184,7 @@ class Autoloader {
* *
* @param \OC\Memcache\Cache $memoryCache Instance of memory cache. * @param \OC\Memcache\Cache $memoryCache Instance of memory cache.
*/ */
public function setMemoryCache(\OC\Memcache\Cache $memoryCache = null) { public function setMemoryCache(\OC\Memcache\Cache $memoryCache = null): void {
$this->memoryCache = $memoryCache; $this->memoryCache = $memoryCache;
} }
} }

View File

@ -1,4 +1,7 @@
<?php <?php
declare(strict_types=1);
/** /**
* @copyright Copyright (c) 2016, ownCloud, Inc. * @copyright Copyright (c) 2016, ownCloud, Inc.
* @copyright Copyright (c) 2016, Lukas Reschke <lukas@statuscode.ch> * @copyright Copyright (c) 2016, Lukas Reschke <lukas@statuscode.ch>
@ -101,7 +104,7 @@ class Updater extends BasicEmitter {
* *
* @return bool true if the operation succeeded, false otherwise * @return bool true if the operation succeeded, false otherwise
*/ */
public function upgrade() { public function upgrade(): bool {
$this->emitRepairEvents(); $this->emitRepairEvents();
$this->logAllEvents(); $this->logAllEvents();
@ -162,7 +165,7 @@ class Updater extends BasicEmitter {
* *
* @return array allowed previous versions per vendor * @return array allowed previous versions per vendor
*/ */
private function getAllowedPreviousVersions() { private function getAllowedPreviousVersions(): array {
// this should really be a JSON file // this should really be a JSON file
require \OC::$SERVERROOT . '/version.php'; require \OC::$SERVERROOT . '/version.php';
/** @var array $OC_VersionCanBeUpgradedFrom */ /** @var array $OC_VersionCanBeUpgradedFrom */
@ -174,7 +177,7 @@ class Updater extends BasicEmitter {
* *
* @return string Get the vendor * @return string Get the vendor
*/ */
private function getVendor() { private function getVendor(): string {
// this should really be a JSON file // this should really be a JSON file
require \OC::$SERVERROOT . '/version.php'; require \OC::$SERVERROOT . '/version.php';
/** @var string $vendor */ /** @var string $vendor */
@ -188,7 +191,7 @@ class Updater extends BasicEmitter {
* @param array $allowedPreviousVersions * @param array $allowedPreviousVersions
* @return bool * @return bool
*/ */
public function isUpgradePossible($oldVersion, $newVersion, array $allowedPreviousVersions) { public function isUpgradePossible(string $oldVersion, string $newVersion, array $allowedPreviousVersions): bool {
$version = explode('.', $oldVersion); $version = explode('.', $oldVersion);
$majorMinor = $version[0] . '.' . $version[1]; $majorMinor = $version[0] . '.' . $version[1];
@ -223,7 +226,7 @@ class Updater extends BasicEmitter {
* *
* @throws \Exception * @throws \Exception
*/ */
private function doUpgrade($currentVersion, $installedVersion) { private function doUpgrade(string $currentVersion, string $installedVersion): void {
// Stop update if the update is over several major versions // Stop update if the update is over several major versions
$allowedPreviousVersions = $this->getAllowedPreviousVersions(); $allowedPreviousVersions = $this->getAllowedPreviousVersions();
if (!$this->isUpgradePossible($installedVersion, $currentVersion, $allowedPreviousVersions)) { if (!$this->isUpgradePossible($installedVersion, $currentVersion, $allowedPreviousVersions)) {
@ -295,7 +298,7 @@ class Updater extends BasicEmitter {
$this->config->setAppValue('core', 'vendor', $this->getVendor()); $this->config->setAppValue('core', 'vendor', $this->getVendor());
} }
protected function doCoreUpgrade() { protected function doCoreUpgrade(): void {
$this->emit('\OC\Updater', 'dbUpgradeBefore'); $this->emit('\OC\Updater', 'dbUpgradeBefore');
// execute core migrations // execute core migrations
@ -311,7 +314,7 @@ class Updater extends BasicEmitter {
* *
* @throws NeedsUpdateException * @throws NeedsUpdateException
*/ */
protected function doAppUpgrade() { protected function doAppUpgrade(): void {
$apps = \OC_App::getEnabledApps(); $apps = \OC_App::getEnabledApps();
$priorityTypes = ['authentication', 'filesystem', 'logging']; $priorityTypes = ['authentication', 'filesystem', 'logging'];
$pseudoOtherType = 'other'; $pseudoOtherType = 'other';
@ -360,7 +363,7 @@ class Updater extends BasicEmitter {
* @return array * @return array
* @throws \Exception * @throws \Exception
*/ */
private function checkAppsRequirements() { private function checkAppsRequirements(): array {
$isCoreUpgrade = $this->isCodeUpgrade(); $isCoreUpgrade = $this->isCodeUpgrade();
$apps = OC_App::getEnabledApps(); $apps = OC_App::getEnabledApps();
$version = implode('.', Util::getVersion()); $version = implode('.', Util::getVersion());
@ -395,7 +398,7 @@ class Updater extends BasicEmitter {
/** /**
* @return bool * @return bool
*/ */
private function isCodeUpgrade() { private function isCodeUpgrade(): bool {
$installedVersion = $this->config->getSystemValue('version', '0.0.0'); $installedVersion = $this->config->getSystemValue('version', '0.0.0');
$currentVersion = implode('.', Util::getVersion()); $currentVersion = implode('.', Util::getVersion());
if (version_compare($currentVersion, $installedVersion, '>')) { if (version_compare($currentVersion, $installedVersion, '>')) {
@ -409,7 +412,7 @@ class Updater extends BasicEmitter {
* @param bool $reenable * @param bool $reenable
* @throws \Exception * @throws \Exception
*/ */
private function upgradeAppStoreApps(array $disabledApps, $reenable = false) { private function upgradeAppStoreApps(array $disabledApps, bool $reenable = false): void {
foreach ($disabledApps as $app) { foreach ($disabledApps as $app) {
try { try {
$this->emit('\OC\Updater', 'checkAppStoreAppBefore', [$app]); $this->emit('\OC\Updater', 'checkAppStoreAppBefore', [$app]);
@ -432,7 +435,7 @@ class Updater extends BasicEmitter {
/** /**
* Forward messages emitted by the repair routine * Forward messages emitted by the repair routine
*/ */
private function emitRepairEvents() { private function emitRepairEvents(): void {
$dispatcher = \OC::$server->getEventDispatcher(); $dispatcher = \OC::$server->getEventDispatcher();
$dispatcher->addListener('\OC\Repair::warning', function ($event) { $dispatcher->addListener('\OC\Repair::warning', function ($event) {
if ($event instanceof GenericEvent) { if ($event instanceof GenericEvent) {
@ -456,7 +459,7 @@ class Updater extends BasicEmitter {
}); });
} }
private function logAllEvents() { private function logAllEvents(): void {
$log = $this->log; $log = $this->log;
$dispatcher = \OC::$server->getEventDispatcher(); $dispatcher = \OC::$server->getEventDispatcher();

View File

@ -1,4 +1,7 @@
<?php <?php
declare(strict_types=1);
/** /**
* @copyright Copyright (c) 2016, ownCloud, Inc. * @copyright Copyright (c) 2016, ownCloud, Inc.
* *

View File

@ -1,4 +1,7 @@
<?php <?php
declare(strict_types=1);
/** /**
* @copyright Copyright (c) 2016, ownCloud, Inc. * @copyright Copyright (c) 2016, ownCloud, Inc.
* *

View File

@ -1,4 +1,7 @@
<?php <?php
declare(strict_types=1);
/** /**
* @copyright Copyright (c) 2016, ownCloud, Inc. * @copyright Copyright (c) 2016, ownCloud, Inc.
* *
@ -65,7 +68,7 @@ class Defaults {
* @return string * @return string
* @since 6.0.0 * @since 6.0.0
*/ */
public function getBaseUrl() { public function getBaseUrl(): string {
return $this->defaults->getBaseUrl(); return $this->defaults->getBaseUrl();
} }
@ -74,7 +77,7 @@ class Defaults {
* @return string * @return string
* @since 6.0.0 * @since 6.0.0
*/ */
public function getSyncClientUrl() { public function getSyncClientUrl(): string {
return $this->defaults->getSyncClientUrl(); return $this->defaults->getSyncClientUrl();
} }
@ -83,7 +86,7 @@ class Defaults {
* @return string * @return string
* @since 8.0.0 * @since 8.0.0
*/ */
public function getiOSClientUrl() { public function getiOSClientUrl(): string {
return $this->defaults->getiOSClientUrl(); return $this->defaults->getiOSClientUrl();
} }
@ -92,7 +95,7 @@ class Defaults {
* @return string * @return string
* @since 8.0.0 * @since 8.0.0
*/ */
public function getAndroidClientUrl() { public function getAndroidClientUrl(): string {
return $this->defaults->getAndroidClientUrl(); return $this->defaults->getAndroidClientUrl();
} }
@ -101,7 +104,7 @@ class Defaults {
* @return string * @return string
* @since 6.0.0 * @since 6.0.0
*/ */
public function getDocBaseUrl() { public function getDocBaseUrl(): string {
return $this->defaults->getDocBaseUrl(); return $this->defaults->getDocBaseUrl();
} }
@ -110,7 +113,7 @@ class Defaults {
* @return string * @return string
* @since 6.0.0 * @since 6.0.0
*/ */
public function getName() { public function getName(): string {
return $this->defaults->getName(); return $this->defaults->getName();
} }
@ -120,7 +123,7 @@ class Defaults {
* @since 8.0.0 * @since 8.0.0
* @depreacted 22.0.0 * @depreacted 22.0.0
*/ */
public function getHTMLName() { public function getHTMLName(): string {
return $this->defaults->getHTMLName(); return $this->defaults->getHTMLName();
} }
@ -129,7 +132,7 @@ class Defaults {
* @return string * @return string
* @since 6.0.0 * @since 6.0.0
*/ */
public function getEntity() { public function getEntity(): string {
return $this->defaults->getEntity(); return $this->defaults->getEntity();
} }
@ -138,7 +141,7 @@ class Defaults {
* @return string * @return string
* @since 6.0.0 * @since 6.0.0
*/ */
public function getSlogan(?string $lang = null) { public function getSlogan(?string $lang = null): string {
return $this->defaults->getSlogan($lang); return $this->defaults->getSlogan($lang);
} }
@ -147,7 +150,7 @@ class Defaults {
* @return string * @return string
* @since 6.0.0 * @since 6.0.0
*/ */
public function getShortFooter() { public function getShortFooter(): string {
return $this->defaults->getShortFooter(); return $this->defaults->getShortFooter();
} }
@ -156,7 +159,7 @@ class Defaults {
* @return string * @return string
* @since 6.0.0 * @since 6.0.0
*/ */
public function getLongFooter() { public function getLongFooter(): string {
return $this->defaults->getLongFooter(); return $this->defaults->getLongFooter();
} }
@ -165,7 +168,7 @@ class Defaults {
* @return string AppId * @return string AppId
* @since 8.0.0 * @since 8.0.0
*/ */
public function getiTunesAppId() { public function getiTunesAppId(): string {
return $this->defaults->getiTunesAppId(); return $this->defaults->getiTunesAppId();
} }
@ -176,7 +179,7 @@ class Defaults {
* @return string * @return string
* @since 12.0.0 * @since 12.0.0
*/ */
public function getLogo($useSvg = true) { public function getLogo(bool $useSvg = true): string {
return $this->defaults->getLogo($useSvg); return $this->defaults->getLogo($useSvg);
} }
@ -185,7 +188,7 @@ class Defaults {
* @return string * @return string
* @since 12.0.0 * @since 12.0.0
*/ */
public function getColorPrimary() { public function getColorPrimary(): string {
return $this->defaults->getColorPrimary(); return $this->defaults->getColorPrimary();
} }
@ -194,7 +197,7 @@ class Defaults {
* @return string URL to doc with key * @return string URL to doc with key
* @since 12.0.0 * @since 12.0.0
*/ */
public function buildDocLinkToKey($key) { public function buildDocLinkToKey(string $key): string {
return $this->defaults->buildDocLinkToKey($key); return $this->defaults->buildDocLinkToKey($key);
} }
@ -203,7 +206,7 @@ class Defaults {
* @return string title * @return string title
* @since 12.0.0 * @since 12.0.0
*/ */
public function getTitle() { public function getTitle(): string {
return $this->defaults->getTitle(); return $this->defaults->getTitle();
} }
@ -212,7 +215,7 @@ class Defaults {
* @return string * @return string
* @since 13.0.0 * @since 13.0.0
*/ */
public function getTextColorPrimary() { public function getTextColorPrimary(): string {
return $this->defaults->getTextColorPrimary(); return $this->defaults->getTextColorPrimary();
} }
} }

View File

@ -1,4 +1,7 @@
<?php <?php
declare(strict_types=1);
/** /**
* @copyright Copyright (c) 2016, ownCloud, Inc. * @copyright Copyright (c) 2016, ownCloud, Inc.
* *

View File

@ -1,4 +1,7 @@
<?php <?php
declare(strict_types=1);
/** /**
* *
* *