Skip to content

Commit

Permalink
[general] Fixing dependencies & configuration (#244)
Browse files Browse the repository at this point in the history
* Fixing dependencies & configuration

* QA fixes
  • Loading branch information
akadlec committed Feb 25, 2024
1 parent e5d6801 commit b216f84
Show file tree
Hide file tree
Showing 23 changed files with 56 additions and 22 deletions.
1 change: 1 addition & 0 deletions src/FastyBird/Addon/VirtualThermostat/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"fastybird/datetime-factory": "^0.6",
"fastybird/devices-module": "dev-main",
"fastybird/metadata-library": "dev-main",
"fastybird/tools-library": "dev-main",
"fastybird/virtual-connector": "dev-main",
"ipub/doctrine-crud": "^4.0",
"nette/di": "^3.0",
Expand Down
1 change: 1 addition & 0 deletions src/FastyBird/Connector/FbMqtt/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"fastybird/datetime-factory": "^0.6",
"fastybird/devices-module": "dev-main",
"fastybird/metadata-library": "dev-main",
"fastybird/tools-library": "dev-main",
"nette/di": "^3.0",
"orisai/nette-object-mapper": "^0.1",
"psr/log": "^3.0",
Expand Down
1 change: 1 addition & 0 deletions src/FastyBird/Connector/HomeKit/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"fastybird/devices-module": "dev-main",
"fastybird/exchange-library": "dev-main",
"fastybird/metadata-library": "dev-main",
"fastybird/tools-library": "dev-main",
"hashids/hashids": "^4.1",
"ipub/slim-router": "^0.2",
"leigh/curve25519": "^0.1",
Expand Down
1 change: 1 addition & 0 deletions src/FastyBird/Connector/Modbus/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"fastybird/datetime-factory": "^0.6",
"fastybird/devices-module": "dev-main",
"fastybird/metadata-library": "dev-main",
"fastybird/tools-library": "dev-main",
"nette/di": "^3.0",
"nettrine/fixtures": "^0.6",
"orisai/nette-object-mapper": "^0.1",
Expand Down
1 change: 1 addition & 0 deletions src/FastyBird/Connector/NsPanel/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"fastybird/datetime-factory": "^0.6",
"fastybird/devices-module": "dev-main",
"fastybird/metadata-library": "dev-main",
"fastybird/tools-library": "dev-main",
"fig/http-message-util": "^1.1",
"guzzlehttp/guzzle": "^7.5",
"ipub/doctrine-crud": "^4.0",
Expand Down
1 change: 1 addition & 0 deletions src/FastyBird/Connector/Shelly/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"fastybird/datetime-factory": "^0.6",
"fastybird/devices-module": "dev-main",
"fastybird/metadata-library": "dev-main",
"fastybird/tools-library": "dev-main",
"guzzlehttp/guzzle": "^7.5",
"nette/di": "^3.0",
"orisai/nette-object-mapper": "^0.1",
Expand Down
1 change: 1 addition & 0 deletions src/FastyBird/Connector/Sonoff/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"fastybird/datetime-factory": "^0.6",
"fastybird/devices-module": "dev-main",
"fastybird/metadata-library": "dev-main",
"fastybird/tools-library": "dev-main",
"guzzlehttp/guzzle": "^7.5",
"nette/di": "^3.0",
"orisai/nette-object-mapper": "^0.1",
Expand Down
1 change: 1 addition & 0 deletions src/FastyBird/Connector/Tuya/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"fastybird/datetime-factory": "^0.6",
"fastybird/devices-module": "dev-main",
"fastybird/metadata-library": "dev-main",
"fastybird/tools-library": "dev-main",
"fig/http-message-util": "^1.1",
"guzzlehttp/guzzle": "^7.5",
"ipub/doctrine-crud": "^4.0",
Expand Down
1 change: 1 addition & 0 deletions src/FastyBird/Connector/Viera/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"fastybird/datetime-factory": "^0.6",
"fastybird/devices-module": "dev-main",
"fastybird/metadata-library": "dev-main",
"fastybird/tools-library": "dev-main",
"fig/http-message-util": "^1.1",
"guzzlehttp/guzzle": "^7.5",
"ipub/doctrine-crud": "^4.0",
Expand Down
1 change: 1 addition & 0 deletions src/FastyBird/Connector/Virtual/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"fastybird/datetime-factory": "^0.6",
"fastybird/devices-module": "dev-main",
"fastybird/metadata-library": "dev-main",
"fastybird/tools-library": "dev-main",
"ipub/doctrine-crud": "^4.0",
"nette/di": "^3.0",
"orisai/nette-object-mapper": "^0.1",
Expand Down
1 change: 1 addition & 0 deletions src/FastyBird/Connector/Zigbee2Mqtt/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"fastybird/datetime-factory": "^0.6",
"fastybird/devices-module": "dev-main",
"fastybird/metadata-library": "dev-main",
"fastybird/tools-library": "dev-main",
"nette/di": "^3.0",
"orisai/nette-object-mapper": "^0.1",
"psr/log": "^3.0",
Expand Down
1 change: 1 addition & 0 deletions src/FastyBird/Library/Exchange/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"nette/di": "^3.0",
"nette/utils": "^3.2",
"psr/event-dispatcher": "^1.0",
"react/promise": "^3",
"symfony/event-dispatcher": "^5.4",
"symplify/vendor-patches": "^11.2"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use FastyBird\Library\Metadata\Formats;
use FastyBird\Library\Metadata\Types;
use FastyBird\Library\Metadata\Utilities;
use FastyBird\Library\Tools\Transformers as ToolsTransformers;
use PHPUnit\Framework\TestCase;
use TypeError;
use ValueError;
Expand All @@ -29,7 +28,6 @@ public function testNormalizeValue(
bool|float|int|string|DateTimeInterface|Types\Payloads\Button|Types\Payloads\Switcher|Types\Payloads\Cover|null $value,
Formats\StringEnum|Formats\NumberRange|Formats\CombinedEnum|null $format = null,
float|int|string|null $invalid = null,
ToolsTransformers\EquationTransformer|null $transformer = null,
float|int|string|null $expected = null,
bool $throwError = false,
): void
Expand Down Expand Up @@ -60,7 +58,6 @@ public static function normalizeValue(): array
'10',
null,
null,
null,
10,
false,
],
Expand All @@ -70,7 +67,6 @@ public static function normalizeValue(): array
new Formats\NumberRange([10, 20]),
null,
null,
null,
true,
],
'integer_3' => [
Expand All @@ -79,15 +75,13 @@ public static function normalizeValue(): array
new Formats\NumberRange([10, 20]),
null,
null,
null,
true,
],
'float_1' => [
Types\DataType::FLOAT,
'30.3',
null,
null,
null,
30.3,
],
];
Expand Down
3 changes: 0 additions & 3 deletions src/FastyBird/Library/Metadata/tools/phpstan.src.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@ includes:

