diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8b5214d..dbf8532 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,7 +34,7 @@ jobs: JBZOO_COMPOSER_UPDATE_FLAGS: ${{ matrix.composer_flags }} strategy: matrix: - php-version: [ 8.1, 8.2 ] + php-version: [ 8.1, 8.2, 8.3 ] coverage: [ xdebug, none ] composer_flags: [ "--prefer-lowest", "" ] steps: @@ -77,7 +77,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-version: [ 8.1, 8.2 ] + php-version: [ 8.1, 8.2, 8.3 ] steps: - name: Checkout code uses: actions/checkout@v3 @@ -111,7 +111,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-version: [ 8.1, 8.2 ] + php-version: [ 8.1, 8.2, 8.3 ] steps: - name: Checkout code uses: actions/checkout@v3 diff --git a/composer.json b/composer.json index 4fa5e60..0dac850 100644 --- a/composer.json +++ b/composer.json @@ -32,11 +32,11 @@ "require" : { "php" : "^8.1", - "jbzoo/utils" : "^7.0" + "jbzoo/utils" : "^7.1" }, "require-dev" : { - "jbzoo/toolbox-dev" : "^7.0" + "jbzoo/toolbox-dev" : "^7.1" }, "autoload" : { diff --git a/src/Formatter.php b/src/Formatter.php index f329675..bf75dc8 100644 --- a/src/Formatter.php +++ b/src/Formatter.php @@ -140,7 +140,7 @@ public function round(float $value, string $rule, array $params = []): float $roundType = $params['roundType']; $roundValue = $params['roundValue']; - if (!$roundType) { + if ($roundType === null) { $roundType = \array_key_exists('round_type', $format) ? $format['round_type'] : self::ROUND_NONE; } diff --git a/src/Parser.php b/src/Parser.php index 626e40e..d2bb5b5 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -102,7 +102,7 @@ public function removeRule(string $rule): bool return false; } - public static function cleanValue(float|int|string|null $value): float + public static function cleanValue(null|float|int|string $value): float { $result = \trim((string)$value); diff --git a/src/Type/AbstractType.php b/src/Type/AbstractType.php index ebf0815..c273bc4 100644 --- a/src/Type/AbstractType.php +++ b/src/Type/AbstractType.php @@ -47,14 +47,11 @@ abstract class AbstractType protected Parser $parser; protected Formatter $formatter; - public function __construct(float|int|string|array|null $value = null, ?AbstractConfig $config = null) + public function __construct(null|array|float|int|string $value = null, ?AbstractConfig $config = null) { $this->prepareObject($value, $config); } - /** - * @psalm-suppress MethodSignatureMustProvideReturnType - */ public function __toString() { $this->log('__toString() called'); @@ -290,7 +287,7 @@ public function getClone(): self * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function compare( - self|float|int|string|null|array $value, + null|array|float|int|self|string $value, string $mode = '==', int $round = Formatter::ROUND_DEFAULT, ): bool { @@ -339,12 +336,12 @@ public function setEmpty(bool $getClone = false): self return $this->modifier(0.0, 'Set empty', $getClone); } - public function add(self|float|int|string|null|array $value, bool $getClone = false): self + public function add(null|array|float|int|self|string $value, bool $getClone = false): self { return $this->customAdd($value, $getClone); } - public function subtract(self|float|int|string|null|array $value, bool $getClone = false): self + public function subtract(null|array|float|int|self|string $value, bool $getClone = false): self { return $this->customAdd($value, $getClone, true); } @@ -438,7 +435,7 @@ public function customFunc(\Closure $function, bool $getClone = false): self return $this->modifier($this->internalValue, '<-- Function finished', $getClone); } - public function set(self|float|int|string|null|array $value, bool $getClone = false): self + public function set(null|array|float|int|self|string $value, bool $getClone = false): self { $value = $this->getValidValue($value); @@ -463,7 +460,7 @@ public function round(int $roundValue, string $mode = Formatter::ROUND_CLASSIC): return $this; } - public function getValidValue(self|float|int|string|null|array $value): self + public function getValidValue(null|array|float|int|self|string $value): self { if ($value instanceof self) { $thisClass = \strtolower(static::class); @@ -608,7 +605,7 @@ protected function customConvert(string $rule, bool $addToLog = false): float } protected function customAdd( - self|float|int|string|null|array $value, + null|array|float|int|self|string $value, bool $getClone = false, bool $isSubtract = false, ): self { @@ -655,7 +652,7 @@ protected function modifier(float $newValue, ?string $logMessage = null, bool $g return $this; } - private function prepareObject(float|int|string|array|null $value = null, ?AbstractConfig $config = null): void + private function prepareObject(null|array|float|int|string $value = null, ?AbstractConfig $config = null): void { // $this->type = Str::class \strtolower(\str_replace(__NAMESPACE__ . '\\', '', static::class)); $this->type = Str::getClassName(static::class, true) ?? 'UndefinedType';