From caff1023ea72bb2ea94130e18a2a6e2ccf819e5f Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Fri, 10 Apr 2020 14:19:56 +0200 Subject: Format control structures, classes, methods and function To continue this formatting madness, here's a tiny patch that adds unified formatting for control structures like if and loops as well as classes, their methods and anonymous functions. This basically forces the constructs to start on the same line. This is not exactly what PSR2 wants, but I think we can have a few exceptions with "our" style. The starting of braces on the same line is pracrically standard for our code. This also removes and empty lines from method/function bodies at the beginning and end. Signed-off-by: Christoph Wurst --- lib/private/Files/Stream/Encryption.php | 16 ++++------------ lib/private/Files/Stream/Quota.php | 7 +++---- 2 files changed, 7 insertions(+), 16 deletions(-) (limited to 'lib/private/Files/Stream') diff --git a/lib/private/Files/Stream/Encryption.php b/lib/private/Files/Stream/Encryption.php index 527453c32e9..1fc14daacbd 100644 --- a/lib/private/Files/Stream/Encryption.php +++ b/lib/private/Files/Stream/Encryption.php @@ -165,7 +165,6 @@ class Encryption extends Wrapper { $headerSize, $signed, $wrapper = Encryption::class) { - $context = stream_context_create([ 'ocencryption' => [ 'source' => $source, @@ -233,7 +232,6 @@ class Encryption extends Wrapper { } } return $context; - } public function stream_open($path, $mode, $options, &$opened_path) { @@ -285,7 +283,6 @@ class Encryption extends Wrapper { } return true; - } public function stream_eof() { @@ -293,7 +290,6 @@ class Encryption extends Wrapper { } public function stream_read($count) { - $result = ''; $count = min($count, $this->unencryptedSize - $this->position); @@ -308,7 +304,7 @@ class Encryption extends Wrapper { $result .= substr($this->cache, $blockPosition, $remainingLength); $this->position += $remainingLength; $count = 0; - // otherwise remainder of current block is fetched, the block is flushed and the position updated + // otherwise remainder of current block is fetched, the block is flushed and the position updated } else { $result .= substr($this->cache, $blockPosition); $this->flush(); @@ -317,7 +313,6 @@ class Encryption extends Wrapper { } } return $result; - } /** @@ -378,7 +373,7 @@ class Encryption extends Wrapper { $this->position += $remainingLength; $length += $remainingLength; $data = ''; - // if $data doesn't fit the current block, the fill the current block and reiterate + // if $data doesn't fit the current block, the fill the current block and reiterate // after the block is filled, it is flushed and $data is updatedxxx } else { $this->cache = substr($this->cache, 0, $blockPosition) . @@ -401,7 +396,6 @@ class Encryption extends Wrapper { } public function stream_seek($offset, $whence = SEEK_SET) { - $return = false; switch ($whence) { @@ -434,7 +428,6 @@ class Encryption extends Wrapper { $return = true; } return $return; - } public function stream_close() { @@ -442,7 +435,7 @@ class Encryption extends Wrapper { $position = (int)floor($this->position/$this->unencryptedBlockSize); $remainingData = $this->encryptionModule->end($this->fullPath, $position . 'end'); if ($this->readOnly === false) { - if(!empty($remainingData)) { + if (!empty($remainingData)) { parent::stream_write($remainingData); } $this->encryptionStorage->updateUnencryptedSize($this->fullPath, $this->unencryptedSize); @@ -502,7 +495,7 @@ class Encryption extends Wrapper { $data = $this->stream_read_block($this->util->getBlockSize()); $position = (int)floor($this->position/$this->unencryptedBlockSize); $numberOfChunks = (int)($this->unencryptedSize / $this->unencryptedBlockSize); - if($numberOfChunks === $position) { + if ($numberOfChunks === $position) { $position .= 'end'; } $this->cache = $this->encryptionModule->decrypt($data, $position); @@ -545,5 +538,4 @@ class Encryption extends Wrapper { public function dir_opendir($path, $options) { return false; } - } diff --git a/lib/private/Files/Stream/Quota.php b/lib/private/Files/Stream/Quota.php index 877a05e6aa9..d0609d7e459 100644 --- a/lib/private/Files/Stream/Quota.php +++ b/lib/private/Files/Stream/Quota.php @@ -67,17 +67,16 @@ class Quota extends Wrapper { } public function stream_seek($offset, $whence = SEEK_SET) { - if ($whence === SEEK_END){ + if ($whence === SEEK_END) { // go to the end to find out last position's offset $oldOffset = $this->stream_tell(); - if (fseek($this->source, 0, $whence) !== 0){ + if (fseek($this->source, 0, $whence) !== 0) { return false; } $whence = SEEK_SET; $offset = $this->stream_tell() + $offset; $this->limit += $oldOffset - $offset; - } - elseif ($whence === SEEK_SET) { + } elseif ($whence === SEEK_SET) { $this->limit += $this->stream_tell() - $offset; } else { $this->limit -= $offset; -- cgit v1.2.3