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
7a74710aaa
commit
b69c20d21a
12 changed files with 25 additions and 19 deletions
2
.github/workflows/ci.yaml
vendored
2
.github/workflows/ci.yaml
vendored
|
|
@ -33,7 +33,7 @@ jobs:
|
||||||
run: composer install
|
run: composer install
|
||||||
- env:
|
- env:
|
||||||
BACKEND: smbclient
|
BACKEND: smbclient
|
||||||
run: php ./vendor/bin/phpstan analyse --level 2 src
|
run: php ./vendor/bin/phpstan analyse --level 5 src
|
||||||
|
|
||||||
phpunit:
|
phpunit:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ abstract class AbstractServer implements IServer {
|
||||||
protected $system;
|
protected $system;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var TimeZoneProvider
|
* @var ITimeZoneProvider
|
||||||
*/
|
*/
|
||||||
protected $timezoneProvider;
|
protected $timezoneProvider;
|
||||||
|
|
||||||
|
|
@ -51,10 +51,10 @@ abstract class AbstractServer implements IServer {
|
||||||
* @param string $host
|
* @param string $host
|
||||||
* @param IAuth $auth
|
* @param IAuth $auth
|
||||||
* @param ISystem $system
|
* @param ISystem $system
|
||||||
* @param TimeZoneProvider $timeZoneProvider
|
* @param ITimeZoneProvider $timeZoneProvider
|
||||||
* @param IOptions $options
|
* @param IOptions $options
|
||||||
*/
|
*/
|
||||||
public function __construct($host, IAuth $auth, ISystem $system, TimeZoneProvider $timeZoneProvider, IOptions $options) {
|
public function __construct($host, IAuth $auth, ISystem $system, ITimeZoneProvider $timeZoneProvider, IOptions $options) {
|
||||||
$this->host = $host;
|
$this->host = $host;
|
||||||
$this->auth = $auth;
|
$this->auth = $auth;
|
||||||
$this->system = $system;
|
$this->system = $system;
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ class Change {
|
||||||
private $code;
|
private $code;
|
||||||
private $path;
|
private $path;
|
||||||
|
|
||||||
public function __construct(string $code, int $path) {
|
public function __construct(int $code, string $path) {
|
||||||
$this->code = $code;
|
$this->code = $code;
|
||||||
$this->path = $path;
|
$this->path = $path;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ class NativeFileInfo implements IFileInfo {
|
||||||
|
|
||||||
// Let us ignore the ATTR_NOT_CONTENT_INDEXED for now
|
// Let us ignore the ATTR_NOT_CONTENT_INDEXED for now
|
||||||
$mode &= ~0x00002000;
|
$mode &= ~0x00002000;
|
||||||
|
|
||||||
return $mode;
|
return $mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -188,7 +188,7 @@ class NativeFileInfo implements IFileInfo {
|
||||||
list($type, $flags, $mask) = explode('/', $permissions);
|
list($type, $flags, $mask) = explode('/', $permissions);
|
||||||
$mask = hexdec($mask);
|
$mask = hexdec($mask);
|
||||||
|
|
||||||
$acls[$user] = new ACL($type, $flags, $mask);
|
$acls[$user] = new ACL((int)$type, (int)$flags, (int)$mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $acls;
|
return $acls;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ use Icewind\SMB\AbstractServer;
|
||||||
use Icewind\SMB\IAuth;
|
use Icewind\SMB\IAuth;
|
||||||
use Icewind\SMB\IOptions;
|
use Icewind\SMB\IOptions;
|
||||||
use Icewind\SMB\ISystem;
|
use Icewind\SMB\ISystem;
|
||||||
use Icewind\SMB\TimeZoneProvider;
|
use Icewind\SMB\ITimeZoneProvider;
|
||||||
|
|
||||||
class NativeServer extends AbstractServer {
|
class NativeServer extends AbstractServer {
|
||||||
/**
|
/**
|
||||||
|
|
@ -19,7 +19,7 @@ class NativeServer extends AbstractServer {
|
||||||
*/
|
*/
|
||||||
protected $state;
|
protected $state;
|
||||||
|
|
||||||
public function __construct($host, IAuth $auth, ISystem $system, TimeZoneProvider $timeZoneProvider, IOptions $options) {
|
public function __construct($host, IAuth $auth, ISystem $system, ITimeZoneProvider $timeZoneProvider, IOptions $options) {
|
||||||
parent::__construct($host, $auth, $system, $timeZoneProvider, $options);
|
parent::__construct($host, $auth, $system, $timeZoneProvider, $options);
|
||||||
$this->state = new NativeState();
|
$this->state = new NativeState();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ class NativeShare extends AbstractShare {
|
||||||
private $name;
|
private $name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var NativeState $state
|
* @var ?NativeState $state
|
||||||
*/
|
*/
|
||||||
private $state;
|
private $state;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ class ServerFactory {
|
||||||
Server::class
|
Server::class
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var System */
|
/** @var ISystem */
|
||||||
private $system;
|
private $system;
|
||||||
|
|
||||||
/** @var IOptions */
|
/** @var IOptions */
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,9 @@ class Connection extends RawConnection {
|
||||||
$this->write('');
|
$this->write('');
|
||||||
do {
|
do {
|
||||||
$promptLine = $this->readLine();
|
$promptLine = $this->readLine();
|
||||||
|
if ($promptLine === false) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
$this->parser->checkConnectionError($promptLine);
|
$this->parser->checkConnectionError($promptLine);
|
||||||
} while (!$this->isPrompt($promptLine));
|
} while (!$this->isPrompt($promptLine));
|
||||||
if ($this->write('') === false) {
|
if ($this->write('') === false) {
|
||||||
|
|
@ -66,6 +69,9 @@ class Connection extends RawConnection {
|
||||||
throw new ConnectionException('Connection not valid');
|
throw new ConnectionException('Connection not valid');
|
||||||
}
|
}
|
||||||
$promptLine = $this->readLine(); //first line is prompt
|
$promptLine = $this->readLine(); //first line is prompt
|
||||||
|
if ($promptLine === false) {
|
||||||
|
$this->unknownError($promptLine);
|
||||||
|
}
|
||||||
$this->parser->checkConnectionError($promptLine);
|
$this->parser->checkConnectionError($promptLine);
|
||||||
|
|
||||||
$output = [];
|
$output = [];
|
||||||
|
|
@ -77,7 +83,7 @@ class Connection extends RawConnection {
|
||||||
if ($line === false) {
|
if ($line === false) {
|
||||||
$this->unknownError($promptLine);
|
$this->unknownError($promptLine);
|
||||||
}
|
}
|
||||||
while (!$this->isPrompt($line)) { //next prompt functions as delimiter
|
while ($line !== false && !$this->isPrompt($line)) { //next prompt functions as delimiter
|
||||||
if (is_callable($callback)) {
|
if (is_callable($callback)) {
|
||||||
$result = $callback($line);
|
$result = $callback($line);
|
||||||
if ($result === false) { // allow the callback to close the connection for infinite running commands
|
if ($result === false) { // allow the callback to close the connection for infinite running commands
|
||||||
|
|
@ -99,11 +105,11 @@ class Connection extends RawConnection {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function isPrompt(string $line) {
|
private function isPrompt(string $line) {
|
||||||
return mb_substr($line, 0, self::DELIMITER_LENGTH) === self::DELIMITER || $line === false;
|
return mb_substr($line, 0, self::DELIMITER_LENGTH) === self::DELIMITER;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $promptLine (optional) prompt line that might contain some info about the error
|
* @param string|bool $promptLine (optional) prompt line that might contain some info about the error
|
||||||
* @throws ConnectException
|
* @throws ConnectException
|
||||||
*/
|
*/
|
||||||
private function unknownError($promptLine = '') {
|
private function unknownError($promptLine = '') {
|
||||||
|
|
|
||||||
|
|
@ -49,13 +49,13 @@ class NotifyHandler implements INotifyHandler {
|
||||||
if (!$this->listening) {
|
if (!$this->listening) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
stream_set_blocking($this->connection->getOutputStream(), 0);
|
stream_set_blocking($this->connection->getOutputStream(), false);
|
||||||
$lines = [];
|
$lines = [];
|
||||||
while (($line = $this->connection->readLine())) {
|
while (($line = $this->connection->readLine())) {
|
||||||
$this->checkForError($line);
|
$this->checkForError($line);
|
||||||
$lines[] = $line;
|
$lines[] = $line;
|
||||||
}
|
}
|
||||||
stream_set_blocking($this->connection->getOutputStream(), 1);
|
stream_set_blocking($this->connection->getOutputStream(), true);
|
||||||
return array_values(array_filter(array_map([$this, 'parseChangeLine'], $lines)));
|
return array_values(array_filter(array_map([$this, 'parseChangeLine'], $lines)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ class Parser {
|
||||||
/**
|
/**
|
||||||
* @param string $timeZone
|
* @param string $timeZone
|
||||||
*/
|
*/
|
||||||
public function __construct($timeZone) {
|
public function __construct(string $timeZone) {
|
||||||
$this->timeZone = $timeZone;
|
$this->timeZone = $timeZone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ class RawConnection {
|
||||||
private $pipes;
|
private $pipes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var resource $process
|
* @var resource|null $process
|
||||||
*/
|
*/
|
||||||
private $process;
|
private $process;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ class Server extends AbstractServer {
|
||||||
throw new ConnectionException($connection->readLine());
|
throw new ConnectionException($connection->readLine());
|
||||||
}
|
}
|
||||||
|
|
||||||
$parser = new Parser($this->timezoneProvider);
|
$parser = new Parser($this->timezoneProvider->get($this->host));
|
||||||
|
|
||||||
$output = $connection->readAll();
|
$output = $connection->readAll();
|
||||||
if (isset($output[0])) {
|
if (isset($output[0])) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue