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
|
|
@ -40,7 +40,7 @@ abstract class AbstractServer implements IServer {
|
|||
protected $system;
|
||||
|
||||
/**
|
||||
* @var TimeZoneProvider
|
||||
* @var ITimeZoneProvider
|
||||
*/
|
||||
protected $timezoneProvider;
|
||||
|
||||
|
|
@ -51,10 +51,10 @@ abstract class AbstractServer implements IServer {
|
|||
* @param string $host
|
||||
* @param IAuth $auth
|
||||
* @param ISystem $system
|
||||
* @param TimeZoneProvider $timeZoneProvider
|
||||
* @param ITimeZoneProvider $timeZoneProvider
|
||||
* @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->auth = $auth;
|
||||
$this->system = $system;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class Change {
|
|||
private $code;
|
||||
private $path;
|
||||
|
||||
public function __construct(string $code, int $path) {
|
||||
public function __construct(int $code, string $path) {
|
||||
$this->code = $code;
|
||||
$this->path = $path;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ class NativeFileInfo implements IFileInfo {
|
|||
|
||||
// Let us ignore the ATTR_NOT_CONTENT_INDEXED for now
|
||||
$mode &= ~0x00002000;
|
||||
|
||||
|
||||
return $mode;
|
||||
}
|
||||
|
||||
|
|
@ -188,7 +188,7 @@ class NativeFileInfo implements IFileInfo {
|
|||
list($type, $flags, $mask) = explode('/', $permissions);
|
||||
$mask = hexdec($mask);
|
||||
|
||||
$acls[$user] = new ACL($type, $flags, $mask);
|
||||
$acls[$user] = new ACL((int)$type, (int)$flags, (int)$mask);
|
||||
}
|
||||
|
||||
return $acls;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use Icewind\SMB\AbstractServer;
|
|||
use Icewind\SMB\IAuth;
|
||||
use Icewind\SMB\IOptions;
|
||||
use Icewind\SMB\ISystem;
|
||||
use Icewind\SMB\TimeZoneProvider;
|
||||
use Icewind\SMB\ITimeZoneProvider;
|
||||
|
||||
class NativeServer extends AbstractServer {
|
||||
/**
|
||||
|
|
@ -19,7 +19,7 @@ class NativeServer extends AbstractServer {
|
|||
*/
|
||||
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);
|
||||
$this->state = new NativeState();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class NativeShare extends AbstractShare {
|
|||
private $name;
|
||||
|
||||
/**
|
||||
* @var NativeState $state
|
||||
* @var ?NativeState $state
|
||||
*/
|
||||
private $state;
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class ServerFactory {
|
|||
Server::class
|
||||
];
|
||||
|
||||
/** @var System */
|
||||
/** @var ISystem */
|
||||
private $system;
|
||||
|
||||
/** @var IOptions */
|
||||
|
|
|
|||
|
|
@ -42,6 +42,9 @@ class Connection extends RawConnection {
|
|||
$this->write('');
|
||||
do {
|
||||
$promptLine = $this->readLine();
|
||||
if ($promptLine === false) {
|
||||
break;
|
||||
}
|
||||
$this->parser->checkConnectionError($promptLine);
|
||||
} while (!$this->isPrompt($promptLine));
|
||||
if ($this->write('') === false) {
|
||||
|
|
@ -66,6 +69,9 @@ class Connection extends RawConnection {
|
|||
throw new ConnectionException('Connection not valid');
|
||||
}
|
||||
$promptLine = $this->readLine(); //first line is prompt
|
||||
if ($promptLine === false) {
|
||||
$this->unknownError($promptLine);
|
||||
}
|
||||
$this->parser->checkConnectionError($promptLine);
|
||||
|
||||
$output = [];
|
||||
|
|
@ -77,7 +83,7 @@ class Connection extends RawConnection {
|
|||
if ($line === false) {
|
||||
$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)) {
|
||||
$result = $callback($line);
|
||||
if ($result === false) { // allow the callback to close the connection for infinite running commands
|
||||
|
|
@ -99,11 +105,11 @@ class Connection extends RawConnection {
|
|||
* @return bool
|
||||
*/
|
||||
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
|
||||
*/
|
||||
private function unknownError($promptLine = '') {
|
||||
|
|
|
|||
|
|
@ -49,13 +49,13 @@ class NotifyHandler implements INotifyHandler {
|
|||
if (!$this->listening) {
|
||||
return [];
|
||||
}
|
||||
stream_set_blocking($this->connection->getOutputStream(), 0);
|
||||
stream_set_blocking($this->connection->getOutputStream(), false);
|
||||
$lines = [];
|
||||
while (($line = $this->connection->readLine())) {
|
||||
$this->checkForError($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)));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class Parser {
|
|||
/**
|
||||
* @param string $timeZone
|
||||
*/
|
||||
public function __construct($timeZone) {
|
||||
public function __construct(string $timeZone) {
|
||||
$this->timeZone = $timeZone;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class RawConnection {
|
|||
private $pipes;
|
||||
|
||||
/**
|
||||
* @var resource $process
|
||||
* @var resource|null $process
|
||||
*/
|
||||
private $process;
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class Server extends AbstractServer {
|
|||
throw new ConnectionException($connection->readLine());
|
||||
}
|
||||
|
||||
$parser = new Parser($this->timezoneProvider);
|
||||
$parser = new Parser($this->timezoneProvider->get($this->host));
|
||||
|
||||
$output = $connection->readAll();
|
||||
if (isset($output[0])) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue