diff --git a/composer.json b/composer.json index 552d2586..a4cbd7ef 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ ], "license": "MIT", "require": { - "php": ">=7.1.0" + "php": "^7.1|^8.0" }, "autoload": { "psr-4": { diff --git a/src/BelongsTo.php b/src/BelongsTo.php index 7e9af956..54084669 100644 --- a/src/BelongsTo.php +++ b/src/BelongsTo.php @@ -54,7 +54,7 @@ class BelongsTo extends NovaBelongsTo * @param mixed $resource * @return array */ - public function formatAssociatableResource(NovaRequest $request, $resource) + public function formatAssociatableResource(NovaRequest $request, $resource): array { $relation = explode(".", $this->groupedBy); @@ -76,7 +76,7 @@ public function formatAssociatableResource(NovaRequest $request, $resource) * @param \Laravel\Nova\Http\Requests\NovaRequest $request * @return array */ - public function getRules(NovaRequest $request) + public function getRules(NovaRequest $request): array { $rules = parent::getRules($request); @@ -96,7 +96,7 @@ public function getRules(NovaRequest $request) * @param string $field * @return $this */ - public function groupedBy($field) + public function groupedBy($field): BelongsTo { $this->groupedBy = $field; @@ -109,7 +109,7 @@ public function groupedBy($field) * @param string $name * @return $this */ - public function displayName($name) + public function displayName($name): BelongsTo { $this->displayName = $name; @@ -121,7 +121,7 @@ public function displayName($name) * * @return $this */ - public function disableRelatableRule() + public function disableRelatableRule(): BelongsTo { $this->disableRelatableRule = true; @@ -133,7 +133,7 @@ public function disableRelatableRule() * * @return $this */ - public function quickCreate($fillValues = []) + public function quickCreate($fillValues = []): BelongsTo { $this->withMeta(['quickCreate' => true, 'fillValues' => $fillValues]); @@ -145,7 +145,7 @@ public function quickCreate($fillValues = []) * * @return $this */ - public function disableTrashed() + public function disableTrashed(): BelongsTo { $this->withMeta(['disableTrashed' => true]); @@ -157,7 +157,7 @@ public function disableTrashed() * * @return array */ - public function meta() + public function meta(): array { return array_merge([ 'wrapperClasses' => $this->wrapperClasses, diff --git a/src/Boolean.php b/src/Boolean.php index 81230e34..c29487f5 100644 --- a/src/Boolean.php +++ b/src/Boolean.php @@ -35,7 +35,7 @@ class Boolean extends NovaBoolean * @param string $classes * @return $this */ - public function dotClasses($classes) + public function dotClasses($classes): Boolean { return $this->withMeta(['dotClasses' => $classes]); } @@ -46,7 +46,7 @@ public function dotClasses($classes) * @param string $class * @return $this */ - public function successClass($class) + public function successClass($class): Boolean { return $this->withMeta(['successClass' => $class]); } @@ -57,7 +57,7 @@ public function successClass($class) * @param string $class * @return $this */ - public function dangerClass($class) + public function dangerClass($class): Boolean { return $this->withMeta(['dangerClass' => $class]); } @@ -68,7 +68,7 @@ public function dangerClass($class) * @param string $label * @return $this */ - public function yesLabel($label) + public function yesLabel($label): Boolean { return $this->withMeta(['yesLabel' => $label]); } @@ -79,7 +79,7 @@ public function yesLabel($label) * @param string $label * @return $this */ - public function noLabel($label) + public function noLabel($label): Boolean { return $this->withMeta(['noLabel' => $label]); } @@ -89,7 +89,7 @@ public function noLabel($label) * * @return $this */ - public function hideBooleanLabel() + public function hideBooleanLabel(): Boolean { return $this->withMeta(['hideBooleanLabel' => true]); } diff --git a/src/Currency.php b/src/Currency.php index 79be2b9b..9f7c7335 100644 --- a/src/Currency.php +++ b/src/Currency.php @@ -35,7 +35,7 @@ class Currency extends NovaCurrency * * @return $this */ - public function colors() + public function colors(): Currency { return $this->withMeta(['colors' => true]); } diff --git a/src/DateTime.php b/src/DateTime.php index ea8e7415..be505cab 100644 --- a/src/DateTime.php +++ b/src/DateTime.php @@ -34,7 +34,7 @@ class DateTime extends NovaDateTime * * @return $this */ - public function hideTimezone() + public function hideTimezone(): DateTime { return $this->withMeta(['hideTimezone' => true]); } diff --git a/src/FieldServiceProvider.php b/src/FieldServiceProvider.php index cd040a94..deb4376f 100644 --- a/src/FieldServiceProvider.php +++ b/src/FieldServiceProvider.php @@ -15,7 +15,7 @@ class FieldServiceProvider extends ServiceProvider * * @return void */ - public function boot() + public function boot(): void { Nova::serving(function (ServingNova $event) { Nova::script('nova-fields', __DIR__.'/../dist/js/field.js'); @@ -31,7 +31,7 @@ public function boot() * * @return void */ - public function register() + public function register(): void { // } @@ -41,7 +41,7 @@ public function register() * * @return array */ - protected function routeConfiguration() + protected function routeConfiguration(): array { return [ 'namespace' => 'R64\NovaFields\Http\Controllers', diff --git a/src/File.php b/src/File.php index 6889eff6..097a8964 100644 --- a/src/File.php +++ b/src/File.php @@ -58,7 +58,7 @@ public function __construct($name, $attribute = null, $disk = 'public', $storage * * @return $this */ - public function draggable() + public function draggable(): File { return $this->withMeta(['draggable' => true]); } @@ -68,7 +68,7 @@ public function draggable() * * @return $this */ - public function previewBeforeUpload() + public function previewBeforeUpload(): File { return $this->withMeta(['previewBeforeUpload' => true]); } @@ -78,7 +78,7 @@ public function previewBeforeUpload() * * @return array */ - public function meta() + public function meta(): array { return array_merge([ 'wrapperClasses' => $this->wrapperClasses, diff --git a/src/HasChilds.php b/src/HasChilds.php index bb312c57..ee27b57a 100644 --- a/src/HasChilds.php +++ b/src/HasChilds.php @@ -23,7 +23,7 @@ public function childConfig($childConfig) * @param \Laravel\Nova\Http\Requests\NovaRequest $request * @return array */ - public function getRules(NovaRequest $request) + public function getRules(NovaRequest $request): array { $result = []; @@ -46,7 +46,7 @@ public function getRules(NovaRequest $request) * @param \Laravel\Nova\Http\Requests\NovaRequest $request * @return array|string */ - public function getCreationRules(NovaRequest $request) + public function getCreationRules(NovaRequest $request): array { $result = []; @@ -69,7 +69,7 @@ public function getCreationRules(NovaRequest $request) * @param \Laravel\Nova\Http\Requests\NovaRequest $request * @return array */ - public function getUpdateRules(NovaRequest $request) + public function getUpdateRules(NovaRequest $request): array { $result = []; diff --git a/src/Http/Controllers/AssociatableController.php b/src/Http/Controllers/AssociatableController.php index fbff5769..a897a327 100644 --- a/src/Http/Controllers/AssociatableController.php +++ b/src/Http/Controllers/AssociatableController.php @@ -10,10 +10,10 @@ class AssociatableController extends Controller /** * List the available related resources for a given resource. * - * @param \Laravel\Nova\Http\Requests\NovaRequest $request - * @return \Illuminate\Http\Response + * @param Laravel\Nova\Http\Requests\NovaRequest $request + * @return array */ - public function index(NovaRequest $request) + public function index(NovaRequest $request): array { $fields = $request->newResource() ->availableFields($request); diff --git a/src/Http/Controllers/ComputedController.php b/src/Http/Controllers/ComputedController.php index cc5f814f..52d02b6f 100644 --- a/src/Http/Controllers/ComputedController.php +++ b/src/Http/Controllers/ComputedController.php @@ -10,10 +10,10 @@ class ComputedController /** * Compute the value. * - * @param \Laravel\Nova\Http\Requests\NovaRequest $request + * @param Laravel\Nova\Http\Requests\NovaRequest $request * @return mixed */ - public function index(NovaRequest $request) + public function index(NovaRequest $request): mixed { $resourceId = $request->input('resourceId'); $resourceClass = Nova::resourceForKey($request->resource); diff --git a/src/Http/Controllers/ComputedValues.php b/src/Http/Controllers/ComputedValues.php index c85071ef..24d442be 100644 --- a/src/Http/Controllers/ComputedValues.php +++ b/src/Http/Controllers/ComputedValues.php @@ -11,7 +11,7 @@ public function __construct($values) return $this->values = (object) $values; } - public function __get($key) + public function __get($key): bool { return property_exists($this->values, $key) ? $this->values->$key : null; } diff --git a/src/Http/Controllers/FieldDownloadController.php b/src/Http/Controllers/FieldDownloadController.php index 3a0df49f..598d01ad 100644 --- a/src/Http/Controllers/FieldDownloadController.php +++ b/src/Http/Controllers/FieldDownloadController.php @@ -2,8 +2,9 @@ namespace R64\NovaFields\Http\Controllers; -use Laravel\Nova\Fields\File; +use Illuminate\Http\Response; use Illuminate\Routing\Controller; +use Laravel\Nova\Fields\File; use Laravel\Nova\Http\Requests\NovaRequest; class FieldDownloadController extends Controller @@ -11,10 +12,10 @@ class FieldDownloadController extends Controller /** * Download the given field's contents. * - * @param \Laravel\Nova\Http\Requests\NovaRequest $request - * @return \Illuminate\Http\Response + * @param Laravel\Nova\Http\Requests\NovaRequest $request + * @return Illuminate\Http\Response */ - public function show(NovaRequest $request) + public function show(NovaRequest $request): Response { $resource = $request->findResourceOrFail(); diff --git a/src/Image.php b/src/Image.php index b9406e1e..7a62e3b7 100644 --- a/src/Image.php +++ b/src/Image.php @@ -34,7 +34,7 @@ class Image extends NovaImage * * @return array */ - public function meta() + public function meta(): array { return array_merge([ 'wrapperClasses' => $this->wrapperClasses, diff --git a/src/JSON.php b/src/JSON.php index fc3b98b1..31c52b9b 100644 --- a/src/JSON.php +++ b/src/JSON.php @@ -87,7 +87,7 @@ public function __construct($name, $fields, $attribute = null, $resolveCallback * @param string $classes * @return $this */ - public function panelTitleClasses($classes) + public function panelTitleClasses($classes): JSON { $this->panelTitleClasses = $classes; @@ -101,7 +101,7 @@ public function panelTitleClasses($classes) * * @return $this */ - public function flatten($value = true) + public function flatten($value = true): JSON { return $this->withMeta([ 'flatten' => $value @@ -115,7 +115,7 @@ public function flatten($value = true) * @param string|null $attribute * @return void */ - public function resolve($resource, $attribute = null) + public function resolve($resource, $attribute = null): void { $attribute = $attribute ?? $this->attribute; @@ -151,7 +151,7 @@ public function resolve($resource, $attribute = null) * @param string $attribute * @return void */ - protected function fillAttributeFromRequest(NovaRequest $request, $requestAttribute, $model, $attribute) + protected function fillAttributeFromRequest(NovaRequest $request, $requestAttribute, $model, $attribute): void { $this->fields->each(function ($field) use ($request, $model, $attribute) { $field->fillInto($request, $model, $attribute . '->' . $field->attribute, $attribute . '.' . $field->attribute); @@ -164,7 +164,7 @@ protected function fillAttributeFromRequest(NovaRequest $request, $requestAttrib * @param array $rules * @return array */ - protected function generateRules($rules) + protected function generateRules($rules): array { return collect($rules)->mapWithKeys(function ($rules, $key) { return [$this->attribute . ($key ? '.' . $key : '') => $rules]; @@ -178,7 +178,7 @@ protected function generateRules($rules) * @param string|null $attribute * @return void */ - public function resolveForDisplay($resource, $attribute = null) + public function resolveForDisplay($resource, $attribute = null): void { $attribute = $attribute ?? $this->attribute; @@ -196,7 +196,7 @@ public function resolveForDisplay($resource, $attribute = null) * * @return array */ - public function jsonSerialize() + public function jsonSerialize(): array { return array_merge(parent::jsonSerialize(), [ 'panelTitleClasses' => $this->panelTitleClasses, diff --git a/src/Number.php b/src/Number.php index c6a4587e..16acd907 100644 --- a/src/Number.php +++ b/src/Number.php @@ -35,7 +35,7 @@ class Number extends NovaNumber * * @return $this */ - public function colors() + public function colors(): Number { return $this->withMeta(['colors' => true]); } diff --git a/src/Password.php b/src/Password.php index 241ab468..ee9a742d 100644 --- a/src/Password.php +++ b/src/Password.php @@ -36,7 +36,7 @@ class Password extends NovaPassword * @param string $placeholder * @return $this */ - public function maskLabel($label) + public function maskLabel($label): Password { return $this->withMeta(['maskLabel' => $label]); } diff --git a/src/Row.php b/src/Row.php index 8370c775..b4a3ac38 100644 --- a/src/Row.php +++ b/src/Row.php @@ -2,6 +2,7 @@ namespace R64\NovaFields; +use Illuminate\Support\Collection; use Illuminate\Support\Str; use Laravel\Nova\Fields\Field; use Laravel\Nova\Fields\Expandable; @@ -116,7 +117,7 @@ public function __construct($name, $fields, $attribute = null, $resolveCallback * * @return $this */ - public function hideHeading() + public function hideHeading(): Row { return $this->withMeta(['hideHeading' => true]); } @@ -126,7 +127,7 @@ public function hideHeading() * * @return $this */ - public function hideHeadingWhenEmpty() + public function hideHeadingWhenEmpty(): Row { return $this->withMeta(['hideHeadingWhenEmpty' => true]); } @@ -136,7 +137,7 @@ public function hideHeadingWhenEmpty() * * @return $this */ - public function sum($field) + public function sum($field): Row { return $this->withMeta(['sum' => $field]); } @@ -146,7 +147,7 @@ public function sum($field) * * @return $this */ - public function hideSumWhenEmpty() + public function hideSumWhenEmpty(): Row { return $this->withMeta(['hideSumWhenEmpty' => true]); } @@ -156,7 +157,7 @@ public function hideSumWhenEmpty() * * @return $this */ - public function prepopulateRowWhenEmpty() + public function prepopulateRowWhenEmpty(): Row { return $this->withMeta(['prepopulateRowWhenEmpty' => true]); } @@ -166,7 +167,7 @@ public function prepopulateRowWhenEmpty() * * @return $this */ - public function maxRows($rows) + public function maxRows($rows): Row { return $this->withMeta(['maxRows' => $rows]); } @@ -176,7 +177,7 @@ public function maxRows($rows) * @param string $name * @return $this */ - public function addRowText($text) + public function addRowText($text): Row { return $this->withMeta(['addRowText' => $text]); } @@ -187,7 +188,7 @@ public function addRowText($text) * @param string $classes * @return $this */ - public function headingClasses($classes) + public function headingClasses($classes): Row { $this->headingClasses = $classes; @@ -200,7 +201,7 @@ public function headingClasses($classes) * @param string $classes * @return $this */ - public function itemWrapperClasses($classes) + public function itemWrapperClasses($classes): Row { $this->itemWrapperClasses = $classes; @@ -213,7 +214,7 @@ public function itemWrapperClasses($classes) * @param string $classes * @return $this */ - public function deleteButtonClasses($classes) + public function deleteButtonClasses($classes): Row { $this->deleteButtonClasses = $classes; @@ -226,7 +227,7 @@ public function deleteButtonClasses($classes) * @param string $classes * @return $this */ - public function sumWrapperClasses($classes) + public function sumWrapperClasses($classes): Row { $this->sumWrapperClasses = $classes; @@ -239,7 +240,7 @@ public function sumWrapperClasses($classes) * @param string $classes * @return $this */ - public function sumFieldClasses($classes) + public function sumFieldClasses($classes): Row { $this->sumFieldClasses = $classes; @@ -252,7 +253,7 @@ public function sumFieldClasses($classes) * @param string $classes * @return $this */ - public function addRowButtonClasses($classes) + public function addRowButtonClasses($classes): Row { $this->addRowButtonClasses = $classes; @@ -265,7 +266,7 @@ public function addRowButtonClasses($classes) * @param string $classes * @return $this */ - public function rowWrapperClasses($classes) + public function rowWrapperClasses($classes): Row { $this->rowWrapperClasses = $classes; @@ -278,7 +279,7 @@ public function rowWrapperClasses($classes) * @param string $classes * @return $this */ - public function useWrapperClassesInHeading() + public function useWrapperClassesInHeading(): Row { return $this->withMeta(['useWrapperClassesInHeading' => true]); } @@ -290,7 +291,7 @@ public function useWrapperClassesInHeading() * @param string|null $attribute * @return void */ - public function resolve($resource, $attribute = null) + public function resolve($resource, $attribute = null): void { $attribute = $attribute ?? $this->attribute; @@ -338,7 +339,7 @@ public function resolve($resource, $attribute = null) * @param array $rules * @return array */ - protected function generateRules($rules) + protected function generateRules($rules): array { return collect($rules)->mapWithKeys(function ($rules, $key) { return [$this->attribute . '.*.' . $key => $rules]; @@ -351,7 +352,7 @@ protected function generateRules($rules) * @param array $fields * @return Collection */ - protected function prepareFields($fields) + protected function prepareFields($fields): Collection { return collect($fields)->each(function($field) { if($field->isReadonly(app(NovaRequest::class))) { @@ -377,7 +378,7 @@ protected function prepareFields($fields) * * @return array */ - public function jsonSerialize() + public function jsonSerialize(): array { return array_merge(parent::jsonSerialize(), [ 'sanitizedAttribute' => Str::plural(Str::kebab($this->attribute)), diff --git a/src/Select.php b/src/Select.php index 95267fc4..687a4487 100644 --- a/src/Select.php +++ b/src/Select.php @@ -34,7 +34,7 @@ class Select extends NovaSelect * * @return $this */ - public function displayUsingLabels() + public function displayUsingLabels(): Select { $this->displayUsing(function ($value) { return collect($this->meta['options']) diff --git a/src/Textarea.php b/src/Textarea.php index 0e5a5ebd..f3cd0d5a 100644 --- a/src/Textarea.php +++ b/src/Textarea.php @@ -35,7 +35,7 @@ class Textarea extends NovaTextarea * @param string $label * @return $this */ - public function showContentLabel($label) + public function showContentLabel($label): Textarea { return $this->withMeta(['showContentLabel' => $label]); } @@ -46,7 +46,7 @@ public function showContentLabel($label) * @param string $label * @return $this */ - public function hideContentLabel($label) + public function hideContentLabel($label): Textarea { return $this->withMeta(['hideContentLabel' => $label]); }