Skip to content

Commit ea6a4d6

Browse files
author
childish-sambino
authored
chore!: drop support for EOL PHP versions and add support for PHP 8 (#153)
Also upgraded phpunit.
1 parent 06dfa13 commit ea6a4d6

10 files changed

+50
-44
lines changed

.github/workflows/test-and-deploy.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
timeout-minutes: 20
1818
strategy:
1919
matrix:
20-
php: [ 5.6, 7.0, 7.1, 7.2, 7.3, 7.4 ]
20+
php: [ '7.3', '7.4', '8.0', '8.1' ]
2121
dependencies:
2222
- "lowest"
2323
- "highest"
@@ -56,7 +56,7 @@ jobs:
5656
- name: Setup PHP
5757
uses: shivammathur/[email protected]
5858
with:
59-
php-version: '7.4'
59+
php-version: '8.1'
6060
id: php
6161

6262
- name: Build Release Artifacts

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ We welcome direct contributions to the php-http-client code base. Thank you!
4747

4848
##### Prerequisites #####
4949

50-
- PHP 5.6 or 7.0
50+
- PHP version 7.3, 7.4, 8.0, or 8.1
5151
- [Composer](https://getcomposer.org/)
5252

5353
##### Initial setup: #####

Dockerfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:7.1-apache
1+
FROM php:8.1
22

33
ARG sendgrid_apikey
44
ENV SENDGRID_API_KEY=$sendgrid_apikey
@@ -7,7 +7,8 @@ COPY . /var/www/client
77
WORKDIR /var/www/client
88

99
RUN apt-get update && \
10-
apt-get install -y git zip zlib1g-dev && docker-php-ext-install zip
10+
apt-get install -y git libzip-dev && \
11+
docker-php-ext-install zip
1112
RUN curl --silent --show-error https://getcomposer.org/installer | php
1213

1314
RUN php composer.phar install

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ci-install: clean
77
composer install --no-dev
88

99
install: clean
10-
composer install --no-suggest --no-scripts --no-progress --no-interaction
10+
composer install --no-scripts --no-progress --no-interaction
1111

1212
test: install
1313
vendor/bin/phpunit test/unit

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ All updates to this library are documented in our [CHANGELOG](CHANGELOG.md).
2727

2828
## Prerequisites
2929

30-
- PHP version 5.6, 7.0, 7.1, 7.2, 7.3, or 7.4
30+
- PHP version 7.3, 7.4, 8.0, or 8.1
3131

3232
## Install with Composer
3333

UPGRADE.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Upgrade Guide
2+
3+
_MAJOR version bumps will have upgrade notes posted here._
4+
5+
[2022-05-04] 3.x.x to 4.x.x
6+
---------------------------
7+
8+
### CHANGED - Drop support for PHP versions 5.6, 7.0, 7.1, and 7.2 which are EOL.

composer.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=5.6",
19+
"php": ">=7.3",
2020
"ext-curl": "*",
2121
"ext-json": "*",
2222
"ext-mbstring": "*"
2323
},
2424
"require-dev": {
25-
"phpunit/phpunit": "^5.7 || ^6.5",
26-
"sebastian/version": "^1.0.6",
25+
"phpunit/phpunit": "^9",
2726
"squizlabs/php_codesniffer": "~2.0",
2827
"friendsofphp/php-cs-fixer": "^2.16"
2928
},

test/unit/ClientTest.php

+22-24
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ClientTest extends TestCase
1515
/** @var array */
1616
private $headers;
1717

18-
protected function setUp()
18+
protected function setUp(): void
1919
{
2020
$this->host = 'https://localhost:4010';
2121
$this->headers = [
@@ -27,13 +27,11 @@ protected function setUp()
2727

2828
public function testConstructor()
2929
{
30-
$this->assertAttributeEquals($this->host, 'host', $this->client);
31-
$this->assertAttributeEquals($this->headers, 'headers', $this->client);
32-
$this->assertAttributeEquals('/v3', 'version', $this->client);
33-
$this->assertAttributeEquals([], 'path', $this->client);
34-
$this->assertAttributeEquals([], 'curlOptions', $this->client);
35-
$this->assertAttributeEquals(false, 'retryOnLimit', $this->client);
36-
$this->assertAttributeEquals(['get', 'post', 'patch', 'put', 'delete'], 'methods', $this->client);
30+
$this->assertEquals($this->host, $this->client->getHost());
31+
$this->assertEquals($this->headers, $this->client->getHeaders());
32+
$this->assertEquals('/v3', $this->client->getVersion());
33+
$this->assertEquals([], $this->client->getPath());
34+
$this->assertEquals([], $this->client->getCurlOptions());
3735
}
3836

3937
public function test_()
@@ -42,34 +40,34 @@ public function test_()
4240
$client->setCurlOptions(['foo' => 'bar']);
4341
$client = $client->_('test');
4442

45-
$this->assertAttributeEquals(['test'], 'path', $client);
46-
$this->assertAttributeEquals(['foo' => 'bar'], 'curlOptions', $client);
43+
$this->assertEquals(['test'], $client->getPath());
44+
$this->assertEquals(['foo' => 'bar'], $client->getCurlOptions());
4745
}
4846

4947
public function test__call()
5048
{
5149
$client = $this->client->get();
52-
$this->assertAttributeEquals('https://localhost:4010/v3/', 'url', $client);
50+
$this->assertEquals('https://localhost:4010/v3/', $client->url);
5351

5452
$queryParams = ['limit' => 100, 'offset' => 0];
5553
$client = $this->client->get(null, $queryParams);
56-
$this->assertAttributeEquals('https://localhost:4010/v3/?limit=100&offset=0', 'url', $client);
54+
$this->assertEquals('https://localhost:4010/v3/?limit=100&offset=0', $client->url);
5755

5856
$requestBody = ['name' => 'A New Hope'];
5957
$client = $this->client->get($requestBody);
60-
$this->assertAttributeEquals($requestBody, 'requestBody', $client);
58+
$this->assertEquals($requestBody, $client->requestBody);
6159

6260
$requestHeaders = ['X-Mock: 200'];
6361
$client = $this->client->get(null, null, $requestHeaders);
64-
$this->assertAttributeEquals($requestHeaders, 'requestHeaders', $client);
62+
$this->assertEquals($requestHeaders, $client->requestHeaders);
6563

6664
$client = $this->client->version('/v4');
67-
$this->assertAttributeEquals('/v4', 'version', $client);
65+
$this->assertEquals('/v4', $client->getVersion());
6866

6967
$client = $this->client->path_to_endpoint();
70-
$this->assertAttributeEquals(['path_to_endpoint'], 'path', $client);
68+
$this->assertEquals(['path_to_endpoint'], $client->getPath());
7169
$client = $client->one_more_segment();
72-
$this->assertAttributeEquals(['path_to_endpoint', 'one_more_segment'], 'path', $client);
70+
$this->assertEquals(['path_to_endpoint', 'one_more_segment'], $client->getPath());
7371
}
7472

7573
public function testGetHost()
@@ -212,7 +210,7 @@ public function testThrowExceptionOnInvalidCall()
212210
public function testMakeRequestWithUntrustedRootCert()
213211
{
214212
$this->expectException(InvalidRequest::class);
215-
$this->expectExceptionMessageRegExp('/certificate/i');
213+
$this->expectExceptionMessageMatches('/certificate/i');
216214

217215
$client = new Client('https://untrusted-root.badssl.com/');
218216
$client->makeRequest('GET', 'https://untrusted-root.badssl.com/');
@@ -223,12 +221,12 @@ public function testFormRepeatUrlArgs()
223221
$client = new Client('https://localhost:4010');
224222

225223
$testParams = [
226-
'thing' => 'stuff',
227-
'foo' => [
228-
'bar',
229-
'bat',
230-
'baz',
231-
],
224+
'thing' => 'stuff',
225+
'foo' => [
226+
'bar',
227+
'bat',
228+
'baz',
229+
],
232230
];
233231
$result = $this->callMethod($client, 'buildUrl', [$testParams]);
234232
$this->assertEquals($result, 'https://localhost:4010/?thing=stuff&foo=bar&foo=bat&foo=baz');

test/unit/MockClient.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
class MockClient extends Client
88
{
9-
protected $requestBody;
10-
protected $requestHeaders;
11-
protected $url;
9+
public $requestBody;
10+
public $requestHeaders;
11+
public $url;
1212

1313
public function makeRequest($method, $url, $requestBody = null, $requestHeaders = null, $retryOnLimit = false)
1414
{

test/unit/ResponseTest.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22

33
namespace SendGrid\Test;
44

5-
use SendGrid\Response;
65
use PHPUnit\Framework\TestCase;
6+
use SendGrid\Response;
77

88
class ResponseTest extends TestCase
99
{
1010
public function testConstructor()
1111
{
1212
$response = new Response();
1313

14-
$this->assertAttributeEquals(200, 'statusCode', $response);
15-
$this->assertAttributeEquals('', 'body', $response);
16-
$this->assertAttributeEquals([], 'headers', $response);
14+
$this->assertEquals(200, $response->statusCode());
15+
$this->assertEquals('', $response->body());
16+
$this->assertEquals([], $response->headers());
1717

1818
$response = new Response(201, 'test', ['Content-Encoding: gzip']);
1919

20-
$this->assertAttributeEquals(201, 'statusCode', $response);
21-
$this->assertAttributeEquals('test', 'body', $response);
22-
$this->assertAttributeEquals(['Content-Encoding: gzip'], 'headers', $response);
20+
$this->assertEquals(201, $response->statusCode());
21+
$this->assertEquals('test', $response->body());
22+
$this->assertEquals(['Content-Encoding: gzip'], $response->headers());
2323
}
2424

2525
public function testStatusCode()

0 commit comments

Comments
 (0)