From d8d5bb3a21b2f8642e99a78d049867300a01ada1 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 13 Jan 2022 12:16:39 +0100 Subject: [PATCH] php8 vc review --- pandora_console/include/rest-api/models/Model.php | 2 +- .../include/rest-api/models/VisualConsole/Item.php | 5 ++++- .../rest-api/models/VisualConsole/Items/BarsGraph.php | 2 +- .../rest-api/models/VisualConsole/Items/Box.php | 2 +- .../rest-api/models/VisualConsole/Items/ColorCloud.php | 4 ++-- .../rest-api/models/VisualConsole/Items/Group.php | 2 +- .../models/VisualConsole/Items/NetworkLink.php | 2 +- .../rest-api/models/VisualConsole/Items/Odometer.php | 2 +- .../rest-api/models/VisualConsole/Items/Percentile.php | 10 +++++----- .../models/VisualConsole/Items/SimpleValue.php | 2 +- 10 files changed, 18 insertions(+), 15 deletions(-) diff --git a/pandora_console/include/rest-api/models/Model.php b/pandora_console/include/rest-api/models/Model.php index 2677f5c3ae..cf79f791a7 100644 --- a/pandora_console/include/rest-api/models/Model.php +++ b/pandora_console/include/rest-api/models/Model.php @@ -56,7 +56,7 @@ abstract class Model * * @abstract */ - abstract static protected function encode(array $data): array; + abstract protected static function encode(array $data): array; /** diff --git a/pandora_console/include/rest-api/models/VisualConsole/Item.php b/pandora_console/include/rest-api/models/VisualConsole/Item.php index bbfebf5416..55e4e4a7dd 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Item.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Item.php @@ -1827,7 +1827,10 @@ class Item extends CachedModel } else { // Update. $dataModelEncode = static::encode($this->toArray()); - $dataEncode = static::encode($data); + // Exception colorcloud... + $dataEncode = static::encode( + array_merge($this->toArray(), $data) + ); $save = array_merge($dataModelEncode, $dataEncode); diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/BarsGraph.php b/pandora_console/include/rest-api/models/VisualConsole/Items/BarsGraph.php index 1c0731ea9b..e990419fb3 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Items/BarsGraph.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Items/BarsGraph.php @@ -59,7 +59,7 @@ final class BarsGraph extends Item * * @overrides Item->encode. */ - protected function encode(array $data): array + protected static function encode(array $data): array { $return = parent::encode($data); diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/Box.php b/pandora_console/include/rest-api/models/VisualConsole/Items/Box.php index d53dbc5f7b..df40bbd13c 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Items/Box.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Items/Box.php @@ -63,7 +63,7 @@ final class Box extends Item * * @overrides Item->encode. */ - protected function encode(array $data): array + protected static function encode(array $data): array { $return = parent::encode($data); diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/ColorCloud.php b/pandora_console/include/rest-api/models/VisualConsole/Items/ColorCloud.php index 5c9f41664c..8620e5bd49 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Items/ColorCloud.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Items/ColorCloud.php @@ -76,7 +76,7 @@ final class ColorCloud extends Item * * @overrides Item->encode. */ - protected function encode(array $data): array + protected static function encode(array $data): array { $return = parent::encode($data); @@ -100,7 +100,7 @@ final class ColorCloud extends Item ] ); } else { - $prevData = $this->toArray(); + $prevData = $data; $prevDataDefaultColor = static::extractDefaultColor( ['defaultColor' => $prevData['defaultColor']] ); diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php b/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php index 885721cda6..8a935be529 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php @@ -78,7 +78,7 @@ final class Group extends Item * * @overrides Item->encode. */ - protected function encode(array $data): array + protected static function encode(array $data): array { $return = parent::encode($data); diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/NetworkLink.php b/pandora_console/include/rest-api/models/VisualConsole/Items/NetworkLink.php index ce5eb8930f..e9ffd7aefb 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Items/NetworkLink.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Items/NetworkLink.php @@ -706,7 +706,7 @@ final class NetworkLink extends Model * * @overrides Model::encode. */ - protected function encode(array $data): array + protected static function encode(array $data): array { $result = []; $result['type'] = NETWORK_LINK; diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/Odometer.php b/pandora_console/include/rest-api/models/VisualConsole/Items/Odometer.php index a9fc3a2de2..ddcdfdf3eb 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Items/Odometer.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Items/Odometer.php @@ -199,7 +199,7 @@ final class Odometer extends Item * * @overrides Item->encode. */ - protected function encode(array $data): array + protected static function encode(array $data): array { $return = parent::encode($data); diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/Percentile.php b/pandora_console/include/rest-api/models/VisualConsole/Items/Percentile.php index e6db556b31..19e14f3456 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Items/Percentile.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Items/Percentile.php @@ -37,7 +37,7 @@ final class Percentile extends Item * 'CIRCULAR_PROGRESS_BAR' or 'CIRCULAR_INTERIOR_PROGRESS_BAR'. * 'PERCENTILE_BAR' by default. */ - protected function encodePercentileType(array $data): ?int + protected static function encodePercentileType(array $data): ?int { $type = null; if (isset($data['percentileType']) === true) { @@ -74,7 +74,7 @@ final class Percentile extends Item * 'CIRCULAR_PROGRESS_BAR' or 'CIRCULAR_INTERIOR_PROGRESS_BAR'. * 'PERCENTILE_BAR' by default. */ - protected function encodeValueType(array $data): ?string + protected static function encodeValueType(array $data): ?string { $valueType = null; if (isset($data['valueType']) === true) { @@ -103,7 +103,7 @@ final class Percentile extends Item * 'CIRCULAR_PROGRESS_BAR' or 'CIRCULAR_INTERIOR_PROGRESS_BAR'. * 'PERCENTILE_BAR' by default. */ - protected function encodeLabelColor(array $data): ?string + protected static function encodeLabelColor(array $data): ?string { $labelColor = null; if (isset($data['labelColor']) === true) { @@ -123,7 +123,7 @@ final class Percentile extends Item * 'CIRCULAR_PROGRESS_BAR' or 'CIRCULAR_INTERIOR_PROGRESS_BAR'. * 'PERCENTILE_BAR' by default. */ - protected function encodeColor(array $data): ?string + protected static function encodeColor(array $data): ?string { $color = null; if (isset($data['color']) === true) { @@ -143,7 +143,7 @@ final class Percentile extends Item * * @overrides Item->encode. */ - protected function encode(array $data): array + protected static function encode(array $data): array { $return = parent::encode($data); diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/SimpleValue.php b/pandora_console/include/rest-api/models/VisualConsole/Items/SimpleValue.php index 4357d3b2a4..3bdd2a9e0e 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Items/SimpleValue.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Items/SimpleValue.php @@ -104,7 +104,7 @@ final class SimpleValue extends Item * * @overrides Item->encode. */ - protected function encode(array $data): array + protected static function encode(array $data): array { $return = parent::encode($data); $process_value = static::encodeProcessValue($data);