Skip to content

Commit 7e8b750

Browse files
committed
fixes
1 parent 309eb3a commit 7e8b750

File tree

8 files changed

+103
-70
lines changed

8 files changed

+103
-70
lines changed

phpstan.src.baseline.neon

Lines changed: 64 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,6 @@ parameters:
2020
count: 1
2121
path: src/External/Dto/Option.php
2222

23-
-
24-
message: "#^PHPDoc tag @param references unknown parameter\\: \\$force$#"
25-
count: 1
26-
path: src/Interfaces/Customer.php
27-
28-
-
29-
message: "#^Method Bavix\\\\Wallet\\\\Internal\\\\Assembler\\\\OptionDtoAssembler\\:\\:create\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
30-
count: 1
31-
path: src/Internal/Assembler/OptionDtoAssembler.php
32-
33-
-
34-
message: "#^Method Bavix\\\\Wallet\\\\Internal\\\\Assembler\\\\OptionDtoAssemblerInterface\\:\\:create\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
35-
count: 1
36-
path: src/Internal/Assembler/OptionDtoAssemblerInterface.php
37-
3823
-
3924
message: "#^Parameter \\#3 \\$payableId of class Bavix\\\\Wallet\\\\Internal\\\\Dto\\\\TransactionDto constructor expects int\\|string, mixed given\\.$#"
4025
count: 1
@@ -56,12 +41,17 @@ parameters:
5641
path: src/Internal/Assembler/TransferDtoAssemblerInterface.php
5742

5843
-
59-
message: "#^Method Bavix\\\\Wallet\\\\Internal\\\\Decorator\\\\StorageServiceLockDecorator\\:\\:get\\(\\) should return string but returns string\\|false\\.$#"
44+
message: "#^Method Bavix\\\\Wallet\\\\Internal\\\\Decorator\\\\StorageServiceLockDecorator\\:\\:multiGet\\(\\) should return non\\-empty\\-array\\<non\\-empty\\-string, non\\-empty\\-string\\> but returns non\\-empty\\-array\\<non\\-empty\\-string, string\\>\\.$#"
45+
count: 1
46+
path: src/Internal/Decorator/StorageServiceLockDecorator.php
47+
48+
-
49+
message: "#^Method Bavix\\\\Wallet\\\\Internal\\\\Decorator\\\\StorageServiceLockDecorator\\:\\:multiIncrease\\(\\) should return non\\-empty\\-array\\<non\\-empty\\-string, non\\-empty\\-string\\> but returns non\\-empty\\-array\\<string, string\\>\\.$#"
6050
count: 1
6151
path: src/Internal/Decorator/StorageServiceLockDecorator.php
6252

6353
-
64-
message: "#^Parameter \\#1 \\$inputs of method Bavix\\\\Wallet\\\\Internal\\\\Decorator\\\\StorageServiceLockDecorator\\:\\:multiSync\\(\\) expects non\\-empty\\-array\\<string, float\\|int\\|string\\>, array\\<string, string\\> given\\.$#"
54+
message: "#^Parameter \\#1 \\$inputs of method Bavix\\\\Wallet\\\\Internal\\\\Decorator\\\\StorageServiceLockDecorator\\:\\:multiSync\\(\\) expects non\\-empty\\-array\\<non\\-empty\\-string, float\\|int\\|non\\-empty\\-string\\>, non\\-empty\\-array\\<non\\-empty\\-string, string\\> given\\.$#"
6555
count: 1
6656
path: src/Internal/Decorator/StorageServiceLockDecorator.php
6757

@@ -80,6 +70,16 @@ parameters:
8070
count: 1
8171
path: src/Internal/Service/StateService.php
8272

