8000 [Feature] Support PHP 8 · positivegroup/laravel-json-api@36cb5ff · GitHub
[go: up one dir, main page]

Skip to content

Commit 36cb5ff

Browse files
committed
[Feature] Support PHP 8
1 parent dc52440 commit 36cb5ff

35 files changed

+111
-93
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22
All notable changes to this project will be documented in this file. This project adheres to
33
[Semantic Versioning](http://semver.org/) and [this changelog format](http://keepachangelog.com/).
44

5+
## Unreleased (4.0)
6+
7+
### Added
8+
9+
- Package now supports PHP 8.
10+
11+
### Changed
12+
13+
- Minimum PHP version is now 7.4 (previously was 7.3).
14+
- Minimum Laravel version is now 8.76. This is needed as we are dependent on all the Laravel PHP 8.1 changes.
15+
- Package now depends on our fork of the Neomerx JSON:API package - `laravel-json-api/neomerx-json-api`. This is a
16+
non-breaking change.
17+
518
## [3.1.0] - 2020-10-28
619

720
### Added

composer.json

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,23 @@
2222
}
2323
],
2424
"require": {
25-
"php": "^7.3",
25+
"php": "^7.4|^8.0",
2626
"ext-json": "*",
27-
"illuminate/console": "^8.0",
28-
"illuminate/contracts": "^8.0",
29-
"illuminate/database": "^8.0",
30-
"illuminate/filesystem": "^8.0",
31-
"illuminate/http": "^8.0",
32-
"illuminate/pagination": "^8.0",
33-
"illuminate/support": "^8.0",
34-
"neomerx/json-api": "^1.0.3",
27+
"laravel-json-api/neomerx-json-api": "^1.1",
28+
"laravel/framework": "^8.76",
3529
"nyholm/psr7": "^1.2",
3630
"ramsey/uuid": "^3.0|^4.0",
3731
"symfony/psr-http-message-bridge": "^2.0"
3832
},
3933
"require-dev": {
4034
"ext-sqlite3": "*",
41-
"cloudcreativity/json-api-testing": "^3.1",
35+
"cloudcreativity/json-api-testing": "^4.0",
4236
"guzzlehttp/guzzle": "^7.0",
4337
"laravel/legacy-factories": "^1.0.4",
44-
"laravel/ui": "^2.0",
38+
"laravel/ui": "^3.0",
4539
"mockery/mockery": "^1.1",
46-
"orchestra/testbench": "^6.0",
47-
"phpunit/phpunit": "^9.0"
40+
"orchestra/testbench": "^6.23",
41+
"phpunit/phpunit": "^9.5.10"
4842
},
4943
"suggest": {
5044
"cloudcreativity/json-api-testing": "Required to use the test helpers."
@@ -78,7 +72,7 @@
7872
}
7973
}
8074
},
81-
"minimum-stability": "stable",
75+
"minimum-stability": "dev",
8276
"prefer-stable": true,
8377
"config": {
8478
"sort-packages": true

phpunit.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
convertErrorsToExceptions="true"
99
convertNoticesToExceptions="true"
1010
convertWarningsToExceptions="true"
11+
convertDeprecationsToExceptions="true"
1112
processIsolation="false"
1213
stopOnError="false"
1314
stopOnFailure="false"
@@ -31,6 +32,8 @@
3132
</testsuite>
3233
</testsuites>
3334
<php>
35+
<ini name="error_reporting" value="E_ALL"/>
36+
<ini name="memory_limit" value="256M"/>
3437
<env name="APP_KEY" value="base64:BMfTqJC1cFk6A/jTPsjQgC+cROx7TDaEeGIAat6CuqY="/>
3538
</php>
3639
</phpunit>

src/Api/ResourceProviders.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function mountAll(RouteRegistrar $api)
7878
/**
7979
* @inheritDoc
8080
*/
81-
public function getIterator()
81+
public function getIterator(): \Generator
8282
{
8383
foreach ($this->providers as $provider) {
8484
yield $provider => $this->factory->createResourceProvider($provider);

src/Codec/DecodingList.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,15 @@ public function all(): array
192192
/**
193193
* @inheritDoc
194194
*/
195-
public function getIterator()
195+
public function getIterator(): \ArrayIterator
196196
{
197197
return new \ArrayIterator($this->stack);
198198
}
199199

200200
/**
201201
* @inheritDoc
202202
*/
203-
public function count()
203+
public function count(): int
204204
{
205205
return count($this->stack);
206206
}

src/Codec/EncodingList.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,15 +242,15 @@ public function all(): array
242242
/**
243243
* @inheritDoc
244244
*/
245-
public function getIterator()
245+
public function getIterator(): \ArrayIterator
246246
{
247247
return new \ArrayIterator($this->stack);
248248
}
249249

250250
/**
251251
* @inheritDoc
252252
*/
253-
public function count()
253+
public function count(): int
254254
{
255255
return count($this->stack);
256256
}

src/Container.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,12 @@ protected function create($className)
495495
* @param $className
496496
* @return bool
497497
*/
498-
protected function exists($className)
498+
protected function exists($className): bool
499499
{
500+
if (null === $className) {
501+
return false;
502+
}
503+
500504
return class_exists($className) || $this->container->bound($className);
501505
}
502506

src/Document/Error/Error.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ public function toArray()
408408
/**
409409
* @inheritDoc
410410
*/
411-
public function jsonSerialize()
411+
public function jsonSerialize(): array
412412
{
413413
return array_filter([
414414
self::ID => $this->getId(),

src/Document/Error/Errors.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function withHeaders(array $headers): self
105105
/**
106106
* @inheritDoc
107107
*/
108-
public function getIterator()
108+
public function getIterator(): ArrayIterator
109109
{
110110
return new ArrayIterator($this->errors);
111111
}
@@ -123,7 +123,7 @@ public function toArray()
123123
/**
124124
* @inheritDoc
125125
*/
126-
public function jsonSerialize()
126+
public function jsonSerialize(): array
127127
{
128128
return [
129129
'errors' => collect($this->errors),

src/Document/ResourceObject.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,30 +149,31 @@ public function __set($field, $value)
149149
* @param $field
150150
* @return bool
151151
*/
152-
public function __isset($field)
152+
public function __isset($field): bool
153153
{
154154
return $this->offsetExists($field);
155155
}
156156

157157
/**
158158
* @param $field
159159
*/
160-
public function __unset($field)
160+
public function __unset($field): void
161161
{
162162
throw new \LogicException('Resource object is immutable.');
163163
}
164164

165165
/**
166166
* @inheritDoc
167167
*/
168-
public function offsetExists($offset)
168+
public function offsetExists($offset): bool
169169
{
170170
return $this->fieldValues->has($offset);
171171
}
172172

173173
/**
174174
* @inheritDoc
175175
*/
176+
#[\ReturnTypeWillChange]
176177
public function offsetGet($offset)
177178
{
178179
return $this->fieldValues->offsetGet($offset);
@@ -181,15 +182,15 @@ public function offsetGet($offset)
181182
/**
182183
* @inheritDoc
183184
*/
184-
public function offsetSet($offset, $value)
185+
public function offsetSet($offset, $value): void
185186
{
186187
throw new \LogicException('Resource object is immutable.');
187188
}
188189

189190
/**
190191
* @inheritDoc
191192
*/
192-
public function offsetUnset($offset)
193+
public function offsetUnset($offset): void
193194
{
194195
throw new \LogicException('Resource object is immutable.');
195196
}
@@ -638,7 +639,7 @@ public function all(): array
638639
/**
639640
* @inheritDoc
640641
*/
641-
public function getIterator()
642+
public function getIterator(): \ArrayIterator
642643
{
643644
return $this->fieldValues->getIterator();
644645
}
@@ -661,7 +662,7 @@ public function toArray()
661662
/**
662663
* @inheritDoc
663664
*/
664-
public function jsonSerialize()
665+
public function jsonSerialize(): array
665666
{
666667
return $this->toArray();
667668
}

0 commit comments

Comments
 (0)
0