Skip to content

Commit c2ca0f6

Browse files
authored
Add workflow job for phpstan (#70)
* add workflow job for phpstan * use custom phpstan.neon * fix name * add ignoreErrors * fix some errors * fix remaining errors * small cleanup
1 parent 73126f5 commit c2ca0f6

17 files changed

Lines changed: 113 additions & 50 deletions

File tree

.github/workflows/lint.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
pint:
11+
name: Pint
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Setup PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: 8.4
22+
tools: composer:v2
23+
coverage: none
24+
25+
- name: Init composer
26+
run: composer init --no-interaction
27+
28+
- name: Install Laravel Pint
29+
run: composer require "laravel/pint:^1.15.3"
30+
31+
- name: Run Pint
32+
run: vendor/bin/pint --test
33+
phpstan:
34+
name: PHPStan
35+
runs-on: ubuntu-latest
36+
37+
steps:
38+
- name: Checkout code
39+
uses: actions/checkout@v4
40+
41+
- name: Clone Pelican Panel
42+
run: git clone --depth=1 https://github.com/pelican-dev/panel pelican
43+
44+
- name: Setup PHP
45+
uses: shivammathur/setup-php@v2
46+
with:
47+
php-version: 8.4
48+
tools: composer:v2
49+
coverage: none
50+
51+
- name: Install panel dependencies
52+
run: |
53+
cd pelican
54+
composer install --no-interaction --no-suggest --no-progress --no-scripts
55+
56+
- name: Install plugin dependencies
57+
run: |
58+
cd pelican
59+
composer require "stripe/stripe-php:^18.0" "kovah/laravel-socialite-oidc:^0.5" "krymosoftware/gameq:^4.0"
60+
61+
- name: Setup .env file
62+
run: cp pelican/.env.example pelican/.env
63+
64+
- name: Move plugin folders and phpstan.neon
65+
run: |
66+
mkdir -p pelican/plugins
67+
rsync -av --progress ./ pelican/plugins/ --exclude=pelican
68+
cp phpstan.neon pelican/phpstan.neon
69+
70+
- name: Run PHPStan Analysis
71+
run: |
72+
cd pelican
73+
vendor/bin/phpstan analyse --memory-limit=-1 --error-format=github
74+

.github/workflows/pint.yml

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

billing/src/Filament/App/Widgets/ProductWidget.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ProductWidget extends Widget implements HasActions, HasSchemas
2222
use InteractsWithActions;
2323
use InteractsWithSchemas;
2424

25-
protected string $view = 'billing::widget';
25+
protected string $view = 'billing::widget'; // @phpstan-ignore property.defaultValue
2626

2727
public ?Product $product = null;
2828

billing/src/Models/Coupon.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected static function boot(): void
5454
static::deleted(function (self $model) {
5555
if (!is_null($model->stripe_coupon_id)) {
5656
/** @var StripeClient $stripeClient */
57-
$stripeClient = app(StripeClient::class); // @phpstan-ignore myCustomRules.forbiddenGlobalFunctions
57+
$stripeClient = app(StripeClient::class);
5858

5959
$stripeClient->coupons->delete($model->stripe_coupon_id);
6060
$stripeClient->coupons->delete($model->stripe_promotion_id);
@@ -65,7 +65,7 @@ protected static function boot(): void
6565
public function sync(): void
6666
{
6767
/** @var StripeClient $stripeClient */
68-
$stripeClient = app(StripeClient::class); // @phpstan-ignore myCustomRules.forbiddenGlobalFunctions
68+
$stripeClient = app(StripeClient::class);
6969

7070
if (is_null($this->stripe_coupon_id)) {
7171
$data = [

billing/src/Models/Order.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function checkExpire(): bool
7575
if ($this->status === OrderStatus::Active && !is_null($this->expires_at) && now('UTC') >= $this->expires_at) {
7676
try {
7777
if ($this->server) {
78-
app(SuspensionService::class)->handle($this->server, SuspendAction::Suspend); // @phpstan-ignore myCustomRules.forbiddenGlobalFunctions
78+
app(SuspensionService::class)->handle($this->server, SuspendAction::Suspend);
7979
}
8080
} catch (Exception $exception) {
8181
report($exception);
@@ -98,7 +98,7 @@ private function expireCheckoutSession(): void
9898
{
9999
if (!is_null($this->stripe_checkout_id)) {
100100
/** @var StripeClient $stripeClient */
101-
$stripeClient = app(StripeClient::class); // @phpstan-ignore myCustomRules.forbiddenGlobalFunctions
101+
$stripeClient = app(StripeClient::class);
102102

103103
$session = $stripeClient->checkout->sessions->retrieve($this->stripe_checkout_id);
104104

@@ -111,7 +111,7 @@ private function expireCheckoutSession(): void
111111
public function getCheckoutSession(): Session
112112
{
113113
/** @var StripeClient $stripeClient */
114-
$stripeClient = app(StripeClient::class); // @phpstan-ignore myCustomRules.forbiddenGlobalFunctions
114+
$stripeClient = app(StripeClient::class);
115115

116116
if (is_null($this->stripe_checkout_id)) {
117117
$session = $stripeClient->checkout->sessions->create([
@@ -165,7 +165,7 @@ public function activate(?string $stripePaymentId): void
165165

166166
try {
167167
if ($this->server) {
168-
app(SuspensionService::class)->handle($this->server, SuspendAction::Unsuspend); // @phpstan-ignore myCustomRules.forbiddenGlobalFunctions
168+
app(SuspensionService::class)->handle($this->server, SuspendAction::Unsuspend);
169169
} else {
170170
$this->createServer();
171171
}
@@ -178,7 +178,7 @@ public function close(): void
178178
{
179179
try {
180180
if ($this->server) {
181-
app(SuspensionService::class)->handle($this->server, SuspendAction::Suspend); // @phpstan-ignore myCustomRules.forbiddenGlobalFunctions
181+
app(SuspensionService::class)->handle($this->server, SuspendAction::Suspend);
182182
}
183183
} catch (Exception $exception) {
184184
report($exception);
@@ -228,7 +228,7 @@ public function createServer(): Server
228228
$object->setTags($product->tags);
229229
$object->setPorts($product->ports);
230230

231-
$server = app(ServerCreationService::class)->handle($data, $object); // @phpstan-ignore myCustomRules.forbiddenGlobalFunctions
231+
$server = app(ServerCreationService::class)->handle($data, $object);
232232

233233
$this->update([
234234
'server_id' => $server->id,

billing/src/Models/Product.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ protected static function boot(): void
7474
static::deleted(function (self $model) {
7575
if (!is_null($model->stripe_id)) {
7676
/** @var StripeClient $stripeClient */
77-
$stripeClient = app(StripeClient::class); // @phpstan-ignore myCustomRules.forbiddenGlobalFunctions
77+
$stripeClient = app(StripeClient::class);
7878

7979
$stripeClient->products->delete($model->stripe_id);
8080
}
@@ -99,7 +99,7 @@ public function getLabel(): string
9999
public function sync(): void
100100
{
101101
/** @var StripeClient $stripeClient */
102-
$stripeClient = app(StripeClient::class); // @phpstan-ignore myCustomRules.forbiddenGlobalFunctions
102+
$stripeClient = app(StripeClient::class);
103103

104104
if (is_null($this->stripe_id)) {
105105
$stripeProduct = $stripeClient->products->create([

billing/src/Models/ProductPrice.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function sync(): void
6565
$this->product->sync();
6666

6767
/** @var StripeClient $stripeClient */
68-
$stripeClient = app(StripeClient::class); // @phpstan-ignore myCustomRules.forbiddenGlobalFunctions
68+
$stripeClient = app(StripeClient::class);
6969

7070
if (is_null($this->stripe_id)) {
7171
$stripePrice = $stripeClient->prices->create([

pastefox-share/src/Filament/Components/Actions/UploadLogsAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ protected function setUp(): void
7474
}
7575

7676
$response = Http::withHeaders($headers)
77-
->post('https://pastefox.com/api/pastes', $payload)
7877
->timeout(30)
7978
->connectTimeout(5)
8079
->throw()
80+
->post('https://pastefox.com/api/pastes', $payload)
8181
->json();
8282

8383
if ($response['success']) {

phpstan.neon

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
includes:
2+
- vendor/larastan/larastan/extension.neon
3+
4+
parameters:
5+
6+
paths:
7+
- plugins
8+
9+
level: 6
10+
11+
ignoreErrors:
12+
- identifier: missingType.generics
13+
- identifier: larastan.noEnvCallsOutsideOfConfig

player-counter/database/Seeders/PlayerCounterSeeder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function run(): void
3232
}
3333
}
3434

35+
// @phpstan-ignore if.alwaysTrue
3536
if ($this->command) {
3637
$this->command->info('Created game query types for minecraft and source');
3738
}

0 commit comments

Comments
 (0)