Skip to content

Commit 4c11533

Browse files
feat!: laravel 11 compatibility
BREAKING CHANGE: drop support for laravel 9 and lower and php 8.1
1 parent cc25612 commit 4c11533

File tree

15 files changed

+65
-78
lines changed

15 files changed

+65
-78
lines changed

.github/workflows/phpstan.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ jobs:
88
runs-on: ubuntu-latest
99

1010
steps:
11-
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
11+
- uses: shivammathur/setup-php@v2
1212
with:
13-
php-version: '8.1'
14-
- uses: actions/checkout@v3
13+
php-version: '8.2'
14+
- uses: actions/checkout@v4
1515
- name: Install Dependencies
1616
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
1717
- name: Test for PHPstan errors

.github/workflows/pint.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ jobs:
88
runs-on: ubuntu-latest
99

1010
steps:
11-
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
11+
- uses: shivammathur/setup-php@v2
1212
with:
13-
php-version: '8.1'
13+
php-version: '8.2'
1414

15-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v4
1616
with:
1717
# Fetch the last 2 commits instead of just 1. (Fetching just 1 commit would overwrite the whole history)
1818
fetch-depth: 2

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ jobs:
88
runs-on: ubuntu-latest
99

1010
steps:
11-
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
11+
- uses: shivammathur/setup-php@v2
1212
with:
13-
php-version: '8.1'
14-
- uses: actions/checkout@v3
13+
php-version: '8.2'
14+
- uses: actions/checkout@v4
1515
- name: Install Dependencies
1616
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
1717
- name: Execute tests (Unit and Feature tests) via PHPUnit

