Skip to content

Commit 8a851a4

Browse files
committed
wip
1 parent def3e63 commit 8a851a4

File tree

5 files changed

+45
-57
lines changed

5 files changed

+45
-57
lines changed

.github/workflows/main.yml

+31-46
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ jobs:
1414
- name: Checkout code
1515
uses: actions/checkout@v3
1616

17-
- name: Setup PHP
18-
uses: shivammathur/setup-php@v2
19-
with:
20-
php-version: '8.1'
21-
coverage: pcov
22-
2317
- name: Get composer cache directory
2418
id: composer-cache
2519
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
@@ -31,15 +25,20 @@ jobs:
3125
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
3226
restore-keys: ${{ runner.os }}-composer-
3327

28+
- name: Setup PHP
29+
uses: shivammathur/setup-php@v2
30+
with:
31+
php-version: '8.1'
32+
coverage: pcov
33+
3434
- name: Install dependencies
35-
run: |
36-
composer update --no-interaction --verbose
35+
run: composer update
3736

3837
- name: Check platform requirements
39-
run: composer check-platform-reqs --verbose
38+
run: composer check-platform-reqs
4039

4140
- name: PHP-CS-Fixer
42-
run: composer fix -- --dry-run --verbose
41+
run: composer fix -- --dry-run
4342

4443
# - name: composer normalize
4544
# run: composer normalize --dry-run --no-interaction --verbose
@@ -67,74 +66,60 @@ jobs:
6766

6867
tests:
6968
runs-on: ubuntu-latest
70-
name: 'PHP: ${{ matrix.php }}; Lara: ${{ matrix.laravel }}; Deps: ${{ matrix.dependency-version }}'
69+
name: 'PHP: ${{ matrix.php }}; Laravel: ${{ matrix.laravel }}; Prefer: ${{ matrix.prefer }}'
7170
strategy:
7271
matrix:
73-
php: ['8.0', '8.1', '8.2']
74-
laravel: ['^8.73.2', '^9.0', '10.x-dev']
75-
dependency-version: ['prefer-lowest', 'prefer-stable']
72+
php: ['8.1', '8.2']
73+
laravel: ['^9.0', '^10.0']
74+
prefer: ['prefer-lowest', 'prefer-stable']
7675
include:
77-
- testbench: '^6.0'
78-
laravel: '^8.73.2'
7976
- testbench: '^7.0'
8077
laravel: '^9.0'
81-
- testbench: '8.x-dev'
82-
laravel: '10.x-dev'
83-
exclude:
84-
- php: '8.0'
85-
laravel: '10.x-dev'
78+
- testbench: '^8.0'
79+
laravel: '^10.0'
8680

8781
steps:
8882
- name: checkout code
8983
uses: actions/checkout@v3
9084

91-
- name: Setup PHP
92-
uses: shivammathur/setup-php@v2
93-
with:
94-
php-version: ${{ matrix.php }}
95-
coverage: none
96-
9785
- name: Get composer cache directory
9886
id: composer-cache
9987
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
10088

10189
- name: Cache dependencies
10290
uses: actions/cache@v3
10391
with:
104-
path: ${{ steps.composer-cache.outputs.dir }}
105-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
106-
restore-keys: ${{ runner.os }}-composer-
92+
path: ${{ steps.composer-cache.outputs.dir }}
93+
key: ${{ runner.os }}-php-${{ matrix.php }}-laravel-${{ matrix.laravel }}-prefer-${{ matrix.prefer }}-composer-${{ hashFiles('**/composer.json') }}
94+
restore-keys: ${{ runner.os }}-php-${{ matrix.php }}-laravel-{{ matrix.laravel }}-prefer-${{ matrix.prefer}}-composer-
95+
96+
- name: Setup PHP
97+
uses: shivammathur/setup-php@v2
98+
with:
99+
php-version: ${{ matrix.php }}
100+
coverage: none
107101

108102
- name: Remove dev packages
109103
run: |
110-
composer remove --dev --no-update --no-interaction --verbose \
104+
composer remove --dev --no-update \
111105
friendsofphp/php-cs-fixer \
112106
infection/infection \
113107
nunomaduro/larastan \
114108
phpstan/phpstan-strict-rules
115109
116110
- name: Require Laravel and Testbench version
117-
run: composer require laravel/framework:"${{ matrix.laravel }}" illuminate/collections:"${{ matrix.laravel }}" illuminate/database:"${{ matrix.laravel }}" illuminate/http:"${{ matrix.laravel }}" illuminate/support:"${{ matrix.laravel }}" orchestra/testbench:"${{ matrix.testbench }}" --no-update --no-interaction --verbose --with-all-dependencies
118-
119-
- name: Support prefer-lowest in PHP 8.0
120-
if: ${{ matrix.php == 8.0 && matrix.dependency-version == 'prefer-lowest' }}
121-
run: composer require --no-update \
122-
mockery/mockery:"^1.3.3"
111+
run: composer require --no-update laravel/framework:"${{ matrix.laravel }}" illuminate/collections:"${{ matrix.laravel }}" illuminate/database:"${{ matrix.laravel }}" illuminate/http:"${{ matrix.laravel }}" illuminate/support:"${{ matrix.laravel }}" orchestra/testbench:"${{ matrix.testbench }}"
123112

124113
- name: Support prefer-lowest in PHP 8.1
125-
if: ${{ matrix.php == 8.1 && matrix.dependency-version == 'prefer-lowest' }}
126-
run: composer require --no-update \
127-
nesbot/carbon:"^2.62.1" \
128-
symfony/http-foundation:"^5.3.7 || ^6.0"
114+
if: ${{ matrix.php == 8.1 && matrix.prefer == 'prefer-lowest' }}
115+
run: composer require --no-update nesbot/carbon:"^2.62.1"
129116

130117
- name: Support prefer-lowest in PHP 8.2
131-
if: ${{ matrix.php == 8.2 && matrix.dependency-version == 'prefer-lowest' }}
132-
run: composer require --no-update \
133-
nesbot/carbon:"^2.62.1" \
134-
symfony/http-foundation:"^5.3.7 || ^6.0"
118+
if: ${{ matrix.php == 8.2 && matrix.prefer == 'prefer-lowest' }}
119+
run: composer require --no-update nesbot/carbon:"^2.62.1"
135120

136121
- name: Install dependencies
137-
run: composer update --${{ matrix.dependency-version }} --no-interaction --verbose
122+
run: composer update --${{ matrix.prefer }}
138123

139124
- name: Check platform requirements
140125
run: composer check-platform-reqs --verbose

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ A lightweight API resource for Laravel that helps you adhere to the `JSON:API` s
2626

2727
## Version support
2828

29-
- **PHP**: `8.0`, `8.1`, `8.2`
29+
- **PHP**: `8.1`, `8.2`
3030
- **Laravel**: `^8.73.2`, `^9.0`, `10.x-dev`
3131

3232
## Installation

composer.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@
1717
}
1818
],
1919
"require": {
20-
"php": "^8.0 || ^8.1 || ^8.2",
21-
"illuminate/collections": "^8.73.2 || ^9.0 || 10.x-dev",
22-
"illuminate/database": "^8.73.2 || ^9.0 || 10.x-dev|^10.0",
23-
"illuminate/http": "^8.73.2 || ^9.0 || 10.x-dev|^10.0",
24-
"illuminate/support": "^8.73.2 || ^9.0 || 10.x-dev|^10.0",
25-
"symfony/http-kernel": "^5.0 || ^6.0"
20+
"php": "^8.1 || ^8.2",
21+
"illuminate/collections": "^9.0 || ^10.0",
22+
"illuminate/database": "^9.0 || ^10.0",
23+
"illuminate/http": "^9.0 || ^10.0",
24+
"illuminate/support": "^9.0 || ^10.0",
25+
"symfony/http-kernel": "^6.0"
2626
},
2727
"require-dev": {
2828
"friendsofphp/php-cs-fixer": "^3.13",
29-
"laravel/framework": "^8.73.2 || ^9.0 || 10.x-dev|^10.0",
29+
"laravel/framework": "^9.0 || ^10.0",
3030
"opis/json-schema": "^2.3",
31-
"orchestra/testbench": "^6.0 || ^7.0 || 8.x-dev|^8.0",
31+
"orchestra/testbench": "^7.0 || ^8.0",
3232
"phpunit/phpunit": "^9.0"
3333
},
3434
"config": {

src/Concerns/Links.php

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use Illuminate\Support\Collection;
88
use TiMacDonald\JsonApi\Link;
99

10+
use function is_string;
11+
1012
trait Links
1113
{
1214
/**

tests/Unit/LinkTest.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44

55
namespace Tests\Unit;
66

7-
use Illuminate\Container\Container;
87
use Illuminate\Http\Request;
98
use PHPUnit\Framework\TestCase;
109
use Tests\Resources\BasicJsonApiResource;
11-
use TiMacDonald\JsonApi\Concerns\Links;
1210
use TiMacDonald\JsonApi\JsonApiResource;
1311
use TiMacDonald\JsonApi\Link;
1412

@@ -73,5 +71,8 @@ public function testItCanUseHash()
7371
$links = json_encode($resource->toArray($request)['links']);
7472

7573
$this->assertSame('{"foo":{"href":"http:\/\/foo.com","meta":{}}}', $links);
74+
75+
JsonApiResource::resolveIdNormally();
76+
JsonApiResource::resolveTypeNormally();
7677
}
7778
}

0 commit comments

Comments
 (0)