diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-08-19 19:34:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-19 19:34:02 +0200 |
commit | c449d5420465a01e0bf5579af8dbb99d64a24133 (patch) | |
tree | 7dcdb282f270f051b1e1c87144556b564dfb2000 /lib/private | |
parent | 4c6eb96471b90c41e26bdf2cb3edf2cb15aec613 (diff) | |
parent | 4db7829f43cef3eb615068fbaffba37dadbf2c06 (diff) | |
download | nextcloud-server-c449d5420465a01e0bf5579af8dbb99d64a24133.tar.gz nextcloud-server-c449d5420465a01e0bf5579af8dbb99d64a24133.zip |
Merge pull request #22304 from nextcloud/techdebt/noid/matching-param-names
Use matching parameter names form interfaces and implementations
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Authentication/Token/IProvider.php | 4 | ||||
-rw-r--r-- | lib/private/Authentication/Token/PublicKeyTokenProvider.php | 10 | ||||
-rw-r--r-- | lib/private/ContactsManager.php | 12 | ||||
-rw-r--r-- | lib/private/DB/OracleConnection.php | 16 | ||||
-rw-r--r-- | lib/private/Files/Cache/Wrapper/CacheJail.php | 4 | ||||
-rw-r--r-- | lib/private/Files/ObjectStore/NoopScanner.php | 2 | ||||
-rw-r--r-- | lib/private/SystemTag/SystemTagManager.php | 8 | ||||
-rw-r--r-- | lib/private/URLGenerator.php | 87 | ||||
-rw-r--r-- | lib/private/User/Database.php | 8 |
9 files changed, 77 insertions, 74 deletions
diff --git a/lib/private/Authentication/Token/IProvider.php b/lib/private/Authentication/Token/IProvider.php index 384828c207e..2b6223fded9 100644 --- a/lib/private/Authentication/Token/IProvider.php +++ b/lib/private/Authentication/Token/IProvider.php @@ -140,13 +140,13 @@ interface IProvider { /** * Get the (unencrypted) password of the given token * - * @param IToken $token + * @param IToken $savedToken * @param string $tokenId * @throws InvalidTokenException * @throws PasswordlessTokenException * @return string */ - public function getPassword(IToken $token, string $tokenId): string; + public function getPassword(IToken $savedToken, string $tokenId): string; /** * Encrypt and set the password of the given token diff --git a/lib/private/Authentication/Token/PublicKeyTokenProvider.php b/lib/private/Authentication/Token/PublicKeyTokenProvider.php index 091f47d7da3..7fe4a0d8703 100644 --- a/lib/private/Authentication/Token/PublicKeyTokenProvider.php +++ b/lib/private/Authentication/Token/PublicKeyTokenProvider.php @@ -227,20 +227,20 @@ class PublicKeyTokenProvider implements IProvider { return $this->mapper->getTokenByUser($uid); } - public function getPassword(IToken $token, string $tokenId): string { - if (!($token instanceof PublicKeyToken)) { + public function getPassword(IToken $savedToken, string $tokenId): string { + if (!($savedToken instanceof PublicKeyToken)) { throw new InvalidTokenException("Invalid token type"); } - if ($token->getPassword() === null) { + if ($savedToken->getPassword() === null) { throw new PasswordlessTokenException(); } // Decrypt private key with tokenId - $privateKey = $this->decrypt($token->getPrivateKey(), $tokenId); + $privateKey = $this->decrypt($savedToken->getPrivateKey(), $tokenId); // Decrypt password with private key - return $this->decryptPassword($token->getPassword(), $privateKey); + return $this->decryptPassword($savedToken->getPassword(), $privateKey); } public function setPassword(IToken $token, string $tokenId, string $password) { diff --git a/lib/private/ContactsManager.php b/lib/private/ContactsManager.php index 999b6597978..984164106d2 100644 --- a/lib/private/ContactsManager.php +++ b/lib/private/ContactsManager.php @@ -69,11 +69,11 @@ class ContactsManager implements IManager { * This function can be used to delete the contact identified by the given id * * @param object $id the unique identifier to a contact - * @param string $addressBookKey identifier of the address book in which the contact shall be deleted + * @param string $address_book_key identifier of the address book in which the contact shall be deleted * @return bool successful or not */ - public function delete($id, $addressBookKey) { - $addressBook = $this->getAddressBook($addressBookKey); + public function delete($id, $address_book_key) { + $addressBook = $this->getAddressBook($address_book_key); if (!$addressBook) { return null; } @@ -90,11 +90,11 @@ class ContactsManager implements IManager { * Otherwise the contact will be updated by replacing the entire data set. * * @param array $properties this array if key-value-pairs defines a contact - * @param string $addressBookKey identifier of the address book in which the contact shall be created or updated + * @param string $address_book_key identifier of the address book in which the contact shall be created or updated * @return array representing the contact just created or updated */ - public function createOrUpdate($properties, $addressBookKey) { - $addressBook = $this->getAddressBook($addressBookKey); + public function createOrUpdate($properties, $address_book_key) { + $addressBook = $this->getAddressBook($address_book_key); if (!$addressBook) { return null; } diff --git a/lib/private/DB/OracleConnection.php b/lib/private/DB/OracleConnection.php index b53ee850149..9dd7620a546 100644 --- a/lib/private/DB/OracleConnection.php +++ b/lib/private/DB/OracleConnection.php @@ -47,24 +47,24 @@ class OracleConnection extends Connection { /** * {@inheritDoc} */ - public function insert($tableName, array $data, array $types = []) { - if ($tableName[0] !== $this->getDatabasePlatform()->getIdentifierQuoteCharacter()) { - $tableName = $this->quoteIdentifier($tableName); + public function insert($tableExpression, array $data, array $types = []) { + if ($tableExpression[0] !== $this->getDatabasePlatform()->getIdentifierQuoteCharacter()) { + $tableExpression = $this->quoteIdentifier($tableExpression); } $data = $this->quoteKeys($data); - return parent::insert($tableName, $data, $types); + return parent::insert($tableExpression, $data, $types); } /** * {@inheritDoc} */ - public function update($tableName, array $data, array $identifier, array $types = []) { - if ($tableName[0] !== $this->getDatabasePlatform()->getIdentifierQuoteCharacter()) { - $tableName = $this->quoteIdentifier($tableName); + public function update($tableExpression, array $data, array $identifier, array $types = []) { + if ($tableExpression[0] !== $this->getDatabasePlatform()->getIdentifierQuoteCharacter()) { + $tableExpression = $this->quoteIdentifier($tableExpression); } $data = $this->quoteKeys($data); $identifier = $this->quoteKeys($identifier); - return parent::update($tableName, $data, $identifier, $types); + return parent::update($tableExpression, $data, $identifier, $types); } /** diff --git a/lib/private/Files/Cache/Wrapper/CacheJail.php b/lib/private/Files/Cache/Wrapper/CacheJail.php index 8d4f412868e..00cd92d7a9e 100644 --- a/lib/private/Files/Cache/Wrapper/CacheJail.php +++ b/lib/private/Files/Cache/Wrapper/CacheJail.php @@ -254,9 +254,9 @@ class CacheJail extends CacheWrapper { * @param string|boolean $path * @param array $data (optional) meta data of the folder */ - public function correctFolderSize($path, $data = null, $isBackgroundSize = false) { + public function correctFolderSize($path, $data = null, $isBackgroundScan = false) { if ($this->getCache() instanceof Cache) { - $this->getCache()->correctFolderSize($this->getSourcePath($path), $data, $isBackgroundSize); + $this->getCache()->correctFolderSize($this->getSourcePath($path), $data, $isBackgroundScan); } } diff --git a/lib/private/Files/ObjectStore/NoopScanner.php b/lib/private/Files/ObjectStore/NoopScanner.php index 25b52416efd..9195e7f8d9f 100644 --- a/lib/private/Files/ObjectStore/NoopScanner.php +++ b/lib/private/Files/ObjectStore/NoopScanner.php @@ -69,7 +69,7 @@ class NoopScanner extends Scanner { * @param array $folderData existing cache data for the folder to be scanned * @return int the size of the scanned folder or -1 if the size is unknown at this stage */ - protected function scanChildren($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $folderData = null, $lock = true) { + protected function scanChildren($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $folderId = null, $lock = true) { return 0; } diff --git a/lib/private/SystemTag/SystemTagManager.php b/lib/private/SystemTag/SystemTagManager.php index 5941400883b..0b21d13d2db 100644 --- a/lib/private/SystemTag/SystemTagManager.php +++ b/lib/private/SystemTag/SystemTagManager.php @@ -230,7 +230,7 @@ class SystemTagManager implements ISystemTagManager { /** * {@inheritdoc} */ - public function updateTag(string $tagId, string $tagName, bool $userVisible, bool $userAssignable) { + public function updateTag(string $tagId, string $newName, bool $userVisible, bool $userAssignable) { try { $tags = $this->getTagsByIds($tagId); } catch (TagNotFoundException $e) { @@ -242,7 +242,7 @@ class SystemTagManager implements ISystemTagManager { $beforeUpdate = array_shift($tags); $afterUpdate = new SystemTag( $tagId, - $tagName, + $newName, $userVisible, $userAssignable ); @@ -253,7 +253,7 @@ class SystemTagManager implements ISystemTagManager { ->set('visibility', $query->createParameter('visibility')) ->set('editable', $query->createParameter('editable')) ->where($query->expr()->eq('id', $query->createParameter('tagid'))) - ->setParameter('name', $tagName) + ->setParameter('name', $newName) ->setParameter('visibility', $userVisible ? 1 : 0) ->setParameter('editable', $userAssignable ? 1 : 0) ->setParameter('tagid', $tagId); @@ -266,7 +266,7 @@ class SystemTagManager implements ISystemTagManager { } } catch (UniqueConstraintViolationException $e) { throw new TagAlreadyExistsException( - 'Tag ("' . $tagName . '", '. $userVisible . ', ' . $userAssignable . ') already exists', + 'Tag ("' . $newName . '", '. $userVisible . ', ' . $userAssignable . ') already exists', 0, $e ); diff --git a/lib/private/URLGenerator.php b/lib/private/URLGenerator.php index b432b0b69ca..e90d8cf1d1c 100644 --- a/lib/private/URLGenerator.php +++ b/lib/private/URLGenerator.php @@ -72,15 +72,16 @@ class URLGenerator implements IURLGenerator { /** * Creates an url using a defined route - * @param string $route - * @param array $parameters args with param=>value, will be appended to the returned url + * + * @param string $routeName + * @param array $arguments args with param=>value, will be appended to the returned url * @return string the url * * Returns a url to the given route. */ - public function linkToRoute(string $route, array $parameters = []): string { + public function linkToRoute(string $routeName, array $arguments = []): string { // TODO: mock router - return \OC::$server->getRouter()->generate($route, $parameters); + return \OC::$server->getRouter()->generate($routeName, $arguments); } /** @@ -111,7 +112,8 @@ class URLGenerator implements IURLGenerator { /** * Creates an url - * @param string $app app + * + * @param string $appName app * @param string $file file * @param array $args array with param=>value, will be appended to the returned url * The value of $args will be urlencoded @@ -119,24 +121,24 @@ class URLGenerator implements IURLGenerator { * * Returns a url to the given app and file. */ - public function linkTo(string $app, string $file, array $args = []): string { + public function linkTo(string $appName, string $file, array $args = []): string { $frontControllerActive = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true'); - if ($app !== '') { - $app_path = \OC_App::getAppPath($app); + if ($appName !== '') { + $app_path = \OC_App::getAppPath($appName); // Check if the app is in the app folder if ($app_path && file_exists($app_path . '/' . $file)) { if (substr($file, -3) === 'php') { - $urlLinkTo = \OC::$WEBROOT . '/index.php/apps/' . $app; + $urlLinkTo = \OC::$WEBROOT . '/index.php/apps/' . $appName; if ($frontControllerActive) { - $urlLinkTo = \OC::$WEBROOT . '/apps/' . $app; + $urlLinkTo = \OC::$WEBROOT . '/apps/' . $appName; } $urlLinkTo .= ($file !== 'index.php') ? '/' . $file : ''; } else { - $urlLinkTo = \OC_App::getAppWebPath($app) . '/' . $file; + $urlLinkTo = \OC_App::getAppWebPath($appName) . '/' . $file; } } else { - $urlLinkTo = \OC::$WEBROOT . '/' . $app . '/' . $file; + $urlLinkTo = \OC::$WEBROOT . '/' . $appName . '/' . $file; } } else { if (file_exists(\OC::$SERVERROOT . '/core/' . $file)) { @@ -159,16 +161,17 @@ class URLGenerator implements IURLGenerator { /** * Creates path to an image - * @param string $app app - * @param string $image image name + * + * @param string $appName app + * @param string $file image name * @throws \RuntimeException If the image does not exist * @return string the url * * Returns the path to the image. */ - public function imagePath(string $app, string $image): string { + public function imagePath(string $appName, string $file): string { $cache = $this->cacheFactory->createDistributed('imagePath-'.md5($this->getBaseUrl()).'-'); - $cacheKey = $app.'-'.$image; + $cacheKey = $appName.'-'.$file; if ($key = $cache->get($cacheKey)) { return $key; } @@ -177,9 +180,9 @@ class URLGenerator implements IURLGenerator { $theme = \OC_Util::getTheme(); //if a theme has a png but not an svg always use the png - $basename = substr(basename($image),0,-4); + $basename = substr(basename($file),0,-4); - $appPath = \OC_App::getAppPath($app); + $appPath = \OC_App::getAppPath($appName); // Check if the app is in the app folder $path = ''; @@ -188,39 +191,39 @@ class URLGenerator implements IURLGenerator { if ($themingEnabled) { $themingDefaults = \OC::$server->getThemingDefaults(); if ($themingDefaults instanceof ThemingDefaults) { - $themingImagePath = $themingDefaults->replaceImagePath($app, $image); + $themingImagePath = $themingDefaults->replaceImagePath($appName, $file); } } - if (file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$image")) { - $path = \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$image"; - } elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.svg") - && file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.png")) { - $path = \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$basename.png"; - } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$image")) { - $path = \OC::$WEBROOT . "/themes/$theme/$app/img/$image"; - } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.svg") - && file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.png"))) { - $path = \OC::$WEBROOT . "/themes/$theme/$app/img/$basename.png"; - } elseif (file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$image")) { - $path = \OC::$WEBROOT . "/themes/$theme/core/img/$image"; + if (file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$appName/img/$file")) { + $path = \OC::$WEBROOT . "/themes/$theme/apps/$appName/img/$file"; + } elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$appName/img/$basename.svg") + && file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$appName/img/$basename.png")) { + $path = \OC::$WEBROOT . "/themes/$theme/apps/$appName/img/$basename.png"; + } elseif (!empty($appName) and file_exists(\OC::$SERVERROOT . "/themes/$theme/$appName/img/$file")) { + $path = \OC::$WEBROOT . "/themes/$theme/$appName/img/$file"; + } elseif (!empty($appName) and (!file_exists(\OC::$SERVERROOT . "/themes/$theme/$appName/img/$basename.svg") + && file_exists(\OC::$SERVERROOT . "/themes/$theme/$appName/img/$basename.png"))) { + $path = \OC::$WEBROOT . "/themes/$theme/$appName/img/$basename.png"; + } elseif (file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$file")) { + $path = \OC::$WEBROOT . "/themes/$theme/core/img/$file"; } elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.svg") && file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.png")) { $path = \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png"; } elseif ($themingEnabled && $themingImagePath) { $path = $themingImagePath; - } elseif ($appPath && file_exists($appPath . "/img/$image")) { - $path = \OC_App::getAppWebPath($app) . "/img/$image"; + } elseif ($appPath && file_exists($appPath . "/img/$file")) { + $path = \OC_App::getAppWebPath($appName) . "/img/$file"; } elseif ($appPath && !file_exists($appPath . "/img/$basename.svg") && file_exists($appPath . "/img/$basename.png")) { - $path = \OC_App::getAppWebPath($app) . "/img/$basename.png"; - } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/$app/img/$image")) { - $path = \OC::$WEBROOT . "/$app/img/$image"; - } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/$app/img/$basename.svg") - && file_exists(\OC::$SERVERROOT . "/$app/img/$basename.png"))) { - $path = \OC::$WEBROOT . "/$app/img/$basename.png"; - } elseif (file_exists(\OC::$SERVERROOT . "/core/img/$image")) { - $path = \OC::$WEBROOT . "/core/img/$image"; + $path = \OC_App::getAppWebPath($appName) . "/img/$basename.png"; + } elseif (!empty($appName) and file_exists(\OC::$SERVERROOT . "/$appName/img/$file")) { + $path = \OC::$WEBROOT . "/$appName/img/$file"; + } elseif (!empty($appName) and (!file_exists(\OC::$SERVERROOT . "/$appName/img/$basename.svg") + && file_exists(\OC::$SERVERROOT . "/$appName/img/$basename.png"))) { + $path = \OC::$WEBROOT . "/$appName/img/$basename.png"; + } elseif (file_exists(\OC::$SERVERROOT . "/core/img/$file")) { + $path = \OC::$WEBROOT . "/core/img/$file"; } elseif (!file_exists(\OC::$SERVERROOT . "/core/img/$basename.svg") && file_exists(\OC::$SERVERROOT . "/core/img/$basename.png")) { $path = \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png"; @@ -231,7 +234,7 @@ class URLGenerator implements IURLGenerator { return $path; } - throw new RuntimeException('image not found: image:' . $image . ' webroot:' . \OC::$WEBROOT . ' serverroot:' . \OC::$SERVERROOT); + throw new RuntimeException('image not found: image:' . $file . ' webroot:' . \OC::$WEBROOT . ' serverroot:' . \OC::$SERVERROOT); } diff --git a/lib/private/User/Database.php b/lib/private/User/Database.php index e88549c8d81..2353aeeb26e 100644 --- a/lib/private/User/Database.php +++ b/lib/private/User/Database.php @@ -293,14 +293,14 @@ class Database extends ABackend implements /** * Check if the password is correct * - * @param string $uid The username + * @param string $loginName The loginname * @param string $password The password * @return string * * Check if the password is correct without logging in the user * returns the user id or false */ - public function checkPassword(string $uid, string $password) { + public function checkPassword(string $loginName, string $password) { $this->fixDI(); $qb = $this->dbConn->getQueryBuilder(); @@ -308,7 +308,7 @@ class Database extends ABackend implements ->from($this->table) ->where( $qb->expr()->eq( - 'uid_lower', $qb->createNamedParameter(mb_strtolower($uid)) + 'uid_lower', $qb->createNamedParameter(mb_strtolower($loginName)) ) ); $result = $qb->execute(); @@ -320,7 +320,7 @@ class Database extends ABackend implements $newHash = ''; if (\OC::$server->getHasher()->verify($password, $storedHash, $newHash)) { if (!empty($newHash)) { - $this->updatePassword($uid, $newHash); + $this->updatePassword($loginName, $newHash); } return (string)$row['uid']; } |