Skip to content

Commit bfd345b

Browse files
authored
Merge pull request #162 from GrahamCampbell/php8
Support PHP 7.1-8.0
2 parents c9b2424 + fb458e4 commit bfd345b

17 files changed

+230
-61
lines changed

.gitattributes

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
.editorconfig export-ignore
2-
.gitattributes export-ignore
3-
/.github/ export-ignore
4-
.gitignore export-ignore
5-
/.php_cs export-ignore
6-
/.scrutinizer.yml export-ignore
7-
/.styleci.yml export-ignore
8-
/.travis.yml export-ignore
9-
/behat.yml.dist export-ignore
10-
/features/ export-ignore
11-
/phpspec.ci.yml export-ignore
12-
/phpspec.yml.dist export-ignore
13-
/phpunit.xml.dist export-ignore
14-
/spec/ export-ignore
15-
/tests/ export-ignore
1+
.editorconfig export-ignore
2+
.gitattributes export-ignore
3+
/.github/ export-ignore
4+
.gitignore export-ignore
5+
/.php_cs.dist export-ignore
6+
/.scrutinizer.yml export-ignore
7+
/.styleci.yml export-ignore
8+
/.travis.yml export-ignore
9+
/phpspec.ci.yml export-ignore
10+
/phpspec.yml.dist export-ignore
11+
/phpstan-baseline.neon export-ignore
12+
/phpstan.neon.dist export-ignore
13+
/phpunit.xml.dist export-ignore
14+
/spec/ export-ignore
15+
/tests/ export-ignore

.github/workflows/.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[*.yml]
2+
indent_size = 2

.github/workflows/checks.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Checks
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
roave-bc-check:
10+
name: Roave BC Check
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v2
16+
17+
- name: Roave BC Check
18+
uses: docker://nyholm/roave-bc-check-ga

.github/workflows/ci.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
latest:
9+
name: PHP ${{ matrix.php }} Latest
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
php: ['7.1', '7.2', '7.3', '7.4', '8.0']
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v2
18+
19+
- name: Setup PHP
20+
uses: shivammathur/setup-php@v2
21+
with:
22+
php-version: ${{ matrix.php }}
23+
tools: composer:v2
24+
coverage: none
25+
26+
- name: Install PHP 7 dependencies
27+
run: composer update --prefer-dist --no-interaction --no-progress
28+
if: "matrix.php != '8.0'"
29+
30+
- name: Install PHP 8 dependencies
31+
run: |
32+
composer require "phpdocumentor/reflection-docblock:^5.2@dev" --no-interaction --no-update
33+
composer update --prefer-dist --prefer-stable --no-interaction --no-progress --ignore-platform-req=php
34+
if: "matrix.php == '8.0'"
35+
36+
- name: Execute tests
37+
run: composer test
38+
39+
lowest:
40+
name: PHP ${{ matrix.php }} Lowest
41+
runs-on: ubuntu-latest
42+
strategy:
43+
matrix:
44+
php: ['7.1', '7.2', '7.3', '7.4']
45+
46+
steps:
47+
- name: Checkout code
48+
uses: actions/checkout@v2
49+
50+
- name: Setup PHP
51+
uses: shivammathur/setup-php@v2
52+
with:
53+
php-version: ${{ matrix.php }}
54+
tools: composer:v2
55+
coverage: none
56+
57+
- name: Install dependencies
58+
run: |
59+
composer require "sebastian/comparator:^3.0.2" --no-interaction --no-update
60+
composer update --prefer-dist --prefer-stable --prefer-lowest --no-interaction --no-progress
61+
62+
- name: Execute tests
63+
run: composer test
64+
65+
coverage:
66+
name: Code Coverage
67+
runs-on: ubuntu-latest
68+
69+
steps:
70+
- name: Checkout code
71+
uses: actions/checkout@v2
72+
73+
- name: Setup PHP
74+
uses: shivammathur/setup-php@v2
75+
with:
76+
php-version: 7.4
77+
tools: composer:v2
78+
coverage: xdebug
79+
80+
- name: Install dependencies
81+
run: |
82+
composer require "friends-of-phpspec/phpspec-code-coverage:^4.3.2" --no-interaction --no-update
83+
composer update --prefer-dist --no-interaction --no-progress
84+
85+
- name: Execute tests
86+
run: composer test-ci
87+
88+
- name: Upload coverage
89+
run: |
90+
wget https://scrutinizer-ci.com/ocular.phar
91+
php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml

.github/workflows/static.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Static analysis
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
phpstan:
11+
name: PHPStan
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v2
17+
18+
- name: PHPStan
19+
uses: docker://oskarstark/phpstan-ga
20+
with:
21+
args: analyze --no-progress
22+
23+
php-cs-fixer:
24+
name: PHP-CS-Fixer
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v2
30+
31+
- name: PHP-CS-Fixer
32+
uses: docker://oskarstark/php-cs-fixer-ga
33+
with:
34+
args: --dry-run --diff-format udiff

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/behat.yml
1+
.php_cs
2+
.php_cs.cache
23
/build/
34
/composer.lock
45
/phpspec.yml

.php_cs

Lines changed: 0 additions & 13 deletions
This file was deleted.

.php_cs.dist

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
$config = PhpCsFixer\Config::create()
4+
->setRiskyAllowed(true)
5+
->setRules([
6+
'@Symfony' => true,
7+
'array_syntax' => ['syntax' => 'short'],
8+
])
9+
->setFinder(
10+
PhpCsFixer\Finder::create()
11+
->in(__DIR__.'/src')
12+
->name('*.php')
13+
)
14+
;
15+
16+
return $config;

