8000 [Refactor] Drop support for Laravel 5.x and PHP 7.1 · CodingSeo/laravel-json-api@34ae3e7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 34ae3e7

Browse files
committed
[Refactor] Drop support for Laravel 5.x and PHP 7.1
1 parent 3d1daa2 commit 34ae3e7

File tree

9 files changed

+35
-100
lines changed

9 files changed

+35
-100
lines changed

.travis.yml

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,21 @@ language: php
22
dist: trusty
33
sudo: false
44

5+
env:
6+
global:
7+
- PHPUNIT_VERSION=^8.0
8+
59
matrix:
610
include:
7-
- php: "7.1"
8-
env:
9-
- LARAVEL_VERSION=5.5.*
10-
- PHPUNIT_VERSION=^6.5
11-
- php: "7.1"
12-
env:
13-
- LARAVEL_VERSION=5.6.*
14-
- PHPUNIT_VERSION=^7.0
15-
- php: "7.1"
16-
env:
17-
- LARAVEL_VERSION=5.7.*
18-
- PHPUNIT_VERSION=^7.0
1911
- php: "7.2"
2012
env:
21-
- LARAVEL_VERSION=5.5.*
22-
- PHPUNIT_VERSION=^6.5
23-
- php: "7.2"
24-
env:
25-
- LARAVEL_VERSION=5.8.*
26-
- PHPUNIT_VERSION=^7.0
27-
- php: "7.3"
28-
env:
29-
- LARAVEL_VERSION=5.5.*
30-
- PHPUNIT_VERSION=^6.5
31-
- php: "7.3"
32-
env:
33-
- LARAVEL_VERSION=5.8.*
34-
- PHPUNIT_VERSION=^7.0
13+
- LARAVEL_VERSION=^6.0
3514
- php: "7.3"
3615
env:
3716
- LARAVEL_VERSION=^6.0
38-
- PHPUNIT_VERSION=^8.0
39-
- php: "7.4"
40-
env:
41-
- LARAVEL_VERSION=5.8.*
42-
- PHPUNIT_VERSION=^7.0
4317
- php: "7.4"
4418
env:
4519
- LARAVEL_VERSION=^6.0
46-
- PHPUNIT_VERSION=^8.0
4720

4821
install:
4922
- composer require "laravel/framework:${LARAVEL_VERSION}" --no-update -n

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ All notable changes to this project will be documented in this file. This projec
99
Can now use route parameters in the API's URL configuration value.
1010

1111
### Changed
12+
- Minimum PHP version is now `7.2`.
13+
- Minimum Laravel version is now `6.0`.
1214
- Amended the store interface so that it always takes a string resource type and string id,
1315
instead of the deprecated resource identifier object.
1416
- Moved the `Validation\ErrorTranslator` class to `Error\Translator`.
@@ -24,6 +26,8 @@ longer available via the facade):
2426
- `defaultApi()`: set the default API via `LaravelJsonApi::defaultApi()` instead.
2527
- All deprecated methods on the `Testing\MakesJsonApiRequests` trait and `Testing\TestResponse` class
2628
were removed.
29+
- Removed the `Http\Requests\ValidatedRequest::validate()` A935 method, as Laravel replaced it with
30+
`validateResolved()`. This affects all JSON API request classes.
2731
- Additionally, the following deprecated interfaces, classes and traits were removed:
2832
- `Api\ResourceProvider` - extend `Api\AbstractProvider` instead.
2933
- `Contracts\Document\MutableErrorInterface`

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# cloudcreativity/laravel-json-api
44

5-
Build feature-rich and standards-compliant APIs in Laravel.
5+
Build feature-rich and standards-compliant APIs in Laravel.
66

