Skip to content

Commit

Permalink
Merge pull request #48 from bushbaby/deprated-php71
Browse files Browse the repository at this point in the history
Deprated php71
  • Loading branch information
basz authored May 18, 2019
2 parents 60e3a5c + 5176f5f commit 64d77fe
Show file tree
Hide file tree
Showing 54 changed files with 776 additions and 370 deletions.
8 changes: 0 additions & 8 deletions .scrutinizer.yml

This file was deleted.

6 changes: 0 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ language: php
matrix:
fast_finish: true
include:
- php: 7.1
env:
- DEPENDENCIES=""
- php: 7.1
env:
- DEPENDENCIES="--prefer-lowest --prefer-stable"
- php: 7.2
env:
- DEPENDENCIES=""
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ I have tried to provide factories (and tests) for each of the adapters that come
- Aws3S (v3 only)
- Dropbox
- Ftp
- Ftpd
- GoogleCloudDrive
- Local
- BsbFlysystem is preconfigured with an adapter named 'local_data' to expose the ./data directory of a ZF2 application.
- Null
Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
}
],
"require": {
"php": "^7.1",
"php": "^7.2",
"league/flysystem": "^1.0.41",
"psr/container": "^1.0",
"zendframework/zend-cache": "^2.7",
"zendframework/zend-stdlib": "^2.2 || ^3.0"
},
Expand All @@ -37,6 +38,7 @@
"php-coveralls/php-coveralls": "^2.1",
"phpunit/phpunit": "^7.0",
"spatie/flysystem-dropbox": "~1.0",
"superbalist/flysystem-google-storage": "^7.2",
"zendframework/zend-code": "^3.3.1",
"zendframework/zend-config": "^2.2 || ^3.0",
"zendframework/zend-filter": "^2.9.1",
Expand Down
13 changes: 9 additions & 4 deletions config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@

declare(strict_types=1);

use BsbFlysystem\Service\AdapterManager;
use BsbFlysystem\Service\Factory\AdapterManagerFactory;
use BsbFlysystem\Service\Factory\FilesystemManagerFactory;
use BsbFlysystem\Service\FilesystemManager;

