Skip to content

chore!: drop support for EOL PHP versions and add support for PHP 8 #153

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 12 commits into from
May 2, 2022
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
4 changes: 2 additions & 2 deletions .github/workflows/test-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
timeout-minutes: 20
strategy:
matrix:
php: [ 5.6, 7.0, 7.1, 7.2, 7.3, 7.4 ]
php: [ '7.3', '7.4', '8.0', '8.1' ]
dependencies:
- "lowest"
- "highest"
Expand Down Expand Up @@ -56,7 +56,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@2.15.0
with:
php-version: '7.4'
php-version: '8.1'
id: php

- name: Build Release Artifacts
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ We welcome direct contributions to the php-http-client code base. Thank you!

##### Prerequisites #####

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

##### Initial setup: #####
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.1-apache
FROM php:8.1

ARG sendgrid_apikey
ENV SENDGRID_API_KEY=$sendgrid_apikey
Expand All @@ -7,7 +7,8 @@ COPY . /var/www/client
WORKDIR /var/www/client

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

RUN php composer.phar install
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ci-install: clean
composer install --no-dev

install: clean
composer install --no-suggest --no-scripts --no-progress --no-interaction
composer install --no-scripts --no-progress --no-interaction

test: install
vendor/bin/phpunit test/unit
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ All updates to this library are documented in our [CHANGELOG](CHANGELOG.md).

## Prerequisites

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

## Install with Composer

Expand Down
8 changes: 8 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Upgrade Guide

_MAJOR version bumps will have upgrade notes posted here._

[2022-05-04] 3.x.x to 4.x.x
---------------------------

### CHANGED - Drop support for PHP versions 5.6, 7.0, 7.1, and 7.2 which are EOL.
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
}
],
"require": {
"php": ">=5.6",
"php": ">=7.3",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*"
},
"require-dev": {
"phpunit/phpunit": "^5.7 || ^6.5",
"sebastian/version": "^1.0.6",
"phpunit/phpunit": "^9",
"squizlabs/php_codesniffer": "~2.0",
"friendsofphp/php-cs-fixer": "^2.16"
},
Expand Down
46 changes: 22 additions & 24 deletions test/unit/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ClientTest extends TestCase
/** @var array */
private $headers;

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

public function testConstructor()
{
$this->assertAttributeEquals($this->host, 'host', $this->client);
$this->assertAttributeEquals($this->headers, 'headers', $this->client);
$this->assertAttributeEquals('/v3', 'version', $this->client);
$this->assertAttributeEquals([], 'path', $this->client);
$this->assertAttributeEquals([], 'curlOptions', $this->client);
$this->assertAttributeEquals(false, 'retryOnLimit', $this->client);
$this->assertAttributeEquals(['get', 'post', 'patch', 'put', 'delete'], 'methods', $this->client);
$this->assertEquals($this->host, $this->client->getHost());
$this->assertEquals($this->headers, $this->client->getHeaders());
$this->assertEquals('/v3', $this->client->getVersion());
$this->assertEquals([], $this->client->getPath());
$this->assertEquals([], $this->client->getCurlOptions());
}

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

$this->assertAttributeEquals(['test'], 'path', $client);
$this->assertAttributeEquals(['foo' => 'bar'], 'curlOptions', $client);
$this->assertEquals(['test'], $client->getPath());
$this->assertEquals(['foo' => 'bar'], $client->getCurlOptions());
}

public function test__call()
{
$client = $this->client->get();
$this->assertAttributeEquals('https://localhost:4010/v3/', 'url', $client);
$this->assertEquals('https://localhost:4010/v3/', $client->url);

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

$requestBody = ['name' => 'A New Hope'];
$client = $this->client->get($requestBody);
$this->assertAttributeEquals($requestBody, 'requestBody', $client);
$this->assertEquals($requestBody, $client->requestBody);

$requestHeaders = ['X-Mock: 200'];
$client = $this->client->get(null, null, $requestHeaders);
$this->assertAttributeEquals($requestHeaders, 'requestHeaders', $client);
$this->assertEquals($requestHeaders, $client->requestHeaders);

$client = $this->client->version('/v4');
$this->assertAttributeEquals('/v4', 'version', $client);
$this->assertEquals('/v4', $client->getVersion());

$client = $this->client->path_to_endpoint();
$this->assertAttributeEquals(['path_to_endpoint'], 'path', $client);
$this->assertEquals(['path_to_endpoint'], $client->getPath());
$client = $client->one_more_segment();
$this->assertAttributeEquals(['path_to_endpoint', 'one_more_segment'], 'path', $client);
$this->assertEquals(['path_to_endpoint', 'one_more_segment'], $client->getPath());
}

public function testGetHost()
Expand Down Expand Up @@ -212,7 +210,7 @@ public function testThrowExceptionOnInvalidCall()
public function testMakeRequestWithUntrustedRootCert()
{
$this->expectException(InvalidRequest::class);
$this->expectExceptionMessageRegExp('/certificate/i');
$this->expectExceptionMessageMatches('/certificate/i');

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

$testParams = [
'thing' => 'stuff',
'foo' => [
'bar',
'bat',
'baz',
],
'thing' => 'stuff',
'foo' => [
'bar',
'bat',
'baz',
],
];
$result = $this->callMethod($client, 'buildUrl', [$testParams]);
$this->assertEquals($result, 'https://localhost:4010/?thing=stuff&foo=bar&foo=bat&foo=baz');
Expand Down
6 changes: 3 additions & 3 deletions test/unit/MockClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

class MockClient extends Client
{
protected $requestBody;
protected $requestHeaders;
protected $url;
public $requestBody;
public $requestHeaders;
public $url;

public function makeRequest($method, $url, $requestBody = null, $requestHeaders = null, $retryOnLimit = false)
{
Expand Down
14 changes: 7 additions & 7 deletions test/unit/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@

namespace SendGrid\Test;

use SendGrid\Response;
use PHPUnit\Framework\TestCase;
use SendGrid\Response;

class ResponseTest extends TestCase
{
public function testConstructor()
{
$response = new Response();

$this->assertAttributeEquals(200, 'statusCode', $response);
$this->assertAttributeEquals('', 'body', $response);
$this->assertAttributeEquals([], 'headers', $response);
$this->assertEquals(200, $response->statusCode());
$this->assertEquals('', $response->body());
$this->assertEquals([], $response->headers());

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

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

public function testStatusCode()
Expand Down