phpstan fixes

This commit is contained in:
Robin Appelman 2025-10-25 21:43:15 +02:00
commit 5d37f6813d
10 changed files with 24 additions and 86 deletions

View file

@ -13,7 +13,7 @@ final class AnonymousAuth implements IAuth {
return null;
}
public function getWorkgroup(): ?string {
public function getWorkgroup(): string {
return 'dummy';
}

View file

@ -20,7 +20,7 @@ final class BasicAuth implements IAuth {
$this->password = $password;
}
public function getUsername(): ?string {
public function getUsername(): string {
return $this->username;
}
@ -28,7 +28,7 @@ final class BasicAuth implements IAuth {
return $this->workgroup;
}
public function getPassword(): ?string {
public function getPassword(): string {
return $this->password;
}

View file

@ -40,7 +40,7 @@ class Exception extends \Exception {
if (isset($exceptionMap[$error])) {
$exceptionClass = $exceptionMap[$error];
if (is_numeric($error)) {
return new $exceptionClass($path, $error);
return new $exceptionClass($path, (int)$error);
} else {
return new $exceptionClass($path);
}

View file

@ -78,7 +78,7 @@ final class NativeReadStream extends NativeStream {
return $this->readBuffer->remaining() <= 0 && parent::stream_eof();
}
public function stream_tell() {
public function stream_tell(): int {
return $this->pos;
}

View file

@ -58,7 +58,7 @@ final class NativeWriteStream extends NativeStream {
parent::stream_write($this->writeBuffer->flush());
}
public function stream_write($data) {
public function stream_write($data): int {
$written = $this->writeBuffer->push($data);
$this->pos += $written;
@ -79,7 +79,7 @@ final class NativeWriteStream extends NativeStream {
return parent::stream_close() && $flushResult;
}
public function stream_tell() {
public function stream_tell(): int {
return $this->pos;
}

View file

@ -146,7 +146,7 @@ final class Parser {
// A line = explode statement may not fill all array elements
// properly. May happen when accessing non Windows Fileservers
$words = explode(':', $line, 2);
$name = isset($words[0]) ? $words[0] : '';
$name = $words[0];
$value = isset($words[1]) ? $words[1] : '';
$value = trim($value);
@ -160,7 +160,7 @@ final class Parser {
}
return [
'mtime' => (int)strtotime($data['write_time']),
'mode' => hexdec(substr($data['attributes'], $attributeStart + 1, -1)),
'mode' => (int)hexdec(substr($data['attributes'], $attributeStart + 1, -1)),
'size' => isset($data['stream']) ? (int)(explode(' ', $data['stream'])[1]) : 0
];
}
@ -255,7 +255,7 @@ final class Parser {
}
if (substr($mask, 0, 2) === '0x') {
$maskInt = hexdec($mask);
$maskInt = (int)hexdec($mask);
} else {
$maskInt = 0;
foreach (explode('|', $mask) as $maskString) {