Skip to content

Commit a46ee52

Browse files
committed
Prezise the type of keys
1 parent 01ccd18 commit a46ee52

26 files changed

+89
-66
lines changed

src/Accessable.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
namespace Art4\JsonApiClient;
1010

11+
use Art4\JsonApiClient\Helper\AccessKey;
12+
1113
/**
1214
* Accessable Interface
1315
*/
@@ -16,7 +18,7 @@ interface Accessable
1618
/**
1719
* Get a value by a key
1820
*
19-
* @param mixed $key The key
21+
* @param int|string|AccessKey<string> $key The key
2022
*
2123
* @return mixed
2224
*/
@@ -27,7 +29,7 @@ public function get($key);
2729
*
2830
* @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.
2931
*
30-
* @param mixed $key The key
32+
* @param int|string|AccessKey<string> $key The key
3133
*
3234
* @return bool
3335
*/
@@ -39,7 +41,7 @@ public function has($key);
3941
*
4042
* @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.
4143
*
42-
* @return array<string> Keys of all setted values
44+
* @return array<string|int> Keys of all setted values
4345
*/
4446
public function getKeys();
4547
// public function getKeys(): array;

src/Helper/AccessableTrait.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ final protected function set(string $key, $value): void
4141
/**
4242
* Returns the keys of all setted values
4343
*
44-
* @return array<string> Keys of all setted values
44+
* @return array<int|string> Keys of all setted values
4545
*/
4646
final public function getKeys(): array
4747
{
@@ -51,7 +51,7 @@ final public function getKeys(): array
5151
/**
5252
* Check if a value exists
5353
*
54-
* @param mixed $key The key
54+
* @param int|string|AccessKey<string> $key The key
5555
*/
5656
final public function has($key): bool
5757
{
@@ -82,7 +82,7 @@ final public function has($key): bool
8282
/**
8383
* Get a value by a key
8484
*
85-
* @param mixed $key The key
85+
* @param int|string|AccessKey<string> $key The key
8686
*
8787
* @return mixed
8888
*/
@@ -126,7 +126,7 @@ private function getValue(string $key)
126126
/**
127127
* Parse a dot.notated.key to an object
128128
*
129-
* @param string|AccessKey<string> $key The key
129+
* @param int|string|AccessKey<string> $key The key
130130
*
131131
* @return AccessKey<string> The parsed key
132132
*/

src/Serializer/ArraySerializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __construct(array $params = [])
3535
/**
3636
* Convert data in an array
3737
*
38-
* @return array<string, mixed>|null
38+
* @return array<int|string, mixed>|null
3939
*/
4040
public function serialize(Accessable $data): ?array
4141
{

src/V1/Attributes.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88

99
namespace Art4\JsonApiClient\V1;
1010

11-
use Art4\JsonApiClient\Helper\AbstractElement;
1211
use Art4\JsonApiClient\Exception\AccessException;
1312
use Art4\JsonApiClient\Exception\ValidationException;
13+
use Art4\JsonApiClient\Helper\AbstractElement;
14+
use Art4\JsonApiClient\Helper\AccessKey;
15+
1416

1517
/**
1618
* Attributes Object
@@ -50,7 +52,7 @@ protected function parse($object): void
5052
/**
5153
* Get a value by the key of this object
5254
*
53-
* @param string $key The key of the value
55+
* @param int|string|AccessKey<string> $key The key of the value
5456
*
5557
* @return mixed The value
5658
*/

src/V1/Document.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
namespace Art4\JsonApiClient\V1;
1010

1111
use Art4\JsonApiClient\Accessable;
12-
use Art4\JsonApiClient\Helper\AbstractElement;
1312
use Art4\JsonApiClient\Exception\AccessException;
1413
use Art4\JsonApiClient\Exception\ValidationException;
14+
use Art4\JsonApiClient\Helper\AbstractElement;
15+
use Art4\JsonApiClient\Helper\AccessKey;
1516

1617
/**
1718
* Document Top Level Object
@@ -73,7 +74,7 @@ protected function parse($object): void
7374
/**
7475
* Get a value by the key of this object
7576
*
76-
* @param string $key The key of the value
77+
* @param int|string|AccessKey<string> $key The key of the value
7778
*
7879
* @return mixed The value
7980
*/

src/V1/DocumentLink.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88

99
namespace Art4\JsonApiClient\V1;
1010

11-
use Art4\JsonApiClient\Helper\AbstractElement;
1211
use Art4\JsonApiClient\Exception\AccessException;
1312
use Art4\JsonApiClient\Exception\ValidationException;
13+
use Art4\JsonApiClient\Helper\AbstractElement;
14+
use Art4\JsonApiClient\Helper\AccessKey;
1415

1516
/**
1617
* Document Link Object
@@ -103,7 +104,7 @@ protected function parse($object): void
103104
/**
104105
* Get a value by the key of this object
105106
*
106-
* @param string $key The key of the value
107+
* @param int|string|AccessKey<string> $key The key of the value
107108
*
108109
* @return mixed The value
109110
*/

src/V1/Error.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88

99
namespace Art4\JsonApiClient\V1;
1010

11-
use Art4\JsonApiClient\Helper\AbstractElement;
1211
use Art4\JsonApiClient\Exception\AccessException;
1312
use Art4\JsonApiClient\Exception\ValidationException;
13+
use Art4\JsonApiClient\Helper\AbstractElement;
14+
use Art4\JsonApiClient\Helper\AccessKey;
1415

1516
/**
1617
* Error Object
@@ -105,7 +106,7 @@ protected function parse($object): void
105106
/**
106107
* Get a value by the key of this object
107108
*
108-
* @param string $key The key of the value
109+
* @param int|string|AccessKey<string> $key The key of the value
109110
*
110111
* @return mixed The value
111112
*/

src/V1/ErrorCollection.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88

99
namespace Art4\JsonApiClient\V1;
1010

11-
use Art4\JsonApiClient\Helper\AbstractElement;
1211
use Art4\JsonApiClient\Exception\AccessException;
1312
use Art4\JsonApiClient\Exception\ValidationException;
13+
use Art4\JsonApiClient\Helper\AbstractElement;
14+
use Art4\JsonApiClient\Helper\AccessKey;
1415

1516
/**
1617
* Error Collection Object
@@ -44,7 +45,7 @@ protected function parse($object): void
4445
/**
4546
* Get a value by the key of this document
4647
*
47-
* @param string $key The key of the value
48+
* @param int|string|AccessKey<string> $key The key of the value
4849
*
4950
* @return mixed The value
5051
*/

src/V1/ErrorLink.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88

99
namespace Art4\JsonApiClient\V1;
1010

11-
use Art4\JsonApiClient\Helper\AbstractElement;
1211
use Art4\JsonApiClient\Exception\AccessException;
1312
use Art4\JsonApiClient\Exception\ValidationException;
13+
use Art4\JsonApiClient\Helper\AbstractElement;
14+
use Art4\JsonApiClient\Helper\AccessKey;
1415

1516
/**
1617
* Error Link Object
@@ -63,7 +64,7 @@ protected function parse($object): void
6364
/**
6465
* Get a value by the key of this object
6566
*
66-
* @param string $key The key of the value
67+
* @param int|string|AccessKey<string> $key The key of the value
6768
*
6869
* @return mixed The value
6970
*/

src/V1/ErrorSource.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88

99
namespace Art4\JsonApiClient\V1;
1010

11-
use Art4\JsonApiClient\Helper\AbstractElement;
1211
use Art4\JsonApiClient\Exception\AccessException;
1312
use Art4\JsonApiClient\Exception\ValidationException;
13+
use Art4\JsonApiClient\Helper\AbstractElement;
14+
use Art4\JsonApiClient\Helper\AccessKey;
1415

1516
/**
1617
* Error Source Object
@@ -52,7 +53,7 @@ protected function parse($object): void
5253
/**
5354
* Get a value by the key of this document
5455
*
55-
* @param string $key The key of the value
56+
* @param int|string|AccessKey<string> $key The key of the value
5657
*
5758
* @return mixed The value
5859
*/

0 commit comments

Comments
 (0)