Skip to content

Commit

Permalink
Add mixed as parameter type, add plan to change return types to mixed…
Browse files Browse the repository at this point in the history
… in v2
  • Loading branch information
Art4 committed Nov 28, 2023
1 parent 9a02a23 commit 0e3919d
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 21 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Dropped support for PHP 7.4 and PHP 8.0

### Deprecated

- `\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.
- `\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.

## [1.2.0 - 2023-11-28](https://github.com/Art4/json-api-client/compare/1.1.0...1.2.0)

### Added
Expand Down
8 changes: 3 additions & 5 deletions src/Accessable.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,20 @@ interface Accessable
/**
* Get a value by a key
*
* @param mixed $key The key
* @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.
*
* @return mixed
*/
public function get($key);
public function get(mixed $key)/*: mixed */;

/**
* Check if a value exists
*
* @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.
*
* @param mixed $key The key
*
* @return bool
*/
public function has($key)/*: bool */;
public function has(mixed $key)/*: bool */;

/**
* Returns the keys of all setted values
Expand Down
2 changes: 1 addition & 1 deletion src/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ interface Element
*
* @param mixed $data The data for this Element
*/
public function __construct($data, Manager $manager, Accessable $parent);
public function __construct(mixed $data, Manager $manager, Accessable $parent);
}
10 changes: 3 additions & 7 deletions src/Helper/AbstractElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ abstract class AbstractElement implements Accessable, Element
*
* @param mixed $data The data for this Element
*/
public function __construct($data, Manager $manager, Accessable $parent)
public function __construct(mixed $data, Manager $manager, Accessable $parent)
{
$this->manager = $manager;
$this->parent = $parent;
Expand All @@ -56,10 +56,8 @@ protected function getParent(): Accessable

/**
* Create an element
*
* @param mixed $data
*/
protected function create(string $name, $data): Accessable
protected function create(string $name, mixed $data): Accessable
{
return $this->getManager()->getFactory()->make(
$name,
Expand All @@ -69,8 +67,6 @@ protected function create(string $name, $data): Accessable

/**
* Parse the data
*
* @param mixed $data
*/
abstract protected function parse($data): void;
abstract protected function parse(mixed $data): void;
}
4 changes: 2 additions & 2 deletions src/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public function getFactory()/*: Factory */;
/**
* Get a param by key
*
* @param mixed $default
* @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.
*
* @return mixed
*/
public function getParam(string $key, $default);
public function getParam(string $key, mixed $default)/*: mixed*/;
}
8 changes: 2 additions & 6 deletions tests/Unit/Helper/AccessableTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ class AccessableTraitTest extends TestCase

/**
* @dataProvider jsonValuesProviderWithoutStringAndInt
*
* @param mixed $key
*/
public function testHasWithInvalidKeyTypeTriggersDeprecationError($key): void
public function testHasWithInvalidKeyTypeTriggersDeprecationError(mixed $key): void
{
$resource = new AccessableTraitMock();

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

/**
* @dataProvider jsonValuesProviderWithoutStringAndInt
*
* @param mixed $key
*/
public function testGetWithInvalidKeyTypeTriggersDeprecationError($key): void
public function testGetWithInvalidKeyTypeTriggersDeprecationError(mixed $key): void
{
$resource = new AccessableTraitMock();

Expand Down

0 comments on commit 0e3919d

Please sign in to comment.