diff --git a/psalm.xml b/psalm.xml index 3cbae62b2..6165f3b64 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,7 +1,7 @@ + diff --git a/src/Attachment/Models/Attachment.php b/src/Attachment/Models/Attachment.php index af249099c..0c1d8eb7c 100644 --- a/src/Attachment/Models/Attachment.php +++ b/src/Attachment/Models/Attachment.php @@ -5,8 +5,6 @@ namespace Orchid\Attachment\Models; use Exception; -use Illuminate\Contracts\Filesystem\Cloud; -use Illuminate\Contracts\Filesystem\Filesystem; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -106,7 +104,7 @@ public function user(): BelongsTo */ public function url(?string $default = null): ?string { - /** @var Filesystem|Cloud $disk */ + /** @var \Illuminate\Filesystem\FilesystemAdapter $disk */ $disk = Storage::disk($this->getAttribute('disk')); $path = $this->physicalPath(); diff --git a/src/Filters/Filter.php b/src/Filters/Filter.php index e2d84f025..108a3da32 100644 --- a/src/Filters/Filter.php +++ b/src/Filters/Filter.php @@ -70,7 +70,7 @@ abstract public function run(Builder $builder): Builder; /** * Get the display fields. * - * @return Fieldable[] + * @return iterable */ public function display(): iterable { @@ -87,7 +87,7 @@ public function name(): string public function render(): string { - $fields = collect($this->display())->map(fn (Fieldable $field) => $field->form('filters')); + $fields = collect($this->display())->map(fn (Fieldable $field) => $field->set('form', 'filters')); $params = $this->query(); $builder = new \Orchid\Screen\Builder($fields, new Repository($params)); @@ -100,7 +100,7 @@ public function render(): string */ public function count(): int { - return count($this->display()); + return collect($this->display())->count(); } /** diff --git a/src/Platform/Http/Screens/SearchScreen.php b/src/Platform/Http/Screens/SearchScreen.php index 4d5dbf3f3..34234e551 100644 --- a/src/Platform/Http/Screens/SearchScreen.php +++ b/src/Platform/Http/Screens/SearchScreen.php @@ -21,6 +21,11 @@ class SearchScreen extends Screen { public const SESSION_NAME = 'orchid_search_type'; + /** + * @var string + */ + protected $description = ''; + /** * Display header name. */ diff --git a/src/Platform/Providers/FoundationServiceProvider.php b/src/Platform/Providers/FoundationServiceProvider.php index a97291258..2088268ff 100644 --- a/src/Platform/Providers/FoundationServiceProvider.php +++ b/src/Platform/Providers/FoundationServiceProvider.php @@ -115,23 +115,33 @@ public function register(): void $this->app->singleton(Dashboard::class, static fn () => new Dashboard); - if (! Route::hasMacro('screen')) { - Route::macro('screen', function ($url, $screen) { - /* @var Router $this */ - $route = $this->match(['GET', 'HEAD', 'POST'], $url.'/{method?}', $screen); + $this + ->registerScreenMacro() + ->mergeConfigFrom( + Dashboard::path('config/platform.php'), 'platform' + ); - $route->where('method', $screen::getAvailableMethods()->implode('|')); + Blade::component('orchid-popover', Popover::class); + Blade::component('orchid-notification', Notification::class); + Blade::component('orchid-stream', Stream::class); + } - return $route; - }); + /** + * Register the 'screen' route macro. + */ + protected function registerScreenMacro(): self + { + if (Route::hasMacro('screen')) { + return $this; } - $this->mergeConfigFrom( - Dashboard::path('config/platform.php'), 'platform' - ); + $macro = function (string $url, string $screen) { + return Route::match(['GET', 'HEAD', 'POST'], $url . '/{method?}', $screen) + ->where('method', $screen::getAvailableMethods()->implode('|')); + }; - Blade::component('orchid-popover', Popover::class); - Blade::component('orchid-notification', Notification::class); - Blade::component('orchid-stream', Stream::class); + Route::macro('screen', $macro); + + return $this; } } diff --git a/src/Screen/Layouts/Content.php b/src/Screen/Layouts/Content.php index a8c89aeba..f1808dd8e 100644 --- a/src/Screen/Layouts/Content.php +++ b/src/Screen/Layouts/Content.php @@ -44,6 +44,10 @@ public function build(Repository $repository): string public function __toString(): string { - return (string) $this->render($this->target); + if (method_exists($this, 'render')) { + return (string) $this->render($this->target); + } + + throw new \RuntimeException('Method render not found'); } } diff --git a/src/Screen/Layouts/Rows.php b/src/Screen/Layouts/Rows.php index 0b7b88165..6c616c613 100644 --- a/src/Screen/Layouts/Rows.php +++ b/src/Screen/Layouts/Rows.php @@ -62,7 +62,7 @@ public function title(?string $title = null): self } /** - * @return Field[] - */ + * @return iterable|iterable + */ abstract protected function fields(): iterable; } diff --git a/src/Screen/Screen.php b/src/Screen/Screen.php index f9c7433ad..852be30f9 100644 --- a/src/Screen/Screen.php +++ b/src/Screen/Screen.php @@ -15,6 +15,7 @@ use Illuminate\Support\Facades\Crypt; use Illuminate\Support\Facades\Route; use Orchid\Platform\Http\Controllers\Controller; +use Orchid\Screen\Layouts\Listener; use Orchid\Support\Facades\Dashboard; /** @@ -90,7 +91,7 @@ public function commandBar() /** * The layout for this screen, consisting of a collection of views. * - * @return Layout[] + * @return iterable<\Orchid\Screen\Layout>|iterable */ abstract public function layout(): iterable; @@ -156,7 +157,7 @@ public function asyncBuild(string $method, string $slug) * * @return \Illuminate\Http\Response */ - public function asyncParticalLayout(Layout $layout, Request $request) + public function asyncParticalLayout(Listener $layout, Request $request): Response { Dashboard::setCurrentScreen($this, true); @@ -291,9 +292,6 @@ public static function unaccessed() } /** - * @param \Illuminate\Http\Request $request - * @param ...$arguments - * * @throws \Illuminate\Contracts\Container\BindingResolutionException * @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface