Skip to content

Commit 4914716

Browse files
authored
Merge pull request #1045 from bavix/bumps
Refactor PHPStan baseline and update type hints
2 parents 3adf027 + 1c88019 commit 4914716

File tree

12 files changed

+273
-149
lines changed

12 files changed

+273
-149
lines changed

.codeclimate.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/workflows/phpunits.yaml

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
- 5432:5432
6060

6161
mysql:
62-
image: bitnami/mysql:8.0
62+
image: bitnamilegacy/mysql:8.0
6363
env:
6464
MYSQL_AUTHENTICATION_PLUGIN: mysql_native_password
6565
MYSQL_ROOT_PASSWORD: wallet
@@ -117,22 +117,14 @@ jobs:
117117
id: composer-dependencies
118118
run: composer install --prefer-dist --no-progress
119119

120-
- name: Check codeclimate
121-
id: codeclimate-check
120+
- name: Check coveralls
121+
id: coveralls-check
122122
run: echo "execute=${{ matrix.php-versions == '8.3' && matrix.caches == 'array' && matrix.locks == 'redis' && matrix.databases == 'testing' }}" >> $GITHUB_OUTPUT
123123

124-
- name: Prepare codeclimate
125-
id: codeclimate-prepare
126-
run: |
127-
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
128-
chmod +x ./cc-test-reporter
129-
./cc-test-reporter before-build
130-
if: ${{ steps.codeclimate-check.outputs.execute == 'true' }}
131-
132124
- name: Prepare run test suite
133125
id: unit-prepare
134126
run: |
135-
mkdir build
127+
mkdir -p build
136128
137129
- name: Run test suite
138130
id: unit-run
@@ -151,21 +143,21 @@ jobs:
151143
WALLET_LOCK_DRIVER: ${{ matrix.locks }}
152144
DB_CONNECTION: ${{ matrix.databases }}
153145
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
154-
if: ${{ steps.codeclimate-check.outputs.execute == 'true' }}
146+
if: ${{ steps.coveralls-check.outputs.execute == 'true' }}
155147

