Skip to content

Commit 0390c58

Browse files
authored
Support PHP 8.0 (#7)
1 parent 152b826 commit 0390c58

File tree

7 files changed

+46
-48
lines changed

7 files changed

+46
-48
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
steps:
1818
- name: "Checkout"
19-
uses: actions/checkout@master
19+
uses: actions/checkout@v2
2020

2121
- name: "Install PHP with extensions"
2222
uses: shivammathur/setup-php@v2
@@ -29,7 +29,7 @@ jobs:
2929
run: composer validate --strict
3030

3131
- name: "Install locked dependencies with composer"
32-
run: composer install --no-interaction --no-progress --no-suggest
32+
run: composer install --no-interaction --no-progress
3333

3434
- name: "Run localheinz/composer-normalize"
3535
run: composer normalize --dry-run
@@ -41,7 +41,7 @@ jobs:
4141

4242
steps:
4343
- name: "Checkout"
44-
uses: actions/checkout@master
44+
uses: actions/checkout@v2
4545

4646
- name: "Install PHP with extensions"
4747
uses: shivammathur/setup-php@v2
@@ -51,31 +51,31 @@ jobs:
5151
php-version: 7.4
5252

5353
- name: "Install locked dependencies with composer"
54-
run: composer install --no-interaction --no-progress --no-suggest
54+
run: composer install --no-interaction --no-progress
5555

5656
- name: "Run phpstan"
5757
run: vendor/bin/phpstan analyse --configuration=phpstan.neon
5858

5959
tests:
60-
name: "Tests"
60+
name: Test for PHP ${{ matrix.php-version }} (${{ matrix.dependencies }})
6161

6262
runs-on: ubuntu-latest
6363

6464
strategy:
6565
matrix:
6666
php-version:
67-
- 7.2
68-
- 7.3
69-
- 7.4
67+
- "7.2"
68+
- "7.3"
69+
- "7.4"
70+
- "8.0"
7071

7172
dependencies:
72-
- lowest
73-
- locked
74-
- highest
73+
- "prefer-lowest"
74+
- "prefer-stable"
7575

7676
steps:
7777
- name: "Checkout"
78-
uses: actions/checkout@master
78+
uses: actions/checkout@v2
7979

8080
- name: "Install PHP with extensions"
8181
uses: shivammathur/setup-php@v2
@@ -84,17 +84,8 @@ jobs:
8484
extensions: mbstring
8585
php-version: ${{ matrix.php-version }}
8686

87-
- name: "Install lowest dependencies with composer"
88-
if: matrix.dependencies == 'lowest'
89-
run: composer update --prefer-lowest --no-interaction --no-progress --no-suggest
90-
91-
- name: "Install locked dependencies with composer"
92-
if: matrix.dependencies == 'locked'
93-
run: composer install --no-interaction --no-progress --no-suggest
94-
95-
- name: "Install highest dependencies with composer"
96-
if: matrix.dependencies == 'highest'
97-
run: composer update --no-interaction --no-progress --no-suggest
87+
- name: "Install dependencies with composer"
88+
run: composer update --${{ matrix.dependencies }} --no-interaction --no-progress
9889

9990
- name: "Run unit tests with phpunit/phpunit"
10091
run: vendor/bin/phpunit
@@ -106,7 +97,7 @@ jobs:
10697

10798
steps:
10899
- name: "Checkout"
109-
uses: actions/checkout@master
100+
uses: actions/checkout@v2
110101

111102
- name: "Install PHP with extensions"
112103
uses: shivammathur/setup-php@v2
@@ -116,7 +107,7 @@ jobs:
116107
php-version: 7.4
117108

118109
- name: "Install locked dependencies with composer"
119-
run: composer install --no-interaction --no-progress --no-suggest
110+
run: composer install --no-interaction --no-progress
120111

121112
- name: "Dump Xdebug filter with phpunit/phpunit"
122113
run: vendor/bin/phpunit --dump-xdebug-filter=.build/phpunit/xdebug-filter.php

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ You can find and compare releases at the [GitHub release page](https://github.co
99

1010
## Unreleased
1111

12+
## 4.0.0
13+
14+
### Added
15+
16+
- Support PHP 8
17+
18+
### Changed
19+
20+
- Rename `Mixed` class to `MixedScalar` because `mixed` is a reserved name in PHP 8.
21+
The GraphQL name of the scalar is still `Mixed` so the schema does not change.
22+
1223
## 3.1.0
1324

1425
### Added

Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
FROM php:7.2-stretch
1+
FROM php:8
22

33
RUN apt-get update \
44
&& apt-get install -y \
55
curl \
66
git \
77
libzip-dev \
88
zip \
9-
&& docker-php-ext-configure zip --with-libzip \
9+
&& docker-php-ext-configure zip \
1010
&& docker-php-ext-install \
1111
zip \
1212
&& rm -rf /var/lib/apt/lists/*
1313

14-
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer \
15-
&& composer global require hirak/prestissimo --no-progress --no-suggest --no-interaction
14+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
1615
ENV COMPOSER_ALLOW_SUPERUSER="1"
1716

1817
WORKDIR /workdir

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ A [RFC 5321](https://tools.ietf.org/html/rfc5321) compliant email.
3131

3232
Arbitrary data encoded in JavaScript Object Notation. See https://www.json.org/.
3333

34-
### [Mixed](src/Mixed.php)
34+
### [Mixed](src/MixedScalar.php)
3535

3636
Loose type that allows any value. Be careful when passing in large `Int` or `Float` literals,
3737
as they may not be parsed correctly on the server side. Use `String` literals if you are

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
}
1515
],
1616
"require": {
17-
"php": ">=7.2",
17+
"php": "^7.2 || ^8.0",
1818
"egulias/email-validator": "^2.1.17",
1919
"spatie/regex": "^1.4.1",
2020
"thecodingmachine/safe": "^1.0.3",

src/Mixed.php renamed to src/MixedScalar.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,10 @@
77
use GraphQL\Type\Definition\ScalarType;
88
use GraphQL\Utils\AST;
99

10-
class Mixed extends ScalarType
10+
class MixedScalar extends ScalarType
1111
{
12-
/**
13-
* The description that is used for schema introspection.
14-
*
15-
* @var string
16-
*/
12+
public $name = 'Mixed';
13+
1714
public $description = <<<'DESCRIPTION'
1815
Loose type that allows any value. Be careful when passing in large `Int` or `Float` literals,
1916
as they may not be parsed correctly on the server side. Use `String` literals if you are

tests/MixedTest.php renamed to tests/MixedScalarTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
use GraphQL\Type\Definition\ObjectType;
1010
use GraphQL\Type\Schema;
1111
use GraphQL\Type\SchemaConfig;
12-
use MLL\GraphQLScalars\Mixed;
12+
use MLL\GraphQLScalars\MixedScalar;
1313
use PHPUnit\Framework\TestCase;
1414

15-
class MixedTest extends TestCase
15+
class MixedScalarTest extends TestCase
1616
{
1717
/**
1818
* @var Schema
@@ -23,7 +23,7 @@ public function setUp(): void
2323
{
2424
parent::setUp();
2525

26-
$mixed = new Mixed();
26+
$mixed = new MixedScalar();
2727

2828
$schemaConfig = new SchemaConfig();
2929
$schemaConfig->setQuery(
@@ -49,13 +49,13 @@ public function setUp(): void
4949
/**
5050
* @dataProvider singleValues
5151
*
52-
* @param mixed $value
52+
* @param mixed $value Anything
5353
*/
5454
public function testSerializePassesThroughAnything($value): void
5555
{
5656
$this->assertSame(
5757
$value,
58-
(new Mixed())->serialize(
58+
(new MixedScalar())->serialize(
5959
$value
6060
)
6161
);
@@ -64,13 +64,13 @@ public function testSerializePassesThroughAnything($value): void
6464
/**
6565
* @dataProvider singleValues
6666
*
67-
* @param mixed $value
67+
* @param mixed $value Anything
6868
*/
6969
public function testParseValuePassesThroughAnything($value): void
7070
{
7171
$this->assertSame(
7272
$value,
73-
(new Mixed())->serialize(
73+
(new MixedScalar())->serialize(
7474
$value
7575
)
7676
);
@@ -79,7 +79,7 @@ public function testParseValuePassesThroughAnything($value): void
7979
/**
8080
* Provide an assortment of values that should pass the Mixed type.
8181
*
82-
* @return array[]
82+
* @return array<int, array<int, mixed>>
8383
*/
8484
public function singleValues(): array
8585
{
@@ -97,7 +97,7 @@ public function singleValues(): array
9797
/**
9898
* @dataProvider literalToPhpMap
9999
*
100-
* @param mixed $expected
100+
* @param mixed $expected Anything
101101
*/
102102
public function testCastsValuesIntoAppropriatePhpValue(string $graphQLLiteral, string $jsonLiteral, $expected): void
103103
{
@@ -117,9 +117,9 @@ public function testCastsValuesIntoAppropriatePhpValue(string $graphQLLiteral, s
117117
}
118118

119119
/**
120-
* Provides a GraphQL literal, a Json literal and the expected PHP value.
120+
* Provides a GraphQL literal, a JSON literal and the expected PHP value.
121121
*
122-
* @return array[]
122+
* @return array<int, array<int, mixed>>
123123
*/
124124
public function literalToPhpMap(): array
125125
{

0 commit comments

Comments
 (0)