diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php index 51d24351c05b3..b7133c31e9a7f 100644 --- a/apps/dav/lib/CardDAV/CardDavBackend.php +++ b/apps/dav/lib/CardDAV/CardDavBackend.php @@ -879,7 +879,7 @@ public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, if ($syncToken) { $query = "SELECT `uri`, `operation` FROM `*PREFIX*addressbookchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `addressbookid` = ? ORDER BY `synctoken`"; if ($limit > 0) { - $query .= " LIMIT " . (int)$limit; + $query .= " LIMIT " . $limit; } // Fetching all changes diff --git a/apps/dav/lib/Connector/Sabre/SharesPlugin.php b/apps/dav/lib/Connector/Sabre/SharesPlugin.php index 98458ff8bfa29..cea5f5a9ffdf3 100644 --- a/apps/dav/lib/Connector/Sabre/SharesPlugin.php +++ b/apps/dav/lib/Connector/Sabre/SharesPlugin.php @@ -69,7 +69,7 @@ class SharesPlugin extends \Sabre\DAV\ServerPlugin { */ private $userFolder; - /** @var IShare[] */ + /** @var IShare[][] */ private $cachedShares = []; private $cachedFolders = []; @@ -112,7 +112,11 @@ public function initialize(\Sabre\DAV\Server $server) { $this->server->on('propFind', [$this, 'handleGetProperties']); } - private function getShare(\OCP\Files\Node $node): array { + /** + * @return IShare[] + */ + private function getSharesForFilesNode(\OCP\Files\Node $node): array { + /** @var IShare[] $result */ $result = []; $requestedShareTypes = [ IShare::TYPE_USER, @@ -139,6 +143,9 @@ private function getShare(\OCP\Files\Node $node): array { return $result; } + /** + * @return IShare[][] + */ private function getSharesFolder(\OCP\Files\Folder $node): array { return $this->shareManager->getSharesInFolder( $this->userId, @@ -147,7 +154,10 @@ private function getSharesFolder(\OCP\Files\Folder $node): array { ); } - private function getShares(\Sabre\DAV\INode $sabreNode): array { + /** + * @return IShare[] + */ + private function getSharesForSabreNode(\Sabre\DAV\INode $sabreNode): array { if (isset($this->cachedShares[$sabreNode->getId()])) { $shares = $this->cachedShares[$sabreNode->getId()]; } else { @@ -158,7 +168,7 @@ private function getShares(\Sabre\DAV\INode $sabreNode): array { // if we already cached the folder this file is in we know there are no shares for this file if (array_search($parentPath, $this->cachedFolders) === false) { $node = $this->userFolder->get($sabreNode->getPath()); - $shares = $this->getShare($node); + $shares = $this->getSharesForFilesNode($node); $this->cachedShares[$sabreNode->getId()] = $shares; } else { return []; @@ -200,7 +210,7 @@ public function handleGetProperties( } $propFind->handle(self::SHARETYPES_PROPERTYNAME, function () use ($sabreNode) { - $shares = $this->getShares($sabreNode); + $shares = $this->getSharesForSabreNode($sabreNode); $shareTypes = array_unique(array_map(function (IShare $share) { return $share->getShareType(); @@ -210,7 +220,7 @@ public function handleGetProperties( }); $propFind->handle(self::SHAREES_PROPERTYNAME, function () use ($sabreNode) { - $shares = $this->getShares($sabreNode); + $shares = $this->getSharesForSabreNode($sabreNode); return new ShareeList($shares); }); diff --git a/apps/dav/lib/Provisioning/Apple/AppleProvisioningPlugin.php b/apps/dav/lib/Provisioning/Apple/AppleProvisioningPlugin.php index 6e45affb3fe59..e306c2a465542 100644 --- a/apps/dav/lib/Provisioning/Apple/AppleProvisioningPlugin.php +++ b/apps/dav/lib/Provisioning/Apple/AppleProvisioningPlugin.php @@ -130,6 +130,7 @@ public function httpGet(RequestInterface $request, ResponseInterface $response): $absoluteURL = $this->urlGenerator->getBaseUrl(); $parsedUrl = parse_url($absoluteURL); if (isset($parsedUrl['port'])) { + /** @psalm-suppress RedundantCast */ $serverPort = (int) $parsedUrl['port']; } else { $serverPort = 443; diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index e999e5dd4bb7d..12408d8e108fa 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -1147,7 +1147,6 @@ public function updateShare( // NOT A LINK SHARE else { if ($permissions !== null) { - $permissions = (int) $permissions; $share->setPermissions($permissions); } diff --git a/apps/theming/lib/IconBuilder.php b/apps/theming/lib/IconBuilder.php index 68d1ff311fe8e..65b7be430edf4 100644 --- a/apps/theming/lib/IconBuilder.php +++ b/apps/theming/lib/IconBuilder.php @@ -198,8 +198,8 @@ public function renderAppIcon($app, $size) { // offset for icon positioning $border_w = (int)($appIconFile->getImageWidth() * 0.05); $border_h = (int)($appIconFile->getImageHeight() * 0.05); - $innerWidth = (int)($appIconFile->getImageWidth() - $border_w * 2); - $innerHeight = (int)($appIconFile->getImageHeight() - $border_h * 2); + $innerWidth = ($appIconFile->getImageWidth() - $border_w * 2); + $innerHeight = ($appIconFile->getImageHeight() - $border_h * 2); $appIconFile->adaptiveResizeImage($innerWidth, $innerHeight); // center icon $offset_w = 512 / 2 - $innerWidth / 2; diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php index fc1f2458fd187..f255e344a9838 100644 --- a/apps/user_ldap/lib/Access.php +++ b/apps/user_ldap/lib/Access.php @@ -180,7 +180,7 @@ public function getConnection() { * array if $attr is empty, false otherwise * @throws ServerNotAvailableException */ - public function readAttribute($dn, $attr, $filter = 'objectClass=*') { + public function readAttribute(string $dn, string $attr, string $filter = 'objectClass=*') { if (!$this->checkConnection()) { \OCP\Util::writeLog('user_ldap', 'No LDAP Connector assigned, access impossible for readAttribute.', @@ -203,6 +203,10 @@ public function readAttribute($dn, $attr, $filter = 'objectClass=*') { // (cf. #12306), 500 is default for paging and should work everywhere. $maxResults = $pagingSize > 20 ? $pagingSize : 500; $attr = mb_strtolower($attr, 'UTF-8'); + if ($attr === false) { + \OCP\Util::writeLog('user_ldap', 'Attribute name could not be converted to lower case.', ILogger::DEBUG); + return false; + } // the actual read attribute later may contain parameters on a ranged // request, e.g. member;range=99-199. Depends on server reply. $attrToRead = $attr; @@ -1759,6 +1763,7 @@ public function getUUID($dn, $isUser = true, $ldapRecord = null) { $uuid = false; if ($this->detectUuidAttribute($dn, $isUser, false, $ldapRecord)) { + /** @var string $attr */ $attr = $this->connection->$uuidAttr; $uuid = isset($ldapRecord[$attr]) ? $ldapRecord[$attr] : $this->readAttribute($dn, $attr); if (!is_array($uuid) diff --git a/lib/private/AppFramework/Routing/RouteConfig.php b/lib/private/AppFramework/Routing/RouteConfig.php index b382e7eb4b033..c522d3436cab8 100644 --- a/lib/private/AppFramework/Routing/RouteConfig.php +++ b/lib/private/AppFramework/Routing/RouteConfig.php @@ -231,7 +231,7 @@ protected function processResources(array $resources, string $routeNamePrefix = $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/Setup.php b/lib/private/Setup.php index 873e82e55de7f..990cc12bc9d15 100644 --- a/lib/private/Setup.php +++ b/lib/private/Setup.php @@ -187,13 +187,12 @@ public function getSupportedDatabases($allowAllDatabases = false) { foreach ($configuredDatabases as $database) { if (array_key_exists($database, $availableDatabases)) { - $working = false; $type = $availableDatabases[$database]['type']; $call = $availableDatabases[$database]['call']; if ($type === 'function') { $working = $this->is_callable($call); - } elseif ($type === 'pdo') { + } else { $working = in_array($call, $this->getAvailableDbDriversForPdo(), true); } if ($working) { diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 9a2b413896b00..4c3866d714e7c 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -1266,6 +1266,7 @@ public function getSharesBy($userId, $shareType, $path = null, $reshares = false return []; } + /** @var IShare[] $shares */ $shares = $provider->getSharesBy($userId, $shareType, $path, $reshares, $limit, $offset); /* @@ -1273,6 +1274,7 @@ public function getSharesBy($userId, $shareType, $path = null, $reshares = false * proper pagination. */ + /** @var IShare[] $shares2 */ $shares2 = []; while (true) { diff --git a/lib/public/AppFramework/Db/QBMapper.php b/lib/public/AppFramework/Db/QBMapper.php index 79b3701be2a3e..72373ba26c303 100644 --- a/lib/public/AppFramework/Db/QBMapper.php +++ b/lib/public/AppFramework/Db/QBMapper.php @@ -147,7 +147,9 @@ public function insert(Entity $entity): Entity { * updates an existing entry if duplicate keys are detected * by the database * + * @param Entity $entity the entity that should be created/updated * @psalm-param T $entity the entity that should be created/updated + * @return Entity the saved entity with the (new) id * @psalm-return T the saved entity with the (new) id * @throws \InvalidArgumentException if entity has no id * @since 15.0.0