diff options
author | Morris Jobke <hey@morrisjobke.de> | 2021-01-11 14:15:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-11 14:15:16 +0100 |
commit | 5ed673e5ebd20884f183cf00bee5cc8938a1d7be (patch) | |
tree | f28a8b0949fb18a94584dcf016d7e78fb2ceebd8 /lib | |
parent | 683685b72c90a892904026560ac4eba740d20382 (diff) | |
parent | 24d436cb600a725ba162a5387552a996a6fc486f (diff) | |
download | nextcloud-server-5ed673e5ebd20884f183cf00bee5cc8938a1d7be.tar.gz nextcloud-server-5ed673e5ebd20884f183cf00bee5cc8938a1d7be.zip |
Merge pull request #25073 from nextcloud/psalm/24521/remove-unneeded-casts
Remove unneeded casts that were found by Psalm
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/App/AppStore/Bundles/EducationBundle.php | 2 | ||||
-rw-r--r-- | lib/private/App/AppStore/Bundles/GroupwareBundle.php | 2 | ||||
-rw-r--r-- | lib/private/App/AppStore/Bundles/SocialSharingBundle.php | 2 | ||||
-rw-r--r-- | lib/private/App/DependencyAnalyzer.php | 18 | ||||
-rw-r--r-- | lib/private/AppFramework/Http/Dispatcher.php | 4 | ||||
-rw-r--r-- | lib/private/AppFramework/Routing/RouteConfig.php | 2 | ||||
-rw-r--r-- | lib/private/Collaboration/Collaborators/Search.php | 2 | ||||
-rw-r--r-- | lib/private/Files/FileInfo.php | 2 | ||||
-rw-r--r-- | lib/private/Files/Storage/Wrapper/Encoding.php | 2 | ||||
-rw-r--r-- | lib/private/L10N/Factory.php | 6 | ||||
-rw-r--r-- | lib/private/Notification/Notification.php | 2 | ||||
-rw-r--r-- | lib/private/Preview/TXT.php | 2 | ||||
-rw-r--r-- | lib/private/Security/Normalizer/IpAddress.php | 4 | ||||
-rw-r--r-- | lib/private/Template/JSConfigHelper.php | 90 |
14 files changed, 70 insertions, 70 deletions
diff --git a/lib/private/App/AppStore/Bundles/EducationBundle.php b/lib/private/App/AppStore/Bundles/EducationBundle.php index 05d6fbbd9d7..f59e8a115e2 100644 --- a/lib/private/App/AppStore/Bundles/EducationBundle.php +++ b/lib/private/App/AppStore/Bundles/EducationBundle.php @@ -29,7 +29,7 @@ class EducationBundle extends Bundle { * {@inheritDoc} */ public function getName() { - return (string)$this->l10n->t('Education Edition'); + return $this->l10n->t('Education Edition'); } /** diff --git a/lib/private/App/AppStore/Bundles/GroupwareBundle.php b/lib/private/App/AppStore/Bundles/GroupwareBundle.php index 49ae1068b10..604ed44aa08 100644 --- a/lib/private/App/AppStore/Bundles/GroupwareBundle.php +++ b/lib/private/App/AppStore/Bundles/GroupwareBundle.php @@ -30,7 +30,7 @@ class GroupwareBundle extends Bundle { * {@inheritDoc} */ public function getName() { - return (string)$this->l10n->t('Groupware bundle'); + return $this->l10n->t('Groupware bundle'); } /** diff --git a/lib/private/App/AppStore/Bundles/SocialSharingBundle.php b/lib/private/App/AppStore/Bundles/SocialSharingBundle.php index 8ce4d1080ff..cd063f6fa88 100644 --- a/lib/private/App/AppStore/Bundles/SocialSharingBundle.php +++ b/lib/private/App/AppStore/Bundles/SocialSharingBundle.php @@ -29,7 +29,7 @@ class SocialSharingBundle extends Bundle { * {@inheritDoc} */ public function getName() { - return (string)$this->l10n->t('Social sharing bundle'); + return $this->l10n->t('Social sharing bundle'); } /** diff --git a/lib/private/App/DependencyAnalyzer.php b/lib/private/App/DependencyAnalyzer.php index eb114adbb48..8476f9bc145 100644 --- a/lib/private/App/DependencyAnalyzer.php +++ b/lib/private/App/DependencyAnalyzer.php @@ -158,19 +158,19 @@ class DependencyAnalyzer { if (isset($dependencies['php']['@attributes']['min-version'])) { $minVersion = $dependencies['php']['@attributes']['min-version']; if ($this->compareSmaller($this->platform->getPhpVersion(), $minVersion)) { - $missing[] = (string)$this->l->t('PHP %s or higher is required.', [$minVersion]); + $missing[] = $this->l->t('PHP %s or higher is required.', [$minVersion]); } } if (isset($dependencies['php']['@attributes']['max-version'])) { $maxVersion = $dependencies['php']['@attributes']['max-version']; if ($this->compareBigger($this->platform->getPhpVersion(), $maxVersion)) { - $missing[] = (string)$this->l->t('PHP with a version lower than %s is required.', [$maxVersion]); + $missing[] = $this->l->t('PHP with a version lower than %s is required.', [$maxVersion]); } } if (isset($dependencies['php']['@attributes']['min-int-size'])) { $intSize = $dependencies['php']['@attributes']['min-int-size']; if ($intSize > $this->platform->getIntSize() * 8) { - $missing[] = (string)$this->l->t('%sbit or higher PHP required.', [$intSize]); + $missing[] = $this->l->t('%sbit or higher PHP required.', [$intSize]); } } return $missing; @@ -194,7 +194,7 @@ class DependencyAnalyzer { }, $supportedArchitectures); $currentArchitecture = $this->platform->getArchitecture(); if (!in_array($currentArchitecture, $supportedArchitectures, true)) { - $missing[] = (string)$this->l->t('The following architectures are supported: %s', [implode(', ', $supportedArchitectures)]); + $missing[] = $this->l->t('The following architectures are supported: %s', [implode(', ', $supportedArchitectures)]); } return $missing; } @@ -221,7 +221,7 @@ class DependencyAnalyzer { }, $supportedDatabases); $currentDatabase = $this->platform->getDatabase(); if (!in_array($currentDatabase, $supportedDatabases)) { - $missing[] = (string)$this->l->t('The following databases are supported: %s', [implode(', ', $supportedDatabases)]); + $missing[] = $this->l->t('The following databases are supported: %s', [implode(', ', $supportedDatabases)]); } return $missing; } @@ -250,7 +250,7 @@ class DependencyAnalyzer { } $commandName = $this->getValue($command); if (!$this->platform->isCommandKnown($commandName)) { - $missing[] = (string)$this->l->t('The command line tool %s could not be found', [$commandName]); + $missing[] = $this->l->t('The command line tool %s could not be found', [$commandName]); } } return $missing; @@ -324,7 +324,7 @@ class DependencyAnalyzer { } $currentOS = $this->platform->getOS(); if (!in_array($currentOS, $oss)) { - $missing[] = (string)$this->l->t('The following platforms are supported: %s', [implode(', ', $oss)]); + $missing[] = $this->l->t('The following platforms are supported: %s', [implode(', ', $oss)]); } return $missing; } @@ -350,12 +350,12 @@ class DependencyAnalyzer { if (!is_null($minVersion)) { if ($this->compareSmaller($this->platform->getOcVersion(), $minVersion)) { - $missing[] = (string)$this->l->t('Server version %s or higher is required.', [$this->toVisibleVersion($minVersion)]); + $missing[] = $this->l->t('Server version %s or higher is required.', [$this->toVisibleVersion($minVersion)]); } } if (!$ignoreMax && !is_null($maxVersion)) { if ($this->compareBigger($this->platform->getOcVersion(), $maxVersion)) { - $missing[] = (string)$this->l->t('Server version %s or lower is required.', [$this->toVisibleVersion($maxVersion)]); + $missing[] = $this->l->t('Server version %s or lower is required.', [$this->toVisibleVersion($maxVersion)]); } } return $missing; diff --git a/lib/private/AppFramework/Http/Dispatcher.php b/lib/private/AppFramework/Http/Dispatcher.php index 828864f1e02..9ec69558e88 100644 --- a/lib/private/AppFramework/Http/Dispatcher.php +++ b/lib/private/AppFramework/Http/Dispatcher.php @@ -133,7 +133,7 @@ class Dispatcher { if ($numBuilt > 50) { $this->logger->debug('Controller {class}::{method} created {count} QueryBuilder objects, please check if they are created inside a loop by accident.' , [ - 'class' => (string) get_class($controller), + 'class' => get_class($controller), 'method' => $methodName, 'count' => $numBuilt, ]); @@ -141,7 +141,7 @@ class Dispatcher { if ($numExecuted > 100) { $this->logger->warning('Controller {class}::{method} executed {count} queries.' , [ - 'class' => (string) get_class($controller), + 'class' => get_class($controller), 'method' => $methodName, 'count' => $numExecuted, ]); diff --git a/lib/private/AppFramework/Routing/RouteConfig.php b/lib/private/AppFramework/Routing/RouteConfig.php index b382e7eb4b0..c522d3436ca 100644 --- a/lib/private/AppFramework/Routing/RouteConfig.php +++ b/lib/private/AppFramework/Routing/RouteConfig.php @@ -231,7 +231,7 @@ class RouteConfig { $controllerName = $this->buildControllerName($controller); $actionName = $this->buildActionName($method); - $routeName = $routeNamePrefix . $this->appName . '.' . strtolower($resource) . '.' . strtolower($method); + $routeName = $routeNamePrefix . $this->appName . '.' . strtolower($resource) . '.' . $method; $route = $this->router->create($routeName, $url) ->method($verb); diff --git a/lib/private/Collaboration/Collaborators/Search.php b/lib/private/Collaboration/Collaborators/Search.php index 7b5789640a0..79dfd5e1d82 100644 --- a/lib/private/Collaboration/Collaborators/Search.php +++ b/lib/private/Collaboration/Collaborators/Search.php @@ -100,7 +100,7 @@ class Search implements ISearch { $searchResult->unsetResult($emailType); } - return [$searchResult->asArray(), (bool)$hasMoreResults]; + return [$searchResult->asArray(), $hasMoreResults]; } public function registerPlugin(array $pluginInfo) { diff --git a/lib/private/Files/FileInfo.php b/lib/private/Files/FileInfo.php index 35e69ae270f..d4cc6ffe4b2 100644 --- a/lib/private/Files/FileInfo.php +++ b/lib/private/Files/FileInfo.php @@ -243,7 +243,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { if (\OCP\Util::isSharingDisabledForUser() || ($this->isShared() && !\OC\Share\Share::isResharingAllowed())) { $perms = $perms & ~\OCP\Constants::PERMISSION_SHARE; } - return (int) $perms; + return $perms; } /** diff --git a/lib/private/Files/Storage/Wrapper/Encoding.php b/lib/private/Files/Storage/Wrapper/Encoding.php index d49420471dd..c0587cd0263 100644 --- a/lib/private/Files/Storage/Wrapper/Encoding.php +++ b/lib/private/Files/Storage/Wrapper/Encoding.php @@ -61,7 +61,7 @@ class Encoding extends Wrapper { * @return bool true if the string is all ASCII, false otherwise */ private function isAscii($str) { - return (bool) !preg_match('/[\\x80-\\xff]+/', $str); + return !preg_match('/[\\x80-\\xff]+/', $str); } /** diff --git a/lib/private/L10N/Factory.php b/lib/private/L10N/Factory.php index 9c9a3cc951e..47191475580 100644 --- a/lib/private/L10N/Factory.php +++ b/lib/private/L10N/Factory.php @@ -123,7 +123,7 @@ class Factory implements IFactory { return new LazyL10N(function () use ($app, $lang, $locale) { $app = \OC_App::cleanAppId($app); if ($lang !== null) { - $lang = str_replace(['\0', '/', '\\', '..'], '', (string)$lang); + $lang = str_replace(['\0', '/', '\\', '..'], '', $lang); } $forceLang = $this->config->getSystemValue('force_language', false); @@ -617,7 +617,7 @@ class Factory implements IFactory { $forceLanguage = $this->config->getSystemValue('force_language', false); if ($forceLanguage !== false) { $l = $this->get('lib', $forceLanguage); - $potentialName = (string) $l->t('__language_name__'); + $potentialName = $l->t('__language_name__'); return [ 'commonlanguages' => [[ @@ -636,7 +636,7 @@ class Factory implements IFactory { foreach ($languageCodes as $lang) { $l = $this->get('lib', $lang); // TRANSLATORS this is the language name for the language switcher in the personal settings and should be the localized version - $potentialName = (string) $l->t('__language_name__'); + $potentialName = $l->t('__language_name__'); if ($l->getLanguageCode() === $lang && $potentialName[0] !== '_') {//first check if the language name is in the translation file $ln = [ 'code' => $lang, diff --git a/lib/private/Notification/Notification.php b/lib/private/Notification/Notification.php index 8ac4e19b7d1..c0848817361 100644 --- a/lib/private/Notification/Notification.php +++ b/lib/private/Notification/Notification.php @@ -206,7 +206,7 @@ class Notification implements INotification { if ($id === '' || isset($id[64])) { throw new \InvalidArgumentException('The given object id is invalid'); } - $this->objectId = (string) $id; + $this->objectId = $id; return $this; } diff --git a/lib/private/Preview/TXT.php b/lib/private/Preview/TXT.php index 968a15a5683..9c5b7aa1440 100644 --- a/lib/private/Preview/TXT.php +++ b/lib/private/Preview/TXT.php @@ -85,7 +85,7 @@ class TXT extends ProviderV2 { foreach ($lines as $index => $line) { $index = $index + 1; - $x = (int) 1; + $x = 1; $y = (int) ($index * $lineSize); if ($canUseTTF === true) { diff --git a/lib/private/Security/Normalizer/IpAddress.php b/lib/private/Security/Normalizer/IpAddress.php index a679936e20c..cbfc212e1ce 100644 --- a/lib/private/Security/Normalizer/IpAddress.php +++ b/lib/private/Security/Normalizer/IpAddress.php @@ -58,7 +58,7 @@ class IpAddress { $binary = \inet_pton($ip); for ($i = 32; $i > $maskBits; $i -= 8) { $j = \intdiv($i, 8) - 1; - $k = (int) \min(8, $i - $maskBits); + $k = \min(8, $i - $maskBits); $mask = (0xff - ((2 ** $k) - 1)); $int = \unpack('C', $binary[$j]); $binary[$j] = \pack('C', $int[1] & $mask); @@ -84,7 +84,7 @@ class IpAddress { $binary = \inet_pton($ip); for ($i = 128; $i > $maskBits; $i -= 8) { $j = \intdiv($i, 8) - 1; - $k = (int) \min(8, $i - $maskBits); + $k = \min(8, $i - $maskBits); $mask = (0xff - ((2 ** $k) - 1)); $int = \unpack('C', $binary[$j]); $binary[$j] = \pack('C', $int[1] & $mask); diff --git a/lib/private/Template/JSConfigHelper.php b/lib/private/Template/JSConfigHelper.php index 69624825ae4..b228cae6ffb 100644 --- a/lib/private/Template/JSConfigHelper.php +++ b/lib/private/Template/JSConfigHelper.php @@ -207,59 +207,59 @@ class JSConfigHelper { 'nc_lastLogin' => $lastConfirmTimestamp, 'nc_pageLoad' => time(), "dayNames" => json_encode([ - (string)$this->l->t('Sunday'), - (string)$this->l->t('Monday'), - (string)$this->l->t('Tuesday'), - (string)$this->l->t('Wednesday'), - (string)$this->l->t('Thursday'), - (string)$this->l->t('Friday'), - (string)$this->l->t('Saturday') + $this->l->t('Sunday'), + $this->l->t('Monday'), + $this->l->t('Tuesday'), + $this->l->t('Wednesday'), + $this->l->t('Thursday'), + $this->l->t('Friday'), + $this->l->t('Saturday') ]), "dayNamesShort" => json_encode([ - (string)$this->l->t('Sun.'), - (string)$this->l->t('Mon.'), - (string)$this->l->t('Tue.'), - (string)$this->l->t('Wed.'), - (string)$this->l->t('Thu.'), - (string)$this->l->t('Fri.'), - (string)$this->l->t('Sat.') + $this->l->t('Sun.'), + $this->l->t('Mon.'), + $this->l->t('Tue.'), + $this->l->t('Wed.'), + $this->l->t('Thu.'), + $this->l->t('Fri.'), + $this->l->t('Sat.') ]), "dayNamesMin" => json_encode([ - (string)$this->l->t('Su'), - (string)$this->l->t('Mo'), - (string)$this->l->t('Tu'), - (string)$this->l->t('We'), - (string)$this->l->t('Th'), - (string)$this->l->t('Fr'), - (string)$this->l->t('Sa') + $this->l->t('Su'), + $this->l->t('Mo'), + $this->l->t('Tu'), + $this->l->t('We'), + $this->l->t('Th'), + $this->l->t('Fr'), + $this->l->t('Sa') ]), "monthNames" => json_encode([ - (string)$this->l->t('January'), - (string)$this->l->t('February'), - (string)$this->l->t('March'), - (string)$this->l->t('April'), - (string)$this->l->t('May'), - (string)$this->l->t('June'), - (string)$this->l->t('July'), - (string)$this->l->t('August'), - (string)$this->l->t('September'), - (string)$this->l->t('October'), - (string)$this->l->t('November'), - (string)$this->l->t('December') + $this->l->t('January'), + $this->l->t('February'), + $this->l->t('March'), + $this->l->t('April'), + $this->l->t('May'), + $this->l->t('June'), + $this->l->t('July'), + $this->l->t('August'), + $this->l->t('September'), + $this->l->t('October'), + $this->l->t('November'), + $this->l->t('December') ]), "monthNamesShort" => json_encode([ - (string)$this->l->t('Jan.'), - (string)$this->l->t('Feb.'), - (string)$this->l->t('Mar.'), - (string)$this->l->t('Apr.'), - (string)$this->l->t('May.'), - (string)$this->l->t('Jun.'), - (string)$this->l->t('Jul.'), - (string)$this->l->t('Aug.'), - (string)$this->l->t('Sep.'), - (string)$this->l->t('Oct.'), - (string)$this->l->t('Nov.'), - (string)$this->l->t('Dec.') + $this->l->t('Jan.'), + $this->l->t('Feb.'), + $this->l->t('Mar.'), + $this->l->t('Apr.'), + $this->l->t('May.'), + $this->l->t('Jun.'), + $this->l->t('Jul.'), + $this->l->t('Aug.'), + $this->l->t('Sep.'), + $this->l->t('Oct.'), + $this->l->t('Nov.'), + $this->l->t('Dec.') ]), "firstDay" => json_encode($this->l->l('firstday', null)), "_oc_config" => json_encode($config), |