parameters:
resultCachePath: %currentWorkingDirectory%/var/tools/PHPStan/resultCache.src.php

ignoreErrors:
- message: '#^Parameter \#1 \$value of function strval expects bool\|float\|int\|resource\|string\|null, mixed given.#'
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
use DateTimeInterface;
use FastyBird\Library\Metadata\Types as MetadataTypes;
use FastyBird\Library\Metadata\Utilities as MetadataUtilities;
use function boolval;
use function in_array;

/**
* Compatible data type value transformer
Expand All @@ -33,8 +35,8 @@

public function __construct(
private bool|float|int|string|DateTimeInterface|MetadataTypes\Payloads\Payload|null $value,
private MetadataTypes\DataType $source,
private MetadataTypes\DataType $destination,
private MetadataTypes\DataType $source,
private MetadataTypes\DataType $destination,
)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
use FastyBird\Library\Metadata\Types as MetadataTypes;
use FastyBird\Library\Tools\Exceptions;
use MathSolver\Math;
use function array_key_exists;
use function floatval;
use function implode;
use function intval;
use function is_array;
use function preg_match;
use function round;

/**
* Equation value transformer
Expand Down
17 changes: 12 additions & 5 deletions src/FastyBird/Library/Tools/src/Transformers/HsbTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@

namespace FastyBird\Library\Tools\Transformers;

use function abs;
use function floor;
use function intval;
use function min;
use function pow;
use function round;

/**
* HSB value object
*
Expand Down Expand Up @@ -160,18 +167,18 @@ public function toMired(): MiredTransformer
$temperature = 0;

// Calculate color temperature based on RGB values
$X = (-0.14282 * $rgb->getRed()) + (1.54924 * $rgb->getGreen()) + (-0.95641 * $rgb->getBlue());
$Y = (-0.32466 * $rgb->getRed()) + (1.57837 * $rgb->getGreen()) + (-0.73191 * $rgb->getBlue());
$Z = (-0.68202 * $rgb->getRed()) + (0.77073 * $rgb->getGreen()) + (0.56332 * $rgb->getBlue());
$X = (-0.142_82 * $rgb->getRed()) + (1.549_24 * $rgb->getGreen()) + (-0.956_41 * $rgb->getBlue());
$Y = (-0.324_66 * $rgb->getRed()) + (1.578_37 * $rgb->getGreen()) + (-0.731_91 * $rgb->getBlue());
$Z = (-0.682_02 * $rgb->getRed()) + (0.770_73 * $rgb->getGreen()) + (0.563_32 * $rgb->getBlue());

// Calculate xy values
$x = $X / ($X + $Y + $Z);
$y = $Y / ($X + $Y + $Z);

// Calculate correlated color temperature (CCT)
$n = ( $x - 0.3320 ) / ( 0.1858 - $y );
$n = ($x - 0.332_0) / (0.185_8 - $y);

$temperature = 449.0 * pow($n, 3) + 3525.0 * pow($n, 2) + 6823.3 * $n + 5520.33;
$temperature = 449.0 * pow($n, 3) + 3_525.0 * pow($n, 2) + 6_823.3 * $n + 5_520.33;

return new MiredTransformer(intval(round(1_000_000 / $temperature)), $this->getBrightness());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@

namespace FastyBird\Library\Tools\Transformers;

use function cos;
use function floatval;
use function fmod;
use function intval;

/**
* HSI value object
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

namespace FastyBird\Library\Tools\Transformers;

use function array_key_exists;
use function round;

/**
* Light temperature in mired transformer
*
Expand Down Expand Up @@ -441,7 +444,7 @@ public function getTemperature(): int
{
if ($this->temperature > 500) {
return 500;
} else if ($this->temperature < 100) {
} elseif ($this->temperature < 100) {
return 100;
}

Expand All @@ -458,7 +461,7 @@ public function toHsb(): HsbTransformer
$saturation = $hue = 0;

if (array_key_exists($this->getTemperature(), self::LOOKUP_TABLE)) {
list($saturation, $hue) = self::LOOKUP_TABLE[$this->getTemperature()] + [null, null];
[$saturation, $hue] = self::LOOKUP_TABLE[$this->getTemperature()] + [null, null];
}

return new HsbTransformer(round($hue ?? 0), round($saturation ?? 0), $this->getBrightness());
Expand Down
12 changes: 9 additions & 3 deletions src/FastyBird/Library/Tools/src/Transformers/RgbTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@

namespace FastyBird\Library\Tools\Transformers;

use function abs;
use function floatval;
use function max;
use function min;
use function round;

/**
* RGB value object
*
Expand All @@ -27,9 +33,9 @@
{

public function __construct(
private int $red,
private int $green,
private int $blue,
private int $red,
private int $green,
private int $blue,
private int|null $white = null,
)
{
Expand Down
1 change: 1 addition & 0 deletions src/FastyBird/Module/Devices/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"fastybird/json-api": "^0.17",
"fastybird/metadata-library": "dev-main",
"fastybird/simple-auth": "^0.10",
"fastybird/tools-library": "dev-main",
"ipub/doctrine-timestampable": "^2.0",
"ipub/slim-router": "^0.2",
"nettrine/dbal": "^0.8",
Expand Down
1 change: 1 addition & 0 deletions src/FastyBird/Plugin/RedisDb/tools/phpstan.config.src.neon
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ parameters:
message: '#^Instanceof between string\|null and Predis\\Response\\ResponseInterface will always evaluate to false.#'
path: ../src/Clients/Client.php
count: 1
- message: '#^Parameter \#1 \$value of function strval expects bool\|float\|int\|resource\|string\|null, mixed given.#'
1 change: 0 additions & 1 deletion tools/phpstan.src.neon
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,5 @@ parameters:
- ../tests/stubs/EventEmitterInterface.stub

ignoreErrors:
- message: '#^Parameter \#1 \$value of function strval expects bool\|float\|int\|resource\|string\|null, mixed given.#'
- message: '#^Parameter \#1 \$value of function floatval expects array\|bool\|float\|int\|resource\|string\|null, mixed given.#'
- message: '#^Parameter \#1 \$value of function intval expects array\|bool\|float\|int\|resource\|string\|null, mixed given.#'

0 comments on commit b216f84

Please sign in to comment.