Skip to content

Commit 8edb5df

Browse files
committed
Replaced implicit nullable parameters with nullable types
Implicit nullable parameters are deprecated in PHP 8.4 See eosnewmedia#28
1 parent b68f75e commit 8edb5df

12 files changed

+17
-17
lines changed

src/Exception/HttpException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class HttpException extends JsonApiException
2020
* @param int $code
2121
* @param \Throwable|null $previous
2222
*/
23-
public function __construct(int $statusCode, string $message = '', $code = 0, \Throwable $previous = null)
23+
public function __construct(int $statusCode, string $message = '', $code = 0, ?\Throwable $previous = null)
2424
{
2525
$this->statusCode = $statusCode;
2626
parent::__construct($message, $code, $previous);

src/JsonApiTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ protected function resource(string $type, string $id): ResourceInterface
2929
* @param ResourceInterface|null $resource
3030
* @return DocumentInterface
3131
*/
32-
protected function singleResourceDocument(ResourceInterface $resource = null): DocumentInterface
32+
protected function singleResourceDocument(?ResourceInterface $resource = null): DocumentInterface
3333
{
3434
return new Document($resource);
3535
}
@@ -48,7 +48,7 @@ protected function multiResourceDocument(array $resource = []): DocumentInterfac
4848
* @param ResourceInterface|null $related
4949
* @return RelationshipInterface
5050
*/
51-
protected function toOneRelationship(string $name, ResourceInterface $related = null): RelationshipInterface
51+
protected function toOneRelationship(string $name, ?ResourceInterface $related = null): RelationshipInterface
5252
{
5353
return new Relationship($name, $related);
5454
}

src/Model/Request/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ public function hasFilter(string $name): bool
466466
* @param string|null $explodeBy
467467
* @return array|string|int|float
468468
*/
469-
public function filterValue(string $name, string $explodeBy = null)
469+
public function filterValue(string $name, ?string $explodeBy = null)
470470
{
471471
if ($explodeBy) {
472472
return explode($explodeBy, $this->filter[$name]);

src/Model/Request/RequestInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function hasFilter(string $name): bool;
117117
* @param string|null $explodeBy
118118
* @return array|string|int|float
119119
*/
120-
public function filterValue(string $name, string $explodeBy = null);
120+
public function filterValue(string $name, ?string $explodeBy = null);
121121

122122
/**
123123
* Define a sort parameter. This method will manipulate the uri of the request.

src/Model/Resource/JsonResource.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ public function metaInformation(): KeyValueCollectionInterface
123123
* Creates a new resource containing all data from the current one.
124124
* If set, the new request will have the given id.
125125
*
126-
* @param string $id
126+
* @param string|null $id
127127
* @return ResourceInterface
128128
* @throws \InvalidArgumentException
129129
*/
130-
public function duplicate(string $id = null): ResourceInterface
130+
public function duplicate(?string $id = null): ResourceInterface
131131
{
132132
$resource = new self($this->type(), $id ?? $this->id(), $this->attributes()->all());
133133

src/Model/Resource/Link/Link.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function metaInformation(): KeyValueCollectionInterface
7777
* @return LinkInterface
7878
* @throws \InvalidArgumentException
7979
*/
80-
public function duplicate(string $name = null): LinkInterface
80+
public function duplicate(?string $name = null): LinkInterface
8181
{
8282
$link = new self($name ?? $this->name(), $this->href());
8383
$link->metaInformation()->mergeCollection($this->metaInformation());

src/Model/Resource/Link/LinkInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ public function metaInformation(): KeyValueCollectionInterface;
3232
* @param string|null $name
3333
* @return LinkInterface
3434
*/
35-
public function duplicate(string $name = null): LinkInterface;
35+
public function duplicate(?string $name = null): LinkInterface;
3636
}

src/Model/Resource/Relationship/Relationship.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function related(): ResourceCollectionInterface
115115
* @return RelationshipInterface
116116
* @throws \InvalidArgumentException
117117
*/
118-
public function duplicate(string $name = null): RelationshipInterface
118+
public function duplicate(?string $name = null): RelationshipInterface
119119
{
120120
if ($this->shouldBeHandledAsCollection()) {
121121
$related = [];

src/Model/Resource/Relationship/RelationshipInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ public function metaInformation(): KeyValueCollectionInterface;
4646
* @param string|null $name
4747
* @return RelationshipInterface
4848
*/
49-
public function duplicate(string $name = null): RelationshipInterface;
49+
public function duplicate(?string $name = null): RelationshipInterface;
5050
}

src/Model/Resource/ResourceCollection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ public function get(string $type, string $id): ResourceInterface
6060
}
6161

6262
/**
63-
* @param string $type
63+
* @param string|null $type
6464
* @return ResourceInterface
6565
* @throws \LogicException
6666
*/
67-
public function first(string $type = null): ResourceInterface
67+
public function first(?string $type = null): ResourceInterface
6868
{
6969
if ($this->isEmpty()) {
7070
throw new \LogicException('Collection does not contain any resources!');

0 commit comments

Comments
 (0)