type fixes

This commit is contained in:
Robin Appelman 2021-03-09 18:10:27 +01:00
commit 7cb4e41f8a
7 changed files with 32 additions and 7 deletions

View file

@ -15,7 +15,8 @@
"require-dev": {
"phpunit/phpunit": "^8.5|^9.3.8",
"friendsofphp/php-cs-fixer": "^2.16",
"phpstan/phpstan": "^0.12.57"
"phpstan/phpstan": "^0.12.57",
"psalm/phar": "^4.3"
},
"autoload" : {
"psr-4": {

15
psalm.xml Normal file
View file

@ -0,0 +1,15 @@
<?xml version="1.0"?>
<psalm
errorLevel="4"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>

View file

@ -316,8 +316,12 @@ class NativeShare extends AbstractShare {
* @return mixed the attribute value
*/
public function setAttribute(string $path, string $attribute, $value) {
if ($attribute === 'system.dos_attr.mode' and is_int($value)) {
$value = '0x' . dechex($value);
if (is_int($value)) {
if ($attribute === 'system.dos_attr.mode') {
$value = '0x' . dechex($value);
} else {
throw new \InvalidArgumentException("Invalid value for attribute");
}
}
return $this->getState()->setxattr($this->buildUrl($path), $attribute, $value);

View file

@ -247,7 +247,7 @@ class NativeState {
* @param int $offset
* @param int $whence SEEK_SET | SEEK_CUR | SEEK_END
* @param string|null $path
* @return int|bool new file offset as measured from the start of the file on success, false on failure.
* @return int new file offset as measured from the start of the file on success.
*/
public function lseek($file, int $offset, int $whence = SEEK_SET, string $path = null) {
$result = @smbclient_lseek($this->state, $file, $offset, $whence);

View file

@ -165,7 +165,7 @@ class Parser {
$mode = $this->parseMode($mode);
$time = strtotime($time . ' ' . $this->timeZone);
$path = $basePath . '/' . $name;
$content[] = new FileInfo($path, $name, $size, $time, $mode, function () use ($aclCallback, $path) {
$content[] = new FileInfo($path, $name, (int)$size, $time, $mode, function () use ($aclCallback, $path) {
return $aclCallback($path);
});
}

View file

@ -85,7 +85,7 @@ class RawConnection {
public function isValid(): bool {
if (is_resource($this->process)) {
$status = proc_get_status($this->process);
return $status['running'];
return (bool)$status['running'];
} else {
return false;
}

View file

@ -355,9 +355,14 @@ class Share extends AbstractShare {
// use a close callback to ensure the upload is finished before continuing
// this also serves as a way to keep the connection in scope
return CallbackWrapper::wrap($fh, null, null, function () use ($connection) {
$stream = CallbackWrapper::wrap($fh, null, null, function () use ($connection) {
$connection->close(false); // dont terminate, give the upload some time
});
if (is_resource($stream)) {
return $stream;
} else {
throw new InvalidRequestException($target);
}
}
/**