Skip to content

Commit 2014bf8

Browse files
committed
Type fixes
1 parent 719300a commit 2014bf8

File tree

14 files changed

+33
-21
lines changed

14 files changed

+33
-21
lines changed

packages/core/src/Traits/Base/BaseInResource.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ trait BaseInResource
1919
{
2020
protected static function modifyEloquentQuery(Builder $query): Builder
2121
{
22+
/** @phpstan-ignore-next-line */
2223
if (method_exists(static::class, 'addTaxonomyRelationsToQuery')) {
2324
$query = static::addTaxonomyRelationsToQuery($query);
2425
}
@@ -35,10 +36,12 @@ public static function getEloquentQuery(): Builder
3536
$query->withoutGlobalScope(SoftDeletingScope::class);
3637
}
3738

39+
/** @phpstan-ignore-next-line */
3840
if (method_exists(static::class, 'applySoftDeleteQuery')) {
3941
$query = static::applySoftDeleteQuery($query);
4042
}
4143

44+
/** @phpstan-ignore-next-line */
4245
if (($currentTab = request()->query('tab')) && method_exists(static::class, 'applyTabQuery')) {
4346
$query = static::applyTabQuery($query, $currentTab);
4447
}
@@ -65,10 +68,12 @@ public static function getTableQuery(): Builder
6568
: static::getModel()::query();
6669
}
6770

71+
/** @phpstan-ignore-next-line */
6872
if (method_exists(static::class, 'applySoftDeleteQuery')) {
6973
$query = static::applySoftDeleteQuery($query);
7074
}
7175

76+
/** @phpstan-ignore-next-line */
7277
if (($currentTab = request()->query('tab')) && method_exists(static::class, 'applyTabQuery')) {
7378
$query = static::applyTabQuery($query, $currentTab);
7479
}

packages/core/src/Traits/Publish/SinglePublishInModel.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public static function getStatusOptions(): array
2222

2323
public function getStatusAttribute(): string
2424
{
25+
/** @phpstan-ignore-next-line */
2526
if (method_exists($this, 'trashed') && $this->trashed()) {
2627
return 'deleted';
2728
}

packages/core/src/Traits/Taxonomy/TaxonomyInPages.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ protected function refreshTaxonomyFormData(): void
214214

215215
public function refreshFormData(array $attributes = []): void
216216
{
217+
/** @phpstan-ignore-next-line */
217218
if (method_exists($this, 'fillForm')) {
218219
$this->fillForm();
219220
}

packages/jobs/src/Traits/JobProgress.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function setProgress(int $progress): void
3131
*/
3232
protected function getJobMonitor(): ?JobManager
3333
{
34+
/** @phpstan-ignore-next-line */
3435
if (! property_exists($this, 'job')) {
3536
return null;
3637
}

packages/login-link/src/Mail/LoginLinkEmail.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ public function __construct(LoginLink $loginLink)
2424

2525
public function build()
2626
{
27+
/** @phpstan-ignore-next-line */
2728
$userId = urlencode(encrypt($this->loginLink->user_id));
29+
/** @phpstan-ignore-next-line */
2830
$url = url(sprintf('/login-link/%s-%s', $userId, $this->loginLink->token));
2931

3032
return $this->subject('Your Login Link')

packages/press/src/Models/WpBasePost.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ protected function getMeta($key)
114114
$this->load('postMeta');
115115
}
116116

117+
/** @var ?WpPostMeta $meta */
117118
$meta = $this->postMeta->where('meta_key', $key)->first();
118119

119120
return $meta ? $meta->meta_value : null;

packages/press/src/Models/WpMedia.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
use Illuminate\Database\Eloquent\Relations\HasMany;
88
use Override;
99

10+
/**
11+
* @property string $image_url
12+
* @property mixed $attachment
13+
* @property array $image_sizes
14+
* @property string $asset
15+
*/
1016
class WpMedia extends WpBasePost
1117
{
1218
use HasFactory;
@@ -52,17 +58,15 @@ public function getAssetAttribute()
5258
$wpslug = config('press.wordpress_slug');
5359
$wpslug = ltrim((string) $wpslug, $wpslug[0]);
5460

55-
// TODO: Check if the file is an image
56-
// TODO: Read wp-config.php to get the upload path
57-
5861
return $file ? asset($wpslug.'/wp-content/uploads/'.$file) : '';
5962
}
6063

6164
public function getImageSizesAttribute()
6265
{
63-
$sizes = $this->postMeta()->where('meta_key', '_wp_attachment_metadata')->first()->meta_value;
66+
/** @var ?WpPostMeta $metadata */
67+
$metadata = $this->postMeta()->where('meta_key', '_wp_attachment_metadata')->first();
6468

65-
return $sizes ? unserialize($sizes)['sizes'] : [];
69+
return $metadata ? unserialize($metadata->meta_value)['sizes'] : [];
6670
}
6771

6872
public function setImageUrlAttribute($value): void

packages/press/src/Models/WpUser.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,10 @@ public function getMeta($key)
176176
$this->load('userMeta');
177177
}
178178

179-
$meta = $this->userMeta->where('meta_key', $key)->first();
179+
/** @var \Illuminate\Database\Eloquent\Collection<\Moox\Press\Models\WpUserMeta> $userMeta */
180+
$userMeta = $this->userMeta;
181+
/** @var ?\Moox\Press\Models\WpUserMeta $meta */
182+
$meta = $userMeta->where('meta_key', $key)->first();
180183

181184
return $meta ? $meta->meta_value : null;
182185
}

packages/press/src/Models/WpUserMeta.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* @property int $user_id
1010
* @property string $meta_key
11-
* @property string $meta_value
11+
* @property mixed $meta_value
1212
*/
1313
class WpUserMeta extends Model
1414
{

packages/press/src/Resources/WpUserResource/Pages/EditWpUser.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ protected function mutateFormDataBeforeFill(array $data): array
3232

3333
if ($user) {
3434
foreach ($user->userMeta as $meta) {
35+
/** @var \Moox\Press\Models\WpUserMeta $meta */
3536
$data[$meta->meta_key] = $meta->meta_value;
3637
}
3738
}
3839

3940
if ($user->attachment) {
41+
/** @var \Moox\Press\Models\WpMedia $user->attachment */
4042
$data['image_url'] = $user->attachment->image_url;
4143
}
4244

@@ -79,7 +81,9 @@ protected function afterSave(): void
7981
Log::error('User record is not an instance of WpUser in EditWpUser::afterSave');
8082
}
8183

82-
Event::dispatch('eloquent.updated: '.($this->record !== null ? $this->record::class : self::class), $this->record);
84+
/** @var \Illuminate\Database\Eloquent\Model $record */
85+
$record = $this->record;
86+
Event::dispatch('eloquent.updated: '.$record::class, $record);
8387
}
8488

8589
protected function handleAvatarUpload(WpUser $user, ?string $userAvatarMetaKey): void

0 commit comments

Comments
 (0)