[COMPOSER] Added predis/predis and updated packages

This commit is contained in:
Miguel Dantas
2019-08-13 01:31:05 +01:00
committed by Diogo Peralta Cordeiro
parent 50c98d53c9
commit 19d68c9f8e
641 changed files with 58448 additions and 83 deletions

View File

@@ -0,0 +1,66 @@
# Change Log
## 1.1.1 - 2016-05-10
### Fixed
- Adapter can again be instantiated without a guzzle client.
## 1.1.0 - 2016-05-09
### Added
- Factory method Client::createWithConfig to create an adapter with custom
configuration for the underlying guzzle client.
## 1.0.0 - 2016-01-26
## 0.4.1 - 2016-01-13
### Changed
- Updated integration tests
### Removed
- Client common dependency
## 0.4.0 - 2016-01-12
### Changed
- Updated package files
- Updated HTTPlug to RC1
## 0.2.1 - 2015-12-17
### Added
- Puli configuration and bindings
### Changed
- Guzzle setup conforms to HTTPlug requirement now: Minimal functionality in client
## 0.2.0 - 2015-12-15
### Added
- Async client capabalities
### Changed
- HTTPlug instead of HTTP Adapter
## 0.1.0 - 2015-06-12
### Added
- Initial release

20
vendor/php-http/guzzle6-adapter/LICENSE vendored Normal file
View File

