Skip to content

Commit

Permalink
- Laravel 11 support
Browse files Browse the repository at this point in the history
- Rector upgrade to 1 stable
  • Loading branch information
slavarazum committed Apr 13, 2024
1 parent c19ce9d commit 99ec5ee
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 107 deletions.
23 changes: 14 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand All @@ -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
Expand All @@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.phpunit.cache
.phpunit.result.cache
build
composer.lock
Expand Down
46 changes: 25 additions & 21 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand All @@ -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": {
Expand All @@ -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": [
Expand Down
1 change: 0 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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#'

19 changes: 19 additions & 0 deletions phpstan.neon.rector.dist
Original file line number Diff line number Diff line change
@@ -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#'
64 changes: 24 additions & 40 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,42 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
executionOrder="random"
failOnWarning="true"
failOnRisky="true"
failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true"
verbose="true"
>
<testsuites>
<testsuite name="Qruto Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<php>
<env name="APP_KEY" value="base64:rGnjE0QlOptsp7mBjaboDWDv6qaBfiGrerGF1Xpsigc="/>
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" executionOrder="random" failOnWarning="true" failOnRisky="true" failOnEmptyTestSuite="true" beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Qruto Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<php>
<env name="APP_KEY" value="base64:rGnjE0QlOptsp7mBjaboDWDv6qaBfiGrerGF1Xpsigc="/>
</php>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
41 changes: 17 additions & 24 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
2 changes: 1 addition & 1 deletion src/Actions/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Actions/Script.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}

Expand Down
14 changes: 10 additions & 4 deletions src/Console/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 === []) {
Expand Down Expand Up @@ -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 !== []) {
Expand Down
2 changes: 1 addition & 1 deletion src/Discovers/Instruction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/Run.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
6 changes: 3 additions & 3 deletions tests/Pest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();

Expand Down

0 comments on commit 99ec5ee

Please sign in to comment.