Skip to content

Commit 0e3919d

Browse files
committed
Add mixed as parameter type, add plan to change return types to mixed in v2
1 parent 9a02a23 commit 0e3919d

File tree

6 files changed

+16
-21
lines changed

6 files changed

+16
-21
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1111

1212
- Dropped support for PHP 7.4 and PHP 8.0
1313

14+
### Deprecated
15+
16+
- `\Art4\Accessable::get()` will add `mixed` as a native return type declaration in 2.0.0, do the same in your implementation now to avoid errors.
17+
- `\Art4\Manager::getParam()` will add `mixed` as a native return type declaration in 2.0.0, do the same in your implementation now to avoid errors.
18+
1419
## [1.2.0 - 2023-11-28](https://github.com/Art4/json-api-client/compare/1.1.0...1.2.0)
1520

1621
### Added

src/Accessable.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,20 @@ interface Accessable
1818
/**
1919
* Get a value by a key
2020
*
21-
* @param mixed $key The key
21+
* @return-type-will-change mixed `\Art4\JsonApiClient\Accessable::get()` will add `mixed` as a native return type declaration in 2.0.0, do the same in your implementation now to avoid errors.
2222
*
2323
* @return mixed
2424
*/
25-
public function get($key);
25+
public function get(mixed $key)/*: mixed */;
2626

2727
/**
2828
* Check if a value exists
2929
*
3030
* @return-type-will-change bool `\Art4\JsonApiClient\Accessable::has()` will add `bool` as a native return type declaration in 2.0.0, do the same in your implementation now to avoid errors.
3131
*
32-
* @param mixed $key The key
33-
*
3432
* @return bool
3533
*/
36-
public function has($key)/*: bool */;
34+
public function has(mixed $key)/*: bool */;
3735

3836
/**
3937
* Returns the keys of all setted values

src/Element.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ interface Element
1818
*
1919
* @param mixed $data The data for this Element
2020
*/
21-
public function __construct($data, Manager $manager, Accessable $parent);
21+
public function __construct(mixed $data, Manager $manager, Accessable $parent);
2222
}

src/Helper/AbstractElement.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ abstract class AbstractElement implements Accessable, Element
3030
*
3131
* @param mixed $data The data for this Element
3232
*/
33-
public function __construct($data, Manager $manager, Accessable $parent)
33+
public function __construct(mixed $data, Manager $manager, Accessable $parent)
3434
{
3535
$this->manager = $manager;
3636
$this->parent = $parent;
@@ -56,10 +56,8 @@ protected function getParent(): Accessable
5656

5757
/**
5858
* Create an element
59-
*
60-
* @param mixed $data
6159
*/
62-
protected function create(string $name, $data): Accessable
60+
protected function create(string $name, mixed $data): Accessable
6361
{
6462
return $this->getManager()->getFactory()->make(
6563
$name,
@@ -69,8 +67,6 @@ protected function create(string $name, $data): Accessable
6967

7068
/**
7169
* Parse the data
72-
*
73-
* @param mixed $data
7470
*/
75-
abstract protected function parse($data): void;
71+
abstract protected function parse(mixed $data): void;
7672
}

src/Manager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ public function getFactory()/*: Factory */;
3939
/**
4040
* Get a param by key
4141
*
42-
* @param mixed $default
42+
* @return-type-will-change mixed `\Art4\JsonApiClient\Manager::getParam()` will add `mixed` as a native return type declaration in 2.0.0, do the same in your implementation now to avoid errors.
4343
*
4444
* @return mixed
4545
*/
46-
public function getParam(string $key, $default);
46+
public function getParam(string $key, mixed $default)/*: mixed*/;
4747
}

tests/Unit/Helper/AccessableTraitTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ class AccessableTraitTest extends TestCase
1919

2020
/**
2121
* @dataProvider jsonValuesProviderWithoutStringAndInt
22-
*
23-
* @param mixed $key
2422
*/
25-
public function testHasWithInvalidKeyTypeTriggersDeprecationError($key): void
23+
public function testHasWithInvalidKeyTypeTriggersDeprecationError(mixed $key): void
2624
{
2725
$resource = new AccessableTraitMock();
2826

@@ -45,10 +43,8 @@ function ($errno, $errstr) use ($key): bool {
4543

4644
/**
4745
* @dataProvider jsonValuesProviderWithoutStringAndInt
48-
*
49-
* @param mixed $key
5046
*/
51-
public function testGetWithInvalidKeyTypeTriggersDeprecationError($key): void
47+
public function testGetWithInvalidKeyTypeTriggersDeprecationError(mixed $key): void
5248
{
5349
$resource = new AccessableTraitMock();
5450

0 commit comments

Comments
 (0)