@@ -0,0 +1,20 @@
Copyright (c) 2014-2015 Eric GELOEN <geloen.eric@gmail.com>
Copyright (c) 2015-2016 PHP HTTP Team <team@php-http.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,59 @@
# Guzzle 6 HTTP Adapter
[![Latest Version](https://img.shields.io/github/release/php-http/guzzle6-adapter.svg?style=flat-square)](https://github.com/php-http/guzzle6-adapter/releases)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
[![Build Status](https://img.shields.io/travis/php-http/guzzle6-adapter.svg?style=flat-square)](https://travis-ci.org/php-http/guzzle6-adapter)
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/php-http/guzzle6-adapter.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/guzzle6-adapter)
[![Quality Score](https://img.shields.io/scrutinizer/g/php-http/guzzle6-adapter.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/guzzle6-adapter)
[![Total Downloads](https://img.shields.io/packagist/dt/php-http/guzzle6-adapter.svg?style=flat-square)](https://packagist.org/packages/php-http/guzzle6-adapter)
**Guzzle 6 HTTP Adapter.**
## Install
Via Composer
``` bash
$ composer require php-http/guzzle6-adapter
```
## Documentation
Please see the [official documentation](http://docs.php-http.org/en/latest/clients/guzzle6-adapter.html).
## Testing
First launch the http server:
```bash
$ ./vendor/bin/http_test_server > /dev/null 2>&1 &
```
Then the test suite:
``` bash
$ composer test
```
## Contributing
Please see our [contributing guide](http://docs.php-http.org/en/latest/development/contributing.html).
## Security
If you discover any security related issues, please contact us at [security@php-http.org](mailto:security@php-http.org).
## Credits
Thanks to [David de Boer](https://github.com/ddeboer) for implementing this adapter.
## License
The MIT License (MIT). Please see [License File](LICENSE) for more information.

View File

@@ -0,0 +1,49 @@
{
"name": "php-http/guzzle6-adapter",
"description": "Guzzle 6 HTTP Adapter",
"license": "MIT",
"keywords": ["guzzle", "http"],
"homepage": "http://httplug.io",
"authors": [
{
"name": "David de Boer",
"email": "david@ddeboer.nl"
},
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com"
}
],
"require": {
"php": ">=5.5.0",
"php-http/httplug": "^1.0",
"guzzlehttp/guzzle": "^6.0"
},
"require-dev": {
"ext-curl": "*",
"php-http/adapter-integration-tests": "^0.4"
},
"provide": {
"php-http/client-implementation": "1.0",
"php-http/async-client-implementation": "1.0"
},
"autoload": {
"psr-4": {
"Http\\Adapter\\Guzzle6\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Http\\Adapter\\Guzzle6\\Tests\\": "tests/"
}
},
"scripts": {
"test": "vendor/bin/phpunit",
"test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml"
},
"extra": {
"branch-alias": {
"dev-master": "1.2-dev"
}
}
}

View File

@@ -0,0 +1,16 @@
{
"version": "1.0",
"name": "php-http/guzzle6-adapter",
"bindings": {
"04b5a002-71a8-473d-a8df-75671551b84a": {
"_class": "Puli\\Discovery\\Binding\\ClassBinding",
"class": "Http\\Adapter\\Guzzle6\\Client",
"type": "Http\\Client\\HttpClient"
},
"9c856476-7f6b-43df-a740-15420a5f839c": {
"_class": "Puli\\Discovery\\Binding\\ClassBinding",
"class": "Http\\Adapter\\Guzzle6\\Client",
"type": "Http\\Client\\HttpAsyncClient"
}
}
}

View File

@@ -0,0 +1,84 @@
<?php
namespace Http\Adapter\Guzzle6;
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
use Http\Client\HttpAsyncClient;
use Http\Client\HttpClient;
use Psr\Http\Message\RequestInterface;
/**
* HTTP Adapter for Guzzle 6.
*
* @author David de Boer <david@ddeboer.nl>
*/
class Client implements HttpClient, HttpAsyncClient
{
/**
* @var ClientInterface
*/
private $client;
/**
* @param ClientInterface|null $client
*/
public function __construct(ClientInterface $client = null)
{
if (!$client) {
$client = static::buildClient();
}
$this->client = $client;
}
/**
* Factory method to create the guzzle 6 adapter with custom configuration for guzzle.
*
* @param array $config Configuration to create guzzle with.
*
* @return Client
*/
public static function createWithConfig(array $config)
{
return new self(static::buildClient($config));
}
/**
* {@inheritdoc}
*/
public function sendRequest(RequestInterface $request)
{
$promise = $this->sendAsyncRequest($request);
return $promise->wait();
}
/**
* {@inheritdoc}
*/
public function sendAsyncRequest(RequestInterface $request)
{
$promise = $this->client->sendAsync($request);
return new Promise($promise, $request);
}
/**
* Build the guzzle client instance.
*
* @param array $config Additional configuration
*
* @return GuzzleClient
*/
private static function buildClient(array $config = [])
{
$handlerStack = new HandlerStack(\GuzzleHttp\choose_handler());
$handlerStack->push(Middleware::prepareBody(), 'prepare_body');
$config = array_merge(['handler' => $handlerStack], $config);
return new GuzzleClient($config);
}
}

View File

@@ -0,0 +1,140 @@
<?php
namespace Http\Adapter\Guzzle6;
use GuzzleHttp\Exception as GuzzleExceptions;
use GuzzleHttp\Promise\PromiseInterface;
use Http\Client\Exception as HttplugException;
use Http\Promise\Promise as HttpPromise;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
/**
* Wrapper around Guzzle promises.
*
* @author Joel Wurtz <joel.wurtz@gmail.com>
*/
class Promise implements HttpPromise
{
/**
* @var PromiseInterface
*/
private $promise;
/**
* @var string State of the promise
*/
private $state;
/**
* @var ResponseInterface
*/
private $response;
/**
* @var HttplugException
*/
private $exception;
/**
* @var RequestInterface
*/
private $request;
/**
* @param PromiseInterface $promise
* @param RequestInterface $request
*/
public function __construct(PromiseInterface $promise, RequestInterface $request)
{
$this->request = $request;
$this->state = self::PENDING;
$this->promise = $promise->then(function ($response) {
$this->response = $response;
$this->state = self::FULFILLED;
return $response;
}, function ($reason) use ($request) {
$this->state = self::REJECTED;
if ($reason instanceof HttplugException) {
$this->exception = $reason;
} elseif ($reason instanceof GuzzleExceptions\GuzzleException) {
$this->exception = $this->handleException($reason, $request);
} elseif ($reason instanceof \Exception) {
$this->exception = new \RuntimeException('Invalid exception returned from Guzzle6', 0, $reason);
} else {
$this->exception = new \UnexpectedValueException('Reason returned from Guzzle6 must be an Exception', 0, $reason);
}
throw $this->exception;
});
}
/**
* {@inheritdoc}
*/
public function then(callable $onFulfilled = null, callable $onRejected = null)
{
return new static($this->promise->then($onFulfilled, $onRejected), $this->request);
}
/**
* {@inheritdoc}
*/
public function getState()
{
return $this->state;
}
/**
* {@inheritdoc}
*/
public function wait($unwrap = true)
{
$this->promise->wait(false);
if ($unwrap) {
if ($this->getState() == self::REJECTED) {
throw $this->exception;
}
return $this->response;
}
}
/**
* Converts a Guzzle exception into an Httplug exception.
*
* @param GuzzleExceptions\GuzzleException $exception
* @param RequestInterface $request
*
* @return HttplugException
*/
private function handleException(GuzzleExceptions\GuzzleException $exception, RequestInterface $request)
{
if ($exception instanceof GuzzleExceptions\SeekException) {
return new HttplugException\RequestException($exception->getMessage(), $request, $exception);
}
if ($exception instanceof GuzzleExceptions\ConnectException) {
return new HttplugException\NetworkException($exception->getMessage(), $exception->getRequest(), $exception);
}
if ($exception instanceof GuzzleExceptions\RequestException) {
// Make sure we have a response for the HttpException
if ($exception->hasResponse()) {
return new HttplugException\HttpException(
$exception->getMessage(),
$exception->getRequest(),
$exception->getResponse(),
$exception
);
}
return new HttplugException\RequestException($exception->getMessage(), $exception->getRequest(), $exception);
}
return new HttplugException\TransferException($exception->getMessage(), 0, $exception);
}
}