From 5d848624c6761544ce83bd6674470aba05172cf2 Mon Sep 17 00:00:00 2001 From: kingIZZZY Date: Wed, 22 Jun 2022 17:45:58 -0400 Subject: [PATCH 1/2] PHP 8.1 compatibility / deprecation warnings PHP Deprecated: Return type of PrintNode\Entity::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in .../vendor/printnode/printnode-php/src/PrintNode/Entity.php on line 105 Explanation: https://stackoverflow.com/a/71133750 PrintNode's class Entity implements \JsonSerializable: https://www.php.net/manual/en/class.jsonserializable.php --- src/PrintNode/Entity.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PrintNode/Entity.php b/src/PrintNode/Entity.php index 1a71c51..2430020 100755 --- a/src/PrintNode/Entity.php +++ b/src/PrintNode/Entity.php @@ -102,7 +102,7 @@ public function mapValuesFromJson($json) * * @return string */ - public function jsonSerialize() + public function jsonSerialize(): mixed { $json = array(); @@ -132,4 +132,4 @@ public function __toString() { } -} \ No newline at end of file +} From 34922afb0415d1fb7e1ecd323cd4458fae790758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tjitse=20Efd=C3=A9?= Date: Thu, 13 Oct 2022 14:17:14 +0200 Subject: [PATCH 2/2] Started working on PHP 8.1 compatibility --- composer.json | 2 +- src/PrintNode/EntityDynamic.php | 48 ++++++++++++++++----------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/composer.json b/composer.json index b5784b8..48a1999 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "printnode/printnode-php", "description": "Connect any printer to your application with PrintNode Client and easy to use JSON API", "require": { - "php": ">=5.3.2", + "php": ">=8.1", "ext-curl": "*" }, "keywords": [ diff --git a/src/PrintNode/EntityDynamic.php b/src/PrintNode/EntityDynamic.php index af474eb..3ff6c41 100644 --- a/src/PrintNode/EntityDynamic.php +++ b/src/PrintNode/EntityDynamic.php @@ -4,7 +4,7 @@ abstract class EntityDynamic extends Entity { - + /** * Reference to the client * @var Client @@ -12,7 +12,7 @@ abstract class EntityDynamic extends Entity protected static $protectedProperties = array( 'client', ); - + /** * Set property on entity * @param mixed $propertyName @@ -21,58 +21,58 @@ abstract class EntityDynamic extends Entity */ public function __set($propertyName, $value) { - + if (\in_array($propertyName, self::$protectedProperties)) { throw new \PrintNode\Exception\InvalidArgumentException($propertyName . ' is a protected property.'); } - + $this->$propertyName = $value; - + } - + /** * Maps a json object to this entity - * + * * @param string $json The JSON to map to this entity * @return string */ public function mapValuesFromJson($json) { - + foreach ($json as $key => $value) { $this->$key = $value; } - + return true; - + } - + /** * Implements the jsonSerialize method - * + * * @return string */ - public function jsonSerialize() + public function jsonSerialize() : mixed { - + $refClass = new \ReflectionClass($this); - + $properties = get_object_vars($this); - + $json = array(); - + foreach ($properties as $property => $value) { - + if (in_array($property, self::$protectedProperties)) { continue; } - + $json[$property] = $value; - + } - + return $json; - + } - -} \ No newline at end of file + +}