Skip to content

Commit e624336

Browse files
authored
feat: Laravel 11.x Compatibility (#8)
* WIP * style: apply Pint * WIP * style: apply Pint * Update TestCase.php * style: apply Pint --------- Co-authored-by: ralphjsmit <ralphjsmit@users.noreply.github.com>
1 parent 2aa2f54 commit e624336

File tree

7 files changed

+83
-42
lines changed

7 files changed

+83
-42
lines changed

.github/workflows/pint.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Lint with Pint
2+
3+
on:
4+
pull_request:
5+
workflow_call:
6+
workflow_dispatch:
7+
8+
jobs:
9+
pint:
10+
name: Run Pint
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
with:
17+
ref: ${{ github.head_ref }}
18+
19+
- name: Run Pint
20+
uses: aglipanci/laravel-pint-action@latest
21+
with:
22+
verboseMode: true
23+
24+
- name: Commit changes
25+
uses: stefanzweifel/git-auto-commit-action@v5
26+
with:
27+
commit_message: "style: apply Pint"

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@
1919
"RalphJSmit\\LaravelHorizonCron\\" : "tests"
2020
}
2121
},
22+
"require": {
23+
"illuminate/contracts": "^8.0|^9.0|^10.0|^11.0"
24+
},
2225
"require-dev" : {
23-
"orchestra/testbench" : "^6.0|^7.0|^8.0",
26+
"orchestra/testbench" : "^6.0|^7.0|^8.0|^9.0",
2427
"phpunit/phpunit" : "^9.5|^10.0"
2528
},
2629
"extra" : {

pint.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"preset": "laravel",
3+
"rules": {
4+
"no_superfluous_phpdoc_tags": true,
5+
"concat_space": {
6+
"spacing": "one"
7+
},
8+
"single_quote": true,
9+
"combine_consecutive_issets": true,
10+
"combine_consecutive_unsets": true,
11+
"explicit_string_variable": true,
12+
"global_namespace_import": true,
13+
"single_trait_insert_per_statement": true,
14+
"ordered_traits": true,
15+
"types_spaces": {
16+
"space": "single"
17+
}
18+
}
19+
}

src/Supervisor/Console/RestartHorizon.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ class RestartHorizon extends Command
2424

2525
/**
2626
* Execute the console command.
27-
*
28-
* @return int
2927
*/
3028
public function handle(): int
3129
{
@@ -41,7 +39,7 @@ public function handle(): int
4139
$masterSupervisors = $horizon->all();
4240

4341
// If none is running, we should start Horizon.
44-
if ( count($masterSupervisors) === 0 ) {
42+
if (count($masterSupervisors) === 0) {
4543
$this->error('Horizon is not running.');
4644

4745
return $this->startHorizon();
@@ -51,12 +49,12 @@ public function handle(): int
5149
$masterSupervisor = $masterSupervisors[0];
5250

5351
// If paused, we can resume it.
54-
if ( $masterSupervisor->status === 'paused' ) {
52+
if ($masterSupervisor->status === 'paused') {
5553
$this->warn('Horizon is running, but the status is paused.');
56-
if ( $this->option('resume-if-paused') ) {
54+
if ($this->option('resume-if-paused')) {
5755
$this->info('Resuming Horizon.');
5856
$this->call('horizon:continue');
59-
} else if ( ! $this->option('silent') && $this->confirm('Do you want to resume Horizon?') ) {
57+
} elseif (! $this->option('silent') && $this->confirm('Do you want to resume Horizon?')) {
6058
$this->info('Resuming Horizon.');
6159
$this->call('horizon:continue');
6260
} else {
@@ -76,14 +74,14 @@ protected function startHorizon(): int
7674

7775
$phpPath = $this->option('php-path') ?? 'php';
7876

79-
$fp = popen("{$phpPath} artisan horizon", "r");
77+
$fp = popen("{$phpPath} artisan horizon", 'r');
8078

8179
while (! feof($fp)) {
8280
$buffer = fgets($fp, 4096);
8381
echo $buffer;
8482
}
8583

86-
$this->error("Horizon was terminated and could not be started");
84+
$this->error('Horizon was terminated and could not be started');
8785

8886
pclose($fp);
8987

src/Supervisor/Supervisor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44

55
class Supervisor
66
{
7-
8-
}
7+
//
8+
}

src/Supervisor/SupervisorServiceProvider.php

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,26 @@
22

33
namespace RalphJSmit\LaravelHorizonCron\Supervisor;
44

5-
use Illuminate\Support\ServiceProvider;
65
use Illuminate\Console\Scheduling\Schedule;
6+
use Illuminate\Support\ServiceProvider;
77

88
class SupervisorServiceProvider extends ServiceProvider
99
{
10-
public function boot()
11-
{
12-
/**
13-
* Register the check horizon status command
14-
*/
10+
public function boot(): void
11+
{
1512
$this->commands([
1613
\RalphJSmit\LaravelHorizonCron\Supervisor\Console\RestartHorizon::class,
1714
]);
1815

19-
/**
20-
* Schedule the command
21-
*/
2216
$this->app->booted(function () {
2317
$schedule = $this->app->make(Schedule::class);
18+
2419
$schedule->command('supervisor:check')->everyThreeMinutes();
2520
});
26-
}
27-
28-
public function register()
29-
{
21+
}
3022

31-
}
32-
}
23+
public function register(): void
24+
{
25+
//
26+
}
27+
}

tests/Supervisor/TestCase.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,20 @@
66

77
class TestCase extends \Orchestra\Testbench\TestCase
88
{
9-
public function setUp(): void
10-
{
11-
parent::setUp();
12-
// additional setup
13-
}
9+
public function setUp(): void
10+
{
11+
parent::setUp();
12+
}
1413

15-
protected function getPackageProviders($app)
16-
{
17-
return [
18-
SupervisorServiceProvider::class,
19-
];
20-
}
14+
protected function getPackageProviders($app)
15+
{
16+
return [
17+
SupervisorServiceProvider::class,
18+
];
19+
}
2120

22-
protected function getEnvironmentSetUp($app)
23-
{
24-
// perform environment setup
25-
}
26-
}
21+
protected function getEnvironmentSetUp($app)
22+
{
23+
//
24+
}
25+
}

0 commit comments

Comments
 (0)