Skip to content

Commit

Permalink
chore: drop support for PHP 7 (#55)
Browse files Browse the repository at this point in the history
Co-authored-by: Sandesh <sandesh2643@gmail.com>
  • Loading branch information
kangasta and sandeshjangam authored Dec 1, 2023
1 parent e27b4bb commit 96ac9f4
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 17 deletions.
28 changes: 21 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@ on:
branches:
- main
pull_request:
branches:
- main
jobs:
Build:
Test:
strategy:
matrix:
os-php-versions: [
{ os: ubuntu-latest, php: 7.2 },
{ os: ubuntu-latest, php: 7.3 },
{ os: ubuntu-latest, php: 7.4 },
os-php-versions: [
{ os: ubuntu-latest, php: 8.0 },
{ os: ubuntu-latest, php: 8.1 },
{ os: ubuntu-latest, php: 8.2 },
]
runs-on: ${{ matrix.os-php-versions.os }}
steps:
Expand All @@ -37,3 +33,21 @@ jobs:
xdebug.max_nesting_level: 512
UPCLOUD_API_TEST_USER: ${{ secrets.UPCLOUD_API_TEST_USER }}
UPCLOUD_API_TEST_PASSWORD: ${{ secrets.UPCLOUD_API_TEST_PASSWORD }}

test-with-laravel:
name: Test install with laravel
strategy:
matrix:
laravel-version:
- 9
- 10
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
- uses: actions/checkout@v2
- name: Test package can be required into laravel project
run: |
./test/test-install-with-laravel.sh ${{ matrix.laravel-version }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ git_push.sh
/phpunit.xml
/composer.lock
.phpunit.result.cache
tmp/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ NOTE: Please test all of your use cases thoroughly before actual production use.

## Requirements

Using this library requires the PHP version 7.2 and later.
Using this library requires the PHP version 8.0 and later.

## Installation
### Composer
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@
}
],
"require": {
"php": "^7.2|^8.0|^8.1",
"php": "^8.0",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"guzzlehttp/guzzle": "^7.1",
"symfony/serializer": "^5.1",
"symfony/property-access": "^5.1",
"symfony/serializer": "^6.0",
"symfony/property-access": "^6.0",
"webmozart/assert": "^1.9"
},
"require-dev": {
"phpunit/phpunit": "^8.5.8",
"squizlabs/php_codesniffer": "~3.5",
"mockery/mockery": "^1.3.3",
"symfony/var-dumper": "^5.1"
"symfony/var-dumper": "^6.0"
},
"autoload": {
"psr-4": {
Expand Down
3 changes: 2 additions & 1 deletion lib/HttpClient/UpcloudApiResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ public function deserializeBody($class)
{
return $this->serializer->deserialize(
(string) $this->getBody(),
$class
$class,
'json'
);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public function __construct()
$this->serializer = new BaseSerializer([$normalizer], [new JsonEncoder()]);
}

public function deserialize($data, string $type, string $format = 'json', array $context = [])
public function deserialize(mixed $data, string $type, string $format = 'json', array $context = []): object|array
{
return $this->serializer->deserialize($data, $type, $format, $context);
}

public function serialize($data, string $format = 'json', array $context = [])
public function serialize(mixed $data, string $format = 'json', array $context = []): string
{
return $this->serializer->serialize($data, $format, array_merge([
'json_encode_options' => self::DEFAULT_ENCODING_OPTIONS,
Expand Down
4 changes: 2 additions & 2 deletions lib/SerializerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface SerializerInterface extends BaseSerializerInterface
*
* @return string
*/
public function serialize($data, string $format = 'json', array $context = []);
public function serialize(mixed $data, string $format, array $context = []): string;

/**
* Deserializes data into the given type.
Expand All @@ -29,5 +29,5 @@ public function serialize($data, string $format = 'json', array $context = []);
* @param array $context
* @return object|array
*/
public function deserialize($data, string $type, string $format = 'json', array $context = []);
public function deserialize(mixed $data, string $type, string $format, array $context = []): object|array;
}
13 changes: 13 additions & 0 deletions test/test-install-with-laravel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh -xe

laravel_version=${1:-9}
dir="test-$laravel_version"

mkdir -p tmp
cd tmp
rm -rf $dir

composer create-project laravel/laravel $dir "^$laravel_version"
cd $dir
composer config repositories.dev path ../../
composer require upcloudltd/upcloud-php-api @dev

0 comments on commit 96ac9f4

Please sign in to comment.