Skip to content

Support PHP 7.1-8.0 #162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
.editorconfig export-ignore
.gitattributes export-ignore
/.github/ export-ignore
.gitignore export-ignore
/.php_cs export-ignore
/.scrutinizer.yml export-ignore
/.styleci.yml export-ignore
/.travis.yml export-ignore
/behat.yml.dist export-ignore
/features/ export-ignore
/phpspec.ci.yml export-ignore
/phpspec.yml.dist export-ignore
/phpunit.xml.dist export-ignore
/spec/ export-ignore
/tests/ export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
/.github/ export-ignore
.gitignore export-ignore
/.php_cs.dist export-ignore
/.scrutinizer.yml export-ignore
/.styleci.yml export-ignore
/.travis.yml export-ignore
/phpspec.ci.yml export-ignore
/phpspec.yml.dist export-ignore
/phpstan-baseline.neon export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml.dist export-ignore
/spec/ export-ignore
/tests/ export-ignore
2 changes: 2 additions & 0 deletions .github/workflows/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[*.yml]
indent_size = 2
18 changes: 18 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Checks

on:
push:
branches:
- master
pull_request:

roave-bc-check:
name: Roave BC Check
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Roave BC Check
uses: docker://nyholm/roave-bc-check-ga
91 changes: 91 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: CI

on:
push:
pull_request:

jobs:
latest:
name: PHP ${{ matrix.php }} Latest
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.1', '7.2', '7.3', '7.4', '8.0']

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none

- name: Install PHP 7 dependencies
run: composer update --prefer-dist --no-interaction --no-progress
if: "matrix.php != '8.0'"

- name: Install PHP 8 dependencies
run: |
composer require "phpdocumentor/reflection-docblock:^5.2@dev" --no-interaction --no-update
composer update --prefer-dist --prefer-stable --no-interaction --no-progress --ignore-platform-req=php
if: "matrix.php == '8.0'"

- name: Execute tests
run: composer test

lowest:
name: PHP ${{ matrix.php }} Lowest
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.1', '7.2', '7.3', '7.4']

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none

- name: Install dependencies
run: |
composer require "sebastian/comparator:^3.0.2" --no-interaction --no-update
composer update --prefer-dist --prefer-stable --prefer-lowest --no-interaction --no-progress

- name: Execute tests
run: composer test

coverage:
name: Code Coverage
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
tools: composer:v2
coverage: xdebug

- name: Install dependencies
run: |
composer require "friends-of-phpspec/phpspec-code-coverage:^4.3.2" --no-interaction --no-update
composer update --prefer-dist --no-interaction --no-progress

- name: Execute tests
run: composer test-ci

- name: Upload coverage
run: |
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml
34 changes: 34 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Static analysis

on:
push:
branches:
- master
pull_request:

jobs:
phpstan:
name: PHPStan
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: PHPStan
uses: docker://oskarstark/phpstan-ga
with:
args: analyze --no-progress

php-cs-fixer:
name: PHP-CS-Fixer
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: PHP-CS-Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --dry-run --diff-format udiff
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/behat.yml
.php_cs
.php_cs.cache
/build/
/composer.lock
/phpspec.yml
Expand Down
13 changes: 0 additions & 13 deletions .php_cs

This file was deleted.

16 changes: 16 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

$config = PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'array_syntax' => ['syntax' => 'short'],
])
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__.'/src')
->name('*.php')
)
;

