Completed
Pull Request — master (#9290)
by Robin
40:28 queued 11:52
created
lib/private/Files/Stream/Encryption.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -196,9 +196,9 @@  discard block
 block discarded – undo
196 196
 		try {
197 197
 			stream_wrapper_register($protocol, $class);
198 198
 			if (self::isDirectoryHandle($source)) {
199
-				$wrapped = opendir($protocol . '://', $context);
199
+				$wrapped = opendir($protocol.'://', $context);
200 200
 			} else {
201
-				$wrapped = fopen($protocol . '://', $mode, false, $context);
201
+				$wrapped = fopen($protocol.'://', $mode, false, $context);
202 202
 			}
203 203
 		} catch (\BadMethodCallException $e) {
204 204
 			stream_wrapper_unregister($protocol);
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 			if (array_key_exists($property, $context)) {
223 223
 				$this->{$property} = $context[$property];
224 224
 			} else {
225
-				throw new \BadMethodCallException('Invalid context, "' . $property . '" options not set');
225
+				throw new \BadMethodCallException('Invalid context, "'.$property.'" options not set');
226 226
 			}
227 227
 		}
228 228
 		return $context;
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 
325 325
 			// for seekable streams the pointer is moved back to the beginning of the encrypted block
326 326
 			// flush will start writing there when the position moves to another block
327
-			$positionInFile = (int)floor($this->position / $this->unencryptedBlockSize) *
327
+			$positionInFile = (int) floor($this->position / $this->unencryptedBlockSize) *
328 328
 				$this->util->getBlockSize() + $this->headerSize;
329 329
 			$resultFseek = $this->parentStreamSeek($positionInFile);
330 330
 
@@ -341,14 +341,14 @@  discard block
 block discarded – undo
341 341
 				// update position and liberate $data
342 342
 				if ($remainingLength < ($this->unencryptedBlockSize - $blockPosition)) {
343 343
 					$this->cache = substr($this->cache, 0, $blockPosition)
344
-						. $data . substr($this->cache, $blockPosition + $remainingLength);
344
+						. $data.substr($this->cache, $blockPosition + $remainingLength);
345 345
 					$this->position += $remainingLength;
346 346
 					$length += $remainingLength;
347 347
 					$data = '';
348 348
 					// if $data doesn't fit the current block, the fill the current block and reiterate
349 349
 					// after the block is filled, it is flushed and $data is updatedxxx
350 350
 				} else {
351
-					$this->cache = substr($this->cache, 0, $blockPosition) .
351
+					$this->cache = substr($this->cache, 0, $blockPosition).
352 352
 						substr($data, 0, $this->unencryptedBlockSize - $blockPosition);
353 353
 					$this->flush();
354 354
 					$this->position += ($this->unencryptedBlockSize - $blockPosition);
@@ -406,10 +406,10 @@  discard block
 block discarded – undo
406 406
 
407 407
 	public function stream_close() {
408 408
 		$this->flush('end');
409
-		$position = (int)floor($this->position/$this->unencryptedBlockSize);
410
-		$remainingData = $this->encryptionModule->end($this->fullPath, $position . 'end');
409
+		$position = (int) floor($this->position / $this->unencryptedBlockSize);
410
+		$remainingData = $this->encryptionModule->end($this->fullPath, $position.'end');
411 411
 		if ($this->readOnly === false) {
412
-			if(!empty($remainingData)) {
412
+			if (!empty($remainingData)) {
413 413
 				parent::stream_write($remainingData);
414 414
 			}
415 415
 			$this->encryptionStorage->updateUnencryptedSize($this->fullPath, $this->unencryptedSize);
@@ -428,16 +428,16 @@  discard block
 block discarded – undo
428 428
 			// automatically attempted when the file is written to disk -
429 429
 			// we are handling that separately here and we don't want to
430 430
 			// get into an infinite loop
431
-			$position = (int)floor($this->position/$this->unencryptedBlockSize);
432
-			$encrypted = $this->encryptionModule->encrypt($this->cache, $position . $positionPrefix);
431
+			$position = (int) floor($this->position / $this->unencryptedBlockSize);
432
+			$encrypted = $this->encryptionModule->encrypt($this->cache, $position.$positionPrefix);
433 433
 			$bytesWritten = parent::stream_write($encrypted);
434 434
 			$this->writeFlag = false;
435 435
 			// Check whether the write concerns the last block
436 436
 			// If so then update the encrypted filesize
437 437
 			// Note that the unencrypted pointer and filesize are NOT yet updated when flush() is called
438 438
 			// We recalculate the encrypted filesize as we do not know the context of calling flush()
439
-			$completeBlocksInFile=(int)floor($this->unencryptedSize/$this->unencryptedBlockSize);
440
-			if ($completeBlocksInFile === (int)floor($this->position/$this->unencryptedBlockSize)) {
439
+			$completeBlocksInFile = (int) floor($this->unencryptedSize / $this->unencryptedBlockSize);
440
+			if ($completeBlocksInFile === (int) floor($this->position / $this->unencryptedBlockSize)) {
441 441
 				$this->size = $this->util->getBlockSize() * $completeBlocksInFile;
442 442
 				$this->size += $bytesWritten;
443 443
 				$this->size += $this->headerSize;
@@ -456,9 +456,9 @@  discard block
 block discarded – undo
456 456
 		if ($this->cache === '' && !($this->position === $this->unencryptedSize && ($this->position % $this->unencryptedBlockSize) === 0)) {
457 457
 			// Get the data from the file handle
458 458
 			$data = parent::stream_read($this->util->getBlockSize());
459
-			$position = (int)floor($this->position/$this->unencryptedBlockSize);
460
-			$numberOfChunks = (int)($this->unencryptedSize / $this->unencryptedBlockSize);
461
-			if($numberOfChunks === $position) {
459
+			$position = (int) floor($this->position / $this->unencryptedBlockSize);
460
+			$numberOfChunks = (int) ($this->unencryptedSize / $this->unencryptedBlockSize);
461
+			if ($numberOfChunks === $position) {
462 462
 				$position .= 'end';
463 463
 			}
464 464
 			$this->cache = $this->encryptionModule->decrypt($data, $position);
Please login to merge, or discard this patch.