73+
-
74+
message: "#^Method Bavix\\\\Wallet\\\\Internal\\\\Service\\\\StorageService\\:\\:get\\(\\) should return non\\-empty\\-string but returns string\\.$#"
75+
count: 1
76+
path: src/Internal/Service/StorageService.php
77+
78+
-
79+
message: "#^Method Bavix\\\\Wallet\\\\Internal\\\\Service\\\\StorageService\\:\\:increase\\(\\) should return non\\-empty\\-string but returns string\\.$#"
80+
count: 1
81+
path: src/Internal/Service/StorageService.php
82+
8383
-
8484
message: "#^Method Bavix\\\\Wallet\\\\Models\\\\Transaction\\:\\:wallet\\(\\) should return Illuminate\\\\Database\\\\Eloquent\\\\Relations\\\\BelongsTo\\<Bavix\\\\Wallet\\\\Models\\\\Wallet, Bavix\\\\Wallet\\\\Models\\\\Transaction\\> but returns Illuminate\\\\Database\\\\Eloquent\\\\Relations\\\\BelongsTo\\<TRelatedModel of Illuminate\\\\Database\\\\Eloquent\\\\Model, \\$this\\(Bavix\\\\Wallet\\\\Models\\\\Transaction\\)\\>\\.$#"
8585
count: 1
@@ -145,16 +145,6 @@ parameters:
145145
count: 1
146146
path: src/Models/Wallet.php
147147

148-
-
149-
message: "#^Method Bavix\\\\Wallet\\\\Models\\\\Wallet\\:\\:deposit\\(\\) has parameter \\$meta with no value type specified in iterable type array\\.$#"
150-
count: 2
151-
path: src/Models/Wallet.php
152-
153-
-
154-
message: "#^Method Bavix\\\\Wallet\\\\Models\\\\Wallet\\:\\:forceWithdraw\\(\\) has parameter \\$meta with no value type specified in iterable type array\\.$#"
155-
count: 2
156-
path: src/Models/Wallet.php
157-
158148
-
159149
message: "#^Method Bavix\\\\Wallet\\\\Models\\\\Wallet\\:\\:getBalanceFloatAttribute\\(\\) should return non\\-empty\\-string but returns string\\.$#"
160150
count: 1
@@ -181,7 +171,7 @@ parameters:
181171
path: src/Models/Wallet.php
182172

183173
-
184-
message: "#^Method Bavix\\\\Wallet\\\\Models\\\\Wallet\\:\\:withdraw\\(\\) has parameter \\$meta with no value type specified in iterable type array\\.$#"
174+
message: "#^Parameter \\#1 \\$amount of method Bavix\\\\Wallet\\\\Interfaces\\\\Wallet\\:\\:forceWithdraw\\(\\) expects int\\|non\\-empty\\-string, int\\|string given\\.$#"
185175
count: 2
186176
path: src/Models/Wallet.php
187177

@@ -205,6 +195,11 @@ parameters:
205195
count: 2
206196
path: src/Models/Wallet.php
207197

198+
-
199+
message: "#^Parameter \\#2 \\$amount of method Bavix\\\\Wallet\\\\Interfaces\\\\Wallet\\:\\:forceTransfer\\(\\) expects int\\|non\\-empty\\-string, int\\|string given\\.$#"
200+
count: 2
201+
path: src/Models/Wallet.php
202+
208203
-
209204
message: "#^Parameter \\#2 \\$value of method Bavix\\\\Wallet\\\\Services\\\\RegulatorService\\:\\:increase\\(\\) expects float\\|int\\|non\\-empty\\-string, string given\\.$#"
210205
count: 1
@@ -251,7 +246,22 @@ parameters:
251246
path: src/Services/AtmService.php
252247

253248
-
254-
message: "#^Method Bavix\\\\Wallet\\\\Services\\\\BookkeeperService\\:\\:multiAmount\\(\\) should return non\\-empty\\-array\\<string, string\\> but returns array\\<string, string\\>\\.$#"
249+
message: "#^Parameter \\#1 \\$inputs of method Bavix\\\\Wallet\\\\Internal\\\\Service\\\\StorageServiceInterface\\:\\:multiIncrease\\(\\) expects non\\-empty\\-array\\<non\\-empty\\-string, float\\|int\\|non\\-empty\\-string\\>, T of non\\-empty\\-array\\<string, float\\|int\\|string\\> given\\.$#"
250+
count: 2
251+
path: src/Services/BookkeeperService.php
252+
253+
-
254+
message: "#^Parameter \\#1 \\$inputs of method Bavix\\\\Wallet\\\\Internal\\\\Service\\\\StorageServiceInterface\\:\\:multiSync\\(\\) expects non\\-empty\\-array\\<non\\-empty\\-string, float\\|int\\|non\\-empty\\-string\\>, non\\-empty\\-array\\<string, float\\|int\\|string\\> given\\.$#"
255+
count: 1
256+
path: src/Services/BookkeeperService.php
257+
258+
-
259+
message: "#^Parameter \\#1 \\$uuid of method Bavix\\\\Wallet\\\\Internal\\\\Service\\\\StorageServiceInterface\\:\\:forget\\(\\) expects non\\-empty\\-string, string given\\.$#"
260+
count: 1
261+
path: src/Services/BookkeeperService.php
262+
263+
-
264+
message: "#^Parameter \\#1 \\$uuids of method Bavix\\\\Wallet\\\\Internal\\\\Service\\\\StorageServiceInterface\\:\\:multiGet\\(\\) expects non\\-empty\\-array\\<non\\-empty\\-string\\>, non\\-empty\\-array\\<int, string\\> given\\.$#"
255265
count: 2
256266
path: src/Services/BookkeeperService.php
257267

@@ -265,6 +275,31 @@ parameters:
265275
count: 1
266276
path: src/Services/RegulatorService.php
267277

278+
-
279+
message: "#^Parameter \\#1 \\$uuid of method Bavix\\\\Wallet\\\\Internal\\\\Service\\\\StorageServiceInterface\\:\\:forget\\(\\) expects non\\-empty\\-string, string given\\.$#"
280+
count: 1
281+
path: src/Services/RegulatorService.php
282+
283+
-
284+
message: "#^Parameter \\#1 \\$uuid of method Bavix\\\\Wallet\\\\Internal\\\\Service\\\\StorageServiceInterface\\:\\:get\\(\\) expects non\\-empty\\-string, string given\\.$#"
285+
count: 1
286+
path: src/Services/RegulatorService.php
287+
288+
-
289+
message: "#^Parameter \\#1 \\$uuid of method Bavix\\\\Wallet\\\\Internal\\\\Service\\\\StorageServiceInterface\\:\\:increase\\(\\) expects non\\-empty\\-string, string given\\.$#"
290+
count: 1
291+
path: src/Services/RegulatorService.php
292+
293+
-
294+
message: "#^Parameter \\#1 \\$uuid of method Bavix\\\\Wallet\\\\Internal\\\\Service\\\\StorageServiceInterface\\:\\:sync\\(\\) expects non\\-empty\\-string, string given\\.$#"
295+
count: 2
296+
path: src/Services/RegulatorService.php
297+
298+
-
299+
message: "#^Parameter \\#2 \\$value of method Bavix\\\\Wallet\\\\Internal\\\\Service\\\\StorageServiceInterface\\:\\:sync\\(\\) expects float\\|int\\|non\\-empty\\-string, string given\\.$#"
300+
count: 2
301+
path: src/Services/RegulatorService.php
302+
268303
-
269304
message: "#^Parameter \\#2 \\$value of method Bavix\\\\Wallet\\\\Services\\\\RegulatorService\\:\\:increase\\(\\) expects float\\|int\\|non\\-empty\\-string, string given\\.$#"
270305
count: 1

src/Interfaces/Customer.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,22 @@ interface Customer extends Wallet
1919
/**
2020
* Purchase a product without payment.
2121
*
22-
* This method purchases the provided product without payment. If the purchase is successful,
23-
* the method returns the transfer object. If the purchase fails due to insufficient funds or
24-
* empty balance, it returns null. If the purchase fails due to a reason
25-
* other than the above, it throws a more specific exception.
22+
* This method allows the user to purchase the provided product without any payment involved.
23+
* If the purchase is successful, the method returns the transfer object representing the purchase.
2624
*
2725
* @param ProductInterface $product The product to be purchased.
28-
* @param bool $force [optional] Whether to force the purchase. Defaults to false.
29-
* @return Transfer|null The transfer object representing the purchase, or null if the purchase fails.
26+
* @return Transfer The transfer object representing the purchase.
3027
*
3128
* @throws ProductEnded If the product is ended.
3229
* @throws BalanceIsEmpty If the balance of the wallet is empty.
3330
* @throws InsufficientFunds If there are insufficient funds in the wallet.
34-
* @throws RecordNotFoundException If the record is not found.
31+
* @throws RecordNotFoundException If the wallet or the product record is not found.
3532
* @throws RecordsNotFoundException If the records are not found.
3633
* @throws TransactionFailedException If the transaction fails.
34+
* @throws ModelNotFoundException If the wallet or the product is not found.
3735
* @throws ExceptionInterface If an exception occurs.
3836
*/
39-
public function payFree(ProductInterface $product): ?Transfer;
37+
public function payFree(ProductInterface $product): Transfer;
4038

