Skip to content

Commit 0d8b080

Browse files
committed
fixing more pint/phpstan issues
1 parent f16ed67 commit 0d8b080

5 files changed

Lines changed: 20 additions & 15 deletions

File tree

subdomains/src/Filament/Admin/Resources/Servers/RelationManagers/SubdomainRelationManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Boy132\Subdomains\Filament\Admin\Resources\Users\RelationManagers;
3+
namespace Boy132\Subdomains\Filament\Admin\Resources\Servers\RelationManagers;
44

55
use App\Models\Server;
66
use Boy132\Subdomains\Models\CloudflareDomain;

subdomains/src/Filament/Components/Actions/SetSrvTargetAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ protected function setUp(): void
2626
return [
2727
TextInput::make('srv_target')
2828
->label(fn () => trans('subdomains::strings.srv_target'))
29-
->default(fn () => $node?->srv_target) // @phpstan-ignore variable.undefined
29+
->default(fn () => $node->srv_target) // @phpstan-ignore property.undefined
3030
->placeholder('play.example.com OR IPv4/IPv6 address')
3131
->helperText(trans('subdomains::strings.srv_target_confirmation'))
3232
->rules(['nullable', 'string', 'regex:/^(?=.{1,253}$)(?!-)[A-Za-z0-9-]{1,63}(?<!-)(?:\.(?!-)[A-Za-z0-9-]{1,63}(?<!-))*$/']),

subdomains/src/Filament/Server/Resources/Subdomains/SubdomainResource.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ public static function canAccess(): bool
3636
{
3737
/** @var Server $server */
3838
$server = Filament::getTenant();
39+
$ip = $server->allocation?->ip ?? null;
3940

40-
return parent::canAccess() && $server->allocation && $server->allocation->ip !== '0.0.0.0' && $server->allocation->ip !== '::' && CloudflareDomain::count() > 0;
41+
return parent::canAccess()
42+
&& $ip !== null
43+
&& $ip !== '0.0.0.0'
44+
&& $ip !== '::'
45+
&& CloudflareDomain::count() > 0;
4146
}
4247

4348
public static function getNavigationLabel(): string
@@ -80,9 +85,9 @@ public static function table(Table $table): Table
8085
->state(fn (Subdomain $subdomain) => $subdomain->getLabel()),
8186
TextColumn::make('record_type')
8287
->label(trans('subdomains::strings.record_type'))
83-
->icon(fn (Subdomain $subdomain) => $subdomain->srv_record && empty($subdomain->server->node->srv_target) ? 'tabler-alert-triangle' : null) // @phpstan-ignore variable.undefined
84-
->color(fn (Subdomain $subdomain) => $subdomain->srv_record && empty($subdomain->server->node->srv_target) ? 'danger' : null) // @phpstan-ignore variable.undefined
85-
->tooltip(fn (Subdomain $subdomain) => $subdomain->srv_record && empty($subdomain->server->node->srv_target) ? trans('subdomains::strings.srv_target_missing') : null), // @phpstan-ignore variable.undefined
88+
->icon(fn (Subdomain $subdomain) => $subdomain->srv_record && empty($subdomain->server->node->srv_target) ? 'tabler-alert-triangle' : null) // @phpstan-ignore property.undefined
89+
->color(fn (Subdomain $subdomain) => $subdomain->srv_record && empty($subdomain->server->node->srv_target) ? 'danger' : null) // @phpstan-ignore property.undefined
90+
->tooltip(fn (Subdomain $subdomain) => $subdomain->srv_record && empty($subdomain->server->node->srv_target) ? trans('subdomains::strings.srv_target_missing') : null), // @phpstan-ignore property.undefined
8691
])
8792
->recordActions([
8893
EditAction::make()
@@ -123,9 +128,9 @@ public static function form(Schema $schema): Schema
123128
->searchable(),
124129
Toggle::make('srv_record')
125130
->label(trans('subdomains::strings.srv_record'))
126-
->helperText(fn () => Filament::getTenant()->node->srv_target ? trans('subdomains::strings.srv_record_help') : trans('subdomains::strings.srv_target_missing')) // @phpstan-ignore variable.undefined
131+
->helperText(fn () => Filament::getTenant()->node->srv_target ? trans('subdomains::strings.srv_record_help') : trans('subdomains::strings.srv_target_missing')) // @phpstan-ignore property.undefined
127132
->reactive()
128-
->disabled(fn () => empty(Filament::getTenant()->node->srv_target)), // @phpstan-ignore variable.undefined
133+
->disabled(fn () => empty(Filament::getTenant()->node->srv_target)), // @phpstan-ignore property.undefined
129134
]);
130135
}
131136

