Skip to content

Commit

Permalink
Поддержка php 8 и повышение php версии до 7.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-theripper committed Dec 21, 2020
1 parent db78fae commit b853433
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

## Список изменений

21/12/2020

- Начиная с 2.1 минимальная версия php 7.3
- zend-diactoros заменён на laminas-diactoros (laminas-zendframework-bridge)

23/08/2016

- метод `upload` поддерживает событие `progress`, слушатель принимает `float` значение в процентах.
Expand All @@ -13,7 +18,7 @@

## Требования

- PHP 5.5
- PHP >= 5.6
- Расширение php_curl

## Внести свой вклад в развитие
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
}
],
"require": {
"php": ">=5.5",
"zendframework/zend-diactoros": "~1.8.4",
"league/event": "2.1.2",
"php": ">=7.3",
"laminas/laminas-diactoros": "^2.5",
"league/event": "^2.2",
"php-http/curl-client": "1.4.*",
"php-http/message": "^1.2",
"php-http/client-common": "^1.1"
},
"require-dev": {
"phpunit/phpunit": "~5.6.2"
"phpunit/phpunit": "^9.4"
},
"autoload": {
"psr-4": {
Expand Down
Binary file modified example/image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions example/manual_request.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
* Пример показывает как нестандартный запрос к API Яндекс.Диска.
*/

use Laminas\Diactoros\Request;

require_once __DIR__.'/../vendor/autoload.php';

$token = 'Access Token';

$disk = new Arhitector\Yandex\Disk($token);

// Внимание! В запрос будет передан Access Token
$request = new \Zend\Diactoros\Request('https://cloud-api.yandex.net/v1/disk/resources?path=O2cXW1AEVWI222.jpg', 'GET');
$request = new Request('https://cloud-api.yandex.net/v1/disk/resources?path=O2cXW1AEVWI222.jpg', 'GET');
$response = $disk->send($request);

var_dump($response->getBody()->getContents());
Expand All @@ -20,7 +22,7 @@
$resource = $disk->getResource('disk:/O2cXW1AEVWI222.jpg')
->setPreview('100x250');

$request = new Zend\Diactoros\Request($resource->preview, 'GET');
$request = new Request($resource->preview, 'GET');
$response = $disk->send($request);

header('Content-type: image/jpeg');
Expand Down
8 changes: 3 additions & 5 deletions src/Client/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function __destruct()
}

/**
* Sends a PSR-7 request.
* Sends a PSR-7 request and returns a PSR-7 response.
*
* @param RequestInterface $request
*
Expand All @@ -110,10 +110,8 @@ public function __destruct()
* @throws \RuntimeException If creating the body stream fails.
* @throws \UnexpectedValueException if unsupported HTTP version requested
* @throws RequestException
*
* @since 1.0
*/
public function sendRequest(RequestInterface $request)
public function sendRequest(RequestInterface $request): ResponseInterface
{
$responseBuilder = $this->createResponseBuilder();
$options = $this->createCurlOptions($request, $responseBuilder);
Expand Down Expand Up @@ -218,7 +216,7 @@ protected function createCurlOptions(RequestInterface $request, ResponseBuilder
$options[CURLOPT_WRITEFUNCTION] = function ($ch, $data) use ($responseBuilder) {
return $responseBuilder->getResponse()->getBody()->write($data);
};

$options[CURLOPT_HTTPHEADER] = $this->createHeaders($request, $options);

if ($request->getUri()->getUserInfo())
Expand Down

0 comments on commit b853433

Please sign in to comment.