77
This package provides all the capabilities you need to add [JSON API](http://jsonapi.org)
88
compliant APIs to your application. Extensive support for the specification, including:
@@ -21,7 +21,7 @@ compliant APIs to your application. Extensive support for the specification, inc
2121
- Validation of:
2222
- JSON API documents; and
2323
- Query parameters.
24-
24+
2525
The following additional features are also supported:
2626

2727
- Full support for Eloquent resources, with features such as:
@@ -37,11 +37,11 @@ The following additional features are also supported:
3737

3838
From [jsonapi.org](http://jsonapi.org)
3939

40-
> If you've ever argued with your team about the way your JSON responses should be formatted, JSON API is your
40+
> If you've ever argued with your team about the way your JSON responses should be formatted, JSON API is your
4141
anti-bikeshedding weapon.
4242
>
43-
> By following shared conventions, you can increase productivity, take advantage of generalized tooling, and focus
44-
on what matters: your application. Clients built around JSON API are able to take advantage of its features around
43+
> By following shared conventions, you can increase productivity, take advantage of generalized tooling, and focus
44+
on what matters: your application. Clients built around JSON API are able to take advantage of its features around
4545
efficiently caching responses, sometimes eliminating network requests entirely.
4646

4747
For full information on the spec, plus examples, see [http://jsonapi.org](http://jsonapi.org).
@@ -62,13 +62,13 @@ A demo application is available at [here](https://github.com/cloudcreativity/dem
6262

6363
| Laravel | This Package |
6464
| --- | --- |
65-
| `^6.0` | `^1.4` |
65+
| `^6.0` | `^2.0` |
6666
| `5.8.*` | `^1.0` |
6767
| `5.7.*` | `^1.0` |
6868
| `5.6.*` | `^1.0` |
6969
| `5.5.*` | `^1.0` |
7070

71-
Make sure you consult the [Upgrade Guide](http://laravel-json-api.readthedocs.io/en/latest/upgrade/)
71+
Make sure you consult the [Upgrade Guide](http://laravel-json-api.readthedocs.io/en/latest/upgrade/)
7272
when upgrading between major or pre-release versions.
7373

7474
> You may notice that there are `2.0.0-alpha` tags. We **do not** recommend using these versions
@@ -90,7 +90,7 @@ Installation is via `composer`. See the documentation for complete instructions.
9090

9191
## Contributing
9292

93-
Contributions are absolutely welcome. Ideally submit a pull request, even more ideally with unit tests.
93+
Contributions are absolutely welcome. Ideally submit a pull request, even more ideally with unit tests.
9494
Please note the following:
9595

9696
- **Bug Fixes** - submit a pull request against the `master` branch.

composer.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,28 @@
2222
}
2323
],
2424
"require": {
25-
"php": "^7.1",
25+
"php": "^7.2",
2626
"ext-json": "*",
27-
"illuminate/console": "^5.5|^6.0",
28-
"illuminate/contracts": "^5.5|^6.0",
29-
"illuminate/database": "^5.5|^6.0",
30-
"illuminate/filesystem": "^5.5|^6.0",
31-
"illuminate/http": "^5.5|^6.0",
32-
"illuminate/pagination": "^5.5|^6.0",
33-
"illuminate/support": "^5.5|^6.0",
27+
"illuminate/console": "^6.0",
28+
"illuminate/contracts": "^6.0",
29+
"illuminate/database": "^6.0",
30+
"illuminate/filesystem": "^6.0",
31+
"illuminate/http": "^6.0",
32+
"illuminate/pagination": "^6.0",
33+
"illuminate/support": "^6.0",
3434
"neomerx/json-api": "^1.0.3",
3535
"ramsey/uuid": "^3.0",
3636
"symfony/psr-http-message-bridge": "^1.0",
37-
"zendframework/zend-diactoros": "^1.0|^2.0"
37+
"zendframework/zend-diactoros": "^2.0"
3838
},
3939
"require-dev": {
4040
"ext-sqlite3": "*",
41-
"cloudcreativity/json-api-testing": "^1.2|^2.0",
41+
"cloudcreativity/json-api-testing": "^2.0",
4242
"composer/semver": "^1.5",
4343
"guzzlehttp/guzzle": "^6.3",
4444
"mockery/mockery": "^1.1",
45-
"orchestra/testbench": "^3.5|^4.0",
46-
"phpunit/phpunit": "^6.0|^7.0|^8.0"
45+
"orchestra/testbench": "^4.0",
46+
"phpunit/phpunit": "^8.0"
4747
},
4848
"suggest": {
4949
"cloudcreativity/json-api-testing": "Required to use the test helpers."

src/Document/Error/Translator.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -529,10 +529,7 @@ public function call(\Closure $closure, ...$args): ErrorInterface
529529
*/
530530
protected function trans(string $key, string $member, array $replace = [], ?string $locale = null)
531531
{
532-
// Laravel 6.0 changes the interface from `trans` to `get`.
533-
$fn = method_exists($this->translator, 'trans') ? 'trans' : 'get';
534-
535-
return $this->translator->{$fn}(
532+
return $this->translator->get(
536533
"jsonapi::errors.{$key}.{$member}",
537534
$replace,
538535
$locale
@@ -596,10 +593,7 @@ protected function createValidationFailure(string $rule, ?array $options): array
596593
*/
597594
protected function convertRuleName(string $rule): string
598595
{
599-
// Laravel 6.0 changes interface from `trans` to `get`
600-
$fn = method_exists($this->translator, 'trans') ? 'trans' : 'get';
601-
602-
return $this->translator->{$fn}(
596+
return $this->translator->get(
603597
Str::dasherize(class_basename($rule))
604598
);
605599
}

src/Document/ResourceObject.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -671,16 +671,10 @@ public function jsonSerialize()
671671
*/
672672
private function fieldValues(): Collection
673673
{
674-
$fields = collect($this->attributes)->merge($this->getRelations())->merge([
674+
return collect($this->attributes)->merge($this->getRelations())->merge([
675675
'type' => $this->type,
676676
'id' => $this->id,
677-
]);
678-
679-
/** Can use `sortKeys()` on collection when Laravel >= 5.6 */
680-
$all = $fields->all();
681-
ksort($all);
682-
683-
return collect($all);
677+
])->sortKeys();
684678
}
685679

686680
/**

src/Http/Requests/ValidatedRequest.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -221,20 +221,6 @@ public function getEncodingParameters()
221221
);
222222
}
223223

224-
/**
225-
* Validate the JSON API request.
226-
*
227-
* This method maintains compatibility with Laravel 5.5, as the `ValidatesWhenResolved`
228-
* method was renamed to `validateResolved` in 5.6.
229-
*
230-
* @return void
231-
* @todo remove when dropping support for Laravel 5.5.
232-
*/
233-
public function validate()
234-
{
235-
$this->validateResolved();
236-
}
237-
238224
/**
239225
* @inheritdoc
240226
*/

src/Pagination/CreatesPages.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,7 @@ protected function createLastLink(Paginator $paginator, array $params)
140140
return null;
141141
}
142142

143-
/** In older versions of Laravel, last page can return zero for an empty collection. */
144-
if (1 > $last = $paginator->lastPage()) {
145-
$last = 1;
146-
}
147-
148-
return $this->createLink($last, $paginator->perPage(), $params);
143+
return $this->createLink($paginator->lastPage(), $paginator->perPage(), $params);
149144
}
150145

151146
/**
@@ -195,13 +190,8 @@ protected function createMeta(Paginator $paginator)
195190
];
196191

197192
if ($paginator instanceof LengthAwarePaginator) {
198-
/** In older versions of Laravel, last page can return zero for an empty collection. */
199-
if (1 > $last = $paginator->lastPage()) {
200-
$last = 1;
201-
}
202-
203193
$meta[$this->normalizeMetaKey('total')] = $paginator->total();
204-
$meta[$this->normalizeMetaKey('last-page')] = $last;
194+
$meta[$this->normalizeMetaKey('last-page')] = $paginator->lastPage();
205195
}
206196

207197
return $meta;

src/Validation/Validator.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
use CloudCreativity\LaravelJsonApi\Contracts\Validation\ValidatorInterface;
2121
use CloudCreativity\LaravelJsonApi\Document\Error\Translator as ErrorTranslator;
22-
use CloudCreativity\LaravelJsonApi\Exceptions\RuntimeException;
2322
use Illuminate\Contracts\Validation\Validator as ValidatorContract;
2423
use Neomerx\JsonApi\Exceptions\ErrorCollection;
2524

@@ -77,11 +76,6 @@ public function validate()
7776
*/
7877
public function validated()
7978
{
80-
// @TODO remove when only supporting Laravel >=5.8
81-
if (!method_exists($this->validator, 'validated')) {
82-
throw new RuntimeException('Not supported until Laravel 5.8');
83-
}
84-
8579
return $this->validator->validated();
8680
}
8781

0 commit comments

Comments
 (0)
0