Skip to content

Commit

Permalink
style: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelpopowicz committed Jun 21, 2024
1 parent 0a1f220 commit c400ade
Show file tree
Hide file tree
Showing 31 changed files with 59 additions and 160 deletions.
6 changes: 0 additions & 6 deletions src/Casts/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ class Asset implements CastsAttributes
{
/**
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @param string|null $value
* @param array $attributes
* @return \Oneduo\NovaFileManager\Support\Asset|null
*
* @throws \JsonException
*/
Expand All @@ -30,10 +27,7 @@ public function get($model, string $key, $value, array $attributes): ?AssetObjec

/**
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @param array|AssetObject|null $value
* @param array $attributes
* @return string|null
*
* @throws \JsonException
*/
Expand Down
5 changes: 0 additions & 5 deletions src/Casts/AssetCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ class AssetCollection implements CastsAttributes
{
/**
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @param string $value
* @param array $attributes
* @return \Illuminate\Support\Collection<\Oneduo\NovaFileManager\Support\Asset>
*
* @throws \JsonException
Expand All @@ -33,10 +31,7 @@ public function get($model, string $key, $value, array $attributes): Collection

/**
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @param \Illuminate\Support\Collection<\Oneduo\NovaFileManager\Support\Asset> $value
* @param array $attributes
* @return string
*/
public function set($model, string $key, $value, array $attributes): string
{
Expand Down
27 changes: 0 additions & 27 deletions src/Entities/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ public function __construct(

/**
* Static helper
*
* @param \Oneduo\NovaFileManager\Contracts\Services\FileManagerContract $manager
* @param string $path
* @param string $disk
* @return static
*/
public static function make(FileManagerContract $manager, string $path, string $disk): static
{
Expand All @@ -38,8 +33,6 @@ public static function make(FileManagerContract $manager, string $path, string $

/**
* Return the entity's data as array
*
* @return array
*/
public function toArray(): array
{
Expand Down Expand Up @@ -80,8 +73,6 @@ public function toArray(): array

/**
* Generate a unique identifier for the entity
*
* @return string
*/
public function id(): string
{
Expand All @@ -90,8 +81,6 @@ public function id(): string

/**
* Get the name of the entity
*
* @return string
*/
public function name(): string
{
Expand All @@ -100,8 +89,6 @@ public function name(): string

/**
* Compute the size of the entity
*
* @return int|string
*/
public function size(): int|string
{
Expand All @@ -122,8 +109,6 @@ public function size(): int|string

/**
* Get the file extension of the entity
*
* @return string
*/
public function extension(): string
{
Expand All @@ -132,8 +117,6 @@ public function extension(): string

/**
* Get the mime type of the entity
*
* @return string
*/
public function mime(): string
{
Expand All @@ -154,8 +137,6 @@ public function mime(): string

/**
* Build an url for the entity based on the disk
*
* @return string
*/
public function url(): string
{
Expand Down Expand Up @@ -186,8 +167,6 @@ public function url(): string

/**
* Get the expiration time from the user defined config
*
* @return \Illuminate\Support\Carbon
*/
public function signedExpirationTime(): Carbon
{
Expand All @@ -199,8 +178,6 @@ public function signedExpirationTime(): Carbon

/**
* Get the last modified time of the entity as string
*
* @return string
*/
public function lastModifiedAt(): string
{
Expand All @@ -213,8 +190,6 @@ public function lastModifiedAt(): string

/**
* Get the last modified time of the entity as a Carbon instance
*
* @return \Illuminate\Support\Carbon
*/
public function lastModifiedAtTimestamp(): Carbon
{
Expand All @@ -223,8 +198,6 @@ public function lastModifiedAtTimestamp(): Carbon

/**
* Define the type of the entity
*
* @return string
*/
public function type(): string
{
Expand Down
16 changes: 8 additions & 8 deletions src/FileManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
use Oneduo\NovaFileManager\Traits\Support\InteractsWithFilesystem;
use stdClass;

class FileManager extends Field implements InteractsWithFilesystemContract, Cover
class FileManager extends Field implements Cover, InteractsWithFilesystemContract
{
use SupportsDependentFields;
use InteractsWithFilesystem;
use HasThumbnail;
use InteractsWithFilesystem;
use PresentsImages;
use SupportsDependentFields;

public $component = 'nova-file-manager-field';

Expand All @@ -39,7 +39,7 @@ class FileManager extends Field implements InteractsWithFilesystemContract, Cove

public ?string $wrapper = null;

public function __construct($name, $attribute = null, Closure $storageCallback = null)
public function __construct($name, $attribute = null, ?Closure $storageCallback = null)
{
parent::__construct($name, $attribute);

Expand Down Expand Up @@ -124,7 +124,7 @@ protected function fillAttribute(NovaRequest $request, $requestAttribute, $model
}
}

protected function prepareStorageCallback(Closure $storageCallback = null): void
protected function prepareStorageCallback(?Closure $storageCallback = null): void
{
$this->storageCallback = $storageCallback ?? function (
NovaRequest $request,
Expand All @@ -143,7 +143,7 @@ protected function prepareStorageCallback(Closure $storageCallback = null): void
$files = collect($payload);

if ($this->multiple) {
$value = collect($files)->map(fn(array $file) => new Asset(...$file));
$value = collect($files)->map(fn (array $file) => new Asset(...$file));
} else {
$value = $files->isNotEmpty() ? new Asset(...$files->first()) : null;
}
Expand All @@ -163,12 +163,12 @@ protected function resolveAttribute($resource, $attribute = null): ?array
}

if ($value instanceof stdClass) {
$value = (array)$value;
$value = (array) $value;
}

if (is_array($value)) {
if ($this->multiple) {
$value = collect($value)->map(fn(array|object $asset) => new Asset(...(array)$asset));
$value = collect($value)->map(fn (array|object $asset) => new Asset(...(array) $asset));
} else {
$value = collect([new Asset(...$value)]);
}
Expand Down
7 changes: 3 additions & 4 deletions src/Filesystem/Support/GetID3.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class GetID3 extends BaseGetID3
* @param string $filename
* @param int $filesize
* @param resource $fp
* @return bool
*
* @throws getid3_exception
*/
Expand Down Expand Up @@ -51,7 +50,7 @@ public function openfile($filename, $filesize = null, $fp = null): bool
if (($fp != null) && ((get_resource_type($fp) == 'file') || (get_resource_type($fp) == 'stream'))) {
$this->fp = $fp;
} elseif ((is_readable($filename) || file_exists($filename)) && is_file($filename) && ($this->fp = fopen($filename,
'rb'))) {
'rb'))) {
// great
} else {
$errormessagelist = [];
Expand Down Expand Up @@ -113,11 +112,11 @@ public function openfile($filename, $filesize = null, $fp = null): bool
fclose($this->fp);

throw new getid3_exception('PHP seems to think the file is larger than '.round(PHP_INT_MAX / 1073741824).'GB, but filesystem reports it as '.number_format($real_filesize / 1073741824,
3).'GB, please report to [email protected]');
3).'GB, please report to [email protected]');
}
$this->info['filesize'] = $real_filesize;
$this->warning('File is larger than '.round(PHP_INT_MAX / 1073741824).'GB (filesystem reports it as '.number_format($real_filesize / 1073741824,
3).'GB) and is not properly supported by PHP.');
3).'GB) and is not properly supported by PHP.');
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/Http/Controllers/DiskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ class DiskController extends Controller
{
/**
* Get the available disks
*
* @return \Illuminate\Http\JsonResponse
*/
public function available(): JsonResponse
{
Expand Down
13 changes: 0 additions & 13 deletions src/Http/Controllers/FileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ class FileController extends Controller
{
/**
* Upload a file from the tool
*
* @param \Oneduo\NovaFileManager\Http\Requests\UploadFileRequest $request
* @param \Oneduo\NovaFileManager\Contracts\Filesystem\Upload\Uploader $uploader
* @return \Illuminate\Http\JsonResponse
*/
public function upload(UploadFileRequest $request, Uploader $uploader): JsonResponse
{
Expand All @@ -37,9 +33,6 @@ public function upload(UploadFileRequest $request, Uploader $uploader): JsonResp

/**
* Rename a file
*
* @param \Oneduo\NovaFileManager\Http\Requests\RenameFileRequest $request
* @return \Illuminate\Http\JsonResponse
*/
public function rename(RenameFileRequest $request): JsonResponse
{
Expand All @@ -64,9 +57,6 @@ public function rename(RenameFileRequest $request): JsonResponse

/**
* Delete a file
*
* @param \Oneduo\NovaFileManager\Http\Requests\DeleteFileRequest $request
* @return \Illuminate\Http\JsonResponse
*/
public function delete(DeleteFileRequest $request): JsonResponse
{
Expand All @@ -93,9 +83,6 @@ public function delete(DeleteFileRequest $request): JsonResponse

/**
* Unzip an archive
*
* @param \Oneduo\NovaFileManager\Http\Requests\UnzipFileRequest $request
* @return \Illuminate\Http\JsonResponse
*/
public function unzip(UnzipFileRequest $request): JsonResponse
{
Expand Down
9 changes: 0 additions & 9 deletions src/Http/Controllers/FolderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ class FolderController extends Controller
{
/**
* Create a new folder
*
* @param \Oneduo\NovaFileManager\Http\Requests\CreateFolderRequest $request
* @return \Illuminate\Http\JsonResponse
*/
public function create(CreateFolderRequest $request): JsonResponse
{
Expand All @@ -48,9 +45,6 @@ public function create(CreateFolderRequest $request): JsonResponse

/**
* Rename a folder
*
* @param \Oneduo\NovaFileManager\Http\Requests\RenameFolderRequest $request
* @return \Illuminate\Http\JsonResponse
*/
public function rename(RenameFolderRequest $request): JsonResponse
{
Expand All @@ -76,9 +70,6 @@ public function rename(RenameFolderRequest $request): JsonResponse

/**
* Delete a folder
*
* @param \Oneduo\NovaFileManager\Http\Requests\DeleteFolderRequest $request
* @return \Illuminate\Http\JsonResponse
*/
public function delete(DeleteFolderRequest $request): JsonResponse
{
Expand Down
1 change: 0 additions & 1 deletion src/Http/Controllers/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class IndexController extends Controller
/**
* Get the data for the tool
*
* @param \Oneduo\NovaFileManager\Http\Requests\IndexRequest $request
* @return \Illuminate\Http\JsonResponse
*/
public function __invoke(IndexRequest $request)
Expand Down
5 changes: 0 additions & 5 deletions src/Http/Middleware/Authorize.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ class Authorize
/**
* Handle the incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request):mixed $next
* @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse
*/
public function handle(Request $request, Closure $next): Response|JsonResponse
{
Expand All @@ -30,9 +28,6 @@ public function handle(Request $request, Closure $next): Response|JsonResponse

/**
* Determine whether this tool belongs to the package.
*
* @param \Laravel\Nova\Tool $tool
* @return bool
*/
public function matchesTool(Tool $tool): bool
{
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Requests/BaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function authorizationAttribute(): string
return strtolower(str(static::class)->classBasename()->ucsplit()->get(1, ''));
}

public function authorizationActionAttribute(string $class = null): string
public function authorizationActionAttribute(?string $class = null): string
{
return (string) str($class ?? static::class)->classBasename()->replace('Request', '')->snake(' ');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Requests/UploadFileRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function authorize(): bool
return true;
}

public function authorizationActionAttribute(string $class = null): string
public function authorizationActionAttribute(?string $class = null): string
{
if (!$this->canUploadFile()) {
return parent::authorizationActionAttribute();
Expand Down
2 changes: 0 additions & 2 deletions src/Rules/FileMissingInFilesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ public function __construct(public UploadFileRequest $request)
}

/**
* @param $attribute
* @param \Illuminate\Http\UploadedFile $value
* @return bool
*/
public function passes($attribute, $value): bool
{
Expand Down
Loading

0 comments on commit c400ade

Please sign in to comment.