From eea53d98b8b72be81acd6f1da0770d5da9fc1249 Mon Sep 17 00:00:00 2001 From: pascalbaljet Date: Sat, 9 Mar 2024 23:06:10 +0000 Subject: [PATCH] Fix styling --- app/app/Models/User.php | 4 ++-- src/AbstractForm.php | 2 +- src/AbstractTable.php | 9 --------- src/Components/Form.php | 2 +- src/Components/Form/Select.php | 2 -- src/EventRedirectFactory.php | 1 - src/FileUploads/ExistingFile.php | 6 +----- src/FileUploads/Filesystem.php | 9 --------- src/FileUploads/SpladeUploadedFile.php | 2 -- src/FormBuilder/Checkboxes.php | 2 +- src/FormBuilder/Component.php | 2 +- src/FormBuilder/Concerns/HasOptions.php | 2 +- src/FormBuilder/Radios.php | 2 +- src/Http/SpladeMiddleware.php | 2 +- src/PasswordValidator.php | 10 +++------- src/ServiceProvider.php | 1 - src/SpladeCore.php | 18 +----------------- src/SpladeForm.php | 20 ++++++++++---------- src/SpladeQueryBuilder.php | 6 +++--- src/SpladeTable.php | 4 ++-- src/SpladeToastBuilder.php | 2 -- src/Table/BulkAction.php | 10 +++++----- src/Table/HasBulkActions.php | 6 +++--- src/Table/HasColumns.php | 16 ++++++++-------- src/Table/HasExports.php | 6 +++--- src/Table/HasFilters.php | 6 +++--- src/Table/HasSearchInputs.php | 10 ++++------ src/TransitionRepository.php | 3 --- 28 files changed, 55 insertions(+), 110 deletions(-) diff --git a/app/app/Models/User.php b/app/app/Models/User.php index 17686f7a..fcf36704 100644 --- a/app/app/Models/User.php +++ b/app/app/Models/User.php @@ -12,7 +12,7 @@ class User extends Authenticatable implements HasMedia { - use HasApiTokens, HasFactory, Notifiable, InteractsWithMedia; + use HasApiTokens, HasFactory, InteractsWithMedia, Notifiable; /** * The attributes that are mass assignable. @@ -61,7 +61,7 @@ public function registerMediaCollections(): void $this->addMediaCollection('photos'); } - public function registerMediaConversions(Media $media = null): void + public function registerMediaConversions(?Media $media = null): void { $this->addMediaConversion('thumb')->fit('contain', 50, 50); } diff --git a/src/AbstractForm.php b/src/AbstractForm.php index 461de640..a71bfecb 100644 --- a/src/AbstractForm.php +++ b/src/AbstractForm.php @@ -75,7 +75,7 @@ public static function rules(...$arguments): array * * @param mixed ...$params */ - public function validate(Request $request = null, ...$params): array + public function validate(?Request $request = null, ...$params): array { /** @var Request */ $request = $request ?? request(); diff --git a/src/AbstractTable.php b/src/AbstractTable.php index 152d0375..37cdaaf7 100644 --- a/src/AbstractTable.php +++ b/src/AbstractTable.php @@ -10,8 +10,6 @@ abstract class AbstractTable { /** * The SpladeTable instance. - * - * @var \ProtoneMedia\Splade\SpladeTable|null */ private ?SpladeTable $table = null; @@ -37,8 +35,6 @@ public function for() /** * Helper method to create a new SpladeTable instance. - * - * @return \ProtoneMedia\Splade\SpladeTable */ public static function build(...$arguments): SpladeTable { @@ -50,8 +46,6 @@ public static function build(...$arguments): SpladeTable /** * Creates a new SpladeTable instance with the resource or * query builder from the 'for()' method of this class. - * - * @return \ProtoneMedia\Splade\SpladeTable */ public function make(): SpladeTable { @@ -71,7 +65,6 @@ function (SpladeTable $table) { /** * Configure the given SpladeTable. * - * @param \ProtoneMedia\Splade\SpladeTable $table * @return void */ public function configure(SpladeTable $table) @@ -81,8 +74,6 @@ public function configure(SpladeTable $table) /** * Returns a TableExporter instance. - * - * @return \ProtoneMedia\Splade\TableExporter|null */ public function makeExporter(int $key): ?TableExporter { diff --git a/src/Components/Form.php b/src/Components/Form.php index ede5467a..bdb36642 100644 --- a/src/Components/Form.php +++ b/src/Components/Form.php @@ -19,8 +19,8 @@ class Form extends Component { - use ParsesJsonDataAttribute; use InteractsWithFormElement; + use ParsesJsonDataAttribute; public string $spladeId; diff --git a/src/Components/Form/Select.php b/src/Components/Form/Select.php index e5cc01d7..115bc3f7 100644 --- a/src/Components/Form/Select.php +++ b/src/Components/Form/Select.php @@ -197,8 +197,6 @@ public function options(): array /** * Returns the placeholder option when necessary. - * - * @return \ProtoneMedia\Splade\FormSelectOption */ public function placeholderOption(): ?FormSelectOption { diff --git a/src/EventRedirectFactory.php b/src/EventRedirectFactory.php index 5eb6f9bc..ddb59753 100644 --- a/src/EventRedirectFactory.php +++ b/src/EventRedirectFactory.php @@ -36,7 +36,6 @@ public function __construct( * * @param string $method * @param array $parameters - * @return \ProtoneMedia\Splade\EventRedirect */ public function __call($method, $parameters): EventRedirect { diff --git a/src/FileUploads/ExistingFile.php b/src/FileUploads/ExistingFile.php index 21e20455..a68caa51 100644 --- a/src/FileUploads/ExistingFile.php +++ b/src/FileUploads/ExistingFile.php @@ -126,8 +126,6 @@ public static function fromMediaLibraryWithoutPreview($media) /** * Returns an instance of ExistingFileFromDisk to load the file from a disk. - * - * @return \ProtoneMedia\Splade\FileUploads\ExistingFileFromDisk */ public static function fromDisk(string $disk): ExistingFileFromDisk { @@ -137,8 +135,6 @@ public static function fromDisk(string $disk): ExistingFileFromDisk /** * Returns an instance of ExistingFileFromDisk to load the file from a disk, * but without a preview. - * - * @return \ProtoneMedia\Splade\FileUploads\ExistingFileFromDisk */ public static function fromDiskWithoutPreview(string $disk): ExistingFileFromDisk { @@ -254,7 +250,7 @@ public function getIdentifier(): string * * @return string */ - public function getMetadata(string $key = null) + public function getMetadata(?string $key = null) { return $key ? Arr::get($this->metadata, $key) : $this->metadata; } diff --git a/src/FileUploads/Filesystem.php b/src/FileUploads/Filesystem.php index 3fc7e1cb..4627aa4d 100644 --- a/src/FileUploads/Filesystem.php +++ b/src/FileUploads/Filesystem.php @@ -25,8 +25,6 @@ public function __construct(private string $disk) /** * Stores the uploaded file as a temporary file. - * - * @return \ProtoneMedia\Splade\FileUploads\TemporaryFileUpload */ public function storeUploadedFileTemporarely(UploadedFile $file): TemporaryFileUpload { @@ -68,8 +66,6 @@ public function deleteTemporaryFiles() /** * Returns a boolean whether the file exists. - * - * @param \ProtoneMedia\Splade\FileUploads\TemporaryFileUpload $temporaryFileUpload */ public function exists(TemporaryFileUpload $temporaryFileUpload): bool { @@ -78,9 +74,6 @@ public function exists(TemporaryFileUpload $temporaryFileUpload): bool /** * Returns an instance of SpladeUploadedFile when the temporary file exists. - * - * @param \ProtoneMedia\Splade\FileUploads\TemporaryFileUpload $temporaryFileUpload - * @return \ProtoneMedia\Splade\FileUploads\SpladeUploadedFile|null */ public function makeUploadedFile(TemporaryFileUpload $temporaryFileUpload): ?SpladeUploadedFile { @@ -99,8 +92,6 @@ public function makeUploadedFile(TemporaryFileUpload $temporaryFileUpload): ?Spl /** * Deletes the temporary file. - * - * @param \ProtoneMedia\Splade\FileUploads\TemporaryFileUpload $temporaryFileUpload */ public function delete(TemporaryFileUpload $temporaryFileUpload): bool { diff --git a/src/FileUploads/SpladeUploadedFile.php b/src/FileUploads/SpladeUploadedFile.php index 8ce9e291..07fb45fd 100644 --- a/src/FileUploads/SpladeUploadedFile.php +++ b/src/FileUploads/SpladeUploadedFile.php @@ -21,8 +21,6 @@ public function isValid(): bool /** * Sets the temporary file upload. - * - * @param \ProtoneMedia\Splade\FileUploads\TemporaryFileUpload $temporaryFileUpload */ public function setTemporaryFileUpload(TemporaryFileUpload $temporaryFileUpload): self { diff --git a/src/FormBuilder/Checkboxes.php b/src/FormBuilder/Checkboxes.php index 72442c2a..044d5675 100644 --- a/src/FormBuilder/Checkboxes.php +++ b/src/FormBuilder/Checkboxes.php @@ -8,8 +8,8 @@ class Checkboxes extends Component { - use HasOptions; use CanBeInline; + use HasOptions; /** * Renders the SpladeCheckboxex diff --git a/src/FormBuilder/Component.php b/src/FormBuilder/Component.php index ad875861..a7324e63 100644 --- a/src/FormBuilder/Component.php +++ b/src/FormBuilder/Component.php @@ -180,7 +180,7 @@ public function attributes(array $attributes): self /** * Adds one or more validation rules to an input field * - * @param mixed ...$rules One or more rules, may be an array of strings or multiple strings + * @param mixed ...$rules One or more rules, may be an array of strings or multiple strings * @return $this */ public function rules(...$rules): self diff --git a/src/FormBuilder/Concerns/HasOptions.php b/src/FormBuilder/Concerns/HasOptions.php index a9d9f568..da188c40 100644 --- a/src/FormBuilder/Concerns/HasOptions.php +++ b/src/FormBuilder/Concerns/HasOptions.php @@ -9,7 +9,7 @@ trait HasOptions /** * Set an array with options * - * @param array $options ['value1' => 'Label 1', 'value2' => 'Label 2'] + * @param array $options ['value1' => 'Label 1', 'value2' => 'Label 2'] * @return $this */ public function options(array $options = []): self diff --git a/src/FormBuilder/Radios.php b/src/FormBuilder/Radios.php index fba214fe..2a09624e 100644 --- a/src/FormBuilder/Radios.php +++ b/src/FormBuilder/Radios.php @@ -8,8 +8,8 @@ class Radios extends Component { - use HasOptions; use CanBeInline; + use HasOptions; /** * Renders the SpladeRadios diff --git a/src/Http/SpladeMiddleware.php b/src/Http/SpladeMiddleware.php index 4b3bdcd7..5e9745ff 100644 --- a/src/Http/SpladeMiddleware.php +++ b/src/Http/SpladeMiddleware.php @@ -125,7 +125,7 @@ public function terminate($request, $response) * * @return void */ - public static function afterOriginalResponse(Closure $callback = null) + public static function afterOriginalResponse(?Closure $callback = null) { static::$afterOriginalResponseCallback = $callback; } diff --git a/src/PasswordValidator.php b/src/PasswordValidator.php index 891dbaef..f7e76da3 100644 --- a/src/PasswordValidator.php +++ b/src/PasswordValidator.php @@ -49,10 +49,8 @@ public function recentlyConfirmed(Request $request): bool /** * Validate the given user's password using Laravel Fortify. - * - * @param \Illuminate\Contracts\Auth\Authenticatable $user */ - private function validateWithFortify(Authenticatable $user = null, string $password): bool + private function validateWithFortify(?Authenticatable $user, string $password): bool { return app(ConfirmPassword::class)( app(StatefulGuard::class), $user, $password @@ -61,10 +59,8 @@ private function validateWithFortify(Authenticatable $user = null, string $passw /** * Validate the given user's password using regular Laravel Auth logic. - * - * @param \Illuminate\Contracts\Auth\Authenticatable $user */ - private function validateWithoutForfify(Authenticatable $user = null, string $password): bool + private function validateWithoutForfify(?Authenticatable $user, string $password): bool { $guard = Auth::guard(config('splade.confirm_password_guard')); @@ -85,7 +81,7 @@ public function validateRequest(Request $request, string $attribute): bool /** * Validates the given User and password. */ - public function validate(Authenticatable $user = null, string $password, string $attribute): bool + public function validate(?Authenticatable $user, string $password, string $attribute): bool { if (!$user) { throw ValidationException::withMessages([ diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index ba818452..2d539adc 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -545,7 +545,6 @@ private function registerRequestMacros() /** * Adds the default transitions to the repository. * - * @param \ProtoneMedia\Splade\TransitionRepository $transitionRepository * @return void */ public static function registerTransitionAnimations(TransitionRepository $transitionRepository) diff --git a/src/SpladeCore.php b/src/SpladeCore.php index 89610542..e316e329 100755 --- a/src/SpladeCore.php +++ b/src/SpladeCore.php @@ -117,8 +117,6 @@ public function reset(): self /** * Getter for the Head instance. - * - * @return \ProtoneMedia\Splade\Head */ public function head(): Head { @@ -269,8 +267,6 @@ public function onLazy($value) /** * Returns a new EventRefresh instance. - * - * @return \ProtoneMedia\Splade\EventRefresh */ public static function refreshOnEvent(): EventRefresh { @@ -279,8 +275,6 @@ public static function refreshOnEvent(): EventRefresh /** * Returns a new EventRedirectFactory instance. - * - * @return \ProtoneMedia\Splade\EventRedirectFactory */ public static function redirectOnEvent(): EventRedirectFactory { @@ -289,8 +283,6 @@ public static function redirectOnEvent(): EventRedirectFactory /** * Returns a new instance of the ToastBuilder. - * - * @return \ProtoneMedia\Splade\SpladeToastBuilder */ public function toastBuilder(): SpladeToastBuilder { @@ -299,8 +291,6 @@ public function toastBuilder(): SpladeToastBuilder /** * Returns a new SpladeToast instance - * - * @return \ProtoneMedia\Splade\SpladeToast */ public static function toastOnEvent(string $message = ''): SpladeToast { @@ -320,10 +310,8 @@ public static function toastOnEvent(string $message = ''): SpladeToast /** * Returns a Closure that prevents generating a response from * a ValidationException when this is a Splade request. - * - * @param callable $renderUsing */ - public static function exceptionHandler(Handler $exceptionHandler, callable $renderUsing = null): Closure + public static function exceptionHandler(Handler $exceptionHandler, ?callable $renderUsing = null): Closure { return Closure::bind(function (Throwable $e, $request) use ($renderUsing) { if ($renderUsing) { @@ -356,8 +344,6 @@ public static function exceptionHandler(Handler $exceptionHandler, callable $ren /** * Returns a new SpladeToast instance, optionally with the given message * if it isn't empty, and it uses the custom toast factory if set. - * - * @return \ProtoneMedia\Splade\SpladeToast */ public function toast(string $message = ''): SpladeToast { @@ -392,8 +378,6 @@ public function getDataStores(): array /** * Adds a new Data Store. - * - * @param \ProtoneMedia\Splade\DataStore $store */ public function addDataStore(DataStore $store): self { diff --git a/src/SpladeForm.php b/src/SpladeForm.php index 4ebc6bd4..25cf29c4 100644 --- a/src/SpladeForm.php +++ b/src/SpladeForm.php @@ -94,9 +94,9 @@ public function class(array|string $class): self */ public function confirm( string|bool $confirm = true, - string $text = null, - string $confirmButton = null, - string $cancelButton = null, + ?string $text = null, + ?string $confirmButton = null, + ?string $cancelButton = null, bool $danger = false, string|bool $requirePassword = false, bool $requirePasswordOnce = false @@ -158,10 +158,10 @@ public function preserveScroll(bool $preserve_scroll = true): self */ public function requirePassword( bool $requirePasswordOnce = false, - string $heading = null, - string $text = null, - string $confirmButton = null, - string $cancelButton = null, + ?string $heading = null, + ?string $text = null, + ?string $confirmButton = null, + ?string $cancelButton = null, bool $danger = false ): self { return $this->confirm( @@ -178,7 +178,7 @@ public function requirePassword( /** * Prevent navigation on submit. * - * @param string $actionOnSuccess reset|restore + * @param string $actionOnSuccess reset|restore * @return $this */ public function stay(bool $stay = true, string $actionOnSuccess = ''): self @@ -201,7 +201,7 @@ public function stay(bool $stay = true, string $actionOnSuccess = ''): self */ public function submitOnChange( bool $enabled = true, - array|string $watchFields = null, + array|string|null $watchFields = null, bool $background = true, int $debounce = 500 ): self { @@ -293,7 +293,7 @@ public function getRules(): array * * @param [type] ...$params */ - public function validate(Request $request = null, ...$params): array + public function validate(?Request $request = null, ...$params): array { /** @var Request */ $request = $request ?? request(); diff --git a/src/SpladeQueryBuilder.php b/src/SpladeQueryBuilder.php index aaaf5020..0ad95762 100644 --- a/src/SpladeQueryBuilder.php +++ b/src/SpladeQueryBuilder.php @@ -37,7 +37,7 @@ class SpladeQueryBuilder extends SpladeTable * Initializes this instance with an empty resource. The results will be * loaded when the Table components calls the beforeRender() method. */ - public function __construct(private BaseQueryBuilder|EloquentBuilder|SpatieQueryBuilder $builder, Request $request = null) + public function __construct(private BaseQueryBuilder|EloquentBuilder|SpatieQueryBuilder $builder, ?Request $request = null) { parent::__construct([], $request); } @@ -76,7 +76,7 @@ public function noPagination(): self * * @return $this */ - private function setPagination(string $method, int $perPage = null): self + private function setPagination(string $method, ?int $perPage = null): self { $this->paginateMethod = $method; @@ -133,7 +133,7 @@ public function parseTermsIntoCollection(string $terms): Collection /** * Formats the terms and returns the right where operator for the given search method. */ - private function getTermAndWhereOperator(EloquentBuilder $builder, string $term, string $searchMethod = null): array + private function getTermAndWhereOperator(EloquentBuilder $builder, string $term, ?string $searchMethod = null): array { $like = 'LIKE'; diff --git a/src/SpladeTable.php b/src/SpladeTable.php index a1bf1875..4e471bc3 100644 --- a/src/SpladeTable.php +++ b/src/SpladeTable.php @@ -21,13 +21,13 @@ class SpladeTable { + use Conditionable; use HasBulkActions; use HasColumns; use HasExports; use HasFilters; use HasResource; use HasSearchInputs; - use Conditionable; const DEFAULT_NAME = 'default'; @@ -60,7 +60,7 @@ class SpladeTable * * @param mixed $resource */ - public function __construct($resource, Request $request = null) + public function __construct($resource, ?Request $request = null) { $this->request = $request ?: request(); diff --git a/src/SpladeToastBuilder.php b/src/SpladeToastBuilder.php index 91844c0b..fb5859cf 100644 --- a/src/SpladeToastBuilder.php +++ b/src/SpladeToastBuilder.php @@ -10,8 +10,6 @@ class SpladeToastBuilder /** * Creates a new instance. - * - * @param \ProtoneMedia\Splade\SpladeCore $splade */ public function __construct( private SpladeCore $splade diff --git a/src/Table/BulkAction.php b/src/Table/BulkAction.php index 94929d13..318ea3d8 100644 --- a/src/Table/BulkAction.php +++ b/src/Table/BulkAction.php @@ -15,11 +15,11 @@ class BulkAction /** * This class represents a bulk action within a Splade Table. * - * @param bool|string $confirm = '', - * @param string $confirmText = '', - * @param string $confirmButton = '', - * @param string $cancelButton = '', - * @param bool $requirePassword = '', + * @param bool|string $confirm = '', + * @param string $confirmText = '', + * @param string $confirmButton = '', + * @param string $cancelButton = '', + * @param bool $requirePassword = '', */ public function __construct( public string $key, diff --git a/src/Table/HasBulkActions.php b/src/Table/HasBulkActions.php index ccfd98f3..536ca612 100644 --- a/src/Table/HasBulkActions.php +++ b/src/Table/HasBulkActions.php @@ -29,9 +29,9 @@ public function hasBulkActions(): bool */ public function bulkAction( string $label, - callable $each = null, - callable $before = null, - callable $after = null, + ?callable $each = null, + ?callable $before = null, + ?callable $after = null, bool|string $confirm = '', string $confirmText = '', string $confirmButton = '', diff --git a/src/Table/HasColumns.php b/src/Table/HasColumns.php index d5de1378..d5889db7 100644 --- a/src/Table/HasColumns.php +++ b/src/Table/HasColumns.php @@ -44,18 +44,18 @@ public static function defaultHighlightFirstColumn(bool $state = true) * @return $this */ public function column( - string $key = null, - string $label = null, - bool $canBeHidden = null, + ?string $key = null, + ?string $label = null, + ?bool $canBeHidden = null, bool $hidden = false, bool|Closure $sortable = false, bool|string $searchable = false, - bool $highlight = null, + ?bool $highlight = null, bool|callable $exportAs = true, - callable|string $exportFormat = null, - callable|array $exportStyling = null, - array|string $classes = null, - callable $as = null, + callable|string|null $exportFormat = null, + callable|array|null $exportStyling = null, + array|string|null $classes = null, + ?callable $as = null, string $alignment = 'left', ): self { $key = $key !== null ? $key : Str::kebab($label); diff --git a/src/Table/HasExports.php b/src/Table/HasExports.php index bc236a3b..f58fa3f4 100644 --- a/src/Table/HasExports.php +++ b/src/Table/HasExports.php @@ -31,9 +31,9 @@ public function hasExports(): bool * @return $this */ public function export( - string $label = null, - string $filename = null, - string $type = null, + ?string $label = null, + ?string $filename = null, + ?string $type = null, array $events = [], ): self { if (!class_exists(Excel::class)) { diff --git a/src/Table/HasFilters.php b/src/Table/HasFilters.php index 544214aa..77cfcaa2 100644 --- a/src/Table/HasFilters.php +++ b/src/Table/HasFilters.php @@ -17,10 +17,10 @@ trait HasFilters public function selectFilter( string $key, array $options, - string $label = null, - string $defaultValue = null, + ?string $label = null, + ?string $defaultValue = null, bool $noFilterOption = true, - string $noFilterOptionLabel = null + ?string $noFilterOptionLabel = null ): self { $this->filters = $this->filters->reject(function (Filter $filter) use ($key) { return $filter->key === $key; diff --git a/src/Table/HasSearchInputs.php b/src/Table/HasSearchInputs.php index 0de147be..032e5c71 100644 --- a/src/Table/HasSearchInputs.php +++ b/src/Table/HasSearchInputs.php @@ -37,8 +37,8 @@ private static function normalizeSearchColumnsWithMethod(array $keys): array */ public function searchInput( array|string $key, - string $label = null, - string $defaultValue = null, + ?string $label = null, + ?string $defaultValue = null, array $columns = [] ): self { if (empty($columns)) { @@ -65,10 +65,8 @@ public function searchInput( /** * Returns all Search Inputs, or finds on when $key is not empty. - * - * @return \Illuminate\Support\Collection|\ProtoneMedia\Splade\Table\SearchInput|null */ - public function searchInputs(string $key = null): Collection|SearchInput|null + public function searchInputs(?string $key = null): Collection|SearchInput|null { $filters = $this->query('filter', []); @@ -121,7 +119,7 @@ public static function defaultGlobalSearch(bool|string $label = 'Search') * * @return $this */ - public function withGlobalSearch(string $label = null, array $columns = []): self + public function withGlobalSearch(?string $label = null, array $columns = []): self { return $this->searchInput( key: SpladeTable::GLOBAL_SEARCH_KEY, diff --git a/src/TransitionRepository.php b/src/TransitionRepository.php index b6d20ff5..5ecf488c 100644 --- a/src/TransitionRepository.php +++ b/src/TransitionRepository.php @@ -9,7 +9,6 @@ class TransitionRepository /** * Adds an animation to this repository. * - * @param \ProtoneMedia\Splade\TransitionAnimation $transitionAnimation * @return $this */ public function add(TransitionAnimation $transitionAnimation): self @@ -40,8 +39,6 @@ public function new( /** * Returns the animation with the given name. - * - * @return \ProtoneMedia\Splade\TransitionAnimation */ public function get(string $name): TransitionAnimation {