Skip to content

Commit 3572d96

Browse files
committed
feat: support php 8.4 by removing deprecation notices
1 parent 8eb7a37 commit 3572d96

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+112
-101
lines changed

.github/workflows/tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
fail-fast: true
1616
matrix:
17-
php: [8.2, 8.3]
17+
php: [8.2, 8.3, 8.4]
1818
laravel: [11]
1919

2020
steps:

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. This projec
55

66
## Unreleased
77

8+
### Changed
9+
10+
- Removed PHP 8.4 deprecation notices.
11+
812
## [7.0.0] - 2024-03-14
913

1014
### Changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"require": {
2525
"php": "^8.2",
2626
"ext-json": "*",
27-
"laravel-json-api/neomerx-json-api": "^5.0.2",
27+
"laravel-json-api/neomerx-json-api": "^5.0.3",
2828
"laravel/framework": "^11.0",
2929
"nyholm/psr7": "^1.8",
3030
"ramsey/uuid": "^4.0",

src/Api/Repository.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function exists($apiName)
7272
* route parameters, if needed.
7373
* @return Api
7474
*/
75-
public function createApi(string $apiName, string $host = null, array $parameters = [])
75+
public function createApi(string $apiName, ?string $host = null, array $parameters = [])
7676
{
7777
$config = $this->configFor($apiName);
7878
$config = $this->normalize($config, $host);

src/Broadcasting/BroadcastsData.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ protected function broadcastEncoder()
5151
* @param array|null $fieldsets
5252
* @return array
5353
*/
54-
protected function serializeData($data, $includePaths = null, array $fieldsets = null)
54+
protected function serializeData($data, $includePaths = null, ?array $fieldsets = null)
5555
{
5656
$params = new QueryParameters($includePaths ? (array) $includePaths : null, $fieldsets);
5757

src/Client/AbstractClient.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ abstract class AbstractClient implements ClientInterface
7272
abstract protected function request(
7373
$method,
7474
$uri,
75-
array $payload = null,
75+
?array $payload = null,
7676
array $parameters = []
7777
);
7878

src/Client/GuzzleClient.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function __construct(
6060
protected function request(
6161
$method,
6262
$uri,
63-
array $payload = null,
63+
?array $payload = null,
6464
array $parameters = []
6565
) {
6666
$request = new Request($method, $uri);

src/Codec/Encoding.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Encoding
5454
public static function create(
5555
$mediaType,
5656
int $options = 0,
57-
string $urlPrefix = null,
57+
?string $urlPrefix = null,
5858
int $depth = 512
5959
): self
6060
{
@@ -73,7 +73,7 @@ public static function create(
7373
* @param int $depth
7474
* @return Encoding
7575
*/
76-
public static function jsonApi(int $options = 0, string $urlPrefix = null, int $depth = 512): self
76+
public static function jsonApi(int $options = 0, ?string $urlPrefix = null, int $depth = 512): self
7777
{
7878
return self::create(
7979
MediaTypeInterface::JSON_API_MEDIA_TYPE,
@@ -104,7 +104,7 @@ public static function custom($mediaType): self
104104
* @param string|null $urlPrefix
105105
* @return Encoding
106106
*/
107-
public static function fromArray($key, $value, string $urlPrefix = null): self
107+
public static function fromArray($key, $value, ?string $urlPrefix = null): self
108108
{
109109
if (is_numeric($key)) {
110110
$key = $value;

src/Codec/EncodingList.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class EncodingList implements IteratorAggregate, Countable
4747
* @param string|null $urlPrefix
4848
* @return EncodingList
4949
*/
50-
public static function fromArray(iterable $config, string $urlPrefix = null): self
50+
public static function fromArray(iterable $config, ?string $urlPrefix = null): self
5151
{
5252
$values = Collection::make($config)
5353
->map(fn($value, $key) => Encoding::fromArray($key, $value, $urlPrefix))

src/Container.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ protected function getCreatedAdapter($resourceType)
379379
* @param ResourceAdapterInterface|null $adapter
380380
* @return void
381381
*/
382-
protected function setCreatedAdapter($resourceType, ResourceAdapterInterface $adapter = null)
382+
protected function setCreatedAdapter($resourceType, ?ResourceAdapterInterface $adapter = null)
383383
{
384384
$this->createdAdapters[$resourceType] = $adapter;
385385
}
@@ -467,7 +467,7 @@ protected function getCreatedAuthorizer($resourceType)
467467
* @param AuthorizerInterface|null $authorizer
468468
* @return void
469469
*/
470-
protected function setCreatedAuthorizer($resourceType, AuthorizerInterface $authorizer = null)
470+
protected function setCreatedAuthorizer($resourceType, ?AuthorizerInterface $authorizer = null)
471471
{
472472
$this->createdAuthorizers[$resourceType] = $authorizer;
473473
}

src/Contracts/Schema/SchemaProviderInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function getRelationships(object $resource, bool $isPrimary, array $inclu
7878
* @param object|null $resource
7979
* @return string
8080
*/
81-
public function getSelfSubUrl(object $resource = null): string;
81+
public function getSelfSubUrl(?object $resource = null): string;
8282

8383
/**
8484
* Get the resource self sub link.

src/Document/Error/Error.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,12 @@ public static function fromArray(array $input): self
134134
public function __construct(
135135
$id = null,
136136
$status = null,
137-
string $code = null,
138-
string $title = null,
139-
string $detail = null,
140-
iterable $source = null,
141-
iterable $links = null,
142-
iterable $meta = null
137+
?string $code = null,
138+
?string $title = null,
139+
?string $detail = null,
140+
?iterable $source = null,
141+
?iterable $links = null,
142+
?iterable $meta = null
143143
)
144144
{
145145
$this->setId($id);

src/Document/Error/Translator.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
namespace CloudCreativity\LaravelJsonApi\Document\Error;
1919

20+
use Closure;
2021
use CloudCreativity\LaravelJsonApi\Exceptions\ValidationException;
2122
use CloudCreativity\LaravelJsonApi\LaravelJsonApi;
2223
use CloudCreativity\LaravelJsonApi\Utils\Str;
@@ -402,7 +403,7 @@ public function resourceFieldExistsInAttributesAndRelationships(
402403
* @param string|null $detail
403404
* @return ErrorInterface
404405
*/
405-
public function resourceCannotBeDeleted(string $detail = null): ErrorInterface
406+
public function resourceCannotBeDeleted(?string $detail = null): ErrorInterface
406407
{
407408
return new NeomerxError(
408409
null,
@@ -475,11 +476,11 @@ public function invalidQueryParameter(string $param, ?string $detail = null, arr
475476
* Create errors for a failed validator.
476477
*
477478
* @param ValidatorContract $validator
478-
* @param \Closure|null $closure
479+
* @param Closure|null $closure
479480
* a closure that is bound to the translator.
480481
* @return ErrorCollection
481482
*/
482-
public function failedValidator(ValidatorContract $validator, \Closure $closure = null): ErrorCollection
483+
public function failedValidator(ValidatorContract $validator, ?Closure $closure = null): ErrorCollection
483484
{
484485
$failed = $this->doesIncludeFailed() ? $validator->failed() : [];
485486
$errors = new ErrorCollection();
@@ -513,12 +514,12 @@ public function failedValidator(ValidatorContract $validator, \Closure $closure
513514
* Create a JSON API exception for a failed validator.
514515
*
515516
* @param ValidatorContract $validator
516-
* @param \Closure|null $closure
517+
* @param Closure|null $closure
517518
* @return JsonApiException
518519
*/
519520
public function failedValidatorException(
520521
ValidatorContract $validator,
521-
\Closure $closure = null
522+
?Closure $closure = null
522523
): JsonApiException
523524
{
524525
return new ValidationException(
@@ -529,11 +530,11 @@ public function failedValidatorException(
529530
/**
530531
* Create an error by calling the closure with it bound to the error translator.
531532
*
532-
* @param \Closure $closure
533+
* @param Closure $closure
533534
* @param mixed ...$args
534535
* @return ErrorInterface
535536
*/
536-
public function call(\Closure $closure, ...$args): ErrorInterface
537+
public function call(Closure $closure, ...$args): ErrorInterface
537538
{
538539
return $closure->call($this, ...$args);
539540
}

src/Eloquent/AbstractAdapter.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
namespace CloudCreativity\LaravelJsonApi\Eloquent;
1919

20+
use Closure;
2021
use CloudCreativity\LaravelJsonApi\Adapter\AbstractResourceAdapter;
2122
use CloudCreativity\LaravelJsonApi\Contracts\Adapter\HasManyAdapterInterface;
2223
use CloudCreativity\LaravelJsonApi\Contracts\Adapter\RelationshipAdapterInterface;
@@ -115,7 +116,7 @@ abstract protected function filter($query, Collection $filters);
115116
* @param Model $model
116117
* @param PagingStrategyInterface|null $paging
117118
*/
118-
public function __construct(Model $model, PagingStrategyInterface $paging = null)
119+
public function __construct(Model $model, ?PagingStrategyInterface $paging = null)
119120
{
120121
$this->model = $model;
121122
$this->paging = $paging;
@@ -259,11 +260,11 @@ public function addScopes(Scope ...$scopes): self
259260
/**
260261
* Add a global scope using a closure.
261262
*
262-
* @param \Closure $scope
263+
* @param Closure $scope
263264
* @param string|null $identifier
264265
* @return $this
265266
*/
266-
public function addClosureScope(\Closure $scope, string $identifier = null): self
267+
public function addClosureScope(Closure $scope, ?string $identifier = null): self
267268
{
268269
$identifier = $identifier ?: spl_object_hash($scope);
269270

@@ -616,20 +617,20 @@ protected function morphMany(HasManyAdapterInterface ...$adapters)
616617
}
617618

618619
/**
619-
* @param \Closure $factory
620+
* @param Closure $factory
620621
* a factory that creates a new Eloquent query builder.
621622
* @return QueriesMany
622623
*/
623-
protected function queriesMany(\Closure $factory)
624+
protected function queriesMany(Closure $factory)
624625
{
625626
return new QueriesMany($factory);
626627
}
627628

628629
/**
629-
* @param \Closure $factory
630+
* @param Closure $factory
630631
* @return QueriesOne
631632
*/
632-
protected function queriesOne(\Closure $factory)
633+
protected function queriesOne(Closure $factory)
633634
{
634635
return new QueriesOne($factory);
635636
}

src/Encoder/EncoderOptions.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class EncoderOptions
4343
* @param string|null $urlPrefix
4444
* @param int $depth
4545
*/
46-
public function __construct(int $options = 0, string $urlPrefix = null, int $depth = 512)
46+
public function __construct(int $options = 0, ?string $urlPrefix = null, int $depth = 512)
4747
{
4848
$this->options = $options;
4949
$this->depth = $depth;

src/Exceptions/ClientException.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
namespace CloudCreativity\LaravelJsonApi\Exceptions;
1919

20+
use Exception;
2021
use Illuminate\Support\Collection;
2122
use Psr\Http\Message\RequestInterface;
2223
use Psr\Http\Message\ResponseInterface;
@@ -50,12 +51,12 @@ class ClientException extends \RuntimeException
5051
*
5152
* @param RequestInterface $request
5253
* @param ResponseInterface|null $response
53-
* @param \Exception|null $previous
54+
* @param Exception|null $previous
5455
*/
5556
public function __construct(
5657
RequestInterface $request,
57-
ResponseInterface $response = null,
58-
\Exception $previous = null
58+
?ResponseInterface $response = null,
59+
?Exception $previous = null
5960
) {
6061
parent::__construct(
6162
$previous ? $previous->getMessage() : 'Client encountered an error.',
@@ -104,7 +105,7 @@ public function getErrors()
104105

105106
try {
106107
$this->errors = $this->parse();
107-
} catch (\Exception $ex) {
108+
} catch (Exception $ex) {
108109
$this->errors = [];
109110
}
110111

src/Exceptions/DocumentRequiredException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class DocumentRequiredException extends InvalidJsonException
3535
*
3636
* @param Exception|null $previous
3737
*/
38-
public function __construct(Exception $previous = null)
38+
public function __construct(?Exception $previous = null)
3939
{
4040
parent::__construct(
4141
null,

src/Exceptions/InvalidJsonException.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class InvalidJsonException extends JsonApiException
4444
* @param Exception|null $previous
4545
* @return InvalidJsonException
4646
*/
47-
public static function create($defaultHttpCode = self::HTTP_CODE_BAD_REQUEST, Exception $previous = null)
47+
public static function create($defaultHttpCode = self::HTTP_CODE_BAD_REQUEST, ?Exception $previous = null)
4848
{
4949
return new self(json_last_error(), json_last_error_msg(), $defaultHttpCode, $previous);
5050
}
@@ -61,7 +61,7 @@ public function __construct(
6161
$jsonError = null,
6262
$jsonErrorMessage = null,
6363
$defaultHttpCode = self::HTTP_CODE_BAD_REQUEST,
64-
Exception $previous = null
64+
?Exception $previous = null
6565
) {
6666
parent::__construct([], $defaultHttpCode, $previous);
6767

src/Exceptions/JsonApiException.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class JsonApiException extends Exception implements HttpExceptionInterface, Resp
4646
* @param Throwable|null $previous
4747
* @return static
4848
*/
49-
public static function make($errors, Throwable $previous = null): self
49+
public static function make($errors, ?Throwable $previous = null): self
5050
{
5151
return new self($errors, $previous);
5252
}
@@ -58,7 +58,7 @@ public static function make($errors, Throwable $previous = null): self
5858
* @param Throwable|null $previous
5959
* @param array $headers
6060
*/
61-
public function __construct($errors, Throwable $previous = null, array $headers = [])
61+
public function __construct($errors, ?Throwable $previous = null, array $headers = [])
6262
{
6363
parent::__construct('JSON API error', 0, $previous);
6464
$this->errors = Errors::cast($errors);

src/Exceptions/ResourceNotFoundException.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
namespace CloudCreativity\LaravelJsonApi\Exceptions;
1919

20+
use Exception;
2021
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
2122

2223
class ResourceNotFoundException extends NotFoundHttpException
@@ -37,14 +38,14 @@ class ResourceNotFoundException extends NotFoundHttpException
3738
*
3839
* @param string $type
3940
* @param string $id
40-
* @param \Exception|null $previous
41+
* @param Exception|null $previous
4142
* @param int $code
4243
* @param array $headers
4344
*/
4445
public function __construct(
4546
string $type,
4647
string $id,
47-
\Exception $previous = null,
48+
?Exception $previous = null,
4849
int $code = 0,
4950
array $headers = []
5051
) {

src/Exceptions/ValidationException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static function create(ValidatorInterface $validator): self
5959
* @param string|int|null $defaultHttpCode
6060
* @param Exception|null $previous
6161
*/
62-
public function __construct($errors, $defaultHttpCode = self::DEFAULT_HTTP_CODE, Exception $previous = null)
62+
public function __construct($errors, $defaultHttpCode = self::DEFAULT_HTTP_CODE, ?Exception $previous = null)
6363
{
6464
parent::__construct(
6565
$errors,

0 commit comments

Comments
 (0)