Skip to content

Commit

Permalink
PHP 8.1 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszdurda committed Nov 28, 2022
1 parent d5b95f2 commit a7616cf
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -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": ">=7.0",
"ext-curl": "*"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion src/PrintNode/Entity.php
Expand Up @@ -102,7 +102,7 @@ public function mapValuesFromJson($json)
*
* @return string
*/
public function jsonSerialize()
public function jsonSerialize(): mixed
{

$json = array();
Expand Down
42 changes: 21 additions & 21 deletions src/PrintNode/EntityDynamic.php
Expand Up @@ -4,15 +4,15 @@

abstract class EntityDynamic extends Entity
{

/**
* Reference to the client
* @var Client
*/
protected static $protectedProperties = array(
'client',
);

/**
* Set property on entity
* @param mixed $propertyName
Expand All @@ -21,15 +21,15 @@ 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
*
Expand All @@ -38,41 +38,41 @@ public function __set($propertyName, $value)
*/
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;

}

}

0 comments on commit a7616cf

Please sign in to comment.