Skip to content

Commit

Permalink
Prezise the type of keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Art4 committed Oct 18, 2023
1 parent 01ccd18 commit a46ee52
Show file tree
Hide file tree
Showing 26 changed files with 89 additions and 66 deletions.
8 changes: 5 additions & 3 deletions src/Accessable.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

namespace Art4\JsonApiClient;

use Art4\JsonApiClient\Helper\AccessKey;

/**
* Accessable Interface
*/
Expand All @@ -16,7 +18,7 @@ interface Accessable
/**
* Get a value by a key
*
* @param mixed $key The key
* @param int|string|AccessKey<string> $key The key
*
* @return mixed
*/
Expand All @@ -27,7 +29,7 @@ public function get($key);
*
* @deprecated `\Art4\JsonApiClient\Accessable::has()` will add `bool` as a native return type declaration in v2.0. Do the same in your implementation now to avoid errors.
*
* @param mixed $key The key
* @param int|string|AccessKey<string> $key The key
*
* @return bool
*/
Expand All @@ -39,7 +41,7 @@ public function has($key);
*
* @deprecated `\Art4\JsonApiClient\Accessable::getKeys()` will add `array` as a native return type declaration in v2.0. Do the same in your implementation now to avoid errors.
*
* @return array<string> Keys of all setted values
* @return array<string|int> Keys of all setted values
*/
public function getKeys();
// public function getKeys(): array;
Expand Down
8 changes: 4 additions & 4 deletions src/Helper/AccessableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ final protected function set(string $key, $value): void
/**
* Returns the keys of all setted values
*
* @return array<string> Keys of all setted values
* @return array<int|string> Keys of all setted values
*/
final public function getKeys(): array
{
Expand All @@ -51,7 +51,7 @@ final public function getKeys(): array
/**
* Check if a value exists
*
* @param mixed $key The key
* @param int|string|AccessKey<string> $key The key
*/
final public function has($key): bool
{
Expand Down Expand Up @@ -82,7 +82,7 @@ final public function has($key): bool
/**
* Get a value by a key
*
* @param mixed $key The key
* @param int|string|AccessKey<string> $key The key
*
* @return mixed
*/
Expand Down Expand Up @@ -126,7 +126,7 @@ private function getValue(string $key)
/**
* Parse a dot.notated.key to an object
*
* @param string|AccessKey<string> $key The key
* @param int|string|AccessKey<string> $key The key
*
* @return AccessKey<string> The parsed key
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Serializer/ArraySerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(array $params = [])
/**
* Convert data in an array
*
* @return array<string, mixed>|null
* @return array<int|string, mixed>|null
*/
public function serialize(Accessable $data): ?array
{
Expand Down
6 changes: 4 additions & 2 deletions src/V1/Attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@

namespace Art4\JsonApiClient\V1;

use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Exception\AccessException;
use Art4\JsonApiClient\Exception\ValidationException;
use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Helper\AccessKey;


/**
* Attributes Object
Expand Down Expand Up @@ -50,7 +52,7 @@ protected function parse($object): void
/**
* Get a value by the key of this object
*
* @param string $key The key of the value
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
Expand Down
5 changes: 3 additions & 2 deletions src/V1/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
namespace Art4\JsonApiClient\V1;

use Art4\JsonApiClient\Accessable;
use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Exception\AccessException;
use Art4\JsonApiClient\Exception\ValidationException;
use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Helper\AccessKey;

/**
* Document Top Level Object
Expand Down Expand Up @@ -73,7 +74,7 @@ protected function parse($object): void
/**
* Get a value by the key of this object
*
* @param string $key The key of the value
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
Expand Down
5 changes: 3 additions & 2 deletions src/V1/DocumentLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

namespace Art4\JsonApiClient\V1;

use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Exception\AccessException;
use Art4\JsonApiClient\Exception\ValidationException;
use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Helper\AccessKey;

/**
* Document Link Object
Expand Down Expand Up @@ -103,7 +104,7 @@ protected function parse($object): void
/**
* Get a value by the key of this object
*
* @param string $key The key of the value
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
Expand Down
5 changes: 3 additions & 2 deletions src/V1/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

namespace Art4\JsonApiClient\V1;

use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Exception\AccessException;
use Art4\JsonApiClient\Exception\ValidationException;
use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Helper\AccessKey;

/**
* Error Object
Expand Down Expand Up @@ -105,7 +106,7 @@ protected function parse($object): void
/**
* Get a value by the key of this object
*
* @param string $key The key of the value
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
Expand Down
5 changes: 3 additions & 2 deletions src/V1/ErrorCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

namespace Art4\JsonApiClient\V1;

use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Exception\AccessException;
use Art4\JsonApiClient\Exception\ValidationException;
use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Helper\AccessKey;

/**
* Error Collection Object
Expand Down Expand Up @@ -44,7 +45,7 @@ protected function parse($object): void
/**
* Get a value by the key of this document
*
* @param string $key The key of the value
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
Expand Down
5 changes: 3 additions & 2 deletions src/V1/ErrorLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

namespace Art4\JsonApiClient\V1;

use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Exception\AccessException;
use Art4\JsonApiClient\Exception\ValidationException;
use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Helper\AccessKey;

/**
* Error Link Object
Expand Down Expand Up @@ -63,7 +64,7 @@ protected function parse($object): void
/**
* Get a value by the key of this object
*
* @param string $key The key of the value
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
Expand Down
5 changes: 3 additions & 2 deletions src/V1/ErrorSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

namespace Art4\JsonApiClient\V1;

use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Exception\AccessException;
use Art4\JsonApiClient\Exception\ValidationException;
use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Helper\AccessKey;

/**
* Error Source Object
Expand Down Expand Up @@ -52,7 +53,7 @@ protected function parse($object): void
/**
* Get a value by the key of this document
*
* @param string $key The key of the value
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
Expand Down
5 changes: 3 additions & 2 deletions src/V1/Jsonapi.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

namespace Art4\JsonApiClient\V1;

use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Exception\AccessException;
use Art4\JsonApiClient\Exception\ValidationException;
use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Helper\AccessKey;

/**
* JSON API Object
Expand Down Expand Up @@ -48,7 +49,7 @@ protected function parse($object): void
/**
* Get a value by the key of this object
*
* @param string $key The key of the value
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
Expand Down
5 changes: 3 additions & 2 deletions src/V1/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

namespace Art4\JsonApiClient\V1;

use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Exception\AccessException;
use Art4\JsonApiClient\Exception\ValidationException;
use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Helper\AccessKey;

/**
* Link Object
Expand Down Expand Up @@ -44,7 +45,7 @@ protected function parse($object): void
/**
* Get a value by the key of this object
*
* @param string $key The key of the value
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
Expand Down
5 changes: 3 additions & 2 deletions src/V1/Meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

namespace Art4\JsonApiClient\V1;

use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Exception\AccessException;
use Art4\JsonApiClient\Exception\ValidationException;
use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Helper\AccessKey;

/**
* Meta Object
Expand Down Expand Up @@ -46,7 +47,7 @@ protected function parse($object): void
/**
* Get a value by the key of this object
*
* @param string $key The key of the value
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
Expand Down
5 changes: 3 additions & 2 deletions src/V1/Relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

namespace Art4\JsonApiClient\V1;

use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Exception\AccessException;
use Art4\JsonApiClient\Exception\ValidationException;
use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Helper\AccessKey;

/**
* Resource Identifier Object
Expand Down Expand Up @@ -59,7 +60,7 @@ protected function parse($object): void
/**
* Get a value by the key of this object
*
* @param string $key The key of the value
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
Expand Down
5 changes: 3 additions & 2 deletions src/V1/RelationshipCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

namespace Art4\JsonApiClient\V1;

use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Exception\AccessException;
use Art4\JsonApiClient\Exception\ValidationException;
use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Helper\AccessKey;

/**
* Relationship Collection Object
Expand Down Expand Up @@ -54,7 +55,7 @@ protected function parse($object): void
/**
* Get a value by the key of this object
*
* @param string $key The key of the value
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
Expand Down
3 changes: 2 additions & 1 deletion src/V1/RelationshipLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Art4\JsonApiClient\Exception\AccessException;
use Art4\JsonApiClient\Exception\ValidationException;
use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Helper\AccessKey;

/**
* Relationship Link Object
Expand Down Expand Up @@ -105,7 +106,7 @@ protected function parse($object): void
/**
* Get a value by the key of this object
*
* @param string $key The key of the value
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
Expand Down
5 changes: 3 additions & 2 deletions src/V1/ResourceCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
namespace Art4\JsonApiClient\V1;

use Art4\JsonApiClient\Accessable;
use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Exception\AccessException;
use Art4\JsonApiClient\Exception\ValidationException;
use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Helper\AccessKey;

/**
* Resource Object
Expand Down Expand Up @@ -47,7 +48,7 @@ protected function parse($object): void
/**
* Get a value by the key of this object
*
* @param string $key The key of the value
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
Expand Down
5 changes: 3 additions & 2 deletions src/V1/ResourceIdentifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

namespace Art4\JsonApiClient\V1;

use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Exception\AccessException;
use Art4\JsonApiClient\Exception\ValidationException;
use Art4\JsonApiClient\Helper\AbstractElement;
use Art4\JsonApiClient\Helper\AccessKey;

/**
* Resource Identifier Object
Expand Down Expand Up @@ -59,7 +60,7 @@ protected function parse($object): void
/**
* Get a value by the key of this object
*
* @param string $key The key of the value
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
Expand Down
Loading

0 comments on commit a46ee52

Please sign in to comment.