Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update PHP version to 8.3 and bump jbzoo dependencies to ^7.1 #14

Merged
merged 4 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" : {
Expand Down
2 changes: 1 addition & 1 deletion src/Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
19 changes: 8 additions & 11 deletions src/Type/AbstractType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);

Expand All @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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';
Expand Down
Loading