From 8638f52f925bb2ac78b8cbf7a1746715374c26e8 Mon Sep 17 00:00:00 2001 From: Maxim Babichev Date: Sun, 11 Feb 2024 18:10:53 +0300 Subject: [PATCH 01/18] github actions --- .github/workflows/code-quality.yaml | 4 ++-- .github/workflows/code-style.yaml | 4 ++-- .github/workflows/deptrac.yaml | 4 ++-- .github/workflows/docs.yaml | 2 +- .github/workflows/phpstan.yaml | 4 ++-- .github/workflows/phpunits.yaml | 4 ++-- .github/workflows/rector.yaml | 4 ++-- .github/workflows/semgrep.yml | 4 ++-- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/code-quality.yaml b/.github/workflows/code-quality.yaml index 1e150b30a..57eac6b47 100644 --- a/.github/workflows/code-quality.yaml +++ b/.github/workflows/code-quality.yaml @@ -2,9 +2,9 @@ name: Qodana on: workflow_dispatch: push: - branches: [ master ] + branches: [ 10.x ] pull_request: - branches: [ master ] + branches: [ 10.x ] jobs: qodana: diff --git a/.github/workflows/code-style.yaml b/.github/workflows/code-style.yaml index 51dc2272a..1addacba9 100644 --- a/.github/workflows/code-style.yaml +++ b/.github/workflows/code-style.yaml @@ -2,9 +2,9 @@ name: code-style on: push: - branches: [ master ] + branches: [ 10.x ] pull_request: - branches: [ master ] + branches: [ 10.x ] jobs: ecs: diff --git a/.github/workflows/deptrac.yaml b/.github/workflows/deptrac.yaml index 13769bde1..64cc3465f 100644 --- a/.github/workflows/deptrac.yaml +++ b/.github/workflows/deptrac.yaml @@ -2,9 +2,9 @@ name: deptrac on: push: - branches: [ master ] + branches: [ 10.x ] pull_request: - branches: [ master ] + branches: [ 10.x ] jobs: deptrac: diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index ff24d585b..77a5ba4af 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -2,7 +2,7 @@ name: build docs on: pull_request: - branches: [ master ] + branches: [ 10.x ] jobs: build_pages: diff --git a/.github/workflows/phpstan.yaml b/.github/workflows/phpstan.yaml index befbf417a..a217b4c98 100644 --- a/.github/workflows/phpstan.yaml +++ b/.github/workflows/phpstan.yaml @@ -2,9 +2,9 @@ name: phpstan on: push: - branches: [ master ] + branches: [ 10.x ] pull_request: - branches: [ master ] + branches: [ 10.x ] jobs: phpstan: diff --git a/.github/workflows/phpunits.yaml b/.github/workflows/phpunits.yaml index 3da3d2e9b..bf133e28b 100644 --- a/.github/workflows/phpunits.yaml +++ b/.github/workflows/phpunits.yaml @@ -2,9 +2,9 @@ name: phpunits on: push: - branches: [ master ] + branches: [ 10.x ] pull_request: - branches: [ master ] + branches: [ 10.x ] env: MEMCACHED_HOST: localhost diff --git a/.github/workflows/rector.yaml b/.github/workflows/rector.yaml index 2739226cc..4bfaae27c 100644 --- a/.github/workflows/rector.yaml +++ b/.github/workflows/rector.yaml @@ -2,9 +2,9 @@ name: rector on: push: - branches: [ master ] + branches: [ 10.x ] pull_request: - branches: [ master ] + branches: [ 10.x ] jobs: rector: diff --git a/.github/workflows/semgrep.yml b/.github/workflows/semgrep.yml index e900f715a..0d0cd01dd 100644 --- a/.github/workflows/semgrep.yml +++ b/.github/workflows/semgrep.yml @@ -2,9 +2,9 @@ name: semgrep on: push: - branches: [ master ] + branches: [ 10.x ] pull_request: - branches: [ master ] + branches: [ 10.x ] jobs: semgrep: From 977086d82d70ff9ff95d3774127db7f9a076e157 Mon Sep 17 00:00:00 2001 From: Maxim Babichev Date: Sun, 11 Feb 2024 18:12:36 +0300 Subject: [PATCH 02/18] autofix --- .github/workflows/autofix.yaml | 89 +++++++++++++++++++++++++++++++ .github/workflows/code-style.yaml | 41 -------------- .github/workflows/rector.yaml | 41 -------------- 3 files changed, 89 insertions(+), 82 deletions(-) create mode 100644 .github/workflows/autofix.yaml delete mode 100644 .github/workflows/code-style.yaml delete mode 100644 .github/workflows/rector.yaml diff --git a/.github/workflows/autofix.yaml b/.github/workflows/autofix.yaml new file mode 100644 index 000000000..123dba7b1 --- /dev/null +++ b/.github/workflows/autofix.yaml @@ -0,0 +1,89 @@ +name: fixer + +on: + push: + branches: [ 10.x ] + pull_request: + branches: [ 10.x ] + +jobs: + autofix: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.1 + extensions: mbstring, pgsql, mysql, sqlite, redis, memcached, bcmath + coverage: pcov + env: + runner: self-hosted + + - name: Validate composer.json and composer.lock + run: composer validate --strict + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v4 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + + - name: Install dependencies + run: composer install --prefer-dist --no-progress + + - name: Run rector-fix + run: composer rector-fix + + - name: Run ecs-fix + run: composer ecs-fix + + - name: Run rector + run: composer rector + + - name: Run ecs + run: composer ecs + + - name: Run parabench + run: composer parabench + + - name: "Check if build has changed" + if: success() + id: has-changes + run: | + echo "stdout<> $GITHUB_OUTPUT + echo "$(git diff --stat)" >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT + + - name: Import GPG key + if: ${{ steps.has-changes.outputs.stdout }} + uses: crazy-max/ghaction-import-gpg@v6 + with: + gpg_private_key: ${{ secrets.GPG_BOT }} + passphrase: ${{ secrets.GPG_PASSPHRASE }} + fingerprint: ${{ secrets.GPG_FINGERPRINT }} + git_config_global: true + git_user_signingkey: true + git_commit_gpgsign: true + git_committer_name: Github bot + git_committer_email: bot@babichev.net + + - name: "Commit files" + if: ${{ steps.has-changes.outputs.stdout }} + env: + GH_TOKEN: ${{ secrets.BOT_TOKEN }} + run: | + gh pr checkout ${{ github.event.pull_request.number }} + git commit -S -m "autofix" -a + + - name: "Push changes" + if: ${{ steps.has-changes.outputs.stdout }} + env: + GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} + run: git push -u origin HEAD \ No newline at end of file diff --git a/.github/workflows/code-style.yaml b/.github/workflows/code-style.yaml deleted file mode 100644 index 1addacba9..000000000 --- a/.github/workflows/code-style.yaml +++ /dev/null @@ -1,41 +0,0 @@ -name: code-style - -on: - push: - branches: [ 10.x ] - pull_request: - branches: [ 10.x ] - -jobs: - ecs: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.1 - extensions: bcmath - env: - runner: self-hosted - - - name: Validate composer.json and composer.lock - run: composer validate --strict - - - name: Cache Composer packages - id: composer-cache - uses: actions/cache@v4 - with: - path: vendor - key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-php- - - - name: Install dependencies - run: composer install --prefer-dist --no-progress - - - name: Run ecs - run: composer ecs diff --git a/.github/workflows/rector.yaml b/.github/workflows/rector.yaml deleted file mode 100644 index 4bfaae27c..000000000 --- a/.github/workflows/rector.yaml +++ /dev/null @@ -1,41 +0,0 @@ -name: rector - -on: - push: - branches: [ 10.x ] - pull_request: - branches: [ 10.x ] - -jobs: - rector: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.1 - extensions: bcmath - env: - runner: self-hosted - - - name: Validate composer.json and composer.lock - run: composer validate --strict - - - name: Cache Composer packages - id: composer-cache - uses: actions/cache@v4 - with: - path: vendor - key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-php- - - - name: Install dependencies - run: composer install --prefer-dist --no-progress - - - name: Run rector - run: composer rector From cdd2b6dd21eedf113d79707174947f733d6183d8 Mon Sep 17 00:00:00 2001 From: Maxim Babichev Date: Sun, 11 Feb 2024 18:13:28 +0300 Subject: [PATCH 03/18] phpstan baseline --- phpstan.src.baseline.neon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpstan.src.baseline.neon b/phpstan.src.baseline.neon index 4b7b1f4ad..b64dd3355 100644 --- a/phpstan.src.baseline.neon +++ b/phpstan.src.baseline.neon @@ -82,7 +82,7 @@ parameters: - message: "#^Parameter \\#1 \\$related of method Illuminate\\\\Database\\\\Eloquent\\\\Model\\:\\:hasMany\\(\\) expects string, mixed given\\.$#" - count: 4 + count: 5 path: src/Models/Wallet.php - From 37acbee74d137fb202aa6a9a1c53d7c4eaa35aea Mon Sep 17 00:00:00 2001 From: Maxim Babichev Date: Sun, 11 Feb 2024 18:21:18 +0300 Subject: [PATCH 04/18] fixes --- composer.json | 13 +++++++------ tests/Infra/PackageModels/TransactionMoney.php | 4 ++-- tests/Infra/Values/Money.php | 14 ++++++++++++++ tests/Units/Domain/WalletExtensionTest.php | 4 ++-- 4 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 tests/Infra/Values/Money.php diff --git a/composer.json b/composer.json index e8d99e14d..dd55a1c12 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,8 @@ "wallet", "payments" ], - "minimum-stability": "stable", + "minimum-stability": "dev", + "prefer-stable": true, "homepage": "https://bavix.github.io/laravel-wallet/", "license": "MIT", "authors": [ @@ -26,14 +27,12 @@ "ext-json": "*", "ext-pdo": "*", "brick/math": "~0.10", - "doctrine/dbal": "^3.5", - "illuminate/contracts": "^10.0", - "illuminate/database": "^10.0", + "illuminate/contracts": "^10.0|^11.0", + "illuminate/database": "^10.0|^11.0", "ramsey/uuid": "^4.0" }, "require-dev": { "brianium/paratest": "^7.2", - "cknow/laravel-money": "^7.1", "ergebnis/phpstan-rules": "^1.0", "infection/infection": "~0.27", "laravel/cashier": "^15.0", @@ -47,7 +46,9 @@ }, "suggest": { "bavix/laravel-wallet-swap": "Addition to the laravel-wallet library for quick setting of exchange rates", - "bavix/laravel-wallet-warmup": "Addition to the laravel-wallet library for refresh balance wallets" + "bavix/laravel-wallet-uuid": "Addition to the laravel-wallet library uuid support in laravel-wallet", + "bavix/laravel-wallet-warmup": "Addition to the laravel-wallet library for refresh balance wallets", + "doctrine/dbal": "Required to rename columns and drop SQLite columns (^3.5.1)." }, "autoload": { "psr-4": { diff --git a/tests/Infra/PackageModels/TransactionMoney.php b/tests/Infra/PackageModels/TransactionMoney.php index 13dcd28ed..b9dfc13b4 100644 --- a/tests/Infra/PackageModels/TransactionMoney.php +++ b/tests/Infra/PackageModels/TransactionMoney.php @@ -4,7 +4,7 @@ namespace Bavix\Wallet\Test\Infra\PackageModels; -use Cknow\Money\Money; +use Bavix\Wallet\Test\Infra\Values\Money; /** * Class Transaction. @@ -17,7 +17,7 @@ final class TransactionMoney extends \Bavix\Wallet\Models\Transaction public function getCurrencyAttribute(): Money { - $this->currency ??= \money($this->amount, $this->meta['currency'] ?? 'USD'); + $this->currency ??= new Money($this->amount, $this->meta['currency'] ?? 'USD'); return $this->currency; } diff --git a/tests/Infra/Values/Money.php b/tests/Infra/Values/Money.php new file mode 100644 index 000000000..49cc06be5 --- /dev/null +++ b/tests/Infra/Values/Money.php @@ -0,0 +1,14 @@ +getKey() > 0); self::assertSame($transaction->amountInt, $buyer->balanceInt); self::assertInstanceOf(TransactionMoney::class, $transaction); - self::assertSame('1000', $transaction->currency->getAmount()); - self::assertSame('EUR', $transaction->currency->getCurrency()->getCode()); + self::assertSame('1000', $transaction->currency->amount); + self::assertSame('EUR', $transaction->currency->currency); } public function testNoCustomAttribute(): void From 2852e717a86f96e6cf67c9e3dcc897bd8fb50482 Mon Sep 17 00:00:00 2001 From: Github bot Date: Sun, 11 Feb 2024 15:22:10 +0000 Subject: [PATCH 05/18] autofix --- src/Models/Wallet.php | 10 +++++----- tests/Units/Domain/DiscountTest.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Models/Wallet.php b/src/Models/Wallet.php index 814513c7e..358e20b34 100644 --- a/src/Models/Wallet.php +++ b/src/Models/Wallet.php @@ -159,11 +159,6 @@ public function getCurrencyAttribute(): string return $this->meta['currency'] ?? Str::upper($this->slug); } - protected function initializeMorphOneWallet(): void - { - $this->uuid = app(UuidFactoryServiceInterface::class)->uuid4(); - } - /** * returns all the receiving transfers to this wallet. * @@ -173,4 +168,9 @@ public function receivedTransfers(): HasMany { return $this->hasMany(config('wallet.transfer.model', Transfer::class), 'to_id'); } + + protected function initializeMorphOneWallet(): void + { + $this->uuid = app(UuidFactoryServiceInterface::class)->uuid4(); + } } diff --git a/tests/Units/Domain/DiscountTest.php b/tests/Units/Domain/DiscountTest.php index 87e7ca86e..8d4b9d95a 100644 --- a/tests/Units/Domain/DiscountTest.php +++ b/tests/Units/Domain/DiscountTest.php @@ -13,9 +13,9 @@ use Bavix\Wallet\Test\Infra\Factories\ItemDiscountFactory; use Bavix\Wallet\Test\Infra\Models\Buyer; use Bavix\Wallet\Test\Infra\Models\ItemDiscount; -use Bavix\Wallet\Test\Infra\TestCase; use Bavix\Wallet\Test\Infra\PackageModels\Transaction as InfraTransaction; use Bavix\Wallet\Test\Infra\PackageModels\Wallet as InfraWallet; +use Bavix\Wallet\Test\Infra\TestCase; /** * @internal From 7df0bd34b76710f68997030f1247bd50e5f85e44 Mon Sep 17 00:00:00 2001 From: Maxim Babichev Date: Sun, 11 Feb 2024 18:23:27 +0300 Subject: [PATCH 06/18] working on laravel11 support --- .github/workflows/phpunits.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/phpunits.yaml b/.github/workflows/phpunits.yaml index bf133e28b..001d37801 100644 --- a/.github/workflows/phpunits.yaml +++ b/.github/workflows/phpunits.yaml @@ -19,6 +19,7 @@ jobs: strategy: matrix: php-versions: [8.1, 8.2, 8.3] + stability: [prefer-lowest, prefer-stable] databases: [testing, pgsql, mysql, mariadb] caches: [array, redis, memcached, database] locks: [redis, memcached] @@ -115,7 +116,7 @@ jobs: - name: Install dependencies id: composer-dependencies - run: composer install --prefer-dist --no-progress + run: composer install --${{ matrix.stability }} --no-progress - name: Check codeclimate id: codeclimate-check From 95ff6b7741b731e3d1fef5ef8b6b79f0226231a2 Mon Sep 17 00:00:00 2001 From: Maxim Babichev Date: Sun, 11 Feb 2024 18:28:48 +0300 Subject: [PATCH 07/18] update require-dev --- composer.json | 12 +++++----- phpstan.common.neon | 58 +++------------------------------------------ phpstan.src.neon | 46 ++++++++++++++++++++--------------- phpstan.tests.neon | 57 +++++++++++++++++++++++++------------------- 4 files changed, 69 insertions(+), 104 deletions(-) diff --git a/composer.json b/composer.json index dd55a1c12..c924d048b 100644 --- a/composer.json +++ b/composer.json @@ -32,15 +32,15 @@ "ramsey/uuid": "^4.0" }, "require-dev": { - "brianium/paratest": "^7.2", - "ergebnis/phpstan-rules": "^1.0", + "brianium/paratest": "^7.4", + "ergebnis/phpstan-rules": "^2.1", "infection/infection": "~0.27", "laravel/cashier": "^15.0", - "nunomaduro/collision": "^7.7", - "nunomaduro/larastan": "^2.6", - "orchestra/testbench": "^8.5", + "nunomaduro/collision": "^7.7|^8.0", + "larastan/larastan": "^2.8", + "orchestra/testbench": "^8.21|^9.0", "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^10.2", + "phpunit/phpunit": "^10.5", "rector/rector": "^0.19", "symplify/easy-coding-standard": "^12.0" }, diff --git a/phpstan.common.neon b/phpstan.common.neon index 8d97ee03a..5e647514c 100644 --- a/phpstan.common.neon +++ b/phpstan.common.neon @@ -1,60 +1,8 @@ includes: - - vendor/nunomaduro/larastan/extension.neon + - vendor/larastan/larastan/extension.neon + - vendor/ergebnis/phpstan-rules/rules.neon parameters: level: 9 fileExtensions: - - php - -parametersSchema: - ergebnis: structure([ - allowAbstractClasses: bool() - classesAllowedToBeExtended: listOf(string()) - classesNotRequiredToBeAbstractOrFinal: listOf(string()) - interfacesImplementedByContainers: listOf(string()) - ]) - -rules: - - Ergebnis\PHPStan\Rules\Closures\NoNullableReturnTypeDeclarationRule - - Ergebnis\PHPStan\Rules\Closures\NoParameterWithNullableTypeDeclarationRule - - Ergebnis\PHPStan\Rules\Expressions\NoCompactRule - - Ergebnis\PHPStan\Rules\Expressions\NoEmptyRule - - Ergebnis\PHPStan\Rules\Expressions\NoErrorSuppressionRule - - Ergebnis\PHPStan\Rules\Expressions\NoEvalRule - - Ergebnis\PHPStan\Rules\Expressions\NoIssetRule - - Ergebnis\PHPStan\Rules\Files\DeclareStrictTypesRule - - Ergebnis\PHPStan\Rules\Functions\NoNullableReturnTypeDeclarationRule - - Ergebnis\PHPStan\Rules\Functions\NoParameterWithNullableTypeDeclarationRule - - Ergebnis\PHPStan\Rules\Functions\NoParameterWithNullDefaultValueRule - - Ergebnis\PHPStan\Rules\Methods\FinalInAbstractClassRule - - Ergebnis\PHPStan\Rules\Methods\NoConstructorParameterWithDefaultValueRule - - Ergebnis\PHPStan\Rules\Methods\PrivateInFinalClassRule - - Ergebnis\PHPStan\Rules\Statements\NoSwitchRule - -services: - - - class: Ergebnis\PHPStan\Rules\Classes\FinalRule - arguments: - allowAbstractClasses: %ergebnis.allowAbstractClasses% - classesNotRequiredToBeAbstractOrFinal: %ergebnis.classesNotRequiredToBeAbstractOrFinal% - tags: - - phpstan.rules.rule - - - - class: Ergebnis\PHPStan\Rules\Classes\NoExtendsRule - arguments: - classesAllowedToBeExtended: %ergebnis.classesAllowedToBeExtended% - tags: - - phpstan.rules.rule - - - - class: Ergebnis\PHPStan\Rules\Classes\PHPUnit\Framework\TestCaseWithSuffixRule - tags: - - phpstan.rules.rule - - - - class: Ergebnis\PHPStan\Rules\Methods\NoParameterWithContainerTypeDeclarationRule - arguments: - interfacesImplementedByContainers: %ergebnis.interfacesImplementedByContainers% - tags: - - phpstan.rules.rule + - php \ No newline at end of file diff --git a/phpstan.src.neon b/phpstan.src.neon index 7952daa9c..1ecc9585d 100644 --- a/phpstan.src.neon +++ b/phpstan.src.neon @@ -7,24 +7,32 @@ parameters: fileExtensions: - php ergebnis: - allowAbstractClasses: true - classesAllowedToBeExtended: - # laravel - - Illuminate\Support\ServiceProvider - - Illuminate\Database\Eloquent\Model + noParameterWithNullableTypeDeclaration: + enabled: false + noNullableReturnTypeDeclaration: + enabled: false + noParameterWithNullDefaultValue: + enabled: false + final: + allowAbstractClasses: true + classesNotRequiredToBeAbstractOrFinal: + - Bavix\Wallet\Models\Wallet + - Bavix\Wallet\Models\Transfer + - Bavix\Wallet\Models\Transaction + noExtends: + classesAllowedToBeExtended: + # laravel + - Illuminate\Support\ServiceProvider + - Illuminate\Database\Eloquent\Model - # php exceptions - - LogicException - - RuntimeException - - UnderflowException - - UnexpectedValueException - - InvalidArgumentException - - classesNotRequiredToBeAbstractOrFinal: - - Bavix\Wallet\Models\Wallet - - Bavix\Wallet\Models\Transfer - - Bavix\Wallet\Models\Transaction - interfacesImplementedByContainers: - - Psr\Container\ContainerInterface + # php exceptions + - LogicException + - RuntimeException + - UnderflowException + - UnexpectedValueException + - InvalidArgumentException + noParameterWithContainerTypeDeclaration: + interfacesImplementedByContainers: + - Psr\Container\ContainerInterface paths: - - src/ + - src/ \ No newline at end of file diff --git a/phpstan.tests.neon b/phpstan.tests.neon index 85854cf85..206a2032c 100644 --- a/phpstan.tests.neon +++ b/phpstan.tests.neon @@ -9,32 +9,41 @@ parameters: fileExtensions: - php ergebnis: - allowAbstractClasses: false - classesAllowedToBeExtended: - # laravel - - Illuminate\Support\ServiceProvider - - Illuminate\Database\Eloquent\Model - - Illuminate\Database\Migrations\Migration - - Illuminate\Database\Eloquent\Factories\Factory + noParameterWithNullableTypeDeclaration: + enabled: false + noNullableReturnTypeDeclaration: + enabled: false + noParameterWithNullDefaultValue: + enabled: false + final: + allowAbstractClasses: false + classesNotRequiredToBeAbstractOrFinal: + - Bavix\Wallet\Models\Wallet + - Bavix\Wallet\Models\Transfer + - Bavix\Wallet\Models\Transaction + noExtends: + classesAllowedToBeExtended: + # laravel + - Illuminate\Support\ServiceProvider + - Illuminate\Database\Eloquent\Model + - Illuminate\Database\Migrations\Migration + - Illuminate\Database\Eloquent\Factories\Factory - # php exceptions - - RuntimeException - - InvalidArgumentException + # php exceptions + - RuntimeException + - InvalidArgumentException - # phpunit - - Orchestra\Testbench\TestCase - - Bavix\Wallet\Test\Infra\TestCase + # phpunit + - Orchestra\Testbench\TestCase + - Bavix\Wallet\Test\Infra\TestCase - # wallet - - Bavix\Wallet\Models\Wallet - - Bavix\Wallet\Models\Transfer - - Bavix\Wallet\Models\Transaction + # wallet + - Bavix\Wallet\Models\Wallet + - Bavix\Wallet\Models\Transfer + - Bavix\Wallet\Models\Transaction - classesNotRequiredToBeAbstractOrFinal: - - Bavix\Wallet\Models\Wallet - - Bavix\Wallet\Models\Transfer - - Bavix\Wallet\Models\Transaction - interfacesImplementedByContainers: - - Psr\Container\ContainerInterface + noParameterWithContainerTypeDeclaration: + interfacesImplementedByContainers: + - Psr\Container\ContainerInterface paths: - - tests/ + - tests/ \ No newline at end of file From a13ddac56151588cfbb6ded9631601066790ac6b Mon Sep 17 00:00:00 2001 From: Maxim Babichev Date: Sun, 11 Feb 2024 18:29:55 +0300 Subject: [PATCH 08/18] fix composer install --- .github/workflows/phpunits.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/phpunits.yaml b/.github/workflows/phpunits.yaml index 001d37801..47600a10b 100644 --- a/.github/workflows/phpunits.yaml +++ b/.github/workflows/phpunits.yaml @@ -116,7 +116,7 @@ jobs: - name: Install dependencies id: composer-dependencies - run: composer install --${{ matrix.stability }} --no-progress + run: composer update --${{ matrix.stability }} --prefer-dist --no-progress - name: Check codeclimate id: codeclimate-check From 95b4efcfc354006c1a34a53d7a05b7b95a20c2b7 Mon Sep 17 00:00:00 2001 From: Maxim Babichev Date: Sun, 11 Feb 2024 18:30:54 +0300 Subject: [PATCH 09/18] revert update brianium/paratest --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c924d048b..03d474f77 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "ramsey/uuid": "^4.0" }, "require-dev": { - "brianium/paratest": "^7.4", + "brianium/paratest": "^7.2", "ergebnis/phpstan-rules": "^2.1", "infection/infection": "~0.27", "laravel/cashier": "^15.0", From d218605575983bfcde0c185cb5f318d7443cd2c3 Mon Sep 17 00:00:00 2001 From: Maxim Babichev Date: Sun, 11 Feb 2024 18:38:40 +0300 Subject: [PATCH 10/18] update mariadb --- .github/workflows/phpunits.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/phpunits.yaml b/.github/workflows/phpunits.yaml index 47600a10b..1f4b3f284 100644 --- a/.github/workflows/phpunits.yaml +++ b/.github/workflows/phpunits.yaml @@ -74,7 +74,7 @@ jobs: - 3306:3306 mariadb: - image: mariadb:10.5 + image: mariadb:10.10 env: MYSQL_ROOT_PASSWORD: wallet MYSQL_DATABASE: wallet From 3b620ec662f1962207b8c654e860dfa11ebbfd26 Mon Sep 17 00:00:00 2001 From: Maxim Babichev Date: Sun, 11 Feb 2024 18:40:07 +0300 Subject: [PATCH 11/18] update rector --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 03d474f77..3aeca726a 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ "orchestra/testbench": "^8.21|^9.0", "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^10.5", - "rector/rector": "^0.19", + "rector/rector": "^1.0", "symplify/easy-coding-standard": "^12.0" }, "suggest": { From 4d9a125708c5080421859406fc3cc8405399971c Mon Sep 17 00:00:00 2001 From: Maxim Babichev Date: Sun, 11 Feb 2024 18:43:13 +0300 Subject: [PATCH 12/18] brianium/paratest ^7.3 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3aeca726a..e28961bf6 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "ramsey/uuid": "^4.0" }, "require-dev": { - "brianium/paratest": "^7.2", + "brianium/paratest": "^7.3", "ergebnis/phpstan-rules": "^2.1", "infection/infection": "~0.27", "laravel/cashier": "^15.0", From b3e879b2ae03fa28bcb5fdeb55e097422f81f879 Mon Sep 17 00:00:00 2001 From: Maxim Babichev Date: Sun, 11 Feb 2024 18:46:30 +0300 Subject: [PATCH 13/18] brianium/paratest ^7.3 --- .github/workflows/phpunits.yaml | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/phpunits.yaml b/.github/workflows/phpunits.yaml index 1f4b3f284..175fc3025 100644 --- a/.github/workflows/phpunits.yaml +++ b/.github/workflows/phpunits.yaml @@ -120,7 +120,7 @@ jobs: - name: Check codeclimate id: codeclimate-check - run: echo "execute=${{ matrix.php-versions == '8.2' && matrix.caches == 'array' && matrix.databases == 'testing' }}" >> $GITHUB_OUTPUT + run: echo "execute=${{ matrix.php-versions == '8.3' && matrix.caches == 'array' && matrix.databases == 'testing' }}" >> $GITHUB_OUTPUT - name: Prepare codeclimate id: codeclimate-prepare diff --git a/composer.json b/composer.json index e28961bf6..27a3253ba 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,7 @@ "ergebnis/phpstan-rules": "^2.1", "infection/infection": "~0.27", "laravel/cashier": "^15.0", - "nunomaduro/collision": "^7.7|^8.0", + "nunomaduro/collision": "^7.8|^8.0", "larastan/larastan": "^2.8", "orchestra/testbench": "^8.21|^9.0", "phpstan/phpstan": "^1.10", From 4359ce80efd17e6efc7e8f62b437ba1df94fab63 Mon Sep 17 00:00:00 2001 From: Maxim Babichev Date: Sun, 11 Feb 2024 19:08:15 +0300 Subject: [PATCH 14/18] revert minimum-stability --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 27a3253ba..23360fce2 100644 --- a/composer.json +++ b/composer.json @@ -12,8 +12,7 @@ "wallet", "payments" ], - "minimum-stability": "dev", - "prefer-stable": true, + "minimum-stability": "stable", "homepage": "https://bavix.github.io/laravel-wallet/", "license": "MIT", "authors": [ From eed73be0e2509b253282fe156b783eacbbbfb053 Mon Sep 17 00:00:00 2001 From: Maxim Babichev Date: Sun, 11 Feb 2024 19:08:53 +0300 Subject: [PATCH 15/18] update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 28ad79152..e66e1243b 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ laravel-wallet - Easy work with virtual wallet. | 7.x | ^6.0,^7.0,^8.0 | 7.4,8.0,8.1 | Nov 25, 2021 | Mar 1, 2022 | Sep 6, 2022 | | 8.x | ^9.0 | 8.0,8.1 | Feb 8, 2022 | May 1, 2022 | Jun 1, 2022 | | 9.x [LTS] | ^9.0,^10.0 | 8.0,8.1,8.2,8.3 | May 2, 2022 | Feb 1, 2023 | Feb 6, 2024 | -| 10.x [LTS] | ^10.0 | 8.1,8.2,8.3 | Jul 8, 2023 | May 1, 2024 | Feb 4, 2025 | +| 10.x [LTS] | ^10.0,^11.0 | 8.1,8.2,8.3 | Jul 8, 2023 | May 1, 2024 | Feb 4, 2025 | ### Upgrade Guide From 64484fbb7930131062baff8eff9fccb798ef67b9 Mon Sep 17 00:00:00 2001 From: Github bot Date: Sat, 9 Mar 2024 15:27:09 +0000 Subject: [PATCH 16/18] autofix --- src/Models/Wallet.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Models/Wallet.php b/src/Models/Wallet.php index 51f32a853..9cec8c5a4 100644 --- a/src/Models/Wallet.php +++ b/src/Models/Wallet.php @@ -159,11 +159,6 @@ public function getCurrencyAttribute(): string return $this->meta['currency'] ?? Str::upper($this->slug); } - protected function initializeMorphOneWallet(): void - { - $this->uuid ??= app(UuidFactoryServiceInterface::class)->uuid4(); - } - /** * returns all the receiving transfers to this wallet. * @@ -173,4 +168,9 @@ public function receivedTransfers(): HasMany { return $this->hasMany(config('wallet.transfer.model', Transfer::class), 'to_id'); } + + protected function initializeMorphOneWallet(): void + { + $this->uuid ??= app(UuidFactoryServiceInterface::class)->uuid4(); + } } From fefcc10e123f324355b7fe6bafc9b8a3a8cd91be Mon Sep 17 00:00:00 2001 From: Maxim Babichev Date: Sat, 9 Mar 2024 18:27:35 +0300 Subject: [PATCH 17/18] phpstan fix --- src/Models/Transaction.php | 2 +- src/Models/Transfer.php | 2 +- src/Models/Wallet.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Models/Transaction.php b/src/Models/Transaction.php index 5672da404..0bae76222 100644 --- a/src/Models/Transaction.php +++ b/src/Models/Transaction.php @@ -38,7 +38,7 @@ class Transaction extends Model final public const TYPE_WITHDRAW = 'withdraw'; /** - * @var string[] + * @var array */ protected $fillable = [ 'payable_type', diff --git a/src/Models/Transfer.php b/src/Models/Transfer.php index 89f23444b..58d35d49e 100644 --- a/src/Models/Transfer.php +++ b/src/Models/Transfer.php @@ -42,7 +42,7 @@ class Transfer extends Model final public const STATUS_GIFT = 'gift'; /** - * @var string[] + * @var array */ protected $fillable = [ 'status', diff --git a/src/Models/Wallet.php b/src/Models/Wallet.php index 51f32a853..f0875e442 100644 --- a/src/Models/Wallet.php +++ b/src/Models/Wallet.php @@ -55,7 +55,7 @@ class Wallet extends Model implements Customer, WalletFloat, Confirmable, Exchan use HasGift; /** - * @var string[] + * @var array */ protected $fillable = [ 'holder_type', From 72fb61c1d1831e111f6d066e86ccaff963b717bd Mon Sep 17 00:00:00 2001 From: Maxim Babichev Date: Sat, 9 Mar 2024 19:36:42 +0300 Subject: [PATCH 18/18] fix phpstan --- tests/Infra/Models/Item.php | 2 +- tests/Infra/Models/ItemDiscount.php | 2 +- tests/Infra/Models/ItemDiscountTax.php | 2 +- tests/Infra/Models/ItemMaxTax.php | 2 +- tests/Infra/Models/ItemMeta.php | 2 +- tests/Infra/Models/ItemMinTax.php | 2 +- tests/Infra/Models/ItemMultiPrice.php | 2 +- tests/Infra/Models/ItemTax.php | 2 +- tests/Infra/Models/ItemWallet.php | 2 +- tests/Infra/Models/Manager.php | 2 +- tests/Infra/Models/User.php | 2 +- tests/Infra/Models/UserConfirm.php | 2 +- tests/Infra/Models/UserDynamic.php | 2 +- tests/Infra/Models/UserFloat.php | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/Infra/Models/Item.php b/tests/Infra/Models/Item.php index 2ae3e37dd..fd2a5e981 100644 --- a/tests/Infra/Models/Item.php +++ b/tests/Infra/Models/Item.php @@ -29,7 +29,7 @@ final class Item extends Model implements ProductLimitedInterface use HasWallets; /** - * @var string[] + * @var array */ protected $fillable = ['name', 'quantity', 'price']; diff --git a/tests/Infra/Models/ItemDiscount.php b/tests/Infra/Models/ItemDiscount.php index 8d0e78567..8cf5ac656 100644 --- a/tests/Infra/Models/ItemDiscount.php +++ b/tests/Infra/Models/ItemDiscount.php @@ -24,7 +24,7 @@ final class ItemDiscount extends Model implements ProductLimitedInterface, Disco use HasWallet; /** - * @var string[] + * @var array */ protected $fillable = ['name', 'quantity', 'price']; diff --git a/tests/Infra/Models/ItemDiscountTax.php b/tests/Infra/Models/ItemDiscountTax.php index 48a41b0c6..14e4ff583 100644 --- a/tests/Infra/Models/ItemDiscountTax.php +++ b/tests/Infra/Models/ItemDiscountTax.php @@ -25,7 +25,7 @@ final class ItemDiscountTax extends Model implements ProductLimitedInterface, Di use HasWallet; /** - * @var string[] + * @var array */ protected $fillable = ['name', 'quantity', 'price']; diff --git a/tests/Infra/Models/ItemMaxTax.php b/tests/Infra/Models/ItemMaxTax.php index 3c3fa3955..4f1ebee67 100644 --- a/tests/Infra/Models/ItemMaxTax.php +++ b/tests/Infra/Models/ItemMaxTax.php @@ -24,7 +24,7 @@ final class ItemMaxTax extends Model implements ProductLimitedInterface, Maximal use HasWallet; /** - * @var string[] + * @var array */ protected $fillable = ['name', 'quantity', 'price']; diff --git a/tests/Infra/Models/ItemMeta.php b/tests/Infra/Models/ItemMeta.php index f6adb0a28..65d4edd08 100644 --- a/tests/Infra/Models/ItemMeta.php +++ b/tests/Infra/Models/ItemMeta.php @@ -25,7 +25,7 @@ final class ItemMeta extends Model implements ProductLimitedInterface use HasWallets; /** - * @var string[] + * @var array */ protected $fillable = ['name', 'quantity', 'price']; diff --git a/tests/Infra/Models/ItemMinTax.php b/tests/Infra/Models/ItemMinTax.php index b2b951842..57832ee6b 100644 --- a/tests/Infra/Models/ItemMinTax.php +++ b/tests/Infra/Models/ItemMinTax.php @@ -24,7 +24,7 @@ final class ItemMinTax extends Model implements ProductLimitedInterface, Minimal use HasWallet; /** - * @var string[] + * @var array */ protected $fillable = ['name', 'quantity', 'price']; diff --git a/tests/Infra/Models/ItemMultiPrice.php b/tests/Infra/Models/ItemMultiPrice.php index ed8696636..8399ab3cc 100644 --- a/tests/Infra/Models/ItemMultiPrice.php +++ b/tests/Infra/Models/ItemMultiPrice.php @@ -25,7 +25,7 @@ final class ItemMultiPrice extends Model implements ProductLimitedInterface use HasWallet; /** - * @var string[] + * @var array */ protected $fillable = ['name', 'quantity', 'price', 'prices']; diff --git a/tests/Infra/Models/ItemTax.php b/tests/Infra/Models/ItemTax.php index e9a812695..9d4e5dec9 100644 --- a/tests/Infra/Models/ItemTax.php +++ b/tests/Infra/Models/ItemTax.php @@ -24,7 +24,7 @@ final class ItemTax extends Model implements ProductLimitedInterface, Taxable use HasWallet; /** - * @var string[] + * @var array */ protected $fillable = ['name', 'quantity', 'price']; diff --git a/tests/Infra/Models/ItemWallet.php b/tests/Infra/Models/ItemWallet.php index 35d30cffe..70fe59e18 100644 --- a/tests/Infra/Models/ItemWallet.php +++ b/tests/Infra/Models/ItemWallet.php @@ -25,7 +25,7 @@ final class ItemWallet extends Model implements ProductLimitedInterface use HasWallets; /** - * @var string[] + * @var array */ protected $fillable = ['name', 'quantity', 'price']; diff --git a/tests/Infra/Models/Manager.php b/tests/Infra/Models/Manager.php index 63c6be65a..62d9b8af2 100644 --- a/tests/Infra/Models/Manager.php +++ b/tests/Infra/Models/Manager.php @@ -19,7 +19,7 @@ final class Manager extends Model implements Wallet use HasWallet; /** - * @var string[] + * @var array */ protected $fillable = ['name', 'email']; } diff --git a/tests/Infra/Models/User.php b/tests/Infra/Models/User.php index f5c5084c2..70b2c2496 100644 --- a/tests/Infra/Models/User.php +++ b/tests/Infra/Models/User.php @@ -19,7 +19,7 @@ final class User extends Model implements Wallet use HasWallet; /** - * @var string[] + * @var array */ protected $fillable = ['name', 'email']; } diff --git a/tests/Infra/Models/UserConfirm.php b/tests/Infra/Models/UserConfirm.php index 269faf96f..66d1781f4 100644 --- a/tests/Infra/Models/UserConfirm.php +++ b/tests/Infra/Models/UserConfirm.php @@ -22,7 +22,7 @@ final class UserConfirm extends Model implements Wallet, Confirmable use CanConfirm; /** - * @var string[] + * @var array */ protected $fillable = ['name', 'email']; diff --git a/tests/Infra/Models/UserDynamic.php b/tests/Infra/Models/UserDynamic.php index af81cff8b..d16b8e04f 100644 --- a/tests/Infra/Models/UserDynamic.php +++ b/tests/Infra/Models/UserDynamic.php @@ -19,7 +19,7 @@ final class UserDynamic extends Model implements Wallet use HasWallet; /** - * @var string[] + * @var array */ protected $fillable = ['name', 'email']; diff --git a/tests/Infra/Models/UserFloat.php b/tests/Infra/Models/UserFloat.php index e93631505..3c7cd24ee 100644 --- a/tests/Infra/Models/UserFloat.php +++ b/tests/Infra/Models/UserFloat.php @@ -20,7 +20,7 @@ final class UserFloat extends Model implements Wallet, WalletFloat use HasWalletFloat; /** - * @var string[] + * @var array */ protected $fillable = ['name', 'email'];