Skip to content

Commit

Permalink
style: fix (updated) code style
Browse files Browse the repository at this point in the history
  • Loading branch information
JaZo committed Mar 4, 2024
1 parent 80cf312 commit 9cc96af
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 26 deletions.
6 changes: 3 additions & 3 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 5 additions & 5 deletions src/Concerns/HasRelations.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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();

Expand All @@ -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();

Expand All @@ -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();

Expand Down Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/DocumentClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
16 changes: 8 additions & 8 deletions src/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/ErrorSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/ItemInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down
2 changes: 1 addition & 1 deletion src/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? []);

Expand Down
2 changes: 1 addition & 1 deletion src/ItemHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Jsonapi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Parsers/DocumentParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Parsers/ResponseParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Parsers/ItemParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 9cc96af

Please sign in to comment.