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/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 +} 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 + +}