Skip to content

Commit 07887a0

Browse files
committed
Fix phpstan errors
1 parent 69d548b commit 07887a0

File tree

9 files changed

+21
-25
lines changed

9 files changed

+21
-25
lines changed

phpstan.neon.dist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ parameters:
1010
tmpDir: build/phpstan
1111
checkOctaneCompatibility: true
1212
checkModelProperties: true
13+
ignoreErrors:
14+
- identifier: trait.unused
15+
-
16+
identifier: larastan.noEnvCallsOutsideOfConfig
17+
path: src/FilamentFlexibleContentBlocksServiceProvider.php
1318

src/Exceptions/LinkableModelNotFoundException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class LinkableModelNotFoundException extends \Exception
88
{
9-
private ?Model $record;
9+
private ?Model $record = null;
1010

1111
public static function create(string $message)
1212
{

src/Filament/Form/Fields/Blocks/Type/AbstractType.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,7 @@ protected function setUp(): void
9898
$keyName = $query->getModel()->getKeyName();
9999

100100
if ($this->hasOptionLabelFromRecordUsingCallback()) {
101-
$locale = null;
102-
if (method_exists($component->getLivewire(), 'getActiveFormsLocale')) {
103-
$locale = $component->getLivewire()->getActiveFormsLocale();
104-
}
101+
$locale = $component->getLivewire()->getActiveFormsLocale();
105102

106103
return $query
107104
->get()
@@ -136,10 +133,7 @@ protected function setUp(): void
136133
$keyName = $query->getModel()->getKeyName();
137134

138135
if ($this->hasOptionLabelFromRecordUsingCallback()) {
139-
$locale = null;
140-
if (method_exists($component->getLivewire(), 'getActiveFormsLocale')) {
141-
$locale = $component->getLivewire()->getActiveFormsLocale();
142-
}
136+
$locale = $component->getLivewire()->getActiveFormsLocale();
143137

144138
return $query
145139
->get()
@@ -172,10 +166,7 @@ protected function setUp(): void
172166
}
173167

174168
if ($this->hasOptionLabelFromRecordUsingCallback()) {
175-
$locale = null;
176-
if (method_exists($component->getLivewire(), 'getActiveFormsLocale')) {
177-
$locale = $component->getLivewire()->getActiveFormsLocale();
178-
}
169+
$locale = $component->getLivewire()->getActiveFormsLocale();
179170

180171
return $this->getOptionLabelFromRecord($record, $locale);
181172
}

src/Filament/Form/Fields/Flexible/FlexibleSelectField.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected function getCachedOptions(): array
5353

5454
protected function hasOnlyOneOption(): bool
5555
{
56-
return is_array($this->getCachedOptions()) && count($this->getCachedOptions()) === 1;
56+
return count($this->getCachedOptions()) === 1;
5757
}
5858

5959
public function isHidden(): bool

src/Filament/Form/Fields/HeroImageField.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static function create(bool $translatable = false): SpatieMediaLibraryFil
1515
return static::createImageField(static::FIELD, $translatable)
1616
->label(trans('filament-flexible-content-blocks::filament-flexible-content-blocks.form_component.hero_image_lbl'))
1717
->collection(function (Model $record) {
18-
/** @var HasHeroImageAttributes $record */
18+
/** @var Model&HasHeroImageAttributes $record */
1919
return $record->getHeroImageCollection();
2020
})
2121
->conversion('thumbnail');

src/Filament/Form/Fields/OverviewImageField.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static function create(bool $translatable = false): SpatieMediaLibraryFil
1515
return static::createImageField(static::FIELD, $translatable)
1616
->label(trans('filament-flexible-content-blocks::filament-flexible-content-blocks.form_component.overview_image_lbl'))
1717
->collection(function (Model $record) {
18-
/** @var HasOverviewAttributes $record */
18+
/** @var Model&HasOverviewAttributes $record */
1919
return $record->getOverviewImageCollection();
2020
})
2121
->conversion('thumbnail');

src/Filament/Form/Fields/SEOImageField.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static function create(bool $translatable = false): SpatieMediaLibraryFil
1515
return static::createImageField('seo_image', $translatable)
1616
->label(trans('filament-flexible-content-blocks::filament-flexible-content-blocks.form_component.seo_image_lbl'))
1717
->collection(function (Model $record) {
18-
/** @var HasSEOAttributes $record */
18+
/** @var Model&HasSEOAttributes $record */
1919
return $record->getSEOImageCollection();
2020
})
2121
->conversion('thumbnail');

src/Filament/Form/Fields/SlugField.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static function create(bool $disabled = true): static
4545
}
4646

4747
if (isset($record->translatable) && in_array(static::FIELD, $record->translatable)) {
48-
if (method_exists($livewire, 'getActiveFormsLocale') && method_exists($record, 'getTranslation')) {
48+
if (method_exists($record, 'getTranslation')) {
4949
$locale = $livewire->getActiveFormsLocale();
5050

5151
$noSlug = empty($record->getTranslation(static::FIELD, $locale, false));
@@ -69,7 +69,7 @@ protected static function getUrlWithReplacementSlug(Page $livewire): string
6969
/* @var Linkable $link */
7070
$link = new $linkModel;
7171

72-
if (method_exists($livewire, 'getActiveFormsLocale') && method_exists($link, 'setTranslation')) {
72+
if (method_exists($link, 'setTranslation')) {
7373
$locale = $livewire->getActiveFormsLocale();
7474
$link->setTranslation('slug', $locale, static::URL_REPLACEMENT_SLUG);
7575
} else {

src/Filament/Table/Actions/PublishAction.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ public function setUp(): void
2222
try {
2323
/** @var Model&HasPageAttributes $page */
2424
$page = $this->getRecord();
25-
if (method_exists($page, 'isPublished') && ! $page->isPublished()) {
25+
if (! $page->isPublished()) {
2626
$page->setAttribute('publishing_begins_at', Carbon::now());
27-
if (method_exists($page, 'wasUnpublished') && $page->wasUnpublished()) {
27+
if ($page->wasUnpublished()) {
2828
$page->setAttribute('publishing_ends_at', null);
2929
}
3030
$page->save();
@@ -56,18 +56,18 @@ public function setUp(): void
5656
return response();
5757
});
5858
$this->label(function () {
59-
/* @var Model|HasPageAttributes $page */
59+
/** @var Model&HasPageAttributes $page */
6060
$page = $this->getRecord();
61-
if (method_exists($page, 'isPublished') && $page->isPublished()) {
61+
if ($page->isPublished()) {
6262
return trans('filament-flexible-content-blocks::filament-flexible-content-blocks.table_action.publish.unpublish_lbl');
6363
} else {
6464
return trans('filament-flexible-content-blocks::filament-flexible-content-blocks.table_action.publish.publish_lbl');
6565
}
6666
});
6767
$this->icon(function () {
68-
/** @var Model|HasPageAttributes $page */
68+
/** @var Model&HasPageAttributes $page */
6969
$page = $this->getRecord();
70-
if (method_exists($page, 'isPublished') && $page->isPublished()) {
70+
if ($page->isPublished()) {
7171
return 'heroicon-o-eye-slash';
7272
} else {
7373
return 'heroicon-o-eye';

0 commit comments

Comments
 (0)