156-
- name: Send coverage
157-
id: codeclimate-send
158-
uses: nick-fields/retry@v3
148+
- name: Coveralls
149+
uses: coverallsapp/github-action@v2
159150
with:
160-
timeout_seconds: 15
161-
max_attempts: 3
162-
command: >-
163-
./cc-test-reporter after-build --coverage-input-type clover --exit-code 0
164-
env:
165-
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
166-
if: ${{ steps.codeclimate-check.outputs.execute == 'true' }}
167-
168-
- uses: codecov/codecov-action@v4
151+
github-token: ${{ secrets.GITHUB_TOKEN }}
152+
file: build/coverage.xml
153+
format: cobertura
154+
flag-name: run-${{ matrix.php-versions }}-${{ matrix.databases }}-${{ matrix.caches }}-${{ matrix.locks }}
155+
parallel: true
156+
if: ${{ steps.coveralls-check.outputs.execute == 'true' }}
157+
158+
- name: Coveralls Finished
159+
uses: coverallsapp/github-action@v2
169160
with:
170-
token: ${{ secrets.CODECOV_TOKEN }}
171-
if: ${{ steps.codeclimate-check.outputs.execute == 'true' }}
161+
github-token: ${{ secrets.GITHUB_TOKEN }}
162+
parallel-finished: true
163+
if: ${{ steps.coveralls-check.outputs.execute == 'true' }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![Laravel Wallet](https://github.com/bavix/laravel-wallet/assets/5111255/95e7877c-a950-4b04-9414-de62216d31c2)
22

3-
[![Maintainability](https://api.codeclimate.com/v1/badges/588400f5f40cbbf3a8ab/maintainability)](https://codeclimate.com/github/bavix/laravel-wallet/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/588400f5f40cbbf3a8ab/test_coverage)](https://codeclimate.com/github/bavix/laravel-wallet/test_coverage) [![Financial Contributors on Open Collective](https://opencollective.com/laravel-wallet/all/badge.svg?label=financial+contributors)](https://opencollective.com/laravel-wallet) [![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fbavix%2Flaravel-wallet%2Fmaster)](https://packagist.org/packages/bavix/laravel-wallet)
3+
[![Coverage Status](https://coveralls.io/repos/github/bavix/laravel-wallet/badge.svg?branch=master)](https://coveralls.io/github/bavix/laravel-wallet?branch=master) [![Financial Contributors on Open Collective](https://opencollective.com/laravel-wallet/all/badge.svg?label=financial+contributors)](https://opencollective.com/laravel-wallet) [![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fbavix%2Flaravel-wallet%2Fmaster)](https://packagist.org/packages/bavix/laravel-wallet)
44

55
[![Latest Stable Version](https://poser.pugx.org/bavix/laravel-wallet/v)](https://packagist.org/packages/bavix/laravel-wallet) [![Latest Unstable Version](https://poser.pugx.org/bavix/laravel-wallet/v/unstable)](https://packagist.org/packages/bavix/laravel-wallet) [![License](https://poser.pugx.org/bavix/laravel-wallet/license)](https://packagist.org/packages/bavix/laravel-wallet) [![composer.lock](https://poser.pugx.org/bavix/laravel-wallet/composerlock)](https://packagist.org/packages/bavix/laravel-wallet)
66

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
}
6060
},
6161
"scripts": {
62-
"parabench": "@php ./vendor/bin/testbench package:test --coverage-xml=build/coverage-xml --log-junit=build/junit.xml",
62+
"parabench": "@php ./vendor/bin/testbench package:test --coverage-xml=build --log-junit=build/junit.xml",
6363
"infect": "@php vendor/bin/infection --coverage=build --min-msi=50 -j$(nproc) --only-covering-test-cases",
6464
"phpstan": [
6565
"@phpstan-src",

phpstan.src.baseline.neon

Lines changed: 127 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,6 @@ parameters:
108108
count: 1
109109
path: src/Internal/Dto/TransferDto.php
110110

111-
-
112-
message: '#^Method Bavix\\Wallet\\Internal\\Dto\\TransferDto\:\:getFromId\(\) never returns string so it can be removed from the return type\.$#'
113-
identifier: return.unusedType
114-
count: 1
115-
path: src/Internal/Dto/TransferDto.php
116-
117-
-
118-
message: '#^Method Bavix\\Wallet\\Internal\\Dto\\TransferDto\:\:getToId\(\) never returns string so it can be removed from the return type\.$#'
119-
identifier: return.unusedType
120-
count: 1
121-
path: src/Internal/Dto/TransferDto.php
122-
123111
-
124112
message: '#^Method Bavix\\Wallet\\Internal\\Dto\\TransferDto\:\:getUuid\(\) should return non\-empty\-string but returns string\.$#'
125113
identifier: return.type
@@ -169,7 +157,7 @@ parameters:
169157
path: src/Internal/Repository/WalletRepository.php
170158

171159
-
172-
message: '#^Parameter \#1 \$name of method Illuminate\\Database\\ConnectionResolverInterface\:\:connection\(\) expects string\|null, mixed given\.$#'
160+
message: '#^Parameter \#1 \$name of method Illuminate\\Database\\ConnectionResolverInterface\:\:connection\(\) expects string\|UnitEnum\|null, mixed given\.$#'
173161
identifier: argument.type
174162
count: 1
175163
path: src/Internal/Service/ConnectionService.php
@@ -180,66 +168,6 @@ parameters:
180168
count: 1
181169
path: src/Internal/Service/LockService.php
182170

183-
-
184-
message: '#^Method Bavix\\Wallet\\Internal\\Service\\MathService\:\:abs\(\) should return non\-empty\-string but returns string\.$#'
185-
identifier: return.type
186-
count: 1
187-
path: src/Internal/Service/MathService.php
188-
189-
-
190-
message: '#^Method Bavix\\Wallet\\Internal\\Service\\MathService\:\:add\(\) should return non\-empty\-string but returns string\.$#'
191-
identifier: return.type
192-
count: 1
193-
path: src/Internal/Service/MathService.php
194-
195-
-
196-
message: '#^Method Bavix\\Wallet\\Internal\\Service\\MathService\:\:ceil\(\) should return non\-empty\-string but returns string\.$#'
197-
identifier: return.type
198-
count: 1
199-
path: src/Internal/Service/MathService.php
200-
201-
-
202-
message: '#^Method Bavix\\Wallet\\Internal\\Service\\MathService\:\:div\(\) should return non\-empty\-string but returns string\.$#'
203-
identifier: return.type
204-
count: 1
205-
path: src/Internal/Service/MathService.php
206-
207-
-
208-
message: '#^Method Bavix\\Wallet\\Internal\\Service\\MathService\:\:floor\(\) should return non\-empty\-string but returns string\.$#'
209-
identifier: return.type
210-
count: 1
211-
path: src/Internal/Service/MathService.php
212-
213-
-
214-
message: '#^Method Bavix\\Wallet\\Internal\\Service\\MathService\:\:mul\(\) should return non\-empty\-string but returns string\.$#'
215-
identifier: return.type
216-
count: 1
217-
path: src/Internal/Service/MathService.php
218-
219-
-
220-
message: '#^Method Bavix\\Wallet\\Internal\\Service\\MathService\:\:negative\(\) should return non\-empty\-string but returns string\.$#'
221-
identifier: return.type
222-
count: 1
223-
path: src/Internal/Service/MathService.php
224-
225-
-
226-
message: '#^Method Bavix\\Wallet\\Internal\\Service\\MathService\:\:pow\(\) should return non\-empty\-string but returns string\.$#'
227-
identifier: return.type
228-
count: 1
229-
path: src/Internal/Service/MathService.php
230-
231-
-
232-
message: '#^Method Bavix\\Wallet\\Internal\\Service\\MathService\:\:round\(\) should return non\-empty\-string but returns string\.$#'
233-
identifier: return.type
234-
count: 1
235-
path: src/Internal/Service/MathService.php
236-
237-
-
238-
message: '#^Method Bavix\\Wallet\\Internal\\Service\\MathService\:\:sub\(\) should return non\-empty\-string but returns string\.$#'
239-
identifier: return.type
240-
count: 1
241-
path: src/Internal/Service/MathService.php
242-
243171
-
244172
message: '#^Binary operation "\." between ''wallet_f\:\:'' and mixed results in an error\.$#'
245173
identifier: binaryOp.invalid
@@ -318,6 +246,12 @@ parameters:
318246
count: 1
319247
path: src/Models/Transaction.php
320248

249+
-
250+
message: '#^Parameter \#1 \$first of method Bavix\\Wallet\\Internal\\Service\\MathServiceInterface\:\:mul\(\) expects float\|int\|non\-empty\-string, float\|int\|string given\.$#'
251+
identifier: argument.type
252+
count: 1
253+
path: src/Models/Transaction.php
254+
321255
-
322256
message: '#^Parameter \#1 \$related of method Illuminate\\Database\\Eloquent\\Model\:\:belongsTo\(\) expects class\-string\<Illuminate\\Database\\Eloquent\\Model\>, mixed given\.$#'
323257
identifier: argument.type
@@ -385,15 +319,15 @@ parameters:
385319
path: src/Models/Transfer.php
386320

387321
-
388-
message: '#^Call to function assert\(\) with true and ''Balance should not…'' will always evaluate to true\.$#'
389-
identifier: function.alreadyNarrowedType
322+
message: '#^Binary operation "\." between literal\-string&non\-falsy\-string and mixed results in an error\.$#'
323+
identifier: binaryOp.invalid
390324
count: 1
391325
path: src/Models/Wallet.php
392326

393327
-
394-
message: '#^Cannot call method getDynamicDefaultSlug\(\) on class\-string\|object\.$#'
395-
identifier: method.nonObject
396-
count: 2
328+
message: '#^Call to function assert\(\) with true and ''Balance should not…'' will always evaluate to true\.$#'
329+
identifier: function.alreadyNarrowedType
330+
count: 1
397331
path: src/Models/Wallet.php
398332

399333
-
@@ -426,6 +360,12 @@ parameters:
426360
count: 2
427361
path: src/Models/Wallet.php
428362

363+
-
364+
message: '#^Method Bavix\\Wallet\\Models\\Wallet\:\:getBalanceFloatAttribute\(\) should return non\-empty\-string but returns string\.$#'
365+
identifier: return.type
366+
count: 1
367+
path: src/Models/Wallet.php
368+
429369
-
430370
message: '#^Method Bavix\\Wallet\\Models\\Wallet\:\:getCurrencyAttribute\(\) should return string but returns mixed\.$#'
431371
identifier: return.type
@@ -438,6 +378,36 @@ parameters:
438378
count: 1
439379
path: src/Models/Wallet.php
440380

381+
-
382+
message: '#^Method Bavix\\Wallet\\Models\\Wallet\:\:receivedTransfers\(\) should return Illuminate\\Database\\Eloquent\\Relations\\HasMany\<Bavix\\Wallet\\Models\\Transfer\> but returns Illuminate\\Database\\Eloquent\\Relations\\HasMany\<Illuminate\\Database\\Eloquent\\Model, Bavix\\Wallet\\Models\\Wallet\>\.$#'
383+
identifier: return.type
384+
count: 2
385+
path: src/Models/Wallet.php
386+
387+
-
388+
message: '#^Method Bavix\\Wallet\\Models\\Wallet\:\:transactions\(\) should return Illuminate\\Database\\Eloquent\\Relations\\MorphMany\<Bavix\\Wallet\\Models\\Transaction\> but returns Illuminate\\Database\\Eloquent\\Relations\\MorphMany\<Illuminate\\Database\\Eloquent\\Model, Illuminate\\Database\\Eloquent\\Model\>\.$#'
389+
identifier: return.type
390+
count: 2
391+
path: src/Models/Wallet.php
392+
393+
-
394+
message: '#^Method Bavix\\Wallet\\Models\\Wallet\:\:transfers\(\) should return Illuminate\\Database\\Eloquent\\Relations\\HasMany\<Bavix\\Wallet\\Models\\Transfer\> but returns Illuminate\\Database\\Eloquent\\Relations\\HasMany\<Illuminate\\Database\\Eloquent\\Model, Bavix\\Wallet\\Models\\Wallet\>\.$#'
395+
identifier: return.type
396+
count: 2
397+
path: src/Models/Wallet.php
398+
399+
-
400+
message: '#^Method Bavix\\Wallet\\Models\\Wallet\:\:wallet\(\) should return Illuminate\\Database\\Eloquent\\Relations\\MorphOne\<Bavix\\Wallet\\Models\\Wallet\> but returns Illuminate\\Database\\Eloquent\\Relations\\MorphOne\<Bavix\\Wallet\\Models\\Wallet, Illuminate\\Database\\Eloquent\\Model\>\.$#'
401+
identifier: return.type
402+
count: 2
403+
path: src/Models/Wallet.php
404+
405+
-
406+
message: '#^Method Bavix\\Wallet\\Models\\Wallet\:\:walletTransactions\(\) should return Illuminate\\Database\\Eloquent\\Relations\\HasMany\<Bavix\\Wallet\\Models\\Transaction\> but returns Illuminate\\Database\\Eloquent\\Relations\\HasMany\<Illuminate\\Database\\Eloquent\\Model, Bavix\\Wallet\\Models\\Wallet\>\.$#'
407+
identifier: return.type
408+
count: 2
409+
path: src/Models/Wallet.php
410+
441411
-
442412
message: '#^PHPDoc tag @var with type Bavix\\Wallet\\Interfaces\\Wallet is not subtype of native type \$this\(Bavix\\Wallet\\Models\\Wallet\)\.$#'
443413
identifier: varTag.nativeType
@@ -456,6 +426,42 @@ parameters:
456426
count: 2
457427
path: src/Models/Wallet.php
458428

429+
-
430+
message: '#^Parameter \#1 \$attributes of method Illuminate\\Database\\Eloquent\\Model\:\:forceFill\(\) expects array\<string, mixed\>, array\<mixed, mixed\> given\.$#'
431+
identifier: argument.type
432+
count: 2
433+
path: src/Models/Wallet.php
434+
435+
-
436+
message: '#^Parameter \#1 \$first of method Bavix\\Wallet\\Internal\\Service\\MathServiceInterface\:\:add\(\) expects float\|int\|non\-empty\-string, int\|string given\.$#'
437+
identifier: argument.type
438+
count: 1
439+
path: src/Models/Wallet.php
440+
441+
-
442+
message: '#^Parameter \#1 \$first of method Bavix\\Wallet\\Internal\\Service\\MathServiceInterface\:\:mul\(\) expects float\|int\|non\-empty\-string, float\|int\|string given\.$#'
443+
identifier: argument.type
444+
count: 7
445+
path: src/Models/Wallet.php
446+
447+
-
448+
message: '#^Parameter \#1 \$first of method Bavix\\Wallet\\Internal\\Service\\MathServiceInterface\:\:mul\(\) expects float\|int\|non\-empty\-string, int\|string given\.$#'
449+
identifier: argument.type
450+
count: 1
451+
path: src/Models/Wallet.php
452+
453+
-
454+
message: '#^Parameter \#1 \$related of method Illuminate\\Database\\Eloquent\\Model\:\:hasMany\(\) expects class\-string\<Illuminate\\Database\\Eloquent\\Model\>, mixed given\.$#'
455+
identifier: argument.type
456+
count: 6
457+
path: src/Models/Wallet.php
458+
459+
-
460+
message: '#^Parameter \#1 \$related of method Illuminate\\Database\\Eloquent\\Model\:\:morphMany\(\) expects class\-string\<Illuminate\\Database\\Eloquent\\Model\>, mixed given\.$#'
461+
identifier: argument.type
462+
count: 2
463+
path: src/Models/Wallet.php
464+
459465
-
460466
message: '#^Parameter \#1 \.\.\.\$arrays of function array_merge expects array, mixed given\.$#'
461467
identifier: argument.type
@@ -468,6 +474,30 @@ parameters:
468474
count: 2
469475
path: src/Models/Wallet.php
470476

477+
-
478+
message: '#^Parameter \#2 \$second of method Bavix\\Wallet\\Internal\\Service\\MathServiceInterface\:\:add\(\) expects float\|int\|non\-empty\-string, string given\.$#'
479+
identifier: argument.type
480+
count: 5
481+
path: src/Models/Wallet.php
482+
483+
-
484+
message: '#^Parameter \#2 \$second of method Bavix\\Wallet\\Internal\\Service\\MathServiceInterface\:\:compare\(\) expects float\|int\|non\-empty\-string, float\|int\|string given\.$#'
485+
identifier: argument.type
486+
count: 1
487+
path: src/Models/Wallet.php
488+
489+
-
490+
message: '#^Parameter \#2 \$second of method Bavix\\Wallet\\Internal\\Service\\MathServiceInterface\:\:mul\(\) expects float\|int\|non\-empty\-string, string given\.$#'
491+
identifier: argument.type
492+
count: 1
493+
path: src/Models/Wallet.php
494+
495+
-
496+
message: '#^Parameter \#2 \$value of method Bavix\\Wallet\\Services\\RegulatorServiceInterface\:\:sync\(\) expects float\|int\|non\-empty\-string, float\|int\|string given\.$#'
497+
identifier: argument.type
498+
count: 1
499+
path: src/Models/Wallet.php
500+
471501
-
472502
message: '#^Property Illuminate\\Database\\Eloquent\\Model\:\:\$table \(string\|null\) does not accept mixed\.$#'
473503
identifier: assign.propertyType
@@ -480,6 +510,18 @@ parameters:
480510
count: 1
481511
path: src/Models/Wallet.php
482512

513+
-
514+
message: '#^Unable to resolve the template type TRelatedModel in call to method Illuminate\\Database\\Eloquent\\Model\:\:hasMany\(\)$#'
515+
identifier: argument.templateType
516+
count: 6
517+
path: src/Models/Wallet.php
518+
519+
-
520+
message: '#^Unable to resolve the template type TRelatedModel in call to method Illuminate\\Database\\Eloquent\\Model\:\:morphMany\(\)$#'
521+
identifier: argument.templateType
522+
count: 2
523+
path: src/Models/Wallet.php
524+
483525
-
484526
message: '#^Binary operation "\." between literal\-string&non\-falsy\-string and mixed results in an error\.$#'
485527
identifier: binaryOp.invalid
@@ -543,7 +585,7 @@ parameters:
543585
-
544586
message: '#^Parameter \#1 \$first of method Bavix\\Wallet\\Internal\\Service\\MathServiceInterface\:\:compare\(\) expects float\|int\|non\-empty\-string, float\|int\|string given\.$#'
545587
identifier: argument.type
546-
count: 2
588+
count: 4
547589
path: src/Services/ConsistencyService.php
548590

549591
-
@@ -552,6 +594,12 @@ parameters:
552594
count: 1
553595
path: src/Services/ConsistencyService.php
554596

597+
-
598+
message: '#^Parameter \#2 \$second of method Bavix\\Wallet\\Internal\\Service\\MathServiceInterface\:\:compare\(\) expects float\|int\|non\-empty\-string, float\|int\|string given\.$#'
599+
identifier: argument.type
600+
count: 1
601+
path: src/Services/ConsistencyService.php
602+
555603
-
556604
message: '#^Parameter \#1 \$first of method Bavix\\Wallet\\Internal\\Service\\MathServiceInterface\:\:sub\(\) expects float\|int\|non\-empty\-string, float\|int\|string given\.$#'
557605
identifier: argument.type

0 commit comments

Comments
 (0)