return $config;
30 changes: 17 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
{
"name": "php-http/httplug",
"description": "HTTPlug, the HTTP client abstraction for PHP",
"license": "MIT",
"keywords": ["http", "client"],
"keywords": [
"http",
"client"
],
"homepage": "http://httplug.io",
"license": "MIT",
"authors": [
{
"name": "Eric GELOEN",
"email": "[email protected]"
},
{
"name": "Márk Sági-Kazár",
"email": "[email protected]"
"email": "[email protected]",
"homepage": "https://sagikazarmark.hu"
}
],
"require": {
"php": "^7.0",
"psr/http-message": "^1.0",
"php": "^7.1 || ^8.0",
"php-http/promise": "^1.1",
"psr/http-client": "^1.0",
"php-http/promise": "^1.0"
"psr/http-message": "^1.0"
},
"require-dev": {
"phpspec/phpspec": "^4.3.4|^5.0|^6.0",
"friends-of-phpspec/phpspec-code-coverage" : "^4.1"
"friends-of-phpspec/phpspec-code-coverage": "^4.1",
"phpspec/phpspec": "^5.1 || ^6.0"
},
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
}
},
"autoload": {
"psr-4": {
Expand All @@ -32,10 +41,5 @@
"scripts": {
"test": "vendor/bin/phpspec run",
"test-ci": "vendor/bin/phpspec run -c phpspec.ci.yml"
},
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
}
}
}
22 changes: 22 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
parameters:
ignoreErrors:
-
message: "#^Method Http\\\\Client\\\\Exception\\\\HttpException\\:\\:create\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/Exception/HttpException.php

-
message: "#^Unsafe usage of new static\\(\\)\\.$#"
count: 1
path: src/Exception/HttpException.php

-
message: "#^Method Http\\\\Client\\\\Exception\\\\NetworkException\\:\\:setRequest\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/Exception/NetworkException.php

-
message: "#^Method Http\\\\Client\\\\Exception\\\\RequestException\\:\\:setRequest\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/Exception/RequestException.php

7 changes: 7 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
includes:
- phpstan-baseline.neon

parameters:
level: max
paths:
- src
5 changes: 1 addition & 4 deletions src/Exception/HttpException.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ class HttpException extends RequestException
protected $response;

/**
* @param string $message
* @param RequestInterface $request
* @param ResponseInterface $response
* @param \Exception|null $previous
* @param string $message
*/
public function __construct(
$message,
Expand Down
6 changes: 2 additions & 4 deletions src/Exception/NetworkException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Http\Client\Exception;

use Psr\Http\Message\RequestInterface;
use Psr\Http\Client\NetworkExceptionInterface as PsrNetworkException;
use Psr\Http\Message\RequestInterface;

/**
* Thrown when the request cannot be completed because of network issues.
Expand All @@ -17,9 +17,7 @@ class NetworkException extends TransferException implements PsrNetworkException
use RequestAwareTrait;

/**
* @param string $message
* @param RequestInterface $request
* @param \Exception|null $previous
* @param string $message
*/
public function __construct($message, RequestInterface $request, \Exception $previous = null)
{
Expand Down
6 changes: 2 additions & 4 deletions src/Exception/RequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Http\Client\Exception;

use Psr\Http\Message\RequestInterface;
use Psr\Http\Client\RequestExceptionInterface as PsrRequestException;
use Psr\Http\Message\RequestInterface;

/**
* Exception for when a request failed, providing access to the failed request.
Expand All @@ -18,9 +18,7 @@ class RequestException extends TransferException implements PsrRequestException
use RequestAwareTrait;

/**
* @param string $message
* @param RequestInterface $request
* @param \Exception|null $previous
* @param string $message
*/
public function __construct($message, RequestInterface $request, \Exception $previous = null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/HttpAsyncClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface HttpAsyncClient
*
* Exceptions related to processing the request are available from the returned Promise.
*
* @return Promise Resolves a PSR-7 Response or fails with an Http\Client\Exception.
* @return Promise resolves a PSR-7 Response or fails with an Http\Client\Exception
*
* @throws \Exception If processing the request is impossible (eg. bad configuration).
*/
Expand Down
3 changes: 0 additions & 3 deletions src/Promise/HttpFulfilledPromise.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ final class HttpFulfilledPromise implements Promise
*/
private $response;

/**
* @param ResponseInterface $response
*/
public function __construct(ResponseInterface $response)
{
$this->response = $response;
Expand Down
3 changes: 0 additions & 3 deletions src/Promise/HttpRejectedPromise.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ final class HttpRejectedPromise implements Promise
*/
private $exception;

/**
* @param Exception $exception
*/
public function __construct(Exception $exception)
{
$this->exception = $exception;
Expand Down