diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9821a41..a3df1b5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,6 +3,12 @@ name: tests on: push: branches: [main] + paths: + - "**.php" + - ".github/workflows/tests.yml" + - "phpunit.xml.dist" + - "composer.json" + - "composer.lock" pull_request: branches: [main] @@ -13,15 +19,14 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest] - php: [8.2, 8.1] - laravel: [10.*] + php: [8.3, 8.2, 8.1] + laravel: [10, 11] stability: [prefer-lowest, prefer-stable] - include: - - laravel: 10.* - testbench: 8.* - carbon: ^2.63 + exclude: + - php: 8.1 + laravel: 11 - name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} + name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} steps: - name: Checkout code @@ -41,11 +46,11 @@ 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 "illuminate/contracts=^${{ matrix.laravel }}" --no-interaction --no-update composer update --${{ matrix.stability }} --prefer-dist --no-interaction - name: List Installed Dependencies run: composer show -D - name: Execute tests - run: vendor/bin/pest + run: composer test:unit diff --git a/.gitignore b/.gitignore index f3854b0..ba51c92 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/.phpunit.cache .phpunit.result.cache build composer.lock diff --git a/composer.json b/composer.json index f1429d2..b9ce8bc 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,10 @@ "tasks" ], "homepage": "https://github.com/qruto/laravel-flora", + "support": { + "issues": "https://github.com/qruto/laravel-wave/issues", + "source": "https://github.com/qruto/laravel-wave" + }, "license": "MIT", "authors": [ { @@ -28,30 +32,30 @@ ], "require": { "php": "^8.1", - "illuminate/bus": "^10.0", - "illuminate/config": "^10.0", - "illuminate/console": "^10.0", - "illuminate/container": "^10.0", - "illuminate/contracts": "^10.0", - "illuminate/support": "^10.0", - "nunomaduro/laravel-desktop-notifier": "^2.7", - "spatie/laravel-package-tools": "^1.14" + "illuminate/bus": "^10.0|^11.0", + "illuminate/config": "^10.0|^11.0", + "illuminate/console": "^10.0|^11.0", + "illuminate/container": "^10.0|^11.0", + "illuminate/contracts": "^11", + "illuminate/support": "^10.0|^11.0", + "nunomaduro/laravel-desktop-notifier": "^2.8", + "spatie/laravel-package-tools": "^1.16" }, "require-dev": { - "laravel/pint": "^v1.4", - "mockery/mockery": "^1.5.1", - "nunomaduro/collision": "^6.4", - "nunomaduro/larastan": "^2.4", - "orchestra/testbench": "^8.0", - "pestphp/pest": "^1.22", - "pestphp/pest-plugin-laravel": "^1.4", - "pestphp/pest-plugin-mock": "^v1.0.3", - "phpstan/extension-installer": "^1.2", + "driftingly/rector-laravel": "^1.1", + "larastan/larastan": "^2.9", + "laravel/pint": "^v1.15", + "mockery/mockery": "^1.6", + "orchestra/canvas": "^8.12|^9.0", + "orchestra/testbench": "^8.0|^9.0", + "pestphp/pest": "^1.22|^2.0", + "pestphp/pest-plugin-laravel": "^1.4|^2.0", + "phpstan/extension-installer": "^1.3", "phpstan/phpstan-deprecation-rules": "^1.1", "phpstan/phpstan-phpunit": "^1.3", - "phpunit/phpunit": "^9.6", - "rector/rector": "^0.15.18", - "spatie/laravel-ray": "^1.32" + "phpunit/phpunit": "^9.6|^10.0", + "rector/rector": "^1.0", + "spatie/laravel-ray": "^1.36" }, "autoload": { "psr-4": { @@ -72,7 +76,7 @@ "refactor": "rector --debug", "test-coverage": "pest --coverage --colors=always", "test:refactor": "rector --dry-run", - "test:types": "phpstan analyse --ansi", + "test:types": "phpstan analyse --ansi --memory-limit=-1", "test:unit": "pest --colors=always", "test:lint": "pint --test -v", "test": [ diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 36839bf..6c796a2 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -16,4 +16,3 @@ parameters: - '#^Class Laravel\\Horizon\\Console\\WorkCommand not found#' - '#^Class Spatie\\TypeScriptTransformer\\TypeScriptTransformerConfig not found#' - '#^Class Laravel\\VaporUi\\Console\\PublishCommand not found#' - diff --git a/phpstan.neon.rector.dist b/phpstan.neon.rector.dist new file mode 100644 index 0000000..167cc41 --- /dev/null +++ b/phpstan.neon.rector.dist @@ -0,0 +1,19 @@ +includes: + - phpstan-baseline.neon + - ./vendor/larastan/larastan/extension.neon + +parameters: + level: 4 + paths: + - src + - config + tmpDir: build/phpstan + checkOctaneCompatibility: true + checkModelProperties: true + checkMissingIterableValueType: false + excludePaths: + - src/setup.php + ignoreErrors: + - '#^Class Laravel\\Horizon\\Console\\WorkCommand not found#' + - '#^Class Spatie\\TypeScriptTransformer\\TypeScriptTransformerConfig not found#' + - '#^Class Laravel\\VaporUi\\Console\\PublishCommand not found#' diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a967176..0bebbd1 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,42 +1,26 @@ - - - - tests - - - - - ./src - - - - - - - - - - - - - + + + + tests + + + + + + + + + + + + + + + + + + ./src + + diff --git a/rector.php b/rector.php index 90890a3..c0c8c29 100644 --- a/rector.php +++ b/rector.php @@ -4,29 +4,22 @@ use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; use Rector\Config\RectorConfig; -use Rector\Set\ValueObject\LevelSetList; -use Rector\Set\ValueObject\SetList; +use Rector\ValueObject\PhpVersion; +use RectorLaravel\Set\LaravelSetList; -return static function (RectorConfig $rectorConfig): void { - $rectorConfig->paths([ +return RectorConfig::configure() + ->withPaths([ __DIR__.'/src', - ]); - - // register a single rule - $rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class); - - // define sets of rules - $rectorConfig->sets([ - LevelSetList::UP_TO_PHP_81, - SetList::CODE_QUALITY, - SetList::DEAD_CODE, - SetList::EARLY_RETURN, - // SetList::CODING_STYLE, - // SetList::NAMING, - // SetList::ACTION_INJECTION_TO_CONSTRUCTOR_INJECTION, - // SetList::PRIVATIZATION, - // SetList::TYPE_DECLARATION, - ]); - - $rectorConfig->phpstanConfig(__DIR__.'/phpstan.neon.dist'); -}; + ]) + ->withRules([InlineConstructorDefaultToPropertyRector::class]) + ->withPreparedSets( + codeQuality: true, + deadCode: true, + earlyReturn: true, + ) + ->withSets([ + LaravelSetList::LARAVEL_110, + ]) + ->withPhpVersion(PhpVersion::PHP_81) + ->withBootstrapFiles([__DIR__.'/vendor/larastan/larastan/bootstrap.php']) + ->withPHPStanConfigs([__DIR__.'/phpstan.neon.rector.dist']); diff --git a/src/Actions/Notification.php b/src/Actions/Notification.php index 506410f..218016b 100644 --- a/src/Actions/Notification.php +++ b/src/Actions/Notification.php @@ -37,7 +37,7 @@ public function run(): bool ->setTitle($this->string) ->setBody($this->body); - $notification->setIcon(empty($this->icon) ? __DIR__.'/../../laravel-logo.png' : $this->icon); + $notification->setIcon($this->icon === null || $this->icon === '' || $this->icon === '0' ? __DIR__.'/../../laravel-logo.png' : $this->icon); return $notifier->send($notification); } diff --git a/src/Actions/Script.php b/src/Actions/Script.php index 7736508..78be6e1 100644 --- a/src/Actions/Script.php +++ b/src/Actions/Script.php @@ -56,7 +56,7 @@ public function __invoke(Factory $outputComponents, int $labelWidth = 0): bool clearOutputLineAbove($this->output); } - if ($this->run->internal->doneWithFailures() && ! empty($this->run->internal->exceptions())) { + if ($this->run->internal->doneWithFailures() && $this->run->internal->exceptions() !== []) { $this->exception = $this->run->internal->exceptions()[0]['e']; } diff --git a/src/Console/Assets.php b/src/Console/Assets.php index a56fe15..8006128 100644 --- a/src/Console/Assets.php +++ b/src/Console/Assets.php @@ -26,9 +26,13 @@ public function publish(Factory $components, bool $verbose = false): bool $assets = $this->config['flora.assets']; foreach (resolve('flora.packages') as $package) { - if ($package->exists() && $tag = $package->instruction()->assetsTag) { - $assets[] = $tag; + if (! $package->exists()) { + continue; } + if (! ($tag = $package->instruction()->assetsTag)) { + continue; + } + $assets[] = $tag; } if ($assets === []) { @@ -117,9 +121,11 @@ private function makePublishCallback(array $assets): Closure $tags[] = $value; } - if (! empty($parameters['--provider'])) { - $publishCallbacks[] = fn (): bool => $this->artisan->call('vendor:publish', $parameters + ['--force' => $forced]) === 0; + if (! ($parameters['--provider'] !== '' && $parameters['--provider'] !== '0')) { + continue; } + + $publishCallbacks[] = fn (): bool => $this->artisan->call('vendor:publish', $parameters + ['--force' => $forced]) === 0; } if ($tags !== []) { diff --git a/src/Discovers/Instruction.php b/src/Discovers/Instruction.php index 27aac76..b4b500c 100644 --- a/src/Discovers/Instruction.php +++ b/src/Discovers/Instruction.php @@ -15,7 +15,7 @@ public function __construct( ) { } - public function get(FloraType $type, Environment $environment = null): Closure + public function get(FloraType $type, ?Environment $environment = null): Closure { if (is_null($environment)) { $environment = Environment::Production; diff --git a/src/Run.php b/src/Run.php index 59ee72c..f5aaa16 100644 --- a/src/Run.php +++ b/src/Run.php @@ -62,14 +62,14 @@ public function exec(string $command, array $parameters = []): static return $this; } - public function call(callable $callback, array $parameters = [], string $name = null): static + public function call(callable $callback, array $parameters = [], ?string $name = null): static { $this->internal->push(new Callback($this->application->getLaravel(), $callback, $parameters, $name)); return $this; } - public function job(object|string $job, string $queue = null, string $connection = null): static + public function job(object|string $job, ?string $queue = null, ?string $connection = null): static { $this->internal->push(new Job($job, $queue, $connection)); diff --git a/tests/Pest.php b/tests/Pest.php index d1f4181..4015553 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -13,7 +13,7 @@ uses(TestCase::class)->in(__DIR__); -function chain(callable $callback = null, $verbose = false): object +function chain(?callable $callback = null, $verbose = false): object { if ($callback) { App::update('testing', $callback); @@ -36,12 +36,12 @@ public function run($options = []) }; } -function makeRunner(OutputInterface $output = null): Run +function makeRunner(?OutputInterface $output = null): Run { return new Run(new Application(app(), app()->make(Dispatcher::class), 'unknown'), $output ?? new BufferedOutput()); } -function actionNamesForEnvironment(FloraType $type, Environment $env, Run $run = null): array +function actionNamesForEnvironment(FloraType $type, Environment $env, ?Run $run = null): array { $run = $run ?? makeRunner();