Skip to content

Commit 7790b3b

Browse files
committed
Add types for parameter and return in final classes
1 parent ac25355 commit 7790b3b

File tree

7 files changed

+10
-20
lines changed

7 files changed

+10
-20
lines changed

src/Factory.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@ interface Factory
1616
/**
1717
* Create a new instance of a class
1818
*
19-
* @deprecated The `\Art4\JsonApiClient\Factory::make()` methods first parameter signature will be `string` in v2.0.
2019
* @deprecated `\Art4\JsonApiClient\Factory::make()` will add `\Art4\JsonApiClient\Accessable` as a native return type declaration in v2.0. Do the same in your implementation now to avoid errors.
2120
*
22-
* @param string $name
23-
* @param array<mixed|Manager|Accessable> $args
21+
* @param array<mixed|Manager|Accessable> $args
2422
*
2523
* @return \Art4\JsonApiClient\Accessable
2624
*/
27-
public function make($name, array $args = []);
25+
public function make(string $name, array $args = []);
2826
// public function make(string $name, array $args = []): Accessable;
2927
}

src/Helper/RootAccessable.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
namespace Art4\JsonApiClient\Helper;
1010

1111
use Art4\JsonApiClient\Accessable;
12-
use Art4\JsonApiClient\Element;
13-
use Art4\JsonApiClient\Manager;
1412

1513
/**
1614
* RootAccessable

src/Manager.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,10 @@ public function getFactory();
4141
/**
4242
* Get a param by key
4343
*
44-
* @deprecated The `\Art4\JsonApiClient\Manager::getParam()` methods first parameter signature will be `string` in v2.0.
45-
*
46-
* @param string $key
47-
* @param mixed $default
44+
* @param mixed $default
4845
*
4946
* @return mixed
5047
*/
51-
public function getParam($key, $default);
48+
public function getParam(string $key, $default);
5249
// public function getParam(string $key, $default);
5350
}

src/Manager/ErrorAbortManager.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,11 @@ public function getFactory(): Factory
7979
/**
8080
* Get a param by key
8181
*
82-
* @param string $key
83-
* @param mixed $default
82+
* @param mixed $default
8483
*
8584
* @return mixed
8685
*/
87-
public function getParam($key, $default)
86+
public function getParam(string $key, $default)
8887
{
8988
if (array_key_exists($key, $this->config)) {
9089
return $this->config[$key];

src/V1/Factory.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,9 @@ public function __construct(array $overload = [])
5555
/**
5656
* Create a new instance of a class
5757
*
58-
* @param string $name
59-
* @param array<mixed> $args
58+
* @param array<mixed> $args
6059
*/
61-
public function make($name, array $args = []): Accessable
60+
public function make(string $name, array $args = []): Accessable
6261
{
6362
if (! isset($this->classes[$name])) {
6463
throw new FactoryException('"' . $name . '" is not a registered class');

src/V1/ResourceItemLink.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ public function get($key)
5757
/**
5858
* Set a link
5959
*
60-
* @param string $name The Name
6160
* @param string|object|mixed $link The Link
6261
*/
6362
private function setLink(string $name, $link): void

src/V1/ResourceNull.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __construct($data, Manager $manager, Accessable $parent) {}
3535
*
3636
* @return bool false
3737
*/
38-
public function has($key)
38+
public function has($key): bool
3939
{
4040
if (! is_int($key) && ! is_string($key) && (! is_object($key) || ! $key instanceof AccessKey)) {
4141
trigger_error(sprintf(
@@ -54,7 +54,7 @@ public function has($key)
5454
*
5555
* @return array<string> Keys of all setted values
5656
*/
57-
public function getKeys()
57+
public function getKeys(): array
5858
{
5959
return [];
6060
}

0 commit comments

Comments
 (0)