Skip to content

Commit

Permalink
fix: phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
Quadrubo committed Jan 9, 2024
1 parent 43c448c commit 4333582
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Commands/MakeModelSettingsPageCommand.php
Expand Up @@ -70,6 +70,7 @@ public function handle(): int

$path = (string) str($page)
->prepend('/')
/** @phpstan-ignore-next-line */
->prepend(($path ?? ''))
->replace('\\', '/')
->replace('//', '/')
Expand All @@ -81,6 +82,7 @@ public function handle(): int

$this->copyStubToApp('ModelSettingsPage', $path, [
'class' => $pageClass,
/** @phpstan-ignore-next-line */
'namespace' => str($namespace ?? '') . ($pageNamespace !== '' ? "\\{$pageNamespace}" : ''),
]);

Expand Down
6 changes: 6 additions & 0 deletions src/Commands/Page.php
Expand Up @@ -219,6 +219,7 @@ public function handle(): int

$path = (string) str($page)
->prepend('/')
/** @phpstan-ignore-next-line */
->prepend(empty($resource) ? ($path ?? '') : ($resourcePath ?? '') . "\\{$resource}\\Pages\\")
->replace('\\', '/')
->replace('//', '/')
Expand All @@ -243,6 +244,7 @@ public function handle(): int
if (empty($resource)) {
$this->copyStubToApp('Page', $path, [
'class' => $pageClass,
/** @phpstan-ignore-next-line */
'namespace' => str($namespace ?? '') . ($pageNamespace !== '' ? "\\{$pageNamespace}" : ''),
'view' => $view,
]);
Expand All @@ -251,9 +253,11 @@ public function handle(): int
'baseResourcePage' => "Filament\\Resources\\Pages\\{$resourcePage}",
'baseResourcePageClass' => $resourcePage,
'modifyQueryUsing' => filled($modifyQueryUsing ?? null) ? PHP_EOL . $this->indentString($modifyQueryUsing ?? '', 3) : $modifyQueryUsing ?? '',
/** @phpstan-ignore-next-line */
'namespace' => ($resourceNamespace ?? '') . "\\{$resource}\\Pages" . ($pageNamespace !== '' ? "\\{$pageNamespace}" : ''),
'recordTitleAttribute' => $recordTitleAttribute ?? null,
'relationship' => $relationship ?? null,
/** @phpstan-ignore-next-line */
'resource' => ($resourceNamespace ?? '') . "\\{$resource}",
'resourceClass' => $resourceClass,
'resourcePageClass' => $pageClass,
Expand All @@ -271,7 +275,9 @@ public function handle(): int
$this->copyStubToApp($resourcePage === 'custom' ? 'CustomResourcePage' : 'ResourcePage', $path, [
'baseResourcePage' => 'Filament\\Resources\\Pages\\' . ($resourcePage === 'custom' ? 'Page' : $resourcePage),
'baseResourcePageClass' => $resourcePage === 'custom' ? 'Page' : $resourcePage,
/** @phpstan-ignore-next-line */
'namespace' => ($resourceNamespace ?? '') . "\\{$resource}\\Pages" . ($pageNamespace !== '' ? "\\{$pageNamespace}" : ''),
/** @phpstan-ignore-next-line */
'resource' => ($resourceNamespace ?? '') . "\\{$resource}",
'resourceClass' => $resourceClass,
'resourcePageClass' => $pageClass,
Expand Down
8 changes: 7 additions & 1 deletion src/Macros/IsModelSetting.php
Expand Up @@ -25,7 +25,13 @@ public function __invoke()
}

if ($state === null && $component->getRecord() !== null) {
$component->state($component->getRecord()->settings()->get($statePath));
$record = $component->getRecord();

if (! method_exists($record, 'settings')) {
return;
}

$component->state($record->settings()->get($statePath));
}
});

Expand Down

0 comments on commit 4333582

Please sign in to comment.