Skip to content

Commit

Permalink
Merge pull request #826 from bavix/11.x
Browse files Browse the repository at this point in the history
[11.x] New Version
  • Loading branch information
rez1dent3 authored Jan 23, 2024
2 parents 2f5f1f2 + ec4b994 commit 1d62e8c
Show file tree
Hide file tree
Showing 84 changed files with 782 additions and 386 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/code-quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,30 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
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@v3
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: 'Qodana Scan'
uses: JetBrains/[email protected]
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/code-style.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.2
extensions: bcmath
env:
runner: self-hosted
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deptrac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.2
extensions: bcmath
env:
runner: self-hosted
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.2
extensions: bcmath
env:
runner: self-hosted
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunits.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

strategy:
matrix:
php-versions: [8.1, 8.2, 8.3]
php-versions: [8.2, 8.3]
databases: [testing, pgsql, mysql, mariadb]
caches: [array, redis, memcached, database]
locks: [redis, memcached]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.2
extensions: bcmath
env:
runner: self-hosted
Expand Down
15 changes: 7 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
}
],
"require": {
"php": "^8.1",
"php": "^8.2",
"ext-json": "*",
"ext-pdo": "*",
"brick/math": "~0.10",
Expand All @@ -32,16 +32,15 @@
"ramsey/uuid": "^4.0"
},
"require-dev": {
"brianium/paratest": "^7.2",
"cknow/laravel-money": "^7.1",
"ergebnis/phpstan-rules": "^1.0",
"brianium/paratest": "^7.3",
"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.10",
"nunomaduro/larastan": "^2.7",
"orchestra/testbench": "^8.19",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^10.2",
"phpunit/phpunit": "^10.5",
"rector/rector": "^0.19",
"symplify/easy-coding-standard": "^12.0"
},
Expand Down
2 changes: 2 additions & 0 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
use Bavix\Wallet\Services\DiscountService;

Check notice on line 44 in config/config.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Usage of internal entity

Class 'DiscountService' is marked as @internal
use Bavix\Wallet\Services\EagerLoaderService;

Check notice on line 45 in config/config.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Usage of internal entity

Class 'EagerLoaderService' is marked as @internal
use Bavix\Wallet\Services\ExchangeService;

Check notice on line 46 in config/config.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Usage of internal entity

Class 'ExchangeService' is marked as @internal
use Bavix\Wallet\Services\FormatterService;

Check notice on line 47 in config/config.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Usage of internal entity

Class 'FormatterService' is marked as @internal
use Bavix\Wallet\Services\PrepareService;

Check notice on line 48 in config/config.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Usage of internal entity

Class 'PrepareService' is marked as @internal
use Bavix\Wallet\Services\PurchaseService;

Check notice on line 49 in config/config.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Usage of internal entity

Class 'PurchaseService' is marked as @internal
use Bavix\Wallet\Services\RegulatorService;

Check notice on line 50 in config/config.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Usage of internal entity

Class 'RegulatorService' is marked as @internal
Expand Down Expand Up @@ -110,6 +111,7 @@
'discount' => DiscountService::class,

Check notice on line 111 in config/config.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Usage of internal entity

Class 'DiscountService' is marked as @internal
'eager_loader' => EagerLoaderService::class,

Check notice on line 112 in config/config.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Usage of internal entity

Class 'EagerLoaderService' is marked as @internal
'exchange' => ExchangeService::class,

Check notice on line 113 in config/config.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Usage of internal entity

Class 'ExchangeService' is marked as @internal
'formatter' => FormatterService::class,

Check notice on line 114 in config/config.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Usage of internal entity

Class 'FormatterService' is marked as @internal
'prepare' => PrepareService::class,

Check notice on line 115 in config/config.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Usage of internal entity

Class 'PrepareService' is marked as @internal
'purchase' => PurchaseService::class,

Check notice on line 116 in config/config.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Usage of internal entity

Class 'PurchaseService' is marked as @internal
'tax' => TaxService::class,

Check notice on line 117 in config/config.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Usage of internal entity

Class 'TaxService' is marked as @internal
Expand Down
32 changes: 32 additions & 0 deletions database/2023_12_30_113122_extra_columns_removed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

use Bavix\Wallet\Models\Transfer;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class() extends Migration {
public function up(): void
{
Schema::dropColumns($this->table(), ['from_type', 'to_type']);
}

public function down(): void
{
Schema::table($this->table(), static function (Blueprint $table) {
$table->string('from_type')
->after('from_id')
;
$table->string('to_type')
->after('to_id')
;
});
}

private function table(): string
{
return (new Transfer())->getTable();
}
};
38 changes: 38 additions & 0 deletions database/2023_12_30_204610_soft_delete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

use Bavix\Wallet\Models\Transaction;
use Bavix\Wallet\Models\Transfer;
use Bavix\Wallet\Models\Wallet;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class() extends Migration {
public function up(): void
{
Schema::table((new Wallet())->getTable(), static function (Blueprint $table) {
$table->softDeletesTz();
});
Schema::table((new Transfer())->getTable(), static function (Blueprint $table) {
$table->softDeletesTz();
});
Schema::table((new Transaction())->getTable(), static function (Blueprint $table) {
$table->softDeletesTz();
});
}

public function down(): void
{
Schema::table((new Wallet())->getTable(), static function (Blueprint $table) {
$table->dropSoftDeletes();
});
Schema::table((new Transfer())->getTable(), static function (Blueprint $table) {
$table->dropSoftDeletes();
});
Schema::table((new Transaction())->getTable(), static function (Blueprint $table) {
$table->dropSoftDeletes();
});
}
};
54 changes: 1 addition & 53 deletions phpstan.common.neon
Original file line number Diff line number Diff line change
@@ -1,60 +1,8 @@
includes:
- vendor/nunomaduro/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
14 changes: 7 additions & 7 deletions phpstan.src.baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ parameters:
path: src/Internal/Assembler/TransactionDtoAssembler.php

-
message: "#^Parameter \\#6 \\$fromId of class Bavix\\\\Wallet\\\\Internal\\\\Dto\\\\TransferDto constructor expects int\\|string, mixed given\\.$#"
message: "#^Parameter \\#5 \\$fromId of class Bavix\\\\Wallet\\\\Internal\\\\Dto\\\\TransferDto constructor expects int, mixed given\\.$#"
count: 1
path: src/Internal/Assembler/TransferDtoAssembler.php

-
message: "#^Parameter \\#8 \\$toId of class Bavix\\\\Wallet\\\\Internal\\\\Dto\\\\TransferDto constructor expects int\\|string, mixed given\\.$#"
message: "#^Parameter \\#6 \\$toId of class Bavix\\\\Wallet\\\\Internal\\\\Dto\\\\TransferDto constructor expects int, mixed given\\.$#"
count: 1
path: src/Internal/Assembler/TransferDtoAssembler.php

Expand Down Expand Up @@ -66,18 +66,18 @@ parameters:
path: src/Models/Transfer.php

-
message: "#^Cannot cast mixed to string\\.$#"
count: 1
message: "#^Call to an undefined method Illuminate\\\\Database\\\\Eloquent\\\\Relations\\\\MorphOne\\:\\:withTrashed\\(\\)\\.$#"
count: 2
path: src/Models/Wallet.php

-
message: "#^Method Bavix\\\\Wallet\\\\Models\\\\Wallet\\:\\:getAvailableBalanceAttribute\\(\\) should return float\\|int\\|string but returns mixed\\.$#"
message: "#^Cannot cast mixed to string\\.$#"
count: 1
path: src/Models/Wallet.php

-
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\\<Illuminate\\\\Database\\\\Eloquent\\\\Model\\>\\.$#"
count: 2
message: "#^Method Bavix\\\\Wallet\\\\Models\\\\Wallet\\:\\:getAvailableBalanceAttribute\\(\\) should return float\\|int\\|string but returns mixed\\.$#"
count: 1
path: src/Models/Wallet.php

-
Expand Down
44 changes: 26 additions & 18 deletions phpstan.src.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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/
2 changes: 1 addition & 1 deletion phpstan.tests.baseline.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
parameters:
ignoreErrors:
-
message: "#^Method Bavix\\\\Wallet\\\\Test\\\\Infra\\\\Models\\\\Item\\:\\:boughtGoods\\(\\) should return Illuminate\\\\Database\\\\Eloquent\\\\Relations\\\\MorphMany\\<Bavix\\\\Wallet\\\\Models\\\\Transfer\\> but returns Illuminate\\\\Database\\\\Eloquent\\\\Relations\\\\MorphMany\\<Illuminate\\\\Database\\\\Eloquent\\\\Model\\>\\.$#"
message: "#^Method Bavix\\\\Wallet\\\\Test\\\\Infra\\\\Models\\\\Item\\:\\:boughtGoods\\(\\) should return Illuminate\\\\Database\\\\Eloquent\\\\Relations\\\\HasMany\\<Bavix\\\\Wallet\\\\Models\\\\Transfer\\> but returns Illuminate\\\\Database\\\\Eloquent\\\\Relations\\\\HasMany\\<Illuminate\\\\Database\\\\Eloquent\\\\Model\\>\\.$#"
count: 1
path: tests/Infra/Models/Item.php

Expand Down
Loading

0 comments on commit 1d62e8c

Please sign in to comment.