mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 17:24:07 +02:00
type fixes
This commit is contained in:
parent
e9f6d00a93
commit
7cb4e41f8a
7 changed files with 32 additions and 7 deletions
|
|
@ -15,7 +15,8 @@
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^8.5|^9.3.8",
|
"phpunit/phpunit": "^8.5|^9.3.8",
|
||||||
"friendsofphp/php-cs-fixer": "^2.16",
|
"friendsofphp/php-cs-fixer": "^2.16",
|
||||||
"phpstan/phpstan": "^0.12.57"
|
"phpstan/phpstan": "^0.12.57",
|
||||||
|
"psalm/phar": "^4.3"
|
||||||
},
|
},
|
||||||
"autoload" : {
|
"autoload" : {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
|
|
||||||
15
psalm.xml
Normal file
15
psalm.xml
Normal 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>
|
||||||
|
|
@ -316,8 +316,12 @@ class NativeShare extends AbstractShare {
|
||||||
* @return mixed the attribute value
|
* @return mixed the attribute value
|
||||||
*/
|
*/
|
||||||
public function setAttribute(string $path, string $attribute, $value) {
|
public function setAttribute(string $path, string $attribute, $value) {
|
||||||
if ($attribute === 'system.dos_attr.mode' and is_int($value)) {
|
if (is_int($value)) {
|
||||||
|
if ($attribute === 'system.dos_attr.mode') {
|
||||||
$value = '0x' . dechex($value);
|
$value = '0x' . dechex($value);
|
||||||
|
} else {
|
||||||
|
throw new \InvalidArgumentException("Invalid value for attribute");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getState()->setxattr($this->buildUrl($path), $attribute, $value);
|
return $this->getState()->setxattr($this->buildUrl($path), $attribute, $value);
|
||||||
|
|
|
||||||
|
|
@ -247,7 +247,7 @@ class NativeState {
|
||||||
* @param int $offset
|
* @param int $offset
|
||||||
* @param int $whence SEEK_SET | SEEK_CUR | SEEK_END
|
* @param int $whence SEEK_SET | SEEK_CUR | SEEK_END
|
||||||
* @param string|null $path
|
* @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) {
|
public function lseek($file, int $offset, int $whence = SEEK_SET, string $path = null) {
|
||||||
$result = @smbclient_lseek($this->state, $file, $offset, $whence);
|
$result = @smbclient_lseek($this->state, $file, $offset, $whence);
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,7 @@ class Parser {
|
||||||
$mode = $this->parseMode($mode);
|
$mode = $this->parseMode($mode);
|
||||||
$time = strtotime($time . ' ' . $this->timeZone);
|
$time = strtotime($time . ' ' . $this->timeZone);
|
||||||
$path = $basePath . '/' . $name;
|
$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);
|
return $aclCallback($path);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ class RawConnection {
|
||||||
public function isValid(): bool {
|
public function isValid(): bool {
|
||||||
if (is_resource($this->process)) {
|
if (is_resource($this->process)) {
|
||||||
$status = proc_get_status($this->process);
|
$status = proc_get_status($this->process);
|
||||||
return $status['running'];
|
return (bool)$status['running'];
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -355,9 +355,14 @@ class Share extends AbstractShare {
|
||||||
|
|
||||||
// use a close callback to ensure the upload is finished before continuing
|
// use a close callback to ensure the upload is finished before continuing
|
||||||
// this also serves as a way to keep the connection in scope
|
// 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
|
$connection->close(false); // dont terminate, give the upload some time
|
||||||
});
|
});
|
||||||
|
if (is_resource($stream)) {
|
||||||
|
return $stream;
|
||||||
|
} else {
|
||||||
|
throw new InvalidRequestException($target);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue