diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/fix-php-code-style-issues.yml similarity index 60% rename from .github/workflows/php-cs-fixer.yml rename to .github/workflows/fix-php-code-style-issues.yml index 96e9a2d..7f61fce 100644 --- a/.github/workflows/php-cs-fixer.yml +++ b/.github/workflows/fix-php-code-style-issues.yml @@ -1,9 +1,9 @@ -name: Check & fix styling +name: Fix PHP code style issues on: [push] jobs: - php-cs-fixer: + php-code-styling: runs-on: ubuntu-latest steps: @@ -12,10 +12,8 @@ jobs: with: ref: ${{ github.head_ref }} - - name: Run PHP CS Fixer - uses: docker://oskarstark/php-cs-fixer-ga - with: - args: --config=.php-cs-fixer.dist.php --allow-risky=yes + - name: Fix PHP code style issues + uses: aglipanci/laravel-pint-action@2.3.1 - name: Commit changes uses: stefanzweifel/git-auto-commit-action@v5 diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 4f3f936..3855a08 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -16,7 +16,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.0' + php-version: '8.1' coverage: none - name: Install composer dependencies diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 59d59f1..0ace6e9 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -13,19 +13,17 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest, windows-latest] - php: [8.3, 8.2, 8.1, 8.0] - laravel: [10.*, 9.*] + php: [8.3, 8.2, 8.1] + laravel: [11.*, 10.*] stability: [prefer-lowest, prefer-stable] include: - laravel: 10.* testbench: 8.* - carbon: ^2.63 - - laravel: 9.* - testbench: 7.* - carbon: ^2.63 + - laravel: 11.* + testbench: 9.* exclude: - - laravel: 10.* - php: 8.0 + - laravel: 11.* + php: 8.1 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} @@ -47,7 +45,7 @@ jobs: - name: Install dependencies run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.carbon }}" --no-interaction --no-update + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update composer update --${{ matrix.stability }} --prefer-dist --no-interaction - name: Execute tests diff --git a/.gitignore b/.gitignore index 9a43686..b212367 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ .php_cs .php_cs.cache .phpunit.result.cache +.phpunit.cache build composer.lock coverage diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php deleted file mode 100644 index 8d8a790..0000000 --- a/.php-cs-fixer.dist.php +++ /dev/null @@ -1,40 +0,0 @@ -in([ - __DIR__ . '/src', - __DIR__ . '/tests', - ]) - ->name('*.php') - ->notName('*.blade.php') - ->ignoreDotFiles(true) - ->ignoreVCS(true); - -return (new PhpCsFixer\Config()) - ->setRules([ - '@PSR12' => true, - 'array_syntax' => ['syntax' => 'short'], - 'ordered_imports' => ['sort_algorithm' => 'alpha'], - 'no_unused_imports' => true, - 'not_operator_with_successor_space' => true, - 'trailing_comma_in_multiline' => true, - 'phpdoc_scalar' => true, - 'unary_operator_spaces' => true, - 'binary_operator_spaces' => true, - 'blank_line_before_statement' => [ - 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], - ], - 'phpdoc_single_line_var_spacing' => true, - 'phpdoc_var_without_name' => true, - 'class_attributes_separation' => [ - 'elements' => [ - 'method' => 'one', - ], - ], - 'method_argument_space' => [ - 'on_multiline' => 'ensure_fully_multiline', - 'keep_multiple_spaces_after_comma' => true, - ], - 'single_trait_insert_per_statement' => true, - ]) - ->setFinder($finder); diff --git a/LICENSE.md b/LICENSE.md index 43c44ab..3b09b56 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2023 MAIZE SRL +Copyright (c) 2024 MAIZE SRL Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/composer.json b/composer.json index 1e3f45e..08e6f42 100644 --- a/composer.json +++ b/composer.json @@ -18,21 +18,21 @@ } ], "require": { - "php": "^8.0", - "illuminate/database": "^9.0|^10.0", - "illuminate/support": "^9.0|^10.0", + "php": "^8.1", + "illuminate/database": "^10.0|^11.0", + "illuminate/support": "^10.0|^11.0", "spatie/laravel-package-tools": "^1.14.1" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.7", - "nunomaduro/larastan": "^2.0.1", - "orchestra/testbench": "^7.0|^8.0", - "pestphp/pest": "^1.21", - "pestphp/pest-plugin-laravel": "^1.1", - "phpstan/extension-installer": "^1.1", + "laravel/pint": "^1.0", + "larastan/larastan": "^2.0.1", + "orchestra/testbench": "^8.0|^9.0", + "pestphp/pest": "^2.34", + "pestphp/pest-plugin-arch": "^2.7", + "pestphp/pest-plugin-laravel": "^2.3", + "phpstan/extension-installer": "^1.3", "phpstan/phpstan-deprecation-rules": "^1.0", - "phpstan/phpstan-phpunit": "^1.0", - "phpunit/phpunit": "^9.5" + "phpstan/phpstan-phpunit": "^1.3" }, "autoload": { "psr-4": { @@ -46,7 +46,7 @@ } }, "scripts": { - "format": "vendor/bin/php-cs-fixer fix --allow-risky=yes", + "format": "vendor/bin/pint", "analyse": "vendor/bin/phpstan analyse", "test": "vendor/bin/pest", "test-coverage": "vendor/bin/pest coverage" diff --git a/database/factories/ArticleFactory.php b/database/factories/ArticleFactory.php index 2628b08..452582b 100644 --- a/database/factories/ArticleFactory.php +++ b/database/factories/ArticleFactory.php @@ -3,8 +3,8 @@ namespace Maize\TenantAware\Database\Factories; use Illuminate\Database\Eloquent\Factories\Factory; -use Maize\TenantAware\Tests\Support\Models\Article; use Illuminate\Database\Eloquent\Model; +use Maize\TenantAware\Tests\Support\Models\Article; class ArticleFactory extends Factory { @@ -13,7 +13,7 @@ class ArticleFactory extends Factory public function definition() { return [ - // + // ]; } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 290f954..10a8150 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,39 +1,23 @@ - - - - tests - - - - - ./src - - - - - - - - - - + + + + tests + + + + + + + + + + + + + + + ./src + + diff --git a/src/Exceptions/InvalidConfig.php b/src/Exceptions/InvalidConfig.php index 86a414d..969c46c 100644 --- a/src/Exceptions/InvalidConfig.php +++ b/src/Exceptions/InvalidConfig.php @@ -8,31 +8,31 @@ class InvalidConfig extends Exception { public static function couldNotDetermineTenantModelName(): self { - return new self("Could not determine the tenant model name. Make sure you specified a valid tenant model in the tenant aware config file"); + return new self('Could not determine the tenant model name. Make sure you specified a valid tenant model in the tenant aware config file'); } public static function couldNotDetermineTenantCurrentActionName(): self { - return new self("Could not determine the tenant current action name. Make sure you specified a valid tenant current action in the tenant aware config file"); + return new self('Could not determine the tenant current action name. Make sure you specified a valid tenant current action in the tenant aware config file'); } public static function couldNotDetermineTenantLandlordActionName(): self { - return new self("Could not determine the tenant landlord action name. Make sure you specified a valid tenant landlord action in the tenant aware config file"); + return new self('Could not determine the tenant landlord action name. Make sure you specified a valid tenant landlord action in the tenant aware config file'); } public static function couldNotDetermineTenantCurrentOrLandlordActionName(): self { - return new self("Could not determine the tenant current or landlord action name. Make sure you specified a valid tenant current or landlord action in the tenant aware config file"); + return new self('Could not determine the tenant current or landlord action name. Make sure you specified a valid tenant current or landlord action in the tenant aware config file'); } public static function couldNotDetermineScopeApplyName(): self { - return new self("Could not determine the scope apply name. Make sure you specified a valid scope apply in the tenant aware config file"); + return new self('Could not determine the scope apply name. Make sure you specified a valid scope apply in the tenant aware config file'); } public static function couldNotDetermineTenantOnlyCurrentActionName(): self { - return new self("Could not determine the tenant only current action name. Make sure you specified a valid tenant only current action in the tenant aware config file"); + return new self('Could not determine the tenant only current action name. Make sure you specified a valid tenant only current action in the tenant aware config file'); } } diff --git a/tests/ActionTest.php b/tests/ActionTest.php index 43f7944..95e33aa 100644 --- a/tests/ActionTest.php +++ b/tests/ActionTest.php @@ -19,7 +19,6 @@ expect(app(TenantCurrentOrLandlordAction::class)())->toBeNull(); }); - it('can get only current tenant', function (Model|Builder $builder, bool $request, bool $result) { if ($request) { request()->merge(['tenant.only_current' => null]); diff --git a/tests/ModelTest.php b/tests/ModelTest.php index 540d8d7..3d026db 100644 --- a/tests/ModelTest.php +++ b/tests/ModelTest.php @@ -48,7 +48,7 @@ ['tenant' => null], ]); -it('can set tenant key on model', function (mixed $key, mixed $result) { +it('can set tenant key on model', function (Tenant|int|null $key, Tenant|int|null $result) { $article = Article::factory()->create(); $article->setTenantKey($key); diff --git a/tests/Support/Models/Article.php b/tests/Support/Models/Article.php index 641a4c2..4a5bb53 100644 --- a/tests/Support/Models/Article.php +++ b/tests/Support/Models/Article.php @@ -8,8 +8,8 @@ class Article extends Model { - use HasFactory; use BelongsToTenant; + use HasFactory; protected $fillable = [ // diff --git a/tests/Support/Models/User.php b/tests/Support/Models/User.php index 681e0ce..0266a85 100644 --- a/tests/Support/Models/User.php +++ b/tests/Support/Models/User.php @@ -8,8 +8,8 @@ class User extends Model { - use HasFactory; use BelongsToTenant; + use HasFactory; protected $fillable = [ //