4139
/**
4240
* Attempts to purchase a product without payment.

src/Interfaces/Wallet.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ interface Wallet
2121
/**
2222
* Deposit the specified amount of money into the wallet.
2323
*
24-
* @param int|string $amount The amount to deposit.
24+
* @param int|non-empty-string $amount The amount to deposit.
2525
* @param array<mixed>|null $meta Additional information for the transaction.
2626
* @param bool $confirmed Whether the transaction is confirmed or not.
2727
* @return Transaction The created transaction.
@@ -36,7 +36,7 @@ public function deposit(int|string $amount, ?array $meta = null, bool $confirmed
3636
/**
3737
* Withdraw the specified amount of money from the wallet.
3838
*
39-
* @param int|string $amount The amount to withdraw.
39+
* @param int|non-empty-string $amount The amount to withdraw.
4040
* @param array<mixed>|null $meta Additional information for the transaction.
4141
* @param bool $confirmed Whether the transaction is confirmed or not.
4242
* @return Transaction The created transaction.
@@ -53,7 +53,7 @@ public function withdraw(int|string $amount, ?array $meta = null, bool $confirme
5353
/**
5454
* Forced to withdraw funds from the wallet.
5555
*
56-
* @param int|string $amount The amount to withdraw.
56+
* @param int|non-empty-string $amount The amount to withdraw.
5757
* @param array<mixed>|null $meta Additional information for the transaction.
5858
* @param bool $confirmed Whether the transaction is confirmed or not.
5959
* @return Transaction The created transaction.
@@ -69,7 +69,7 @@ public function forceWithdraw(int|string $amount, ?array $meta = null, bool $con
6969
* Transfer funds from this wallet to another.
7070
*
7171
* @param self $wallet The wallet to transfer funds to.
72-
* @param int|string $amount The amount to transfer.
72+
* @param int|non-empty-string $amount The amount to transfer.
7373
* @param ExtraDtoInterface|array<mixed>|null $meta Additional information for the transaction.
7474
* @return Transfer The created transaction.
7575
*
@@ -89,7 +89,7 @@ public function transfer(self $wallet, int|string $amount, ExtraDtoInterface|arr
8989
* If an error occurs during the process, null is returned.
9090
*
9191
* @param self $wallet The wallet to transfer funds to.
92-
* @param int|string $amount The amount to transfer.
92+
* @param int|non-empty-string $amount The amount to transfer.
9393
* @param ExtraDtoInterface|array<mixed>|null $meta Additional information for the transaction.
9494
* This can be an instance of an ExtraDtoInterface
9595
* or an array of arbitrary data.
@@ -116,7 +116,7 @@ public function safeTransfer(
116116
* method with caution as it can result in negative balances or other unintended consequences.
117117
*
118118
* @param self $wallet The wallet instance to which funds will be transferred.
119-
* @param int|string $amount The amount of funds to transfer. Can be specified as an integer or a string.
119+
* @param int|non-empty-string $amount The amount of funds to transfer. Can be specified as an integer or a string.
120120
* @param ExtraDtoInterface|array<mixed>|null $meta Additional metadata associated with the transfer. This
121121
* can be used to store extra information about the transaction, such as reasons for the transfer or
122122
* identifiers linking to other systems.
@@ -138,7 +138,7 @@ public function forceTransfer(
138138
/**
139139
* Checks if the wallet can safely withdraw the specified amount.
140140
*
141-
* @param int|string $amount The amount to withdraw.
141+
* @param int|non-empty-string $amount The amount to withdraw.
142142
* @param bool $allowZero Whether to allow withdrawing when the balance is zero.
143143
* @return bool Returns true if the wallet can withdraw the specified amount, false otherwise.
144144
*/