return [
'bsb_flysystem' => [
'adapters' => [
Expand Down Expand Up @@ -56,12 +61,12 @@
],
'service_manager' => [
'aliases' => [
'BsbFlysystemManager' => \BsbFlysystem\Service\FilesystemManager::class,
'BsbFlysystemAdapterManager' => \BsbFlysystem\Service\AdapterManager::class,
'BsbFlysystemManager' => FilesystemManager::class,
'BsbFlysystemAdapterManager' => AdapterManager::class,
],
'factories' => [
\BsbFlysystem\Service\AdapterManager::class => \BsbFlysystem\Service\Factory\AdapterManagerFactory::class,
\BsbFlysystem\Service\FilesystemManager::class => \BsbFlysystem\Service\Factory\FilesystemManagerFactory::class,
AdapterManager::class => AdapterManagerFactory::class,
FilesystemManager::class => FilesystemManagerFactory::class,
],
],
];
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<logging>
<log type="coverage-clover" target="./test/_build/logs/clover.xml"/>
<log type="coverage-html" target="./test/_build/coverage" charset="UTF-8" yui="true" highlight="true" lowUpperBound="90" highLowerBound="100"/>
<log type="coverage-html" target="./test/_build/coverage" lowUpperBound="90" highLowerBound="100"/>
</logging>

</phpunit>
8 changes: 4 additions & 4 deletions src/Adapter/Factory/AbstractAdapterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct(array $options = [])
/**
* Set creation options.
*/
public function setCreationOptions(array $options)
public function setCreationOptions(array $options): void
{
$this->options = $options;
}
Expand Down Expand Up @@ -79,7 +79,7 @@ public function createService(ContainerInterface $container): AdapterInterface
/**
* Merges the options given from the ServiceLocator Config object with the create options of the class.
*/
protected function mergeMvcConfig(ContainerInterface $container, string $requestedName = null)
protected function mergeMvcConfig(ContainerInterface $container, string $requestedName = null): void
{
$config = $container->has('config') ? $container->get('config') : [];

Expand Down Expand Up @@ -108,7 +108,7 @@ public function getLazyFactory(ContainerInterface $container): LazyLoadingValueH
);

if (! isset($config['lazy_services'])) {
throw new \InvalidArgumentException('Missing "lazy_services" config key');
throw new InvalidArgumentException('Missing "lazy_services" config key');
}

$lazyServices = $config['lazy_services'];
Expand Down Expand Up @@ -142,5 +142,5 @@ abstract protected function doCreateService(ContainerInterface $container): Adap
*
* @throw UnexpectedValueException
*/
abstract protected function validateConfig();
abstract protected function validateConfig(): void;
}
8 changes: 3 additions & 5 deletions src/Adapter/Factory/AwsS3v3AdapterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AwsS3v3AdapterFactory extends AbstractAdapterFactory
{
public function doCreateService(ContainerInterface $container): AdapterInterface
{
if (! \class_exists(\League\Flysystem\AwsS3v3\AwsS3Adapter::class)) {
if (! \class_exists(Adapter::class)) {
throw new RequirementsException(
['league/flysystem-aws-s3-v3'],
'AwsS3v3'
Expand Down Expand Up @@ -63,12 +63,10 @@ public function doCreateService(ContainerInterface $container): AdapterInterface

$client = new S3Client($config);

$adapter = new Adapter($client, $this->options['bucket'], $this->options['prefix'], $adapterOptions);

return $adapter;
return new Adapter($client, $this->options['bucket'], $this->options['prefix'], $adapterOptions);
}

protected function validateConfig()
protected function validateConfig(): void
{
if (! isset($this->options['iam']) || (isset($this->options['iam']) && (false === $this->options['iam']))) {
if (! isset($this->options['credentials']) || ! \is_array($this->options['credentials'])) {
Expand Down
9 changes: 4 additions & 5 deletions src/Adapter/Factory/AzureAdapterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
use BsbFlysystem\Exception\UnexpectedValueException;
use League\Flysystem\AdapterInterface;
use League\Flysystem\Azure\AzureAdapter as Adapter;
use MicrosoftAzure\Storage\Common\ServicesBuilder;
use Psr\Container\ContainerInterface;
use WindowsAzure\Common\ServicesBuilder;

class AzureAdapterFactory extends AbstractAdapterFactory
{
public function doCreateService(ContainerInterface $container): AdapterInterface
{
if (! \class_exists(\League\Flysystem\Azure\AzureAdapter::class)) {
if (! \class_exists(Adapter::class)) {
throw new RequirementsException(
['league/flysystem-azure'],
'Azure'
Expand All @@ -43,12 +43,11 @@ public function doCreateService(ContainerInterface $container): AdapterInterface
);

$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($endpoint);
$adapter = new Adapter($blobRestProxy, $this->options['container']);

return $adapter;
return new Adapter($blobRestProxy, $this->options['container']);
}

protected function validateConfig()
protected function validateConfig(): void
{
if (! isset($this->options['account-name'])) {
throw new UnexpectedValueException("Missing 'account-name' as option");
Expand Down
11 changes: 5 additions & 6 deletions src/Adapter/Factory/DropboxAdapterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,28 @@
use BsbFlysystem\Exception\UnexpectedValueException;
use League\Flysystem\AdapterInterface;
use Psr\Container\ContainerInterface;
use Spatie\Dropbox\Client;
use Spatie\FlysystemDropbox\DropboxAdapter as Adapter;

class DropboxAdapterFactory extends AbstractAdapterFactory
{
public function doCreateService(ContainerInterface $container): AdapterInterface
{
if (! \class_exists(\Spatie\FlysystemDropbox\DropboxAdapter::class)) {
if (! \class_exists(Adapter::class)) {
throw new RequirementsException(
['spatie/flysystem-dropbox'],
'Dropbox'
);
}

$client = new \Spatie\Dropbox\Client(
$client = new Client(
$this->options['access_token']
);

$adapter = new Adapter($client, $this->options['prefix']);

return $adapter;
return new Adapter($client, $this->options['prefix']);
}

protected function validateConfig()
protected function validateConfig(): void
{
if (! isset($this->options['access_token'])) {
throw new UnexpectedValueException("Missing 'access_token' as option");
Expand Down
6 changes: 2 additions & 4 deletions src/Adapter/Factory/FtpAdapterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@ class FtpAdapterFactory extends AbstractAdapterFactory
{
public function doCreateService(ContainerInterface $container): AdapterInterface
{
$adapter = new Adapter($this->options);

return $adapter;
return new Adapter($this->options);
}

protected function validateConfig()
protected function validateConfig(): void
{
if (! isset($this->options['host'])) {
throw new UnexpectedValueException("Missing 'host' as option");
Expand Down
52 changes: 52 additions & 0 deletions src/Adapter/Factory/FtpdAdapterFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

/**
* BsbFlystem
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @see https://bushbaby.nl/
*
* @copyright Copyright (c) 2014-2019 bushbaby multimedia. (https://bushbaby.nl)
* @author Bas Kamer <[email protected]>
* @license MIT
*
* @package bushbaby/flysystem
*/

declare(strict_types=1);

namespace BsbFlysystem\Adapter\Factory;

use BsbFlysystem\Exception\UnexpectedValueException;
use League\Flysystem\Adapter\Ftpd as Adapter;
use League\Flysystem\AdapterInterface;
use Psr\Container\ContainerInterface;

class FtpdAdapterFactory extends AbstractAdapterFactory
{
public function doCreateService(ContainerInterface $container): AdapterInterface
{
return new Adapter($this->options);
}

protected function validateConfig(): void
{
if (! isset($this->options['host'])) {
throw new UnexpectedValueException("Missing 'host' as option");
}

if (! isset($this->options['port'])) {
throw new UnexpectedValueException("Missing 'port' as option");
}

if (! isset($this->options['username'])) {
throw new UnexpectedValueException("Missing 'username' as option");
}

if (! isset($this->options['password'])) {
throw new UnexpectedValueException("Missing 'password' as option");
}
}
}
59 changes: 59 additions & 0 deletions src/Adapter/Factory/GoogleCloudDriveAdapterFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

/**
* BsbFlystem
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @see https://bushbaby.nl/
*
* @copyright Copyright (c) 2014-2019 bushbaby multimedia. (https://bushbaby.nl)
* @author Bas Kamer <[email protected]>
* @license MIT
*
* @package bushbaby/flysystem
*/

declare(strict_types=1);

namespace BsbFlysystem\Adapter\Factory;

use BsbFlysystem\Exception\RequirementsException;
use BsbFlysystem\Exception\UnexpectedValueException;
use Google\Cloud\Storage\StorageClient;
use League\Flysystem\AdapterInterface;
use Psr\Container\ContainerInterface;
use Superbalist\Flysystem\GoogleStorage\GoogleStorageAdapter as Adapter;

class GoogleCloudDriveAdapterFactory extends AbstractAdapterFactory
{
public function doCreateService(ContainerInterface $container): AdapterInterface
{
if (! \class_exists(Adapter::class)) {
throw new RequirementsException(
['superbalist/flysystem-google-storage'],
'GoogleCloudDrive'
);
}

$storageClient = new StorageClient([
'projectId' => $this->options['project_id'],
]);

$bucket = $storageClient->bucket($this->options['bucket']);

return new Adapter($storageClient, $bucket);
}

protected function validateConfig(): void
{
if (! isset($this->options['project_id'])) {
throw new UnexpectedValueException("Missing 'project_id' as option");
}

if (! isset($this->options['bucket'])) {
throw new UnexpectedValueException("Missing 'bucket' as option");
}
}
}
16 changes: 13 additions & 3 deletions src/Adapter/Factory/LocalAdapterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,22 @@ class LocalAdapterFactory extends AbstractAdapterFactory
{
public function doCreateService(ContainerInterface $container): AdapterInterface
{
$adapter = new Adapter($this->options['root']);
$options = [];
$options[] = $this->options['root'];
$options[] = $this->options['writeFlags'] ?? null;

return $adapter;
if (isset($this->options['linkHandling'])) { // since 1.0.8
$options[] = $this->options['linkHandling'];

if (isset($this->options['permissions'])) { // since 1.0.14
$options[] = $this->options['permissions'];
}
}

return new Adapter(...$options);
}

protected function validateConfig()
protected function validateConfig(): void
{
if (! isset($this->options['root'])) {
throw new UnexpectedValueException("Missing 'root' as option");
Expand Down
Loading

0 comments on commit 64d77fe

Please sign in to comment.