Skip to content

Commit

Permalink
Add support for PHP 8.2 (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
antsunji authored Jun 12, 2023
1 parent 09df1ac commit 51e0203
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 20 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '8.0', '8.1' ]
php: [ '8.1', '8.2' ]
composer-flags: [ '', '--prefer-lowest' ]

steps:
Expand All @@ -31,7 +31,6 @@ jobs:

- name: Check coding standards
run: dev/bin/php composer lint -- --ansi --diff --dry-run --using-cache=no --verbose
if: matrix.php < 8.1

- name: Clear docker volumes
if: ${{ always() }}
Expand Down
9 changes: 8 additions & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@
'array_syntax' => ['syntax' => 'short'],
'no_unused_imports' => true,
'blank_line_after_namespace' => true,
'braces' => true,
'single_space_around_construct' => true,
'control_structure_braces' => true,
'curly_braces_position' => true,
'control_structure_continuation_position' => true,
'declare_parentheses' => true,
'statement_indentation' => true,
'no_multiple_statements_per_line' => true,
'no_extra_blank_lines' => true,
'class_definition' => true,
'declare_strict_types' => true,
'elseif' => true,
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ composer require petersons/d2l-client

## Requirements

* [PHP 8.0](https://www.php.net/releases/8_0_0.php) or greater
* [PHP 8.1](https://www.php.net/releases/8_1_0.php) or greater

## Usage example

Expand Down Expand Up @@ -78,7 +78,7 @@ Docker dependencies for local development:

0. Build the Docker image
```bash
dev/bin/docker-compose build --build-arg PHP_VERSION=8.0 php
dev/bin/docker-compose build --build-arg PHP_VERSION=8.1 php
```

0. Install library dependencies
Expand Down
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.1",
"ext-curl": "*",
"ext-simplexml": "*",
"illuminate/collections": "^8.56 || ^9.0",
"illuminate/contracts": "^8.0 || ^9.0",
"illuminate/support": "^8.0 || ^9.0",
"nesbot/carbon": "^2.55",
"symfony/http-client": "^5.4 || ^6.0"
"nesbot/carbon": "^2.67",
"symfony/http-client": "^5.4.21 || ^6.3"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.5",
"friendsofphp/php-cs-fixer": "^3.17",
"illuminate/container": "^8.62 || ^9.0",
"phpunit/phpunit": "^9.5.13"
"phpunit/phpunit": "^9.6.9",
"nikic/php-parser": "^4.15.5"
},
"autoload": {
"psr-4": {
Expand Down
7 changes: 4 additions & 3 deletions dev/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
ARG PHP_VERSION=8.0
ARG PHP_VERSION=8.1

FROM php:${PHP_VERSION}-cli-alpine
LABEL maintainer="Antonio Pauletich <[email protected]>"

ARG COMPOSER_VERSION=2.2.4
ARG XDEBUG_VERSION=3.1.2
ARG COMPOSER_VERSION=2.5.8
ARG XDEBUG_VERSION=3.2.1

ENV XDEBUG_START_WITH_REQUEST "no"

Expand All @@ -17,6 +17,7 @@ RUN apk add --update --no-cache --virtual .build-deps \
${PHPIZE_DEPS} \
libzip-dev \
zlib-dev \
linux-headers \
&& docker-php-ext-install -j $(getconf _NPROCESSORS_ONLN) \
zip \
&& pecl install \
Expand Down
4 changes: 2 additions & 2 deletions src/D2LSigner.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class D2LSigner
*
* Both the key and data parameters should be UTF-8 strings.
*
* This method first generates a SHA-256-based HMAC of the provided base
* This method first generates an SHA-256-based HMAC of the provided base
* string data. Then, it renders the result URL-safe by Base64-encoding it,
* and removing all equal-sign characters, replacing all plus-sign characters
* with hyphens, and replacing all forward-slash characters with underbars.
Expand All @@ -24,7 +24,7 @@ final class D2LSigner
*/
public static function getBase64HashString(string $key, string $data): string
{
$return = hash_hmac('sha256', utf8_encode($data), utf8_encode($key), true);
$return = hash_hmac('sha256', $data, $key, true);
$return = base64_encode($return);

$return = str_replace('=', '', $return);
Expand Down
10 changes: 5 additions & 5 deletions tests/Unit/SymfonyHttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public function testFetchingUserByEmail(): void

$userJsonResponse = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'Fixture' . DIRECTORY_SEPARATOR . 'user_show_response.json');
$callback = function (string $method, string $url, array $options) use ($userJsonResponse): MockResponse {
if ('GET' === $method && 'https://petersonstest.brightspace.com/d2l/api/lp/1.30/users/?x_a=baz&x_b=foo&x_c=FGDZzyI8CiSOWa-c6hr_rcwj4fY58CFqzuvWiapEyQY&x_d=OjWXyQhHjYt2qgfJEDFezAIZfYpy9jyb3Jlzknywe7o&x_t=1615390200&externalEmail=petersons_1296_0%40email.fake' === $url) {
if ('GET' === $method && 'https://petersonstest.brightspace.com/d2l/api/lp/1.30/users/?x_a=baz&x_b=foo&x_c=FGDZzyI8CiSOWa-c6hr_rcwj4fY58CFqzuvWiapEyQY&x_d=OjWXyQhHjYt2qgfJEDFezAIZfYpy9jyb3Jlzknywe7o&x_t=1615390200&externalEmail=petersons_1296_0@email.fake' === $url) {
return new MockResponse($userJsonResponse);
}

Expand Down Expand Up @@ -229,7 +229,7 @@ public function testFetchingUserByEmailWhenD2LReturnsForbiddenResponse(): void
$this->freezeTime();

$callback = function (string $method, string $url, array $options): MockResponse {
if ('GET' === $method && 'https://petersonstest.brightspace.com/d2l/api/lp/1.30/users/?x_a=baz&x_b=foo&x_c=FGDZzyI8CiSOWa-c6hr_rcwj4fY58CFqzuvWiapEyQY&x_d=OjWXyQhHjYt2qgfJEDFezAIZfYpy9jyb3Jlzknywe7o&x_t=1615390200&externalEmail=petersons_1296_0%40email.fake' === $url) {
if ('GET' === $method && 'https://petersonstest.brightspace.com/d2l/api/lp/1.30/users/?x_a=baz&x_b=foo&x_c=FGDZzyI8CiSOWa-c6hr_rcwj4fY58CFqzuvWiapEyQY&x_d=OjWXyQhHjYt2qgfJEDFezAIZfYpy9jyb3Jlzknywe7o&x_t=1615390200&externalEmail=petersons_1296_0@email.fake' === $url) {
return new MockResponse('', ['http_code' => 403]);
}

Expand All @@ -242,7 +242,7 @@ public function testFetchingUserByEmailWhenD2LReturnsForbiddenResponse(): void

$this->expectExceptionObject(
new ApiException(
'HTTP 403 returned for "https://petersonstest.brightspace.com/d2l/api/lp/1.30/users/?x_a=baz&x_b=foo&x_c=FGDZzyI8CiSOWa-c6hr_rcwj4fY58CFqzuvWiapEyQY&x_d=OjWXyQhHjYt2qgfJEDFezAIZfYpy9jyb3Jlzknywe7o&x_t=1615390200&externalEmail=petersons_1296_0%40email.fake".',
'HTTP 403 returned for "https://petersonstest.brightspace.com/d2l/api/lp/1.30/users/?x_a=baz&x_b=foo&x_c=FGDZzyI8CiSOWa-c6hr_rcwj4fY58CFqzuvWiapEyQY&x_d=OjWXyQhHjYt2qgfJEDFezAIZfYpy9jyb3Jlzknywe7o&x_t=1615390200&externalEmail=petersons_1296_0@email.fake".',
403
)
);
Expand All @@ -255,7 +255,7 @@ public function testFetchingUserByEmailWhenD2LReturnsNotFoundResponse(): void
$this->freezeTime();

$callback = function (string $method, string $url, array $options): MockResponse {
if ('GET' === $method && 'https://petersonstest.brightspace.com/d2l/api/lp/1.30/users/?x_a=baz&x_b=foo&x_c=FGDZzyI8CiSOWa-c6hr_rcwj4fY58CFqzuvWiapEyQY&x_d=OjWXyQhHjYt2qgfJEDFezAIZfYpy9jyb3Jlzknywe7o&x_t=1615390200&externalEmail=petersons_1296_0%40email.fake' === $url) {
if ('GET' === $method && 'https://petersonstest.brightspace.com/d2l/api/lp/1.30/users/?x_a=baz&x_b=foo&x_c=FGDZzyI8CiSOWa-c6hr_rcwj4fY58CFqzuvWiapEyQY&x_d=OjWXyQhHjYt2qgfJEDFezAIZfYpy9jyb3Jlzknywe7o&x_t=1615390200&externalEmail=petersons_1296_0@email.fake' === $url) {
return new MockResponse('', ['http_code' => 404]);
}

Expand All @@ -268,7 +268,7 @@ public function testFetchingUserByEmailWhenD2LReturnsNotFoundResponse(): void

$this->expectExceptionObject(
new ApiException(
'HTTP 404 returned for "https://petersonstest.brightspace.com/d2l/api/lp/1.30/users/?x_a=baz&x_b=foo&x_c=FGDZzyI8CiSOWa-c6hr_rcwj4fY58CFqzuvWiapEyQY&x_d=OjWXyQhHjYt2qgfJEDFezAIZfYpy9jyb3Jlzknywe7o&x_t=1615390200&externalEmail=petersons_1296_0%40email.fake".',
'HTTP 404 returned for "https://petersonstest.brightspace.com/d2l/api/lp/1.30/users/?x_a=baz&x_b=foo&x_c=FGDZzyI8CiSOWa-c6hr_rcwj4fY58CFqzuvWiapEyQY&x_d=OjWXyQhHjYt2qgfJEDFezAIZfYpy9jyb3Jlzknywe7o&x_t=1615390200&externalEmail=petersons_1296_0@email.fake".',
404
)
);
Expand Down

0 comments on commit 51e0203

Please sign in to comment.