composer.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@
99
}
1010
],
1111
"require": {
12-
"php": ">=8.1",
12+
"php": ">=8.2",
1313
"ext-json": "*",
14-
"intermax/laravel-open-api": "^1.0",
15-
"laravel/framework": "^8.0 || ^9.0 || ^10.0",
14+
"intermax/laravel-open-api": "^2.0",
15+
"laravel/framework": "^10.0 || ^11.0",
1616
"spatie/laravel-json-api-paginate": "^1.12",
17-
"spatie/laravel-query-builder": "^4.0 || ^5.0"
17+
"spatie/laravel-query-builder": "^5.0"
1818
},
1919
"require-dev": {
2020
"laravel/pint": "^1.1",
21-
"nunomaduro/collision": "^7.0",
22-
"phpunit/phpunit": "^9.0 || ^10.0",
23-
"nunomaduro/larastan": "^2.2",
24-
"orchestra/testbench": "^6.6 || ^7.0 || ^8.0"
21+
"nunomaduro/collision": "^8.0",
22+
"phpunit/phpunit": "^11.0",
23+
"larastan/larastan": "^2.2",
24+
"orchestra/testbench": "^9.0"
2525
},
2626
"autoload-dev": {
2727
"psr-4": {

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
includes:
2-
- %currentWorkingDirectory%/vendor/nunomaduro/larastan/extension.neon
2+
- %currentWorkingDirectory%/vendor/larastan/larastan/extension.neon
33

44
parameters:
55

src/Exceptions/JsonApiException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ class JsonApiException extends HttpException implements RenderableError
2424
public function __construct(
2525
int $statusCode = 500,
2626
?string $message = '',
27-
Throwable $previous = null,
27+
?Throwable $previous = null,
2828
?int $code = 0,
29-
iterable $errors = null,
29+
?iterable $errors = null,
3030
) {
3131
parent::__construct($statusCode, (string) $message, $previous, [], (int) $code);
3232

src/Filters/OperatorFilter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ class OperatorFilter implements Filter, QueryBuilderFilter
4949
*/
5050
public function __construct(
5151
string $fieldName,
52-
string $columnName = null,
52+
?string $columnName = null,
5353
string $type = 'string',
54-
array $allowedOperators = null
54+
?array $allowedOperators = null
5555
) {
5656
$this->fieldName = $fieldName;
5757
$this->columnName = $columnName;

src/Resources/JsonApiResourceCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class JsonApiResourceCollection extends ResourceCollection
1414
{
1515
use IncludesGathering;
1616

17-
public function __construct($resource, IncludesBag $included = null)
17+
public function __construct($resource, ?IncludesBag $included = null)
1818
{
1919
$resource = $this->preparePaginationFields($resource);
2020
$this->setIncludesBag($included);

tests/Exceptions/ExceptionHandlerTest.php

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
use Intermax\LaravelJsonApi\Exceptions\JsonApiException;
1717
use Intermax\LaravelJsonApi\Middleware\RenderJsonApiExceptions;
1818
use Orchestra\Testbench\TestCase;
19+
use PHPUnit\Framework\Attributes\Test;
1920
use Symfony\Component\HttpKernel\Exception\HttpException;
20-
use Throwable;
2121

2222
class ExceptionHandlerTest extends TestCase
2323
{
@@ -30,24 +30,15 @@ protected function setUp(): void
3030
$this->request = \request();
3131
}
3232

33-
/**
34-
* @test
35-
*
36-
* @throws BindingResolutionException
37-
*/
33+
#[Test]
3834
public function it_is_registered_when_middleware_is_added()
3935
{
4036
$handler = $this->getHandler();
4137

4238
$this->assertInstanceOf(Handler::class, $handler);
4339
}
4440

45-
/**
46-
* @test
47-
*
48-
* @throws BindingResolutionException
49-
* @throws Throwable
50-
*/
41+
#[Test]
5142
public function it_renders_an_exception_in_json_api_format()
5243
{
5344
$handler = $this->getHandler();
@@ -62,7 +53,7 @@ public function it_renders_an_exception_in_json_api_format()
6253
);
6354
}
6455

65-
/** @test */
56+
#[Test]
6657
public function it_respects_the_status_code_of_the_exception()
6758
{
6859
$response = $this->getHandler()->render($this->request, new HttpException(419));
@@ -73,7 +64,7 @@ public function it_respects_the_status_code_of_the_exception()
7364
);
7465
}
7566

76-
/** @test */
67+
#[Test]
7768
public function it_renders_an_authorization_exception()
7869
{
7970
$response = $this->getHandler()->render(
@@ -89,12 +80,7 @@ public function it_renders_an_authorization_exception()
8980
$this->assertEquals('My authorization exception.', $content->errors[0]->title);
9081
}
9182

92-
/**
93-
* @test
94-
*
95-
* @throws BindingResolutionException
96-
* @throws Throwable
97-
*/
83+
#[Test]
9884
public function it_renders_a_validation_exception_in_json_api_format()
9985
{
10086
$handler = $this->getHandler();
@@ -118,12 +104,7 @@ public function it_renders_a_validation_exception_in_json_api_format()
118104
}
119105
}
120106

121-
/**
122-
* @test
123-
*
124-
* @throws BindingResolutionException
125-
* @throws Throwable
126-
*/
107+
#[Test]
127108
public function it_renders_a_json_api_exception_in_json_api_format()
128109
{
129110
$handler = $this->getHandler();

tests/Filters/OperatorFilterTest.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Intermax\LaravelJsonApi\Filters\OperatorFilter;
88
use Intermax\LaravelJsonApi\Tests\Utilities\User;
99
use Orchestra\Testbench\TestCase;
10+
use PHPUnit\Framework\Attributes\Test;
1011
use Spatie\QueryBuilder\AllowedFilter;
1112
use Spatie\QueryBuilder\QueryBuilder;
1213

@@ -28,7 +29,7 @@ protected function setUp(): void
2829
]);
2930
}
3031

31-
/** @test */
32+
#[Test]
3233
public function it_produces_a_greater_than_query()
3334
{
3435
request()->query->set('filter', [
@@ -37,11 +38,11 @@ public function it_produces_a_greater_than_query()
3738

3839
$query = $this->createQuery('id');
3940

40-
$this->assertEquals('select * from `users` where `id` > ?', $query->toSql());
41+
$this->assertEquals('select * from "users" where "id" > ?', $query->toSql());
4142
$this->assertEquals(2, $query->getBindings()[0]);
4243
}
4344

44-
/** @test */
45+
#[Test]
4546
public function it_produces_an_equals_query()
4647
{
4748
request()->query->set('filter', [
@@ -50,11 +51,11 @@ public function it_produces_an_equals_query()
5051

5152
$query = $this->createQuery('id');
5253

53-
$this->assertEquals('select * from `users` where `id` = ?', $query->toSql());
54+
$this->assertEquals('select * from "users" where "id" = ?', $query->toSql());
5455
$this->assertEquals(3, $query->getBindings()[0]);
5556
}
5657

57-
/** @test */
58+
#[Test]
5859
public function it_produces_a_greater_than_or_equals_query()
5960
{
6061
request()->query->set('filter', [
@@ -63,11 +64,11 @@ public function it_produces_a_greater_than_or_equals_query()
6364

6465
$query = $this->createQuery('id');
6566

66-
$this->assertEquals('select * from `users` where `id` >= ?', $query->toSql());
67+
$this->assertEquals('select * from "users" where "id" >= ?', $query->toSql());
6768
$this->assertEquals(3, $query->getBindings()[0]);
6869
}
6970

70-
/** @test */
71+
#[Test]
7172
public function it_produces_a_lesser_than_or_equals_query()
7273
{
7374
request()->query->set('filter', [
@@ -76,11 +77,11 @@ public function it_produces_a_lesser_than_or_equals_query()
7677

7778
$query = $this->createQuery('id');
7879

79-
$this->assertEquals('select * from `users` where `id` <= ?', $query->toSql());
80+
$this->assertEquals('select * from "users" where "id" <= ?', $query->toSql());
8081
$this->assertEquals(3, $query->getBindings()[0]);
8182
}
8283

83-
/** @test */
84+
#[Test]
8485
public function it_produces_a_lesser_than_query()
8586
{
8687
request()->query->set('filter', [
@@ -89,11 +90,11 @@ public function it_produces_a_lesser_than_query()
8990

9091
$query = $this->createQuery('id');
9192

92-
$this->assertEquals('select * from `users` where `id` < ?', $query->toSql());
93+
$this->assertEquals('select * from "users" where "id" < ?', $query->toSql());
9394
$this->assertEquals(3, $query->getBindings()[0]);
9495
}
9596

96-
/** @test */
97+
#[Test]
9798
public function it_produces_a_not_equal_query()
9899
{
99100
request()->query->set('filter', [
@@ -102,11 +103,11 @@ public function it_produces_a_not_equal_query()
102103

103104
$query = $this->createQuery('id');
104105

105-
$this->assertEquals('select * from `users` where `id` <> ?', $query->toSql());
106+
$this->assertEquals('select * from "users" where "id" <> ?', $query->toSql());
106107
$this->assertEquals(3, $query->getBindings()[0]);
107108
}
108109

109-
/** @test */
110+
#[Test]
110111
public function it_produces_an_in_query()
111112
{
112113
request()->query->set('filter', [
@@ -115,7 +116,7 @@ public function it_produces_an_in_query()
115116

116117
$query = $this->createQuery('id');
117118

118-
$this->assertEquals('select * from `users` where `id` in (?, ?, ?)', $query->toSql());
119+
$this->assertEquals('select * from "users" where "id" in (?, ?, ?)', $query->toSql());
119120
$this->assertCount(3, $query->getBindings());
120121
}
121122

0 commit comments

Comments
 (0)