Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for PHP 7.4 and PHP 8.0 #95

Merged
merged 7 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
operating-system: ['ubuntu-latest']
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
php: ['8.1', '8.2', '8.3', '8.4']

steps:
- name: Checkout
Expand Down
4 changes: 2 additions & 2 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
->setRules([
'@PER-CS2.0' => true,
'@PER-CS2.0:risky' => true,
'@PHP74Migration' => true,
'@PHP74Migration:risky' => true,
'@PHP81Migration' => true,
'@PHP80Migration:risky' => true,
'@PHPUnit84Migration:risky' => true,
'no_alias_functions' => true,
])
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased](https://github.com/Art4/json-api-client/compare/1.2.0...v1.x)

### Changed

- 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
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
}
],
"require": {
"php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0"
"php": "~8.1.0 || ~8.2.0 || ~8.3.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.35",
"friendsofphp/php-cs-fixer": "^3.40",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-phpunit": "^1.3",
"phpunit/phpunit": "^9 || ^10"
"phpunit/phpunit": "^10.4"
},
"autoload": {
"psr-4": {
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;
}
12 changes: 3 additions & 9 deletions src/Helper/AccessableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ trait AccessableTrait

/**
* Set a value
*
* @param mixed $value The Value
*/
final protected function set(string $key, $value): void
final protected function set(string $key, mixed $value): void
{
// Allow non-associative array for collections
if ($key === '') {
Expand Down Expand Up @@ -93,10 +91,8 @@ final public function has($key): bool
* Get a value by a key
*
* @param int|string|AccessKey<string> $key The key
*
* @return mixed
*/
public function get($key)
public function get($key): mixed
{
if (!is_int($key) && !is_string($key) && (!is_object($key) || !$key instanceof AccessKey)) {
trigger_error(sprintf(
Expand Down Expand Up @@ -131,10 +127,8 @@ public function get($key)
* Get a value by the key
*
* @throws AccessException
*
* @return mixed The value
*/
private function getValue(string $key)
private function getValue(string $key): mixed
{
if (array_key_exists($key, $this->data)) {
return $this->data[$key];
Expand Down
4 changes: 1 addition & 3 deletions src/Input/StringInputTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ final public function prepareString($string): string
* Decodes a json string
*
* @throws InputException if something went wrong with the input
*
* @return mixed
*/
final protected function decodeJson(string $jsonString)
final protected function decodeJson(string $jsonString): mixed
{
$jsonErrors = [
\JSON_ERROR_DEPTH => 'JSON_ERROR_DEPTH - Maximum stack depth exceeded',
Expand Down
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*/;
}
6 changes: 1 addition & 5 deletions src/Manager/ErrorAbortManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,8 @@ public function getFactory(): Factory

/**
* Get a param by key
*
* @param mixed $default
*
* @return mixed
*/
public function getParam(string $key, $default)
public function getParam(string $key, mixed $default): mixed
{
if (array_key_exists($key, $this->config)) {
return $this->config[$key];
Expand Down
6 changes: 1 addition & 5 deletions src/Serializer/ArraySerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,8 @@ public function serialize(Accessable $data): ?array

/**
* Transforms objects to arrays
*
* @param mixed $val
*
* @return mixed
*/
private function objectTransform($val)
private function objectTransform(mixed $val): mixed
{
if (!is_object($val)) {
return $val;
Expand Down
8 changes: 2 additions & 6 deletions src/V1/Attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ final class Attributes extends AbstractElement
/**
* Parses the data for this element
*
* @param mixed $object The data
*
* @throws ValidationException
*/
protected function parse($object): void
protected function parse(mixed $object): void
{
if (!is_object($object)) {
throw new ValidationException('Attributes has to be an object, "' . gettype($object) . '" given.');
Expand All @@ -52,10 +50,8 @@ protected function parse($object): void
* Get a value by the key of this object
*
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
public function get($key)
public function get($key): mixed
{
try {
return parent::get($key);
Expand Down
8 changes: 2 additions & 6 deletions src/V1/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ final class Document extends AbstractElement
/**
* Parses the data for this element
*
* @param mixed $object The data
*
* @throws ValidationException
*/
protected function parse($object): void
protected function parse(mixed $object): void
{
if (!is_object($object)) {
throw new ValidationException('Document has to be an object, "' . gettype($object) . '" given.');
Expand Down Expand Up @@ -75,10 +73,8 @@ protected function parse($object): void
* Get a value by the key of this object
*
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
public function get($key)
public function get($key): mixed
{
try {
return parent::get($key);
Expand Down
8 changes: 2 additions & 6 deletions src/V1/DocumentLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ final class DocumentLink extends AbstractElement
/**
* Parses the data for this element
*
* @param mixed $object The data
*
* @throws ValidationException
*/
protected function parse($object): void
protected function parse(mixed $object): void
{
if (!is_object($object)) {
throw new ValidationException(
Expand Down Expand Up @@ -105,10 +103,8 @@ protected function parse($object): void
* Get a value by the key of this object
*
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
public function get($key)
public function get($key): mixed
{
try {
return parent::get($key);
Expand Down
8 changes: 2 additions & 6 deletions src/V1/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ final class Error extends AbstractElement
/**
* Parses the data for this element
*
* @param mixed $object The data
*
* @throws ValidationException
*/
protected function parse($object): void
protected function parse(mixed $object): void
{
if (!is_object($object)) {
throw new ValidationException(
Expand Down Expand Up @@ -107,10 +105,8 @@ protected function parse($object): void
* Get a value by the key of this object
*
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
public function get($key)
public function get($key): mixed
{
try {
return parent::get($key);
Expand Down
8 changes: 2 additions & 6 deletions src/V1/ErrorCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ final class ErrorCollection extends AbstractElement
/**
* Parses the data for this element
*
* @param mixed $object The data
*
* @throws ValidationException
*/
protected function parse($object): void
protected function parse(mixed $object): void
{
if (!is_array($object)) {
throw new ValidationException('Errors for a collection has to be in an array, "' . gettype($object) . '" given.');
Expand All @@ -46,10 +44,8 @@ protected function parse($object): void
* Get a value by the key of this document
*
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
public function get($key)
public function get($key): mixed
{
try {
return parent::get($key);
Expand Down
8 changes: 2 additions & 6 deletions src/V1/ErrorLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ final class ErrorLink extends AbstractElement
/**
* Parses the data for this element
*
* @param mixed $object The data
*
* @throws ValidationException
*/
protected function parse($object): void
protected function parse(mixed $object): void
{
if (!is_object($object)) {
throw new ValidationException('Link has to be an object, "' . gettype($object) . '" given.');
Expand Down Expand Up @@ -65,10 +63,8 @@ protected function parse($object): void
* Get a value by the key of this object
*
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
public function get($key)
public function get($key): mixed
{
try {
return parent::get($key);
Expand Down
8 changes: 2 additions & 6 deletions src/V1/ErrorSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ final class ErrorSource extends AbstractElement
/**
* Parses the data for this element
*
* @param mixed $object The data
*
* @throws ValidationException
*/
protected function parse($object): void
protected function parse(mixed $object): void
{
if (!is_object($object)) {
throw new ValidationException('ErrorSource has to be an object, "' . gettype($object) . '" given.');
Expand All @@ -54,10 +52,8 @@ protected function parse($object): void
* Get a value by the key of this document
*
* @param int|string|AccessKey<string> $key The key of the value
*
* @return mixed The value
*/
public function get($key)
public function get($key): mixed
{
try {
return parent::get($key);
Expand Down
Loading