From fb66c3fa26128dae2286957b5ed0f15971f66419 Mon Sep 17 00:00:00 2001 From: Peter Elmered Date: Wed, 4 Dec 2024 21:01:58 +0100 Subject: [PATCH] Add type hints --- composer.json | 3 +++ src/Forms/Components/MoneyInput.php | 4 ++-- src/Infolists/Components/MoneyEntry.php | 4 ++-- src/Tables/Columns/MoneyColumn.php | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 55c6d4d..d59e080 100644 --- a/composer.json +++ b/composer.json @@ -72,6 +72,9 @@ "coverage": [ "@php vendor/bin/pest --testsuite=default --coverage-clover=coverage.xml --coverage-filter=src --path-coverage" ], + "types": [ + "@php vendor/bin/pest --type-coverage" + ], "check" : [ "composer lint", "composer test" diff --git a/src/Forms/Components/MoneyInput.php b/src/Forms/Components/MoneyInput.php index b2191d0..3540c09 100644 --- a/src/Forms/Components/MoneyInput.php +++ b/src/Forms/Components/MoneyInput.php @@ -32,7 +32,7 @@ protected function setUp(): void $this->prepare(); - $this->formatStateUsing(function (MoneyInput $component, $state): ?string { + $this->formatStateUsing(function (MoneyInput $component, null|int|string $state): ?string { $this->prepare(); @@ -49,7 +49,7 @@ protected function setUp(): void return MoneyFormatter::formatAsDecimal((int) $state, $currency, $locale, $this->getDecimals()); }); - $this->dehydrateStateUsing(function (MoneyInput $component, $state): ?string { + $this->dehydrateStateUsing(function (MoneyInput $component, null|int|string $state): ?string { $currency = $component->getCurrency(); $state = MoneyFormatter::parseDecimal($state, $currency, $component->getLocale(), $this->getDecimals()); diff --git a/src/Infolists/Components/MoneyEntry.php b/src/Infolists/Components/MoneyEntry.php index 3071483..511af7a 100644 --- a/src/Infolists/Components/MoneyEntry.php +++ b/src/Infolists/Components/MoneyEntry.php @@ -17,7 +17,7 @@ protected function setUp(): void $this->isMoney = true; $this->numeric(); - $this->formatStateUsing(function (MoneyEntry $component, $state): string { + $this->formatStateUsing(function (MoneyEntry $component, null|int|string $state): string { return MoneyFormatter::format( $state, $component->getCurrency(), @@ -29,7 +29,7 @@ protected function setUp(): void public function short(): static { - $this->formatStateUsing(function (MoneyEntry $component, $state) { + $this->formatStateUsing(function (MoneyEntry $component, null|int|string $state) { return MoneyFormatter::formatShort( $state, $component->getCurrency(), diff --git a/src/Tables/Columns/MoneyColumn.php b/src/Tables/Columns/MoneyColumn.php index 8243444..237d1e5 100644 --- a/src/Tables/Columns/MoneyColumn.php +++ b/src/Tables/Columns/MoneyColumn.php @@ -17,7 +17,7 @@ protected function setUp(): void $this->isMoney = true; $this->numeric(); - $this->formatStateUsing(function (MoneyColumn $component, $state): string { + $this->formatStateUsing(function (MoneyColumn $component, null|int|string $state): string { return MoneyFormatter::format( $state, $component->getCurrency(), @@ -29,7 +29,7 @@ protected function setUp(): void public function short(): static { - $this->formatStateUsing(function (MoneyColumn $component, $state) { + $this->formatStateUsing(function (MoneyColumn $component, null|int|string $state) { return MoneyFormatter::formatShort( $state, $component->getCurrency(),