Skip to content

Commit 0922961

Browse files
authored
fix: Deprecations for PHP 8.4 (#96)
1 parent 77a67d3 commit 0922961

File tree

15 files changed

+95
-24
lines changed

15 files changed

+95
-24
lines changed

Dockerfile renamed to .docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:8.1
1+
FROM php:8.4
22

33
WORKDIR /usr/src/app
44

@@ -15,7 +15,7 @@ RUN apt-get update \
1515
# && docker-php-ext-install pdo mysqli pdo_mysql zip intl gd
1616

1717
# Copy the PHP config
18-
# COPY php.ini /usr/local/etc/php/php.ini
18+
COPY php.ini /usr/local/etc/php/php.ini
1919

2020
# Copy composer
2121
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer

.docker/docker-compose.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Command to run from the project root :
2+
# docker-compose -f .docker/docker-compose.yml run --build dev /bin/bash
3+
services:
4+
dev:
5+
build: .
6+
stdin_open: true
7+
tty: true
8+
volumes:
9+
- ..:/usr/src/app

.docker/php.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
display_errors = On
2+
error_reporting = E_ALL | E_DEPRECATED | E_NOTICE

.github/workflows/build-test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ on:
88

99
jobs:
1010
build:
11-
1211
runs-on: ubuntu-latest
1312
strategy:
1413
matrix:
1514
# follows https://www.php.net/supported-versions.php
16-
php-versions: ['8.1', '8.2', '8.3']
15+
php-versions: ['8.1', '8.2', '8.3', '8.4']
1716
phpunit-versions: ['latest']
1817

1918
steps:

docker-compose.yml

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

phpunit.xml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,22 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
55
backupGlobals="true"
6-
backupStaticAttributes="false"
76
bootstrap="vendor/autoload.php"
87
cacheResult="false"
98
colors="true"
10-
convertErrorsToExceptions="true"
11-
convertNoticesToExceptions="true"
12-
convertWarningsToExceptions="true"
13-
forceCoversAnnotation="false"
149
processIsolation="false"
1510
stopOnError="true"
1611
stopOnFailure="false"
1712
stopOnIncomplete="false"
1813
stopOnSkipped="false"
1914
stopOnRisky="false"
15+
displayDetailsOnTestsThatTriggerDeprecations="true"
16+
displayDetailsOnTestsThatTriggerErrors="true"
17+
displayDetailsOnTestsThatTriggerNotices="true"
18+
displayDetailsOnTestsThatTriggerWarnings="true"
2019
timeoutForSmallTests="1"
2120
timeoutForMediumTests="10"
2221
timeoutForLargeTests="60"
23-
verbose="false"
2422
>
2523
<coverage>
2624
<include>

src/Endpoints/Endpoint.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,17 @@ public function __construct(
2525
}
2626

2727
/**
28-
* @return Item
28+
* @return Item|null
2929
*/
3030
public function get(string|int $id)
3131
{
3232
$res = $this->tcgdex->fetch($this->endpoint, $id);
33+
34+
// handle case where result is not defined or an error
35+
if (is_null($res)) {
36+
return null;
37+
}
38+
3339
return Model::build(new $this->itemModel($this->tcgdex), $res);
3440
}
3541

src/Model/Serie.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,18 @@ class Serie extends SerieResume
99
*/
1010
public array $sets = [];
1111

12+
public ?SetResume $firstSet = null;
13+
public ?SetResume $lastSet = null;
14+
1215
protected function fill(object $data): void
1316
{
1417
foreach ($data as $key => $value) {
1518
if ($key === 'sets') {
1619
$this->sets = array_map(function ($item) {
1720
return Model::build(new SetResume($this->sdk), $item);
1821
}, $value);
22+
} elseif ($key === 'firstSet' || $key === 'lastSet') {
23+
$this->{$key} = Model::build(new SetResume($this->sdk), $value);
1924
} else {
2025
$this->{$key} = $value;
2126
}

src/Model/Set.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,51 @@
55
use TCGdex\Model\SubModel\CardCount;
66
use TCGdex\Model\SubModel\Variants;
77
use TCGdex\Model\SubModel\Legal;
8+
use TCGdex\Model\SubModel\Abbreviation;
89

910
class Set extends SetResume
1011
{
12+
/**
13+
* the serie the set is part of
14+
*/
1115
public SerieResume $serie;
1216

17+
/**
18+
* the TCG Online ID
19+
*/
1320
public ?string $tcgOnline = null;
1421

22+
/**
23+
* @deprecated this variable is inexistant in the API
24+
*/
1525
public ?Variants $variants = null;
1626

27+
/**
28+
* the set release date as an ISO8601 string (ex: `2020-02-01`)
29+
*/
1730
public string $releaseDate = '';
1831

32+
/**
33+
* Designate if the set is usable in tournaments
34+
*
35+
* Note: this is specific to the set and if a
36+
* card is banned from the set it will still be true
37+
*/
1938
public Legal $legal;
2039

2140
/**
41+
* the number of cards of the set in total & by variant
2242
* @var CardCount
2343
*/
2444
public $cardCount;
2545

2646
/**
47+
* The official and localized abbreviation used by TPC
48+
*/
49+
public Abbreviation $abbreviation;
50+
51+
/**
52+
* the list of cards of the set
2753
* @var CardResume[]
2854
*/
2955
public array $cards = [];
@@ -35,8 +61,8 @@ protected function fill(object $data): void
3561
$this->cardCount = Model::build(new CardCount($this->sdk), $value);
3662
} elseif ($key === 'serie') {
3763
$this->serie = Model::build(new SerieResume($this->sdk), $value);
38-
} elseif ($key === 'variants') {
39-
$this->variants = Model::build(new Variants($this->sdk), $value);
64+
} elseif ($key === 'abbreviation') {
65+
$this->abbreviation = Model::build(new Abbreviation($this->sdk), $value);
4066
} elseif ($key === 'legal') {
4167
$this->legal = Model::build(new Legal($this->sdk), $value);
4268
} elseif ($key === 'cards') {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace TCGdex\Model\SubModel;
4+
5+
use TCGdex\Model\Model;
6+
7+
class Abbreviation extends Model
8+
{
9+
public ?string $official = null;
10+
public ?string $localized = null;
11+
}

0 commit comments

Comments
 (0)