Skip to content

Commit 30976c1

Browse files
committed
fix: larastan errors
1 parent 31e9daf commit 30976c1

File tree

10 files changed

+794
-794
lines changed

10 files changed

+794
-794
lines changed

src/Console/Commands/ApiVersionConfigCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private function showConfiguration(): void
5151

5252
// Show version mappings
5353
$mappings = $this->configService->getVersionMappings();
54-
if (empty($mappings)) {
54+
if ($mappings === []) {
5555
$this->warn('No version method mappings configured.');
5656
return;
5757
}
@@ -60,7 +60,7 @@ private function showConfiguration(): void
6060
['Version', 'Method', 'Inheritance'],
6161
collect($mappings)->map(function (string $method, string $version): array {
6262
$inheritance = implode('', $this->configService->getInheritanceChain($version));
63-
return [$version, $method, $inheritance ?: 'None'];
63+
return [$version, $method, $inheritance !== '' ? $inheritance : 'None'];
6464
})->toArray()
6565
);
6666
}
@@ -72,7 +72,7 @@ private function addVersionMapping(string $version): void
7272
$method = $this->ask('Method name for version '.$version);
7373
}
7474

75-
if (!is_string($method) || empty($method)) {
75+
if (!is_string($method) || $method === '') {
7676
$this->error('Method name is required.');
7777
return;
7878
}

src/Console/Commands/ApiVersionsCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ public function handle(): int
7878
$methods,
7979
$uri,
8080
$action,
81-
$versionsStr ?: 'None',
82-
$deprecatedInfo ?: 'No',
83-
$sunsetDate ?: '-',
81+
$versionsStr !== '' ? $versionsStr : 'None',
82+
$deprecatedInfo !== '' ? $deprecatedInfo : 'No',
83+
$sunsetDate !== '' ? $sunsetDate : '-',
8484
];
8585
}
8686

87-
if (empty($rows)) {
87+
if ($rows === []) {
8888
$this->info('No matching routes found.');
8989
return self::SUCCESS;
9090
}

src/Console/Commands/MakeVersionedControllerCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ private function buildDeprecatedAttribute(?string $sunsetDate, ?string $replaced
5959
{
6060
$attributes = [];
6161

62-
if (is_string($sunsetDate) && !empty($sunsetDate)) {
62+
if (is_string($sunsetDate) && $sunsetDate !== '') {
6363
$attributes[] = "sunsetDate: '{$sunsetDate}'";
6464
}
6565

66-
if (is_string($replacedBy) && !empty($replacedBy)) {
66+
if (is_string($replacedBy) && $replacedBy !== '') {
6767
$attributes[] = "replacedBy: '{$replacedBy}'";
6868
}
6969

70-
$attributeParams = empty($attributes) ? '' : implode(', ', $attributes);
70+
$attributeParams = $attributes === [] ? '' : implode(', ', $attributes);
7171

7272
return "#[Deprecated({$attributeParams})]";
7373
}

src/Examples/UserDynamicResource.php

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -20,50 +20,50 @@
2020
*/
2121
class DynamicUserResource extends VersionedJsonResource
2222
{
23-
/**
24-
* Define version configurations directly in the resource
25-
*/
26-
protected array $versionConfigs = [
27-
'1.0' => ['id', 'name'],
28-
'1.1' => ['id', 'name', 'email'],
29-
'2.0' => ['id', 'name', 'email', 'created_at', 'profile'],
30-
'2.1' => ['id', 'name', 'email', 'created_at', 'updated_at', 'profile', 'preferences', 'stats'],
31-
];
23+
/**
24+
* Define version configurations directly in the resource
25+
*/
26+
protected array $versionConfigs = [
27+
'1.0' => ['id', 'name'],
28+
'1.1' => ['id', 'name', 'email'],
29+
'2.0' => ['id', 'name', 'email', 'created_at', 'profile'],
30+
'2.1' => ['id', 'name', 'email', 'created_at', 'updated_at', 'profile', 'preferences', 'stats'],
31+
];
3232

33-
protected function toArrayDefault(Request $request): array
34-
{
35-
$version = $this->getCurrentApiVersion();
36-
$config = $this->versionConfigs[$version] ?? $this->versionConfigs['2.1'];
33+
protected function toArrayDefault(Request $request): array
34+
{
35+
$version = $this->getCurrentApiVersion();
36+
$config = $this->versionConfigs[$version] ?? $this->versionConfigs['2.1'];
3737

38-
$data = [];
39-
foreach ($config as $field) {
40-
$data[$field] = $this->getFieldValue($field);
41-
}
38+
$data = [];
39+
foreach ($config as $field) {
40+
$data[$field] = $this->getFieldValue($field);
41+
}
4242

43-
return $data;
44-
}
43+
return $data;
44+
}
4545

46-
private function getFieldValue(string $field): mixed
47-
{
48-
return match($field) {
49-
'id' => $this->id,
50-
'name' => $this->name,
51-
'email' => $this->email,
52-
'created_at' => $this->created_at->toISOString(),
53-
'updated_at' => $this->updated_at->toISOString(),
54-
'profile' => [
55-
'avatar' => $this->avatar_url,
56-
'bio' => $this->bio,
57-
],
58-
'preferences' => [
59-
'theme' => $this->theme ?? 'light',
60-
'language' => $this->language ?? 'en',
61-
],
62-
'stats' => [
63-
'login_count' => $this->login_count ?? 0,
64-
'posts_count' => $this->posts_count ?? 0,
65-
],
66-
default => $this->resource->$field ?? null,
67-
};
68-
}
46+
private function getFieldValue(string $field): mixed
47+
{
48+
return match($field) {
49+
'id' => $this->id,
50+
'name' => $this->name,
51+
'email' => $this->email,
52+
'created_at' => $this->created_at->toISOString(),
53+
'updated_at' => $this->updated_at->toISOString(),
54+
'profile' => [
55+
'avatar' => $this->avatar_url,
56+
'bio' => $this->bio,
57+
],
58+
'preferences' => [
59+
'theme' => $this->theme ?? 'light',
60+
'language' => $this->language ?? 'en',
61+
],
62+
'stats' => [
63+
'login_count' => $this->login_count ?? 0,
64+
'posts_count' => $this->posts_count ?? 0,
65+
],
66+
default => data_get($this->resource, $field),
67+
};
68+
}
6969
}

0 commit comments

Comments
 (0)