Skip to content

Commit aa2af6e

Browse files
authored
Larastan 3.x and fixes for the phpstan errors (#140)
1 parent da15c53 commit aa2af6e

27 files changed

+90
-124
lines changed

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
"require": {
2222
"php": "^8.2",
2323
"doctrine/dbal": "^3.6",
24-
"filament/filament": "^3.2.23",
24+
"filament/filament": "^3.2.57",
2525
"filament/spatie-laravel-settings-plugin": "^3.2",
2626
"guzzlehttp/guzzle": "^7.8",
27-
"illuminate/console": "^11.0",
28-
"illuminate/database": "^11.0",
29-
"illuminate/events": "^11.0",
30-
"illuminate/queue": "^11.0",
31-
"illuminate/support": "^11.0",
27+
"illuminate/console": "^11.23.0",
28+
"illuminate/database": "^11.23.0",
29+
"illuminate/events": "^11.23.0",
30+
"illuminate/queue": "^11.23.0",
31+
"illuminate/support": "^11.23.0",
3232
"nesbot/carbon": "^2.70",
3333
"spatie/laravel-data": "^4.11",
3434
"spatie/laravel-query-builder": "^5.5",
@@ -37,7 +37,7 @@
3737
"twig/twig": "^3.0"
3838
},
3939
"require-dev": {
40-
"larastan/larastan": "^2.9",
40+
"larastan/larastan": "^3.0",
4141
"laravel/pail": "^1.1",
4242
"orchestra/testbench": "^9.5.1",
4343
"pestphp/pest": "^3.2",

config/cachet.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
| This is the model that will be used to authenticate users. This model
3434
| must be an instance of Illuminate\Foundation\Auth\User.
3535
*/
36-
'user_model' => App\Models\User::class,
36+
'user_model' => \App\Models\User::class,
3737

3838
/*
3939
|--------------------------------------------------------------------------

database/seeders/DatabaseSeeder.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,21 @@ public function run(): void
8282
'visible' => ResourceVisibilityEnum::guest,
8383
]);
8484

85+
/** @phpstan-ignore-next-line argument.type Larastan bug */
8586
$componentGroup->components()->createMany([
8687
[
8788
'name' => 'Cachet Website',
8889
'description' => 'The Cachet website.',
8990
'link' => 'https://cachethq.io',
9091
'status' => ComponentStatusEnum::operational,
91-
], [
92+
],
93+
[
9294
'name' => 'Cachet Documentation',
9395
'description' => 'The Cachet docs, powered by Mintlify.',
9496
'link' => 'https://docs.cachethq.io',
9597
'status' => ComponentStatusEnum::operational,
96-
], [
98+
],
99+
[
97100
'name' => 'Cachet Blog',
98101
'description' => 'Learn more about Cachet.',
99102
'link' => 'https://blog.cachethq.io',

phpstan-baseline.neon

Lines changed: 0 additions & 66 deletions
This file was deleted.

phpstan.neon.dist

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
includes:
22
- vendor/larastan/larastan/extension.neon
3-
- phpstan-baseline.neon
43

54
parameters:
65
level: 5
76

87
paths:
98
- src
109
- routes
11-
- config
1210
- database/factories
1311
- database/seeders
1412

@@ -18,4 +16,10 @@ parameters:
1816
- public
1917

2018
databaseMigrationsPath:
21-
- database/migrations
19+
- database/migrations
20+
21+
ignoreErrors:
22+
-
23+
path: src/Http/Resources
24+
identifier: return.type
25+
message: '#Method Cachet\\Http\\Resources\\.*?::toRelationships\(\).*#'

src/Actions/Metric/CreateMetricPoint.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ public function handle(Metric $metric, ?CreateMetricPointData $data = null): Met
1616
$lastPoint = $metric->metricPoints()->latest()->first();
1717

1818
// If the last point was created within the threshold, increment the counter.
19-
if ($lastPoint && $lastPoint->withinThreshold($metric->threshold, $data?->timestamp ?? null)) {
19+
if ($lastPoint && $lastPoint->withinThreshold($metric->threshold, $data->timestamp ?? null)) {
2020
$lastPoint->increment('counter');
2121

2222
return $lastPoint;
2323
}
2424

2525
return $metric->metricPoints()->create([
26-
'value' => $data?->value ?? $metric->default_value,
26+
'value' => $data->value ?? $metric->default_value,
2727
'counter' => 1,
28-
'created_at' => $data?->timestamp ?? now(),
28+
'created_at' => $data->timestamp ?? now(),
2929
]);
3030
}
3131
}

src/Enums/ComponentGroupVisibilityEnum.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function getLabel(): string
2121
};
2222
}
2323

24-
public function getIcon(): ?string
24+
public function getIcon(): string
2525
{
2626
return match ($this) {
2727
self::expanded => 'heroicon-o-chevron-down',
@@ -30,7 +30,7 @@ public function getIcon(): ?string
3030
};
3131
}
3232

33-
public function getColor(): string|array|null
33+
public function getColor(): string
3434
{
3535
return 'gray';
3636
}

src/Enums/ComponentStatusEnum.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function getLabel(): string
3535
};
3636
}
3737

38-
public function getIcon(): ?string
38+
public function getIcon(): string
3939
{
4040
return match ($this) {
4141
self::operational => 'cachet-circle-check',
@@ -46,7 +46,7 @@ public function getIcon(): ?string
4646
};
4747
}
4848

49-
public function getColor(): string|array|null
49+
public function getColor(): array
5050
{
5151
return match ($this) {
5252
self::operational => Color::Green,

src/Enums/ExternalProviderEnum.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ enum ExternalProviderEnum: string
1111
*/
1212
public function status(mixed $status): IncidentStatusEnum
1313
{
14-
if ($this === self::OhDear) {
15-
return match ($status) {
14+
return match ($this) {
15+
self::OhDear => match ($status) {
1616
'resolved' => IncidentStatusEnum::fixed,
1717
'warning' => IncidentStatusEnum::investigating,
1818
default => IncidentStatusEnum::unknown,
19-
};
20-
}
19+
},
20+
};
2121
}
2222
}

src/Enums/IncidentStatusEnum.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function getLabel(): string
4646
};
4747
}
4848

49-
public function getIcon(): ?string
49+
public function getIcon(): string
5050
{
5151
return match ($this) {
5252
self::investigating => 'cachet-incident-investigating',
@@ -57,7 +57,7 @@ public function getIcon(): ?string
5757
};
5858
}
5959

60-
public function getColor(): string|array|null
60+
public function getColor(): array
6161
{
6262
return match ($this) {
6363
self::investigating => Color::Blue,

0 commit comments

Comments
 (0)