src/Interfaces/WalletFloat.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ interface WalletFloat
1919
/**
2020
* Deposit a float amount of money into the wallet.
2121
*
22-
* @param float|int|string $amount The amount to deposit.
22+
* @param float|int|non-empty-string $amount The amount to deposit.
2323
* @param null|array<mixed> $meta Additional information for the transaction.
2424
* @param bool $confirmed Whether the transaction is confirmed or not.
2525
* @return Transaction The created transaction.
@@ -38,7 +38,7 @@ public function depositFloat(
3838
/**
3939
* Withdraw the specified float amount of money from the wallet.
4040
*
41-
* @param float|int|string $amount The amount to withdraw.
41+
* @param float|int|non-empty-string $amount The amount to withdraw.
4242
* @param array<mixed>|null $meta Additional information for the transaction.
4343
* @param bool $confirmed Whether the transaction is confirmed or not.
4444
* @return Transaction The created transaction.
@@ -59,7 +59,7 @@ public function withdrawFloat(
5959
/**
6060
* Forced to withdraw funds from the wallet.
6161
*
62-
* @param float|int|string $amount The amount to withdraw.
62+
* @param float|int|non-empty-string $amount The amount to withdraw.
6363
* @param null|array<mixed> $meta Additional information for the transaction.
6464
* @param bool $confirmed Whether the transaction is confirmed or not.
6565
* @return Transaction The created transaction.
@@ -79,7 +79,7 @@ public function forceWithdrawFloat(
7979
* Transfer funds from this wallet to another.
8080
*
8181
* @param Wallet $wallet The wallet to transfer funds to.
82-
* @param float|int|string $amount The amount to transfer.
82+
* @param float|int|non-empty-string $amount The amount to transfer.
8383
* @param ExtraDtoInterface|array<mixed>|null $meta Additional information for the transaction.
8484
* This can be an instance of an ExtraDtoInterface
8585
* or an array of arbitrary data.
@@ -104,7 +104,7 @@ public function transferFloat(
104104
* This method will not throw an exception if the transfer fails. Instead, it will return null.
105105
*
106106
* @param Wallet $wallet The wallet to transfer funds to.
107-
* @param float|int|string $amount The amount to transfer.
107+
* @param float|int|non-empty-string $amount The amount to transfer.
108108
* @param ExtraDtoInterface|array<mixed>|null $meta Additional information for the transaction.
109109
* This can be an instance of an ExtraDtoInterface
110110
* or an array of arbitrary data.
@@ -126,7 +126,7 @@ public function safeTransferFloat(
126126
* method with caution as it can result in negative balances or other unintended consequences.
127127
*
128128
* @param Wallet $wallet The wallet instance to which funds will be transferred.
129-
* @param float|int|string $amount The amount of funds to transfer. Can be specified as a float, int, or string.
129+
* @param float|int|non-empty-string $amount The amount of funds to transfer. Can be specified as a float, int, or string.
130130
* @param ExtraDtoInterface|array<mixed>|null $meta Additional metadata associated with the transfer. This
131131
* can be used to store extra information about the transaction, such as reasons for the transfer or
132132
* identifiers linking to other systems.
@@ -148,7 +148,7 @@ public function forceTransferFloat(
148148
/**
149149
* Checks if the user can withdraw the specified amount of funds.
150150
*
151-
* @param float|int|string $amount The amount of funds to withdraw. Can be specified as a float, int, or string.
151+
* @param float|int|non-empty-string $amount The amount of funds to withdraw. Can be specified as a float, int, or string.
152152
* @return bool Returns TRUE if the withdrawal is possible, FALSE otherwise.
153153
*
154154
* @throws AmountInvalid If the amount is invalid (e.g., negative values).
@@ -161,7 +161,7 @@ public function canWithdrawFloat(float|int|string $amount): bool;
161161
* This method returns the balance of the wallet as a string. The balance is the total amount of funds
162162
* held by the wallet.
163163
*
164-
* @return string The user's current balance as a string (e.g. "1.23").
164+
* @return non-empty-string The user's current balance as a string (e.g. "1.23").
165165
*/
166166
public function getBalanceFloatAttribute(): string;
167167

src/Internal/Assembler/OptionDtoAssemblerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ interface OptionDtoAssemblerInterface
1111
/**
1212
* Create an OptionDto object from the given data.
1313
*
14-
* @param array|null $data The data to create the OptionDto from.
14+
* @param array<mixed>|null $data The data to create the OptionDto from.
1515
* This can be null, in which case an empty
1616
* OptionDto object will be created.
1717
* @return OptionDtoInterface The created OptionDto object.

0 commit comments

Comments
 (0)