Return value immediately instead of assigning to a one-time variable

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
Morris Jobke 2018-01-26 00:02:03 +01:00
parent b9bbb894f8
commit 0a56d2185e
No known key found for this signature in database
GPG Key ID: FE03C3A163FEDE68
19 changed files with 21 additions and 47 deletions

View File

@ -143,8 +143,7 @@ class Converter {
*/ */
private function getAvatarImage(IUser $user) { private function getAvatarImage(IUser $user) {
try { try {
$image = $user->getAvatarImage(-1); return $user->getAvatarImage(-1);
return $image;
} catch (\Exception $ex) { } catch (\Exception $ex) {
return null; return null;
} }

View File

@ -340,8 +340,7 @@ class FilesPlugin extends ServerPlugin {
}); });
$propFind->handle(self::IS_ENCRYPTED_PROPERTYNAME, function() use ($node) { $propFind->handle(self::IS_ENCRYPTED_PROPERTYNAME, function() use ($node) {
$result = $node->getFileInfo()->isEncrypted() ? '1' : '0'; return $node->getFileInfo()->isEncrypted() ? '1' : '0';
return $result;
}); });
$propFind->handle(self::HAS_PREVIEW_PROPERTYNAME, function () use ($node) { $propFind->handle(self::HAS_PREVIEW_PROPERTYNAME, function () use ($node) {

View File

@ -196,8 +196,7 @@ class Util {
* @return \OC\Files\Storage\Storage * @return \OC\Files\Storage\Storage
*/ */
public function getStorage($path) { public function getStorage($path) {
$storage = $this->files->getMount($path)->getStorage(); return $this->files->getMount($path)->getStorage();
return $storage;
} }
} }

View File

@ -84,8 +84,7 @@ class AddressHandler {
* @return string url of the current server * @return string url of the current server
*/ */
public function generateRemoteURL() { public function generateRemoteURL() {
$url = $this->urlGenerator->getAbsoluteURL('/'); return $this->urlGenerator->getAbsoluteURL('/');
return $url;
} }
/** /**

View File

@ -370,8 +370,7 @@ class Share extends AbstractShare {
protected function execute($command) { protected function execute($command) {
$this->connect(); $this->connect();
$this->connection->write($command . PHP_EOL); $this->connection->write($command . PHP_EOL);
$output = $this->connection->read(); return $this->connection->read();
return $output;
} }
/** /**

View File

@ -112,8 +112,7 @@ class UserStoragesService extends StoragesService {
*/ */
public function addStorage(StorageConfig $newStorage) { public function addStorage(StorageConfig $newStorage) {
$newStorage->setApplicableUsers([$this->getUser()->getUID()]); $newStorage->setApplicableUsers([$this->getUser()->getUID()]);
$config = parent::addStorage($newStorage); return parent::addStorage($newStorage);
return $config;
} }
/** /**

View File

@ -230,9 +230,7 @@ class ShareesAPIController extends OCSController {
$url = $this->urlGenerator->getAbsoluteURL('/ocs/v1.php/apps/files_sharing/api/v1/sharees') . '?'; $url = $this->urlGenerator->getAbsoluteURL('/ocs/v1.php/apps/files_sharing/api/v1/sharees') . '?';
} }
$params['page'] = $page + 1; $params['page'] = $page + 1;
$link = '<' . $url . http_build_query($params) . '>; rel="next"'; return '<' . $url . http_build_query($params) . '>; rel="next"';
return $link;
} }
/** /**

View File

@ -73,9 +73,7 @@ class Folder extends File implements \OCP\Share_Backend_Collection {
$query = \OCP\DB::prepare('SELECT `parent` FROM `*PREFIX*filecache` WHERE `fileid` = ?'); $query = \OCP\DB::prepare('SELECT `parent` FROM `*PREFIX*filecache` WHERE `fileid` = ?');
$result = $query->execute(array($child)); $result = $query->execute(array($child));
$row = $result->fetchRow(); $row = $result->fetchRow();
$parent = $row ? $row['parent'] : null; return $row ? $row['parent'] : null;
return $parent;
} }
public function getChildren($itemSource) { public function getChildren($itemSource) {

View File

@ -254,8 +254,7 @@ class Storage extends Wrapper {
* @return MoveToTrashEvent * @return MoveToTrashEvent
*/ */
protected function createMoveToTrashEvent(Node $node) { protected function createMoveToTrashEvent(Node $node) {
$event = new MoveToTrashEvent($node); return new MoveToTrashEvent($node);
return $event;
} }
/** /**

View File

@ -90,8 +90,7 @@ class BackupCodesProvider implements IProvider {
* @return Template * @return Template
*/ */
public function getTemplate(IUser $user) { public function getTemplate(IUser $user) {
$tmpl = new Template('twofactor_backupcodes', 'challenge'); return new Template('twofactor_backupcodes', 'challenge');
return $tmpl;
} }
/** /**

View File

@ -123,8 +123,7 @@ class Helper {
sort($serverConnections); sort($serverConnections);
$lastKey = array_pop($serverConnections); $lastKey = array_pop($serverConnections);
$lastNumber = intval(str_replace('s', '', $lastKey)); $lastNumber = intval(str_replace('s', '', $lastKey));
$nextPrefix = 's' . str_pad($lastNumber + 1, 2, '0', STR_PAD_LEFT); return 's' . str_pad($lastNumber + 1, 2, '0', STR_PAD_LEFT);
return $nextPrefix;
} }
private function getServersConfig($value) { private function getServersConfig($value) {

View File

@ -113,8 +113,7 @@ class Import extends Command implements CompletionAwareInterface {
* @return string * @return string
*/ */
protected function getArrayFromFile($importFile) { protected function getArrayFromFile($importFile) {
$content = file_get_contents($importFile); return file_get_contents($importFile);
return $content;
} }
/** /**

View File

@ -94,7 +94,6 @@ class Platform {
public function getLibraryVersion($name) { public function getLibraryVersion($name) {
$repo = new PlatformRepository(); $repo = new PlatformRepository();
$lib = $repo->findLibrary($name); return $repo->findLibrary($name);
return $lib;
} }
} }

View File

@ -426,8 +426,7 @@ class View {
flush(); flush();
} }
fclose($handle); fclose($handle);
$size = $this->filesize($path); return $this->filesize($path);
return $size;
} }
return false; return false;
} }
@ -476,8 +475,7 @@ class View {
echo fread($handle, $len); echo fread($handle, $len);
flush(); flush();
} }
$size = ftell($handle) - $from; return ftell($handle) - $from;
return $size;
} }
throw new \OCP\Files\UnseekableException('fseek error'); throw new \OCP\Files\UnseekableException('fseek error');
@ -1083,8 +1081,7 @@ class View {
} }
list($storage, $internalPath) = Filesystem::resolvePath($absolutePath . $postFix); list($storage, $internalPath) = Filesystem::resolvePath($absolutePath . $postFix);
if ($storage) { if ($storage) {
$result = $storage->hash($type, $internalPath, $raw); return $storage->hash($type, $internalPath, $raw);
return $result;
} }
} }
return null; return null;

View File

@ -249,9 +249,7 @@ class CertificateManager implements ICertificateManager {
if ($uid === '') { if ($uid === '') {
$uid = $this->uid; $uid = $this->uid;
} }
$path = is_null($uid) ? '/files_external/' : '/' . $uid . '/files_external/'; return is_null($uid) ? '/files_external/' : '/' . $uid . '/files_external/';
return $path;
} }
/** /**

View File

@ -243,9 +243,7 @@ class Server extends ServerContainer implements IServerContainer {
$this->registerService('SystemTagManagerFactory', function (Server $c) { $this->registerService('SystemTagManagerFactory', function (Server $c) {
$config = $c->getConfig(); $config = $c->getConfig();
$factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory');
/** @var \OC\SystemTag\ManagerFactory $factory */ return new $factoryClass($this);
$factory = new $factoryClass($this);
return $factory;
}); });
$this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) {
return $c->query('SystemTagManagerFactory')->getManager(); return $c->query('SystemTagManagerFactory')->getManager();

View File

@ -170,8 +170,7 @@ class OC_DB {
*/ */
public static function createDbFromStructure( $file ) { public static function createDbFromStructure( $file ) {
$schemaManager = self::getMDB2SchemaManager(); $schemaManager = self::getMDB2SchemaManager();
$result = $schemaManager->createDbFromStructure($file); return $schemaManager->createDbFromStructure($file);
return $result;
} }
/** /**

View File

@ -77,8 +77,7 @@ class OC_DB_StatementWrapper {
return false; return false;
} }
if ($this->isManipulation) { if ($this->isManipulation) {
$count = $this->statement->rowCount(); return $this->statement->rowCount();
return $count;
} else { } else {
return $this; return $this;
} }

View File

@ -723,9 +723,7 @@ class UsersController extends Controller {
protected function signMessage(IUser $user, $message) { protected function signMessage(IUser $user, $message) {
$privateKey = $this->keyManager->getKey($user)->getPrivate(); $privateKey = $this->keyManager->getKey($user)->getPrivate();
openssl_sign(json_encode($message), $signature, $privateKey, OPENSSL_ALGO_SHA512); openssl_sign(json_encode($message), $signature, $privateKey, OPENSSL_ALGO_SHA512);
$signatureBase64 = base64_encode($signature); return base64_encode($signature);
return $signatureBase64;
} }
/** /**