Skip to content

Commit

Permalink
Update CHANGELOG.md, fix deprecation error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Art4 committed Oct 26, 2023
1 parent 4b14fe0 commit f015aa7
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 31 deletions.
25 changes: 15 additions & 10 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.

- Add support for PHP 8.2

### Deprecated

- Providing Argument #1 ($key) in `\Art4\JsonApiClient\Accessable::has()` not as `int|string` is deprecated and will throw an Exception in 2.0.0.
- Providing Argument #1 ($key) in `\Art4\JsonApiClient\Accessable::get()` not as `int|string` is deprecated and will throw an Exception in 2.0.0.

## [1.1.0 - 2021-10-05](https://github.com/Art4/json-api-client/compare/1.0.0...1.1.0)

### Added
Expand All @@ -25,16 +30,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### 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.
- `\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.
- `\Art4\JsonApiClient\Exception\Exception` will extend `\Throwable` in v2.0, do the same in your implementation now to avoid errors.
- `\Art4\JsonApiClient\Factory::make()` methods first parameter signature will be `string` in v2.0.
- `\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.
- `\Art4\JsonApiClient\Input\Input::getAsObject()` will add `\stdClass` as a native return type declaration in v2.0, do the same in your implementation now to avoid errors.
- `\Art4\JsonApiClient\Manager::parse()` will add `\Art4\JsonApiClient\Accessable` as a native return type declaration in v2.0, do the same in your implementation now to avoid errors.
- `\Art4\JsonApiClient\Manager::getFactory()` will add `\Art4\JsonApiClient\Factory` as a native return type declaration in v2.0, do the same in your implementation now to avoid errors.
- `\Art4\JsonApiClient\Manager::getParam()` methods first parameter signature will be `string` in v2.0.
- `\Art4\JsonApiClient\Serializer\Serializer::serialize()` will add `?array` as a native return type declaration in v2.0, do the same in your implementation now to avoid errors.
- `\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.
- `\Art4\JsonApiClient\Accessable::getKeys()` will add `array` as a native return type declaration in 2.0.0, do the same in your implementation now to avoid errors.
- `\Art4\JsonApiClient\Exception\Exception` will extend `\Throwable` in 2.0.0, do the same in your implementation now to avoid errors.
- `\Art4\JsonApiClient\Factory::make()` methods first parameter signature will be `string` in 2.0.0.
- `\Art4\JsonApiClient\Factory::make()` will add `\Art4\JsonApiClient\Accessable` as a native return type declaration in 2.0.0, do the same in your implementation now to avoid errors.
- `\Art4\JsonApiClient\Input\Input::getAsObject()` will add `\stdClass` as a native return type declaration in 2.0.0, do the same in your implementation now to avoid errors.
- `\Art4\JsonApiClient\Manager::parse()` will add `\Art4\JsonApiClient\Accessable` as a native return type declaration in 2.0.0, do the same in your implementation now to avoid errors.
- `\Art4\JsonApiClient\Manager::getFactory()` will add `\Art4\JsonApiClient\Factory` as a native return type declaration in 2.0.0, do the same in your implementation now to avoid errors.
- `\Art4\JsonApiClient\Manager::getParam()` methods first parameter signature will be `string` in 2.0.0.
- `\Art4\JsonApiClient\Serializer\Serializer::serialize()` will add `?array` as a native return type declaration in 2.0.0, do the same in your implementation now to avoid errors.

## [1.0.0 - 2021-03-05](https://github.com/Art4/json-api-client/compare/0.10.2...1.0.0)

Expand Down
4 changes: 2 additions & 2 deletions src/Accessable.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function get($key);
/**
* Check if a value exists
*
* @return-type-will-change bool `\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.
* @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
*
Expand All @@ -38,7 +38,7 @@ public function has($key)/*: bool */;
/**
* Returns the keys of all setted values
*
* @return-type-will-change array `\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-type-will-change array `\Art4\JsonApiClient\Accessable::getKeys()` will add `array` as a native return type declaration in 2.0.0, do the same in your implementation now to avoid errors.
*
* @return array<string|int> Keys of all setted values
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace Art4\JsonApiClient\Exception;

/**
* Please note: `\Art4\JsonApiClient\Exception\Exception` will extend `\Throwable` in v2.0. Do the same in your implementation now to avoid errors.
* Please note: `\Art4\JsonApiClient\Exception\Exception` will extend `\Throwable` in 2.0.0, do the same in your implementation now to avoid errors.
*/
interface Exception /*extends \Throwable */
{}
2 changes: 1 addition & 1 deletion src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface Factory
/**
* Create a new instance of a class
*
* @return-type-will-change Accessable `\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.
* @return-type-will-change Accessable `\Art4\JsonApiClient\Factory::make()` will add `\Art4\JsonApiClient\Accessable` as a native return type declaration in 2.0.0, do the same in your implementation now to avoid errors.
*
* @param array<mixed|Manager|Accessable> $args
*
Expand Down
10 changes: 4 additions & 6 deletions src/Helper/AccessableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ final public function has($key): bool
{
if (! is_int($key) && ! is_string($key) && (! is_object($key) || ! $key instanceof AccessKey)) {
trigger_error(sprintf(
'%s::has(): Providing Argument #1 ($key) as %s is deprecated since 1.2.0, please provide as int|string|%s instead.',
'%s::has(): Providing Argument #1 ($key) as `%s` is deprecated since 1.2.0, please provide as `int|string` instead.',
get_class($this),
gettype($key),
AccessKey::class
gettype($key)
), \E_USER_DEPRECATED);

$key = '';
Expand Down Expand Up @@ -101,10 +100,9 @@ public function get($key)
{
if (! is_int($key) && ! is_string($key) && (! is_object($key) || ! $key instanceof AccessKey)) {
trigger_error(sprintf(
'%s::get(): Providing Argument #1 ($key) as %s is deprecated since 1.2.0, please provide as int|string|%s instead.',
'%s::get(): Providing Argument #1 ($key) as `%s` is deprecated since 1.2.0, please provide as `int|string` instead.',
get_class($this),
gettype($key),
AccessKey::class
gettype($key)
), \E_USER_DEPRECATED);

$key = '';
Expand Down
2 changes: 1 addition & 1 deletion src/Input/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface Input
/**
* Get the input as simple object
*
* @return-type-will-change \stdClass `\Art4\JsonApiClient\Input\Input::getAsObject()` will add `\stdClass` as a native return type declaration in v2.0. Do the same in your implementation now to avoid errors.
* @return-type-will-change \stdClass `\Art4\JsonApiClient\Input\Input::getAsObject()` will add `\stdClass` as a native return type declaration in 2.0.0, do the same in your implementation now to avoid errors.
*
* This should be a native PHP stdClass object, so Manager could
* iterate over all public attributes
Expand Down
4 changes: 2 additions & 2 deletions src/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface Manager
/**
* Parse the input
*
* @return-type-will-change Accessable `\Art4\JsonApiClient\Manager::parse()` will add `\Art4\JsonApiClient\Accessable` as a native return type declaration in v2.0. Do the same in your implementation now to avoid errors.
* @return-type-will-change Accessable `\Art4\JsonApiClient\Manager::parse()` will add `\Art4\JsonApiClient\Accessable` as a native return type declaration in 2.0.0, do the same in your implementation now to avoid errors.
*
* @throws \Art4\JsonApiClient\Exception\InputException If $input contains invalid JSON API
* @throws \Art4\JsonApiClient\Exception\ValidationException If $input contains invalid JSON API
Expand All @@ -30,7 +30,7 @@ public function parse(Input $input)/*: Accessable */;
/**
* Get a factory from the manager
*
* @return-type-will-change Factory `\Art4\JsonApiClient\Manager::getFactory()` will add `\Art4\JsonApiClient\Factory` as a native return type declaration in v2.0. Do the same in your implementation now to avoid errors.
* @return-type-will-change Factory `\Art4\JsonApiClient\Manager::getFactory()` will add `\Art4\JsonApiClient\Factory` as a native return type declaration in 2.0.0, do the same in your implementation now to avoid errors.
*
* @return \Art4\JsonApiClient\Factory
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Serializer/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface Serializer
/**
* Serialize data
*
* @return-type-will-change ?array `\Art4\JsonApiClient\Serializer\Serializer::serialize()` will add `?array` as a native return type declaration in v2.0. Do the same in your implementation now to avoid errors.
* @return-type-will-change ?array `\Art4\JsonApiClient\Serializer\Serializer::serialize()` will add `?array` as a native return type declaration in 2.0.0, do the same in your implementation now to avoid errors.
*
* @return array<string, mixed>|null
*/
Expand Down
5 changes: 2 additions & 3 deletions src/V1/ResourceNull.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ public function has($key): bool
{
if (! is_int($key) && ! is_string($key) && (! is_object($key) || ! $key instanceof AccessKey)) {
trigger_error(sprintf(
'%s::has(): Providing Argument #1 ($key) as %s is deprecated since 1.2.0, please provide as int|string|%s instead.',
'%s::has(): Providing Argument #1 ($key) as `%s` is deprecated since 1.2.0, please provide as `int|string` instead.',
get_class($this),
gettype($key),
AccessKey::class
gettype($key)
), \E_USER_DEPRECATED);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Helper/AccessableTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testHasWithInvalidKeyTypeTriggersDeprecationError($key): void
set_error_handler(
function ($errno, $errstr) use ($key): bool {
$this->assertSame(
'Art4\JsonApiClient\Tests\Fixtures\AccessableTraitMock::has(): Providing Argument #1 ($key) as ' . gettype($key) . ' is deprecated since 1.2.0, please provide as int|string|Art4\JsonApiClient\Helper\AccessKey instead.',
'Art4\JsonApiClient\Tests\Fixtures\AccessableTraitMock::has(): Providing Argument #1 ($key) as `' . gettype($key) . '` is deprecated since 1.2.0, please provide as `int|string` instead.',
$errstr
);

Expand All @@ -56,7 +56,7 @@ public function testGetWithInvalidKeyTypeTriggersDeprecationError($key): void
set_error_handler(
function ($errno, $errstr) use ($key): bool {
$this->assertSame(
'Art4\JsonApiClient\Tests\Fixtures\AccessableTraitMock::get(): Providing Argument #1 ($key) as ' . gettype($key) . ' is deprecated since 1.2.0, please provide as int|string|Art4\JsonApiClient\Helper\AccessKey instead.',
'Art4\JsonApiClient\Tests\Fixtures\AccessableTraitMock::get(): Providing Argument #1 ($key) as `' . gettype($key) . '` is deprecated since 1.2.0, please provide as `int|string` instead.',
$errstr
);

Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/V1/ResourceNullTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function testHasWithObjectAsKeyTriggersException(): void
set_error_handler(
function ($errno, $errstr): bool {
$this->assertSame(
'Art4\JsonApiClient\V1\ResourceNull::has(): Providing Argument #1 ($key) as object is deprecated since 1.2.0, please provide as int|string|Art4\JsonApiClient\Helper\AccessKey instead.',
'Art4\JsonApiClient\V1\ResourceNull::has(): Providing Argument #1 ($key) as `object` is deprecated since 1.2.0, please provide as `int|string` instead.',
$errstr
);

Expand All @@ -102,7 +102,7 @@ public function testHasWithArrayAsKeyTriggersException(): void
set_error_handler(
function ($errno, $errstr): bool {
$this->assertSame(
'Art4\JsonApiClient\V1\ResourceNull::has(): Providing Argument #1 ($key) as array is deprecated since 1.2.0, please provide as int|string|Art4\JsonApiClient\Helper\AccessKey instead.',
'Art4\JsonApiClient\V1\ResourceNull::has(): Providing Argument #1 ($key) as `array` is deprecated since 1.2.0, please provide as `int|string` instead.',
$errstr
);

Expand Down

0 comments on commit f015aa7

Please sign in to comment.