subdomains/src/Models/Subdomain.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ protected function upsertOnCloudflare(): bool
172172
return false;
173173
}
174174

175-
// @phpstan-ignore variable.undefined
175+
// @phpstan-ignore property.undefined
176176
if (empty($this->server->node->srv_target)) {
177-
Log::warning('Node missing SRV target for SRV record', ['node_id' => $this->server->node?->id]);
177+
Log::warning('Node missing SRV target for SRV record', ['node_id' => $this->server->node->id]);
178178
Notification::make()
179179
->danger()
180180
->title(trans('subdomains::strings.notifications.cloudflare_missing_srv_target_title'))
@@ -185,7 +185,7 @@ protected function upsertOnCloudflare(): bool
185185
}
186186

187187
$recordName = sprintf('%s.%s.%s', $serviceRecordType->service(), $serviceRecordType->protocol(), $this->name);
188-
// @phpstan-ignore variable.undefined
188+
// @phpstan-ignore property.undefined
189189
$result = $registrar->upsertDnsRecord($zoneId, $recordName, 'SRV', $this->server->node->srv_target, $this->cloudflare_id, $port);
190190

191191
if ($result['success'] && !empty($result['id'])) {
@@ -255,7 +255,7 @@ protected function deleteOnCloudflare(): bool
255255
Notification::make()
256256
->danger()
257257
->title(trans('subdomains::strings.notifications.cloudflare_delete_failed_title'))
258-
->body(trans('subdomains::strings.notifications.cloudflare_delete_failed', ['subdomain' => $this->name . '.' . ($this->domain?->name ?? 'unknown'), 'errors' => json_encode($result['errors'])]))
258+
->body(trans('subdomains::strings.notifications.cloudflare_delete_failed', ['subdomain' => $this->name . '.' . ($this->domain->name ?? 'unknown'), 'errors' => json_encode($result['errors'])]))
259259
->send();
260260

261261
return false;

subdomains/src/Services/CloudflareService.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function upsertDnsRecord(string $zoneId, string $name, string $recordType
120120
} catch (\Throwable $e) {
121121
Log::error('Cloudflare upsert exception: ' . $e->getMessage(), ['zone' => $zoneId, 'payload' => $payload, 'status' => $e->getCode()]);
122122

123-
return ['success' => false, 'errors' => ['exception' => $e->getMessage()], 'status' => $e->getCode(), 'body' => $e->getTraceAsString()];
123+
return ['success' => false, 'id' => null, 'errors' => ['exception' => $e->getMessage()], 'status' => $e->getCode(), 'body' => $e->getTraceAsString()];
124124
}
125125
}
126126

@@ -130,7 +130,7 @@ public function upsertDnsRecord(string $zoneId, string $name, string $recordType
130130
public function deleteDnsRecord(string $zoneId, string $recordId): array
131131
{
132132
if (empty($zoneId) || empty($recordId)) {
133-
return ['success' => false, 'errors' => ['missing_parameters' => true], 'status' => 0, 'body' => null];
133+
return ['success' => false, 'id' => null, 'errors' => ['missing_parameters' => true], 'status' => 0, 'body' => null];
134134
}
135135

136136
try {
@@ -149,7 +149,7 @@ public function deleteDnsRecord(string $zoneId, string $recordId): array
149149
} catch (\Throwable $e) {
150150
Log::error('Cloudflare delete exception: ' . $e->getMessage(), ['zone' => $zoneId, 'id' => $recordId, 'status' => $e->getCode()]);
151151

152-
return ['success' => false, 'errors' => ['exception' => $e->getMessage()], 'status' => $e->getCode(), 'body' => $e->getTraceAsString()];
152+
return ['success' => false, 'id' => null, 'errors' => ['exception' => $e->getMessage()], 'status' => $e->getCode(), 'body' => $e->getTraceAsString()];
153153
}
154154
}
155155

0 commit comments

Comments
 (0)