composer.json

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,37 @@
11
{
22
"name": "php-http/httplug",
33
"description": "HTTPlug, the HTTP client abstraction for PHP",
4-
"license": "MIT",
5-
"keywords": ["http", "client"],
4+
"keywords": [
5+
"http",
6+
"client"
7+
],
68
"homepage": "http://httplug.io",
9+
"license": "MIT",
710
"authors": [
811
{
912
"name": "Eric GELOEN",
1013
"email": "[email protected]"
1114
},
1215
{
1316
"name": "Márk Sági-Kazár",
14-
"email": "[email protected]"
17+
"email": "[email protected]",
18+
"homepage": "https://sagikazarmark.hu"
1519
}
1620
],
1721
"require": {
18-
"php": "^7.0",
19-
"psr/http-message": "^1.0",
22+
"php": "^7.1 || ^8.0",
23+
"php-http/promise": "^1.1",
2024
"psr/http-client": "^1.0",
21-
"php-http/promise": "^1.0"
25+
"psr/http-message": "^1.0"
2226
},
2327
"require-dev": {
24-
"phpspec/phpspec": "^4.3.4|^5.0|^6.0",
25-
"friends-of-phpspec/phpspec-code-coverage" : "^4.1"
28+
"friends-of-phpspec/phpspec-code-coverage": "^4.1",
29+
"phpspec/phpspec": "^5.1 || ^6.0"
30+
},
31+
"extra": {
32+
"branch-alias": {
33+
"dev-master": "2.x-dev"
34+
}
2635
},
2736
"autoload": {
2837
"psr-4": {
@@ -32,10 +41,5 @@
3241
"scripts": {
3342
"test": "vendor/bin/phpspec run",
3443
"test-ci": "vendor/bin/phpspec run -c phpspec.ci.yml"
35-
},
36-
"extra": {
37-
"branch-alias": {
38-
"dev-master": "2.x-dev"
39-
}
4044
}
4145
}

phpstan-baseline.neon

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: "#^Method Http\\\\Client\\\\Exception\\\\HttpException\\:\\:create\\(\\) has no return typehint specified\\.$#"
5+
count: 1
6+
path: src/Exception/HttpException.php
7+
8+
-
9+
message: "#^Unsafe usage of new static\\(\\)\\.$#"
10+
count: 1
11+
path: src/Exception/HttpException.php
12+
13+
-
14+
message: "#^Method Http\\\\Client\\\\Exception\\\\NetworkException\\:\\:setRequest\\(\\) has no return typehint specified\\.$#"
15+
count: 1
16+
path: src/Exception/NetworkException.php
17+
18+
-
19+
message: "#^Method Http\\\\Client\\\\Exception\\\\RequestException\\:\\:setRequest\\(\\) has no return typehint specified\\.$#"
20+
count: 1
21+
path: src/Exception/RequestException.php
22+

phpstan.neon.dist

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
includes:
2+
- phpstan-baseline.neon
3+
4+
parameters:
5+
level: max
6+
paths:
7+
- src

src/Exception/HttpException.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ class HttpException extends RequestException
2020
protected $response;
2121

2222
/**
23-
* @param string $message
24-
* @param RequestInterface $request
25-
* @param ResponseInterface $response
26-
* @param \Exception|null $previous
23+
* @param string $message
2724
*/
2825
public function __construct(
2926
$message,

src/Exception/NetworkException.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Http\Client\Exception;
44

5-
use Psr\Http\Message\RequestInterface;
65
use Psr\Http\Client\NetworkExceptionInterface as PsrNetworkException;
6+
use Psr\Http\Message\RequestInterface;
77

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

1919
/**
20-
* @param string $message
21-
* @param RequestInterface $request
22-
* @param \Exception|null $previous
20+
* @param string $message
2321
*/
2422
public function __construct($message, RequestInterface $request, \Exception $previous = null)
2523
{

src/Exception/RequestException.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Http\Client\Exception;
44

5-
use Psr\Http\Message\RequestInterface;
65
use Psr\Http\Client\RequestExceptionInterface as PsrRequestException;
6+
use Psr\Http\Message\RequestInterface;
77

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

2020
/**
21-
* @param string $message
22-
* @param RequestInterface $request
23-
* @param \Exception|null $previous
21+
* @param string $message
2422
*/
2523
public function __construct($message, RequestInterface $request, \Exception $previous = null)
2624
{

src/HttpAsyncClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface HttpAsyncClient
1717
*
1818
* Exceptions related to processing the request are available from the returned Promise.
1919
*
20-
* @return Promise Resolves a PSR-7 Response or fails with an Http\Client\Exception.
20+
* @return Promise resolves a PSR-7 Response or fails with an Http\Client\Exception
2121
*
2222
* @throws \Exception If processing the request is impossible (eg. bad configuration).
2323
*/

src/Promise/HttpFulfilledPromise.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ final class HttpFulfilledPromise implements Promise
1313
*/
1414
private $response;
1515

16-
/**
17-
* @param ResponseInterface $response
18-
*/
1916
public function __construct(ResponseInterface $response)
2017
{
2118
$this->response = $response;

src/Promise/HttpRejectedPromise.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ final class HttpRejectedPromise implements Promise
1212
*/
1313
private $exception;
1414

15-
/**
16-
* @param Exception $exception
17-
*/
1815
public function __construct(Exception $exception)
1916
{
2017
$this->exception = $exception;

0 commit comments

Comments
 (0)