run php-cs-fixer

This commit is contained in:
Robin Appelman 2018-08-24 17:51:32 +02:00
commit 2842dffb51
41 changed files with 151 additions and 141 deletions

View file

@ -21,7 +21,6 @@
namespace Icewind\SMB;
abstract class AbstractServer implements IServer {
const LOCALE = 'en_US.UTF-8';

View file

@ -13,7 +13,7 @@ abstract class AbstractShare implements IShare {
private $forbiddenCharacters;
public function __construct() {
$this->forbiddenCharacters = array('?', '<', '>', ':', '*', '|', '"', chr(0), "\n", "\r");
$this->forbiddenCharacters = ['?', '<', '>', ':', '*', '|', '"', chr(0), "\n", "\r"];
}
protected function verifyPath($path) {

View file

@ -21,7 +21,6 @@
namespace Icewind\SMB;
class AnonymousAuth implements IAuth {
public function getUsername() {
return null;

View file

@ -21,7 +21,6 @@
namespace Icewind\SMB;
class BasicAuth implements IAuth {
/** @var string */
private $username;
@ -62,5 +61,4 @@ class BasicAuth implements IAuth {
public function setExtraSmbClientOptions($smbClientState) {
// noop
}
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception;
class AccessDeniedException extends ConnectException {}
class AccessDeniedException extends ConnectException {
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception;
class AlreadyExistsException extends InvalidRequestException {}
class AlreadyExistsException extends InvalidRequestException {
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception;
class AuthenticationException extends ConnectException{}
class AuthenticationException extends ConnectException {
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception;
class ConnectException extends Exception {}
class ConnectException extends Exception {
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception;
class ConnectionException extends ConnectException {}
class ConnectionException extends ConnectException {
}

View file

@ -8,7 +8,7 @@
namespace Icewind\SMB\Exception;
class Exception extends \Exception {
static public function unknown($path, $error) {
public static function unknown($path, $error) {
$message = 'Unknown error (' . $error . ')';
if ($path) {
$message .= ' for ' . $path;
@ -23,7 +23,7 @@ class Exception extends \Exception {
* @param string $path
* @return Exception
*/
static public function fromMap(array $exceptionMap, $error, $path) {
public static function fromMap(array $exceptionMap, $error, $path) {
if (isset($exceptionMap[$error])) {
$exceptionClass = $exceptionMap[$error];
if (is_numeric($error)) {

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception;
class FileInUseException extends InvalidRequestException {}
class FileInUseException extends InvalidRequestException {
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception;
class ForbiddenException extends InvalidRequestException {}
class ForbiddenException extends InvalidRequestException {
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception;
class InvalidArgumentException extends InvalidRequestException {}
class InvalidArgumentException extends InvalidRequestException {
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception;
class InvalidHostException extends ConnectException {}
class InvalidHostException extends ConnectException {
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception;
class InvalidParameterException extends InvalidRequestException {}
class InvalidParameterException extends InvalidRequestException {
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception;
class InvalidPathException extends InvalidRequestException {}
class InvalidPathException extends InvalidRequestException {
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception;
class InvalidTypeException extends InvalidRequestException {}
class InvalidTypeException extends InvalidRequestException {
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception;
class NoLoginServerException extends ConnectException {}
class NoLoginServerException extends ConnectException {
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception;
class NotEmptyException extends InvalidRequestException {}
class NotEmptyException extends InvalidRequestException {
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception;
class NotFoundException extends InvalidRequestException {}
class NotFoundException extends InvalidRequestException {
}

View file

@ -8,7 +8,6 @@
namespace Icewind\SMB;
interface INotifyHandler {
// https://msdn.microsoft.com/en-us/library/dn392331.aspx
const NOTIFY_ADDED = 1;

View file

@ -45,5 +45,4 @@ class KerberosAuth implements IAuth {
smbclient_option_set($smbClientState, SMBCLIENT_OPT_USE_KERBEROS, true);
smbclient_option_set($smbClientState, SMBCLIENT_OPT_FALLBACK_AFTER_KERBEROS, false);
}
}

View file

@ -25,7 +25,6 @@ class NativeReadStream extends NativeStream {
$this->readBuffer = fopen('php://memory', 'r+');
return parent::stream_open($path, $mode, $options, $opened_path);
}
/**
@ -39,13 +38,13 @@ class NativeReadStream extends NativeStream {
*/
public static function wrap($state, $smbStream, $mode, $url) {
stream_wrapper_register('nativesmb', NativeReadStream::class);
$context = stream_context_create(array(
'nativesmb' => array(
$context = stream_context_create([
'nativesmb' => [
'state' => $state,
'handle' => $smbStream,
'url' => $url
)
));
]
]);
$fh = fopen('nativesmb://', $mode, false, $context);
stream_wrapper_unregister('nativesmb');
return $fh;

View file

@ -35,7 +35,7 @@ class NativeServer extends AbstractServer {
*/
public function listShares() {
$this->connect();
$shares = array();
$shares = [];
$dh = $this->state->opendir('smb://' . $this->getHost());
while ($share = $this->state->readdir($dh)) {
if ($share['type'] === 'file share') {

View file

@ -87,7 +87,7 @@ class NativeShare extends AbstractShare {
* @throws \Icewind\SMB\Exception\InvalidTypeException
*/
public function dir($path) {
$files = array();
$files = [];
$dh = $this->getState()->opendir($this->buildUrl($path));
while ($file = $this->getState()->readdir($dh)) {
@ -277,7 +277,6 @@ class NativeShare extends AbstractShare {
* @return string the attribute value
*/
public function setAttribute($path, $attribute, $value) {
if ($attribute === 'system.dos_attr.mode' and is_int($value)) {
$value = '0x' . dechex($value);
}

View file

@ -48,13 +48,13 @@ class NativeStream implements File {
*/
public static function wrap($state, $smbStream, $mode, $url) {
stream_wrapper_register('nativesmb', NativeStream::class);
$context = stream_context_create(array(
'nativesmb' => array(
$context = stream_context_create([
'nativesmb' => [
'state' => $state,
'handle' => $smbStream,
'url' => $url
)
));
]
]);
$fh = fopen('nativesmb://', $mode, false, $context);
stream_wrapper_unregister('nativesmb');
return $fh;

View file

@ -25,7 +25,6 @@ class NativeWriteStream extends NativeStream {
$this->writeBuffer = fopen('php://memory', 'r+');
return parent::stream_open($path, $mode, $options, $opened_path);
}
/**
@ -39,13 +38,13 @@ class NativeWriteStream extends NativeStream {
*/
public static function wrap($state, $smbStream, $mode, $url) {
stream_wrapper_register('nativesmb', NativeWriteStream::class);
$context = stream_context_create(array(
'nativesmb' => array(
$context = stream_context_create([
'nativesmb' => [
'state' => $state,
'handle' => $smbStream,
'url' => $url
)
));
]
]);
$fh = fopen('nativesmb://', $mode, false, $context);
stream_wrapper_unregister('nativesmb');
return $fh;

View file

@ -21,7 +21,6 @@
namespace Icewind\SMB;
class Options implements IOptions {
/** @var int */
private $timeout = 20;

View file

@ -21,7 +21,6 @@
namespace Icewind\SMB;
use Icewind\SMB\Exception\DependencyException;
use Icewind\SMB\Native\NativeServer;
use Icewind\SMB\Wrapped\Server;

View file

@ -52,7 +52,7 @@ class System implements ISystem {
protected function getBinaryPath($binary) {
if (!isset($this->paths[$binary])) {
$result = null;
$output = array();
$output = [];
exec("which $binary 2>&1", $output, $result);
$this->paths[$binary] = $result === 0 ? trim(implode('', $output)) : false;
}

View file

@ -30,7 +30,8 @@ class TimeZoneProvider implements ITimeZoneProvider {
$net = $this->system->getNetPath();
// for local domain names we can assume same timezone
if ($net && $host && strpos($host, '.') !== false) {
$command = sprintf('%s time zone -S %s',
$command = sprintf(
'%s time zone -S %s',
$net,
escapeshellarg($host)
);

View file

@ -20,7 +20,7 @@ class Connection extends RawConnection {
/** @var Parser */
private $parser;
public function __construct($command, Parser $parser, $env = array()) {
public function __construct($command, Parser $parser, $env = []) {
parent::__construct($command, $env);
$this->parser = $parser;
}
@ -65,7 +65,7 @@ class Connection extends RawConnection {
$promptLine = $this->readLine(); //first line is prompt
$this->parser->checkConnectionError($promptLine);
$output = array();
$output = [];
$line = $this->readLine();
if ($line === false) {
$this->unknownError($promptLine);

View file

@ -8,7 +8,6 @@
namespace Icewind\SMB\Wrapped;
use Icewind\SMB\Change;
use Icewind\SMB\Exception\Exception;
use Icewind\SMB\Exception\RevisionMismatchException;

View file

@ -141,7 +141,7 @@ class Parser {
$value = trim($value);
if (!isset($data[$name])) {
$data[$name] = $value;
$data[$name] = $value;
}
}
return [
@ -156,7 +156,7 @@ class Parser {
array_pop($output);
$regex = '/^\s*(.*?)\s\s\s\s+(?:([NDHARS]*)\s+)?([0-9]+)\s+(.*)$/';
//2 spaces, filename, optional type, size, date
$content = array();
$content = [];
foreach ($output as $line) {
if (preg_match($regex, $line, $matches)) {
list(, $name, $mode, $size, $time) = $matches;
@ -171,14 +171,14 @@ class Parser {
}
public function parseListShares($output) {
$shareNames = array();
$shareNames = [];
foreach ($output as $line) {
if (strpos($line, '|')) {
list($type, $name, $description) = explode('|', $line);
if (strtolower($type) === 'disk') {
$shareNames[$name] = $description;
}
} else if (strpos($line, 'Disk')) {
} elseif (strpos($line, 'Disk')) {
// new output format
list($name, $description) = explode('Disk', $line);
$shareNames[trim($name)] = trim($description);

View file

@ -42,7 +42,8 @@ class Server extends AbstractServer {
* @throws ConnectException
*/
public function listShares() {
$command = sprintf('%s %s %s -L %s',
$command = sprintf(
'%s %s %s -L %s',
$this->system->getSmbclientPath(),
$this->getAuthFileArgument(),
$this->getAuth()->getExtraCommandLineArguments(),
@ -73,7 +74,7 @@ class Server extends AbstractServer {
$shareNames = $parser->parseListShares($output);
$shares = array();
$shares = [];
foreach ($shareNames as $name => $description) {
$shares[] = $this->getShare($name);
}

View file

@ -74,7 +74,8 @@ class Share extends AbstractShare {
}
protected function getConnection() {
$command = sprintf('%s%s -t %s %s %s %s',
$command = sprintf(
'%s%s -t %s %s %s %s',
$this->system->getStdBufPath() ? $this->system->getStdBufPath() . ' -o0 ' : '',
$this->system->getSmbclientPath(),
$this->server->getOptions()->getTimeout(),
@ -159,7 +160,7 @@ class Share extends AbstractShare {
if ($path !== "" && $path !== "/") {
$parent = dirname($path);
$dir = $this->dir($parent);
$file = array_values(array_filter($dir, function(IFileInfo $info) use ($path) {
$file = array_values(array_filter($dir, function (IFileInfo $info) use ($path) {
return $info->getPath() === $path;
}));
if ($file) {