From 9cc96af4169f8be3ee3993ca828fab8051ab755c Mon Sep 17 00:00:00 2001 From: Jasper Zonneveld Date: Mon, 4 Mar 2024 16:40:17 +0100 Subject: [PATCH] style: fix (updated) code style --- src/Client.php | 6 +++--- src/Concerns/HasRelations.php | 10 +++++----- src/DocumentClient.php | 2 +- src/Error.php | 16 ++++++++-------- src/ErrorSource.php | 2 +- src/Interfaces/ItemInterface.php | 2 +- src/Item.php | 2 +- src/ItemHydrator.php | 2 +- src/Jsonapi.php | 2 +- src/Link.php | 2 +- src/Parsers/DocumentParser.php | 2 +- src/Parsers/ResponseParser.php | 2 +- tests/Parsers/ItemParserTest.php | 2 +- 13 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/Client.php b/src/Client.php index e45b93a..5e50f7f 100644 --- a/src/Client.php +++ b/src/Client.php @@ -30,9 +30,9 @@ class Client implements ClientInterface ]; public function __construct( - HttpClientInterface $client = null, - RequestFactoryInterface $requestFactory = null, - StreamFactoryInterface $streamFactory = null + ?HttpClientInterface $client = null, + ?RequestFactoryInterface $requestFactory = null, + ?StreamFactoryInterface $streamFactory = null ) { $this->client = $client ?: Psr18ClientDiscovery::find(); $this->requestFactory = $requestFactory ?: Psr17FactoryDiscovery::findRequestFactory(); diff --git a/src/Concerns/HasRelations.php b/src/Concerns/HasRelations.php index f8553a9..2482e9d 100644 --- a/src/Concerns/HasRelations.php +++ b/src/Concerns/HasRelations.php @@ -31,7 +31,7 @@ trait HasRelations * * @return \Swis\JsonApi\Client\Relations\HasOneRelation */ - public function hasOne(string $itemClass, string $name = null): OneRelationInterface + public function hasOne(string $itemClass, ?string $name = null): OneRelationInterface { $name = $name ?: $this->guessRelationName(); @@ -55,7 +55,7 @@ protected function newHasOne(string $type): OneRelationInterface * * @return \Swis\JsonApi\Client\Relations\HasManyRelation */ - public function hasMany(string $itemClass, string $name = null): ManyRelationInterface + public function hasMany(string $itemClass, ?string $name = null): ManyRelationInterface { $name = $name ?: $this->guessRelationName(); @@ -78,7 +78,7 @@ protected function newHasMany(string $type): ManyRelationInterface * * @return \Swis\JsonApi\Client\Relations\MorphToRelation */ - public function morphTo(string $name = null): OneRelationInterface + public function morphTo(?string $name = null): OneRelationInterface { $name = $name ?: $this->guessRelationName(); @@ -101,7 +101,7 @@ protected function newMorphTo(): OneRelationInterface * * @return \Swis\JsonApi\Client\Relations\MorphToManyRelation */ - public function morphToMany(string $name = null): ManyRelationInterface + public function morphToMany(?string $name = null): ManyRelationInterface { $name = $name ?: $this->guessRelationName(); @@ -182,7 +182,7 @@ public function getRelationValue(string $name): ?DataInterface * * @return static */ - public function setRelation(string $relation, $value = false, Links $links = null, Meta $meta = null) + public function setRelation(string $relation, $value = false, ?Links $links = null, ?Meta $meta = null) { $method = Util::stringCamel($relation); if (method_exists($this, $method)) { diff --git a/src/DocumentClient.php b/src/DocumentClient.php index 3c45dab..824ef74 100644 --- a/src/DocumentClient.php +++ b/src/DocumentClient.php @@ -32,7 +32,7 @@ public function __construct(ClientInterface $client, ResponseParserInterface $pa * * @return static */ - public static function create(TypeMapperInterface $typeMapper = null, HttpClientInterface $client = null): self + public static function create(?TypeMapperInterface $typeMapper = null, ?HttpClientInterface $client = null): self { return new static(new Client($client), ResponseParser::create($typeMapper)); } diff --git a/src/Error.php b/src/Error.php index 11ff1d6..d6d2912 100644 --- a/src/Error.php +++ b/src/Error.php @@ -53,14 +53,14 @@ class Error * @param \Swis\JsonApi\Client\Meta|null $meta */ public function __construct( - string $id = null, - Links $links = null, - string $status = null, - string $code = null, - string $title = null, - string $detail = null, - ErrorSource $source = null, - Meta $meta = null + ?string $id = null, + ?Links $links = null, + ?string $status = null, + ?string $code = null, + ?string $title = null, + ?string $detail = null, + ?ErrorSource $source = null, + ?Meta $meta = null ) { $this->id = $id; $this->links = $links; diff --git a/src/ErrorSource.php b/src/ErrorSource.php index 539d73d..bbcf3e6 100644 --- a/src/ErrorSource.php +++ b/src/ErrorSource.php @@ -20,7 +20,7 @@ class ErrorSource * @param string|null $pointer * @param string|null $parameter */ - public function __construct(string $pointer = null, string $parameter = null) + public function __construct(?string $pointer = null, ?string $parameter = null) { $this->pointer = $pointer; $this->parameter = $parameter; diff --git a/src/Interfaces/ItemInterface.php b/src/Interfaces/ItemInterface.php index ffe63e2..d6f86ea 100644 --- a/src/Interfaces/ItemInterface.php +++ b/src/Interfaces/ItemInterface.php @@ -136,7 +136,7 @@ public function getAvailableRelations(): array; * * @return static */ - public function setRelation(string $relation, $value = false, Links $links = null, Meta $meta = null); + public function setRelation(string $relation, $value = false, ?Links $links = null, ?Meta $meta = null); /** * @return \Swis\JsonApi\Client\Interfaces\OneRelationInterface[]|\Swis\JsonApi\Client\Interfaces\ManyRelationInterface[] diff --git a/src/Item.php b/src/Item.php index e112e89..b36b5e2 100644 --- a/src/Item.php +++ b/src/Item.php @@ -196,7 +196,7 @@ public function toArray() * * @return static */ - public function replicate(array $except = null) + public function replicate(?array $except = null) { $attributes = Util::arrayExcept($this->getAttributes(), $except ?? []); diff --git a/src/ItemHydrator.php b/src/ItemHydrator.php index a3dd98a..41f644f 100644 --- a/src/ItemHydrator.php +++ b/src/ItemHydrator.php @@ -38,7 +38,7 @@ public function __construct(TypeMapperInterface $typeMapper) * * @return \Swis\JsonApi\Client\Interfaces\ItemInterface */ - public function hydrate(ItemInterface $item, array $attributes, string $id = null): ItemInterface + public function hydrate(ItemInterface $item, array $attributes, ?string $id = null): ItemInterface { $this->fill($item, $attributes); $this->fillRelations($item, $attributes); diff --git a/src/Jsonapi.php b/src/Jsonapi.php index f41a0af..0e6d552 100644 --- a/src/Jsonapi.php +++ b/src/Jsonapi.php @@ -21,7 +21,7 @@ class Jsonapi implements Arrayable, Jsonable, \JsonSerializable * @param string|null $version * @param \Swis\JsonApi\Client\Meta|null $meta */ - public function __construct(string $version = null, Meta $meta = null) + public function __construct(?string $version = null, ?Meta $meta = null) { $this->version = $version; $this->meta = $meta; diff --git a/src/Link.php b/src/Link.php index c29183e..39125fa 100644 --- a/src/Link.php +++ b/src/Link.php @@ -19,7 +19,7 @@ class Link * @param string $href * @param \Swis\JsonApi\Client\Meta|null $meta */ - public function __construct(string $href, Meta $meta = null) + public function __construct(string $href, ?Meta $meta = null) { $this->href = $href; $this->meta = $meta; diff --git a/src/Parsers/DocumentParser.php b/src/Parsers/DocumentParser.php index 826d3b2..398868f 100644 --- a/src/Parsers/DocumentParser.php +++ b/src/Parsers/DocumentParser.php @@ -52,7 +52,7 @@ public function __construct( * * @return static */ - public static function create(TypeMapperInterface $typeMapper = null): self + public static function create(?TypeMapperInterface $typeMapper = null): self { $metaParser = new MetaParser(); $linksParser = new LinksParser($metaParser); diff --git a/src/Parsers/ResponseParser.php b/src/Parsers/ResponseParser.php index cc80806..029b4a6 100644 --- a/src/Parsers/ResponseParser.php +++ b/src/Parsers/ResponseParser.php @@ -26,7 +26,7 @@ public function __construct(DocumentParserInterface $parser) * * @return static */ - public static function create(TypeMapperInterface $typeMapper = null): self + public static function create(?TypeMapperInterface $typeMapper = null): self { return new static(DocumentParser::create($typeMapper)); } diff --git a/tests/Parsers/ItemParserTest.php b/tests/Parsers/ItemParserTest.php index ecf8a24..2d5b394 100644 --- a/tests/Parsers/ItemParserTest.php +++ b/tests/Parsers/ItemParserTest.php @@ -698,7 +698,7 @@ public function itParsesMetaInRelationshipData() * * @return \Swis\JsonApi\Client\Parsers\ItemParser */ - private function getItemParser(TypeMapperInterface $typeMapper = null): ItemParser + private function getItemParser(?TypeMapperInterface $typeMapper = null): ItemParser { return new ItemParser( $typeMapper ?? $this->getTypeMapperMock(),