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 sudo: required
language: php language: php
php: php:
- 5.4
- 5.5
- 5.6 - 5.6
- 7.0 - 7.0
- 7.1 - 7.1

View file

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

View file

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

View file

@ -10,6 +10,7 @@ namespace Icewind\SMB;
use Icewind\SMB\Exception\Exception; use Icewind\SMB\Exception\Exception;
use Icewind\SMB\Exception\RevisionMismatchException;
class NotifyHandler implements INotifyHandler { class NotifyHandler implements INotifyHandler {
/** /**
@ -24,10 +25,9 @@ class NotifyHandler implements INotifyHandler {
private $listening = true; private $listening = true;
// todo replace with static once <5.6 support is dropped
// see error.h // see error.h
private static $exceptionMap = [ const EXCEPTION_MAP = [
ErrorCodes::RevisionMismatch => '\Icewind\SMB\Exception\RevisionMismatchException', ErrorCodes::RevisionMismatch => RevisionMismatchException::class,
]; ];
/** /**
@ -93,7 +93,7 @@ class NotifyHandler implements INotifyHandler {
private function checkForError($line) { private function checkForError($line) {
if (substr($line, 0, 16) === 'notify returned ') { if (substr($line, 0, 16) === 'notify returned ') {
$error = substr($line, 16); $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\Exception;
use Icewind\SMB\Exception\FileInUseException; use Icewind\SMB\Exception\FileInUseException;
use Icewind\SMB\Exception\InvalidHostException; use Icewind\SMB\Exception\InvalidHostException;
use Icewind\SMB\Exception\InvalidParameterException;
use Icewind\SMB\Exception\InvalidResourceException; use Icewind\SMB\Exception\InvalidResourceException;
use Icewind\SMB\Exception\InvalidTypeException; use Icewind\SMB\Exception\InvalidTypeException;
use Icewind\SMB\Exception\NoLoginServerException; use Icewind\SMB\Exception\NoLoginServerException;
@ -29,18 +30,18 @@ class Parser {
// todo replace with static once <5.6 support is dropped // todo replace with static once <5.6 support is dropped
// see error.h // see error.h
private static $exceptionMap = [ const EXCEPTION_MAP = [
ErrorCodes::LogonFailure => '\Icewind\SMB\Exception\AuthenticationException', ErrorCodes::LogonFailure => AuthenticationException::class,
ErrorCodes::PathNotFound => '\Icewind\SMB\Exception\NotFoundException', ErrorCodes::PathNotFound => NotFoundException::class,
ErrorCodes::ObjectNotFound => '\Icewind\SMB\Exception\NotFoundException', ErrorCodes::ObjectNotFound => NotFoundException::class,
ErrorCodes::NoSuchFile => '\Icewind\SMB\Exception\NotFoundException', ErrorCodes::NoSuchFile => NotFoundException::class,
ErrorCodes::NameCollision => '\Icewind\SMB\Exception\AlreadyExistsException', ErrorCodes::NameCollision => AlreadyExistsException::class,
ErrorCodes::AccessDenied => '\Icewind\SMB\Exception\AccessDeniedException', ErrorCodes::AccessDenied => AccessDeniedException::class,
ErrorCodes::DirectoryNotEmpty => '\Icewind\SMB\Exception\NotEmptyException', ErrorCodes::DirectoryNotEmpty => NotEmptyException::class,
ErrorCodes::FileIsADirectory => '\Icewind\SMB\Exception\InvalidTypeException', ErrorCodes::FileIsADirectory => InvalidTypeException::class,
ErrorCodes::NotADirectory => '\Icewind\SMB\Exception\InvalidTypeException', ErrorCodes::NotADirectory => InvalidTypeException::class,
ErrorCodes::SharingViolation => '\Icewind\SMB\Exception\FileInUseException', ErrorCodes::SharingViolation => FileInUseException::class,
ErrorCodes::InvalidParameter => '\Icewind\SMB\Exception\InvalidParameterException' ErrorCodes::InvalidParameter => InvalidParameterException::class
]; ];
/** /**
@ -71,7 +72,7 @@ class Parser {
throw new InvalidResourceException('Failed opening local file "' . $localPath . '" for writing'); 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);
} }
/** /**