aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2023-01-23 15:03:56 +0100
committerCôme Chilliet <come.chilliet@nextcloud.com>2023-02-07 11:23:31 +0100
commitcd885b57057b506169faf8ac455f5b1fba811bbf (patch)
treeb7993a9756bed4c697b24d6070d043b3c1cffed1 /lib
parent5c1a0e0307408b9f9031b40beaadaa9f45732c84 (diff)
downloadnextcloud-server-cd885b57057b506169faf8ac455f5b1fba811bbf.tar.gz
nextcloud-server-cd885b57057b506169faf8ac455f5b1fba811bbf.zip
Type sizes as int|float throughout the code base
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/Node/LazyFolder.php2
-rw-r--r--lib/private/Files/Node/Node.php4
-rw-r--r--lib/private/Files/Node/NonExistingFile.php2
-rw-r--r--lib/private/Files/Node/NonExistingFolder.php2
-rw-r--r--lib/private/Files/Node/Root.php4
-rw-r--r--lib/private/Files/SimpleFS/NewSimpleFile.php2
-rw-r--r--lib/private/Files/SimpleFS/SimpleFile.php2
-rw-r--r--lib/private/Streamer.php12
-rw-r--r--lib/private/legacy/OC_Files.php15
-rw-r--r--lib/public/Files/Node.php2
-rw-r--r--lib/public/Files/SimpleFS/ISimpleFile.php2
-rw-r--r--lib/public/Files/SimpleFS/InMemoryFile.php2
12 files changed, 24 insertions, 27 deletions
diff --git a/lib/private/Files/Node/LazyFolder.php b/lib/private/Files/Node/LazyFolder.php
index 1bae0f52e59..cc1f64889a1 100644
--- a/lib/private/Files/Node/LazyFolder.php
+++ b/lib/private/Files/Node/LazyFolder.php
@@ -225,7 +225,7 @@ class LazyFolder implements \OCP\Files\Folder {
/**
* @inheritDoc
*/
- public function getSize($includeMounts = true) {
+ public function getSize($includeMounts = true): int|float {
return $this->__call(__FUNCTION__, func_get_args());
}
diff --git a/lib/private/Files/Node/Node.php b/lib/private/Files/Node/Node.php
index 8a752ff281d..6c4e0b0f908 100644
--- a/lib/private/Files/Node/Node.php
+++ b/lib/private/Files/Node/Node.php
@@ -209,11 +209,11 @@ class Node implements \OCP\Files\Node {
/**
* @param bool $includeMounts
- * @return int
+ * @return int|float
* @throws InvalidPathException
* @throws NotFoundException
*/
- public function getSize($includeMounts = true) {
+ public function getSize($includeMounts = true): int|float {
return $this->getFileInfo()->getSize($includeMounts);
}
diff --git a/lib/private/Files/Node/NonExistingFile.php b/lib/private/Files/Node/NonExistingFile.php
index e1d706006ba..b21a2a6c65b 100644
--- a/lib/private/Files/Node/NonExistingFile.php
+++ b/lib/private/Files/Node/NonExistingFile.php
@@ -65,7 +65,7 @@ class NonExistingFile extends File {
}
}
- public function getSize($includeMounts = true) {
+ public function getSize($includeMounts = true): int|float {
if ($this->fileInfo) {
return parent::getSize($includeMounts);
} else {
diff --git a/lib/private/Files/Node/NonExistingFolder.php b/lib/private/Files/Node/NonExistingFolder.php
index d99446e8ff8..100687c3e6f 100644
--- a/lib/private/Files/Node/NonExistingFolder.php
+++ b/lib/private/Files/Node/NonExistingFolder.php
@@ -66,7 +66,7 @@ class NonExistingFolder extends Folder {
}
}
- public function getSize($includeMounts = true) {
+ public function getSize($includeMounts = true): int|float {
if ($this->fileInfo) {
return parent::getSize($includeMounts);
} else {
diff --git a/lib/private/Files/Node/Root.php b/lib/private/Files/Node/Root.php
index ca930c1002c..8d0a65d2a68 100644
--- a/lib/private/Files/Node/Root.php
+++ b/lib/private/Files/Node/Root.php
@@ -290,9 +290,9 @@ class Root extends Folder implements IRootFolder {
/**
* @param bool $includeMounts
- * @return int
+ * @return int|float
*/
- public function getSize($includeMounts = true) {
+ public function getSize($includeMounts = true): int|float {
return 0;
}
diff --git a/lib/private/Files/SimpleFS/NewSimpleFile.php b/lib/private/Files/SimpleFS/NewSimpleFile.php
index e2d1ae274b1..1d0972bcc54 100644
--- a/lib/private/Files/SimpleFS/NewSimpleFile.php
+++ b/lib/private/Files/SimpleFS/NewSimpleFile.php
@@ -56,7 +56,7 @@ class NewSimpleFile implements ISimpleFile {
/**
* Get the size in bytes
*/
- public function getSize(): int {
+ public function getSize(): int|float {
if ($this->file) {
return $this->file->getSize();
} else {
diff --git a/lib/private/Files/SimpleFS/SimpleFile.php b/lib/private/Files/SimpleFS/SimpleFile.php
index a2571ac50e8..95ef332e2f5 100644
--- a/lib/private/Files/SimpleFS/SimpleFile.php
+++ b/lib/private/Files/SimpleFS/SimpleFile.php
@@ -46,7 +46,7 @@ class SimpleFile implements ISimpleFile {
/**
* Get the size in bytes
*/
- public function getSize(): int {
+ public function getSize(): int|float {
return $this->file->getSize();
}
diff --git a/lib/private/Streamer.php b/lib/private/Streamer.php
index 1375489d360..52f824fedf8 100644
--- a/lib/private/Streamer.php
+++ b/lib/private/Streamer.php
@@ -40,7 +40,7 @@ use ZipStreamer\ZipStreamer;
class Streamer {
// array of regexp. Matching user agents will get tar instead of zip
- private $preferTarFor = [ '/macintosh|mac os x/i' ];
+ private array $preferTarFor = [ '/macintosh|mac os x/i' ];
// streamer instance
private $streamerInstance;
@@ -49,11 +49,11 @@ class Streamer {
* Streamer constructor.
*
* @param IRequest $request
- * @param int $size The size of the files in bytes
+ * @param int|float $size The size of the files in bytes
* @param int $numberOfFiles The number of files (and directories) that will
* be included in the streamed file
*/
- public function __construct(IRequest $request, int $size, int $numberOfFiles) {
+ public function __construct(IRequest $request, int|float $size, int $numberOfFiles) {
/**
* zip32 constraints for a basic (without compression, volumes nor
* encryption) zip file according to the Zip specification:
@@ -149,11 +149,11 @@ class Streamer {
*
* @param resource $stream Stream to read data from
* @param string $internalName Filepath and name to be used in the archive.
- * @param int $size Filesize
- * @param int|bool $time File mtime as int, or false
+ * @param int|float $size Filesize
+ * @param int|false $time File mtime as int, or false
* @return bool $success
*/
- public function addFileFromStream($stream, string $internalName, int $size, $time): bool {
+ public function addFileFromStream($stream, string $internalName, int|float $size, $time): bool {
$options = [];
if ($time) {
$options = [
diff --git a/lib/private/legacy/OC_Files.php b/lib/private/legacy/OC_Files.php
index 6a3a44d6cc0..5655139b24a 100644
--- a/lib/private/legacy/OC_Files.php
+++ b/lib/private/legacy/OC_Files.php
@@ -59,14 +59,11 @@ class OC_Files {
public const UPLOAD_MIN_LIMIT_BYTES = 1048576; // 1 MiB
- private static $multipartBoundary = '';
+ private static string $multipartBoundary = '';
- /**
- * @return string
- */
- private static function getBoundary() {
+ private static function getBoundary(): string {
if (empty(self::$multipartBoundary)) {
- self::$multipartBoundary = md5(mt_rand());
+ self::$multipartBoundary = md5((string)mt_rand());
}
return self::$multipartBoundary;
}
@@ -76,7 +73,7 @@ class OC_Files {
* @param string $name
* @param array $rangeArray ('from'=>int,'to'=>int), ...
*/
- private static function sendHeaders($filename, $name, array $rangeArray) {
+ private static function sendHeaders($filename, $name, array $rangeArray): void {
OC_Response::setContentDispositionHeader($name, 'attachment');
header('Content-Transfer-Encoding: binary', true);
header('Pragma: public');// enable caching in IE
@@ -247,10 +244,10 @@ class OC_Files {
/**
* @param string $rangeHeaderPos
- * @param int $fileSize
+ * @param int|float $fileSize
* @return array $rangeArray ('from'=>int,'to'=>int), ...
*/
- private static function parseHttpRangeHeader($rangeHeaderPos, $fileSize) {
+ private static function parseHttpRangeHeader($rangeHeaderPos, $fileSize): array {
$rArray = explode(',', $rangeHeaderPos);
$minOffset = 0;
$ind = 0;
diff --git a/lib/public/Files/Node.php b/lib/public/Files/Node.php
index b892d8e0a73..b49b4a0f83d 100644
--- a/lib/public/Files/Node.php
+++ b/lib/public/Files/Node.php
@@ -145,7 +145,7 @@ interface Node extends FileInfo {
* Get the size of the file or folder in bytes
*
* @param bool $includeMounts
- * @return int
+ * @return int|float
* @throws InvalidPathException
* @throws NotFoundException
* @since 6.0.0
diff --git a/lib/public/Files/SimpleFS/ISimpleFile.php b/lib/public/Files/SimpleFS/ISimpleFile.php
index 9050fe770b9..e55261497be 100644
--- a/lib/public/Files/SimpleFS/ISimpleFile.php
+++ b/lib/public/Files/SimpleFS/ISimpleFile.php
@@ -49,7 +49,7 @@ interface ISimpleFile {
*
* @since 11.0.0
*/
- public function getSize(): int;
+ public function getSize(): int|float;
/**
* Get the ETag
diff --git a/lib/public/Files/SimpleFS/InMemoryFile.php b/lib/public/Files/SimpleFS/InMemoryFile.php
index 393449d4f1f..ace9bef465a 100644
--- a/lib/public/Files/SimpleFS/InMemoryFile.php
+++ b/lib/public/Files/SimpleFS/InMemoryFile.php
@@ -68,7 +68,7 @@ class InMemoryFile implements ISimpleFile {
* @inheritdoc
* @since 16.0.0
*/
- public function getSize(): int {
+ public function getSize(): int|float {
return strlen($this->contents);
}