Skip to content

Commit f16ed67

Browse files
committed
pint/phpstan issues
1 parent 109a2c6 commit f16ed67

6 files changed

Lines changed: 21 additions & 29 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ protected function setUp(): void
2222

2323
$this->icon('tabler-world-www');
2424

25-
$this->schema(function (?Node $node) {
25+
$this->schema(function (Node $node) {
2626
return [
2727
TextInput::make('srv_target')
2828
->label(fn () => trans('subdomains::strings.srv_target'))
29-
->default(fn () => $node?->srv_target)
29+
->default(fn () => $node?->srv_target) // @phpstan-ignore variable.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: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ public static function table(Table $table): Table
8080
->state(fn (Subdomain $subdomain) => $subdomain->getLabel()),
8181
TextColumn::make('record_type')
8282
->label(trans('subdomains::strings.record_type'))
83-
->icon(fn (Subdomain $subdomain) => $subdomain->srv_record && empty($subdomain->server?->node->srv_target) ? 'tabler-alert-triangle' : null)
84-
->color(fn (Subdomain $subdomain) => $subdomain->srv_record && empty($subdomain->server?->node->srv_target) ? 'danger' : null)
85-
->tooltip(fn (Subdomain $subdomain) => $subdomain->srv_record && empty($subdomain->server?->node->srv_target) ? trans('subdomains::strings.srv_target_missing') : null),
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
8686
])
8787
->recordActions([
8888
EditAction::make()
@@ -123,9 +123,9 @@ public static function form(Schema $schema): Schema
123123
->searchable(),
124124
Toggle::make('srv_record')
125125
->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'))
126+
->helperText(fn () => Filament::getTenant()->node->srv_target ? trans('subdomains::strings.srv_record_help') : trans('subdomains::strings.srv_target_missing')) // @phpstan-ignore variable.undefined
127127
->reactive()
128-
->disabled(fn () => empty(Filament::getTenant()->node->srv_target)),
128+
->disabled(fn () => empty(Filament::getTenant()->node->srv_target)), // @phpstan-ignore variable.undefined
129129
]);
130130
}
131131

subdomains/src/Models/CloudflareDomain.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Filament\Notifications\Notification;
77
use Illuminate\Database\Eloquent\Model;
88
use Illuminate\Database\Eloquent\Relations\HasMany;
9+
use Illuminate\Support\Facades\Http;
910

1011
/**
1112
* @property int $id

subdomains/src/Models/Subdomain.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function setSrvRecordAttribute(bool $isSrvRecord): void
120120
if ($isSrvRecord) {
121121
$this->attributes['record_type'] = 'SRV';
122122
} else {
123-
$ip = $this->server?->allocation?->ip;
123+
$ip = $this->server->allocation?->ip;
124124
if (!empty($ip) && filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
125125
$this->attributes['record_type'] = 'AAAA';
126126
} else {
@@ -133,7 +133,7 @@ protected function upsertOnCloudflare(): bool
133133
{
134134
$registrar = app(CloudflareService::class);
135135

136-
$zoneId = $this->domain?->cloudflare_id;
136+
$zoneId = $this->domain->cloudflare_id;
137137
if (empty($zoneId)) {
138138
Log::warning('Cloudflare zone id missing for domain', ['domain_id' => $this->domain_id]);
139139

@@ -172,7 +172,8 @@ protected function upsertOnCloudflare(): bool
172172
return false;
173173
}
174174

175-
if (empty($this->server?->node->srv_target)) {
175+
// @phpstan-ignore variable.undefined
176+
if (empty($this->server->node->srv_target)) {
176177
Log::warning('Node missing SRV target for SRV record', ['node_id' => $this->server->node?->id]);
177178
Notification::make()
178179
->danger()
@@ -184,7 +185,7 @@ protected function upsertOnCloudflare(): bool
184185
}
185186

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

190191
if ($result['success'] && !empty($result['id'])) {
@@ -198,20 +199,20 @@ protected function upsertOnCloudflare(): bool
198199
Notification::make()
199200
->danger()
200201
->title(trans('subdomains::strings.notifications.cloudflare_upsert_failed_title'))
201-
->body(trans('subdomains::strings.notifications.cloudflare_upsert_failed', ['subdomain' => $this->name . '.' . ($this->domain->name ?? 'unknown'), 'errors' => json_encode($result['errors'] ?? $result['body'] ?? [])]))
202+
->body(trans('subdomains::strings.notifications.cloudflare_upsert_failed', ['subdomain' => $this->name . '.' . ($this->domain->name ?? 'unknown'), 'errors' => json_encode($result['errors'])]))
202203
->send();
203204

204205
return false;
205206
}
206207

207208
// A/AAAA
208-
$ip = $this->server?->allocation?->ip;
209+
$ip = $this->server->allocation?->ip;
209210
if (empty($ip) || $ip === '0.0.0.0' || $ip === '::') {
210211
Log::warning('Server allocation missing or invalid IP', ['server_id' => $this->server_id]);
211212
Notification::make()
212213
->danger()
213214
->title(trans('subdomains::strings.notifications.cloudflare_missing_ip_title'))
214-
->body(trans('subdomains::strings.notifications.cloudflare_missing_ip', ['subdomain' => $this->name . '.' . ($this->domain?->name ?? 'unknown')]))
215+
->body(trans('subdomains::strings.notifications.cloudflare_missing_ip', ['subdomain' => $this->name . '.' . ($this->domain->name ?? 'unknown')]))
215216
->send();
216217

217218
return false;
@@ -227,14 +228,14 @@ protected function upsertOnCloudflare(): bool
227228
return true;
228229
}
229230

230-
$domainName = $this->domain?->name ?? 'unknown';
231+
$domainName = $this->domain->name ?? 'unknown';
231232
$subdomain = sprintf('%s.%s', $this->name, $domainName);
232233

233234
Log::error('Failed to upsert record on Cloudflare for Subdomain ID ' . $this->id, ['result' => $result]);
234235
Notification::make()
235236
->danger()
236237
->title(trans('subdomains::strings.notifications.cloudflare_upsert_failed_title'))
237-
->body(trans('subdomains::strings.notifications.cloudflare_upsert_failed', ['subdomain' => $subdomain, 'errors' => json_encode($result['errors'] ?? $result['body'] ?? [])]))
238+
->body(trans('subdomains::strings.notifications.cloudflare_upsert_failed', ['subdomain' => $subdomain, 'errors' => json_encode($result['errors'])]))
238239
->send();
239240

240241
return false;
@@ -254,7 +255,7 @@ protected function deleteOnCloudflare(): bool
254255
Notification::make()
255256
->danger()
256257
->title(trans('subdomains::strings.notifications.cloudflare_delete_failed_title'))
257-
->body(trans('subdomains::strings.notifications.cloudflare_delete_failed', ['subdomain' => $this->name . '.' . ($this->domain?->name ?? 'unknown'), 'errors' => json_encode($result['errors'] ?? $result['body'] ?? [])]))
258+
->body(trans('subdomains::strings.notifications.cloudflare_delete_failed', ['subdomain' => $this->name . '.' . ($this->domain?->name ?? 'unknown'), 'errors' => json_encode($result['errors'])]))
258259
->send();
259260

260261
return false;

subdomains/src/Providers/SubdomainsPluginProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
namespace Boy132\Subdomains\Providers;
44

55
use App\Enums\HeaderActionPosition;
6+
use App\Filament\Admin\Resources\Nodes\Pages\EditNode;
67
use App\Filament\Admin\Resources\Servers\ServerResource;
78
use App\Models\Role;
89
use App\Models\Server;
9-
use App\Filament\Admin\Resources\Nodes\Pages\EditNode;
10-
use Boy132\Subdomains\Filament\Components\Actions\SetSrvTargetAction;
1110
use Boy132\Subdomains\Filament\Admin\Resources\Servers\RelationManagers\SubdomainRelationManager;
11+
use Boy132\Subdomains\Filament\Components\Actions\SetSrvTargetAction;
1212
use Boy132\Subdomains\Models\Subdomain;
1313
use Illuminate\Support\Facades\Http;
1414
use Illuminate\Support\ServiceProvider;

subdomains/src/Services/CloudflareService.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,6 @@ public function getZoneId(string $domainName): ?string
4141
}
4242

4343
/**
44-
* @param string $zoneId
45-
* @param string $name
46-
* @param string $recordType
47-
* @param string $target
48-
* @param string|null $recordId
49-
* @param int|null $port
50-
*
5144
* @return array{success: bool, id: string|null, errors: array<string, mixed>, status: int, body: mixed|null}
5245
*/
5346
public function upsertDnsRecord(string $zoneId, string $name, string $recordType, string $target, ?string $recordId = null, ?int $port = null): array
@@ -132,8 +125,6 @@ public function upsertDnsRecord(string $zoneId, string $name, string $recordType
132125
}
133126

134127
/**
135-
* @param string $zoneId
136-
* @param string $recordId
137128
* @return array{success: bool, id: string|null, errors: array<string, mixed>, status: int, body: mixed|null}
138129
*/
139130
public function deleteDnsRecord(string $zoneId, string $recordId): array
@@ -163,7 +154,6 @@ public function deleteDnsRecord(string $zoneId, string $recordId): array
163154
}
164155

165156
/**
166-
* @param Response $response
167157
* @return array{success: bool, id: string|null, errors: array<string, mixed>, status: int, body: mixed|null}
168158
*/
169159
protected function parseCloudflareHttpResponse(Response $response): array

0 commit comments

Comments
 (0)