require php5.6+

This commit is contained in:
Robin Appelman 2018-03-09 14:54:36 +01:00
commit 0cbfd0872d
5 changed files with 47 additions and 37 deletions

View file

@ -2,8 +2,6 @@ dist: trusty
sudo: required
language: php
php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1

View file

@ -9,7 +9,7 @@
}
],
"require" : {
"php": ">=5.4",
"php": ">=5.6",
"icewind/streams": ">=0.2.0"
},
"require-dev": {

View file

@ -7,7 +7,19 @@
namespace Icewind\SMB;
use Icewind\SMB\Exception\AlreadyExistsException;
use Icewind\SMB\Exception\ConnectionRefusedException;
use Icewind\SMB\Exception\Exception;
use Icewind\SMB\Exception\FileInUseException;
use Icewind\SMB\Exception\ForbiddenException;
use Icewind\SMB\Exception\HostDownException;
use Icewind\SMB\Exception\InvalidArgumentException;
use Icewind\SMB\Exception\InvalidTypeException;
use Icewind\SMB\Exception\NoRouteToHostException;
use Icewind\SMB\Exception\NotEmptyException;
use Icewind\SMB\Exception\NotFoundException;
use Icewind\SMB\Exception\OutOfSpaceException;
use Icewind\SMB\Exception\TimedOutException;
/**
* Low level wrapper for libsmbclient-php with error handling
@ -22,23 +34,22 @@ class NativeState {
protected $connected = false;
// todo replace with static once <5.6 support is dropped
// see error.h
private static $exceptionMap = [
1 => '\Icewind\SMB\Exception\ForbiddenException',
2 => '\Icewind\SMB\Exception\NotFoundException',
13 => '\Icewind\SMB\Exception\ForbiddenException',
16 => '\Icewind\SMB\Exception\FileInUseException',
17 => '\Icewind\SMB\Exception\AlreadyExistsException',
20 => '\Icewind\SMB\Exception\InvalidTypeException',
21 => '\Icewind\SMB\Exception\InvalidTypeException',
22 => '\Icewind\SMB\Exception\InvalidArgumentException',
28 => '\Icewind\SMB\Exception\OutOfSpaceException',
39 => '\Icewind\SMB\Exception\NotEmptyException',
110 => '\Icewind\SMB\Exception\TimedOutException',
111 => '\Icewind\SMB\Exception\ConnectionRefusedException',
112 => '\Icewind\SMB\Exception\HostDownException',
113 => '\Icewind\SMB\Exception\NoRouteToHostException'
const EXCEPTION_MAP = [
1 => ForbiddenException::class,
2 => NotFoundException::class,
13 => ForbiddenException::class,
16 => FileInUseException::class,
17 => AlreadyExistsException::class,
20 => InvalidTypeException::class,
21 => InvalidTypeException::class,
22 => InvalidArgumentException::class,
28 => OutOfSpaceException::class,
39 => NotEmptyException::class,
110 => TimedOutException::class,
111 => ConnectionRefusedException::class,
112 => HostDownException::class,
113 => NoRouteToHostException::class
];
protected function handleError($path) {
@ -46,7 +57,7 @@ class NativeState {
if ($error === 0) {
return;
}
throw Exception::fromMap(self::$exceptionMap, $error, $path);
throw Exception::fromMap(self::EXCEPTION_MAP, $error, $path);
}
protected function testResult($result, $uri) {

View file

@ -10,6 +10,7 @@ namespace Icewind\SMB;
use Icewind\SMB\Exception\Exception;
use Icewind\SMB\Exception\RevisionMismatchException;
class NotifyHandler implements INotifyHandler {
/**
@ -24,10 +25,9 @@ class NotifyHandler implements INotifyHandler {
private $listening = true;
// todo replace with static once <5.6 support is dropped
// see error.h
private static $exceptionMap = [
ErrorCodes::RevisionMismatch => '\Icewind\SMB\Exception\RevisionMismatchException',
const EXCEPTION_MAP = [
ErrorCodes::RevisionMismatch => RevisionMismatchException::class,
];
/**
@ -93,7 +93,7 @@ class NotifyHandler implements INotifyHandler {
private function checkForError($line) {
if (substr($line, 0, 16) === 'notify returned ') {
$error = substr($line, 16);
throw Exception::fromMap(self::$exceptionMap, $error, 'Notify is not supported with the used smb version');
throw Exception::fromMap(array_merge(self::EXCEPTION_MAP, Parser::EXCEPTION_MAP), $error, 'Notify is not supported with the used smb version');
}
}

View file

@ -13,6 +13,7 @@ use Icewind\SMB\Exception\AuthenticationException;
use Icewind\SMB\Exception\Exception;
use Icewind\SMB\Exception\FileInUseException;
use Icewind\SMB\Exception\InvalidHostException;
use Icewind\SMB\Exception\InvalidParameterException;
use Icewind\SMB\Exception\InvalidResourceException;
use Icewind\SMB\Exception\InvalidTypeException;
use Icewind\SMB\Exception\NoLoginServerException;
@ -29,18 +30,18 @@ class Parser {
// todo replace with static once <5.6 support is dropped
// see error.h
private static $exceptionMap = [
ErrorCodes::LogonFailure => '\Icewind\SMB\Exception\AuthenticationException',
ErrorCodes::PathNotFound => '\Icewind\SMB\Exception\NotFoundException',
ErrorCodes::ObjectNotFound => '\Icewind\SMB\Exception\NotFoundException',
ErrorCodes::NoSuchFile => '\Icewind\SMB\Exception\NotFoundException',
ErrorCodes::NameCollision => '\Icewind\SMB\Exception\AlreadyExistsException',
ErrorCodes::AccessDenied => '\Icewind\SMB\Exception\AccessDeniedException',
ErrorCodes::DirectoryNotEmpty => '\Icewind\SMB\Exception\NotEmptyException',
ErrorCodes::FileIsADirectory => '\Icewind\SMB\Exception\InvalidTypeException',
ErrorCodes::NotADirectory => '\Icewind\SMB\Exception\InvalidTypeException',
ErrorCodes::SharingViolation => '\Icewind\SMB\Exception\FileInUseException',
ErrorCodes::InvalidParameter => '\Icewind\SMB\Exception\InvalidParameterException'
const EXCEPTION_MAP = [
ErrorCodes::LogonFailure => AuthenticationException::class,
ErrorCodes::PathNotFound => NotFoundException::class,
ErrorCodes::ObjectNotFound => NotFoundException::class,
ErrorCodes::NoSuchFile => NotFoundException::class,
ErrorCodes::NameCollision => AlreadyExistsException::class,
ErrorCodes::AccessDenied => AccessDeniedException::class,
ErrorCodes::DirectoryNotEmpty => NotEmptyException::class,
ErrorCodes::FileIsADirectory => InvalidTypeException::class,
ErrorCodes::NotADirectory => InvalidTypeException::class,
ErrorCodes::SharingViolation => FileInUseException::class,
ErrorCodes::InvalidParameter => InvalidParameterException::class
];
/**
@ -71,7 +72,7 @@ class Parser {
throw new InvalidResourceException('Failed opening local file "' . $localPath . '" for writing');
}
throw Exception::fromMap(self::$exceptionMap, $error, $path);
throw Exception::fromMap(self::EXCEPTION_MAP, $error, $path);
}
/**