Skip to content

Commit

Permalink
Merge branch 'main' of github.com:kiwilan/steward-laravel
Browse files Browse the repository at this point in the history
  • Loading branch information
ewilan-riviere committed Dec 13, 2023
2 parents a3b3c47 + 9e449ed commit fa658e0
Show file tree
Hide file tree
Showing 37 changed files with 61 additions and 61 deletions.
4 changes: 2 additions & 2 deletions src/Commands/Commandable.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class Commandable extends Command
{
public function title(string $signature = null, string $description = null)
public function title(?string $signature = null, ?string $description = null)
{
$app = config('app.name');
$this->newLine();
Expand Down Expand Up @@ -37,7 +37,7 @@ public function title(string $signature = null, string $description = null)
$this->newLine();
}

public function askOnProduction(Closure $closure = null, bool $with_force = true, string $option = 'force')
public function askOnProduction(?Closure $closure = null, bool $with_force = true, string $option = 'force')
{
$force = false;

Expand Down
2 changes: 1 addition & 1 deletion src/Engines/SearchEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(
/**
* Create an instance of SearchEngine from query.
*/
public static function create(?string $q = '', bool $relevant = false, bool $opds = false, string|array $types = null): SearchEngine
public static function create(?string $q = '', bool $relevant = false, bool $opds = false, string|array|null $types = null): SearchEngine
{
if (gettype($types) === 'string') {
$types = explode(',', $types);
Expand Down
2 changes: 1 addition & 1 deletion src/Filament/Components/AutoPicture.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static function make(
'image/svg+xml',
],
string $hint = 'Accepte JPG, WEBP, PNG, SVG',
Closure $disabled = null,
?Closure $disabled = null,
): Forms\Components\FileUpload {
if (! $disabled) {
$disabled = false;
Expand Down
2 changes: 1 addition & 1 deletion src/Filament/Components/DescriptionInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static function make(
string $field = 'description',
string|false $metaField = 'meta_description',
string $label = 'Description',
string $helper = null,
?string $helper = null,
string $skipContext = 'edit',
int $width = 1,
bool $required = false,
Expand Down
2 changes: 1 addition & 1 deletion src/Filament/Components/NameInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static function make(
string|false $metaLink = 'slug',
string|false $metaTitle = 'meta_title',
string $label = 'Name',
string $helper = null,
?string $helper = null,
string $skipContext = 'edit',
int $width = 1,
bool $required = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ public function field(string $field = 'content'): self
return $this;
}

public function minItems(int $minItems = null): self
public function minItems(?int $minItems = null): self
{
$this->minItems = $minItems;

return $this;
}

public function maxItems(int $maxItems = null): self
public function maxItems(?int $maxItems = null): self
{
$this->maxItems = $maxItems;

Expand Down
4 changes: 2 additions & 2 deletions src/Filament/Config/FilamentChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(
) {
}

public static function chartBy(string $table, string $field, string $limit_year = null, bool $published = false): FilamentChart
public static function chartBy(string $table, string $field, ?string $limit_year = null, bool $published = false): FilamentChart
{
$models_db = DB::table($table)
->selectRaw("
Expand Down Expand Up @@ -59,7 +59,7 @@ public static function chartBy(string $table, string $field, string $limit_year
return $chart_helper;
}

public static function chartByField(string $table, string $field, string $limit_year = null, bool $published = false): self
public static function chartByField(string $table, string $field, ?string $limit_year = null, bool $published = false): self
{
$models_db = DB::table($table)
->selectRaw("
Expand Down
6 changes: 3 additions & 3 deletions src/Filament/Config/FilamentForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static function name(
string|false $metaLink = 'slug',
string|false $metaTitle = 'meta_title',
string $label = 'Name',
string $helper = null,
?string $helper = null,
string $skipContext = 'edit',
int $width = 1,
bool $required = true,
Expand Down Expand Up @@ -77,7 +77,7 @@ public static function description(
string $field = 'description',
string|false $metaField = 'meta_description',
string $label = 'Description',
string $helper = null,
?string $helper = null,
string $skipContext = 'edit',
int $width = 1,
bool $required = false,
Expand Down Expand Up @@ -263,7 +263,7 @@ public static function pictureField(
'image/svg+xml',
],
string $hint = 'Accepte JPG, WEBP, PNG, SVG',
Closure $disabled = null,
?Closure $disabled = null,
) {
if (! $disabled) {
$disabled = false;
Expand Down
2 changes: 1 addition & 1 deletion src/Filament/Config/FilamentLayout/FilamentLayoutCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class FilamentLayoutCard
* @param Field[] $fields
* @param ?string $title
*/
public static function make(array $fields = [], string $title = null, int $width = 2): Section
public static function make(array $fields = [], ?string $title = null, int $width = 2): Section
{
$list = [];

Expand Down
2 changes: 1 addition & 1 deletion src/Livewire/Traits/LiveNotify.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait LiveNotify
/**
* Send notification to user.
*/
public function notify(string $message = null): LiveNotifyItem
public function notify(?string $message = null): LiveNotifyItem
{
if (method_exists($this, 'mount')) {
$this->mount();
Expand Down
2 changes: 1 addition & 1 deletion src/Livewire/Traits/LiveUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function deleteAllUpload(string $field)
/**
* Delete existing upload in model.
*/
protected function deleteToModel(string $field, string|int $index = null, bool $all = false): void
protected function deleteToModel(string $field, string|int|null $index = null, bool $all = false): void
{
$isArray = is_array($this->{$field});
$current = $this->{$field} ?? null;
Expand Down
2 changes: 1 addition & 1 deletion src/Livewire/Traits/LiveValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait LiveValidator
{
use LiveNotify;

public function validator(Closure $callback = null): array
public function validator(?Closure $callback = null): array
{
return $this->withValidator(
fn (Validator $validator) => $validator->after(
Expand Down
4 changes: 2 additions & 2 deletions src/Queries/BaseQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ abstract class BaseQuery
*/
protected int $pagination = 15;

protected function setup(string|Builder $model, Request $request = null): self
protected function setup(string|Builder $model, ?Request $request = null): self
{
if (! \Composer\InstalledVersions::isInstalled('spatie/laravel-query-builder')) {
throw new \Exception('Package `spatie/laravel-query-builder` not installed, see: https://github.com/spatie/laravel-query-builder');
Expand Down Expand Up @@ -147,7 +147,7 @@ public function inertia(): QueryResponse
* @param string|null $toSave Path to save file, if null return download response.
* @param bool $skipExcel If you have `maatwebsite/excel` installed, you can skip Excel export and use only CSV.
*/
public function export(string $toSave = null, bool $skipExcel = false): Response|BinaryFileResponse|bool
public function export(?string $toSave = null, bool $skipExcel = false): Response|BinaryFileResponse|bool
{
$this->loadRequest();
$this->exportGuess();
Expand Down
4 changes: 2 additions & 2 deletions src/Queries/ExportQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected function __construct(
) {
}

public static function make(Collection $data, QueryBuilder $query, string $name, string $export = null, string $path = null, bool $skipExcel = false): self
public static function make(Collection $data, QueryBuilder $query, string $name, ?string $export = null, ?string $path = null, bool $skipExcel = false): self
{
$filename = $name;
$date = date('Ymd-His');
Expand Down Expand Up @@ -121,7 +121,7 @@ private function selectType(): string
return \Composer\InstalledVersions::isInstalled('maatwebsite/excel') ? 'excel' : 'standard';
}

private function arrayFlatten(array $array, string $prefix = null): ?array
private function arrayFlatten(array $array, ?string $prefix = null): ?array
{
if (! is_array($array)) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Api/Seeds/SeedsApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function medias(): Collection
public function fetchPictures(
SeedsApiCategoryEnum $category = SeedsApiCategoryEnum::all,
SeedsApiSizeEnum $size = SeedsApiSizeEnum::medium,
int $count = null
?int $count = null
): Collection {
$count = $count ?? null;

Expand Down
2 changes: 1 addition & 1 deletion src/Services/ClassParser/MetaClassItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function __construct(
*
* @param string $classString like `WikipediaItem::class`
*/
public static function make(string $classString, ReflectionClass $reflect = null): self
public static function make(string $classString, ?ReflectionClass $reflect = null): self
{
$self = new self($classString);

Expand Down
2 changes: 1 addition & 1 deletion src/Services/Factory/FactoryJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private function parseEntity(mixed $entity): void
$created_model->save();
}

public function setMedia(mixed $model, string $path = null): ?string
public function setMedia(mixed $model, ?string $path = null): ?string
{
if (! $model instanceof Model) {
return null;
Expand Down
6 changes: 3 additions & 3 deletions src/Services/Factory/FactoryMediaDownloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public function __construct(
* @param SeedsApiSizeEnum|null $size default is `medium`
*/
public function config(
SeedsApiCategoryEnum $category = null,
SeedsApiSizeEnum $size = null,
?SeedsApiCategoryEnum $category = null,
?SeedsApiSizeEnum $size = null,
): self {
$this->config = [
'category' => $category ?? StewardConfig::factoryMediaDownloaderDefaultCategory(),
Expand Down Expand Up @@ -98,7 +98,7 @@ private function associateByChunk(Collection $models, string $field, bool $multi
/**
* @return Collection<int,string>
*/
private function fetchMedias(int $count = 1, string $basePath = null)
private function fetchMedias(int $count = 1, ?string $basePath = null)
{
$this->config['count'] = $count;

Expand Down
2 changes: 1 addition & 1 deletion src/Services/Factory/FactoryMediaLocal.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private function associateByChunk(Collection $models, string $field, bool $multi
/**
* @return Collection<int,string>
*/
private function fetchMedias(string $basePath = null): Collection
private function fetchMedias(?string $basePath = null): Collection
{
$path = "{$this->basePath}/{$this->path}";

Expand Down
4 changes: 2 additions & 2 deletions src/Services/Factory/FactoryText.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function title(): string
return TextProvider::capitalizeFirst($this->words());
}

public function category(string $class = null, string $field = 'name'): string
public function category(?string $class = null, string $field = 'name'): string
{
if (! $class) {
return MeaningProvider::find();
Expand Down Expand Up @@ -58,7 +58,7 @@ public function category(string $class = null, string $field = 'name'): string
// }
}

public function tag(string $class = null, string $field = 'name'): string
public function tag(?string $class = null, string $field = 'name'): string
{
if (! $class) {
return MeaningProvider::find('tag');
Expand Down
4 changes: 2 additions & 2 deletions src/Services/Factory/Media/MediaProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public static function make(): self
}

public function seeds(
SeedsApiCategoryEnum $category = null,
SeedsApiSizeEnum $size = null,
?SeedsApiCategoryEnum $category = null,
?SeedsApiSizeEnum $size = null,
int $count = 1,
): MediaApi {
$this->type = MediaApiEnum::seeds;
Expand Down
18 changes: 9 additions & 9 deletions src/Services/FactoryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static function afterSeed(): void
Artisan::call(MediaCleanCommand::class, ['--force' => true]);
}

public static function make(string|\UnitEnum $mediaPath = null): self
public static function make(string|\UnitEnum|null $mediaPath = null): self
{
$faker = \Faker\Factory::create();
$service = new FactoryService($faker);
Expand All @@ -82,7 +82,7 @@ public static function noSearch(string $model, Closure $closure): mixed
return $model::withoutSyncingToSearch(fn () => $closure());
}

public function useText(FactoryTextEnum $type = null): self
public function useText(?FactoryTextEnum $type = null): self
{
$this->text = $this->setFactoryText($type);
$this->richText = $this->setFactoryRichText($type);
Expand Down Expand Up @@ -113,7 +113,7 @@ public function dateTime(): FactoryDateTime
/**
* @param string|null $basePath If null, use `database_path('seeders/media')`
*/
public function mediaLocal(string $path, string $basePath = null): FactoryMediaLocal
public function mediaLocal(string $path, ?string $basePath = null): FactoryMediaLocal
{
if (! $basePath) {
$this->mediaLocal->basePath = database_path('seeders/media');
Expand All @@ -139,14 +139,14 @@ public function json(): FactoryJson
// return FactoryBuilder::make($this, $builder);
// }

private function setFactoryText(FactoryTextEnum $type = null): FactoryText
private function setFactoryText(?FactoryTextEnum $type = null): FactoryText
{
$type = $type ?? \Kiwilan\Steward\StewardConfig::factoryText();

return new FactoryText($this, $type);
}

private function setFactoryRichText(FactoryTextEnum $type = null): FactoryRichText
private function setFactoryRichText(?FactoryTextEnum $type = null): FactoryRichText
{
$type = $type ?? \Kiwilan\Steward\StewardConfig::factoryText();
$text = $this->setFactoryText($type);
Expand All @@ -159,7 +159,7 @@ private function setFactoryDate(): FactoryDateTime
return new FactoryDateTime($this);
}

private function setFactoryMediaLocal(string|\UnitEnum $media_path = null): FactoryMediaLocal
private function setFactoryMediaLocal(string|\UnitEnum|null $media_path = null): FactoryMediaLocal
{
if ($media_path && $media_path instanceof \UnitEnum) {
$media_path = $media_path->name;
Expand All @@ -178,7 +178,7 @@ private function setFactoryJson(): FactoryJson
return new FactoryJson($this);
}

public static function mediaFromResponse(?HttpPoolResponse $response, string $basePath = null): ?string
public static function mediaFromResponse(?HttpPoolResponse $response, ?string $basePath = null): ?string
{
if (! $response || ! $response->isSuccess()) {
return null;
Expand All @@ -195,15 +195,15 @@ public static function mediaFromResponse(?HttpPoolResponse $response, string $ba
return FactoryService::saveFile($data, $ext, $basePath);
}

public static function mediaFromFile(string $path, string $basePath = null): ?string
public static function mediaFromFile(string $path, ?string $basePath = null): ?string
{
$data = File::get($path);
$ext = pathinfo($path)['extension'];

return FactoryService::saveFile($data, $ext, $basePath);
}

private static function saveFile(string $data, string $ext = 'jpg', string $basePath = null): string
private static function saveFile(string $data, string $ext = 'jpg', ?string $basePath = null): string
{
$random = uniqid();

Expand Down
6 changes: 3 additions & 3 deletions src/Services/FileUploadService.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ protected function __construct(
) {
}

public static function make(string $saveDirectory = null, string $baseUrl = null): self
public static function make(?string $saveDirectory = null, ?string $baseUrl = null): self
{
$self = new self();

Expand All @@ -36,7 +36,7 @@ public static function make(string $saveDirectory = null, string $baseUrl = null
*
* @return FileServiceItem[]|FileServiceItem|null
*/
public function uploadAll(array|string $paths, string $prefix = null): array|FileServiceItem|null
public function uploadAll(array|string $paths, ?string $prefix = null): array|FileServiceItem|null
{
/** @var FileServiceItem[] $items */
$items = [];
Expand All @@ -52,7 +52,7 @@ public function uploadAll(array|string $paths, string $prefix = null): array|Fil
return $items;
}

public function upload(string $p, string $prefix = null): FileServiceItem
public function upload(string $p, ?string $prefix = null): FileServiceItem
{
$self = new FileServiceItem($p);
$path = str_replace(['(', ')'], '', $p);
Expand Down
2 changes: 1 addition & 1 deletion src/Services/IframelyService.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected function __construct(
/**
* @param string $api Iframely instance to use, can be set from `steward.iframely.api`
*/
public static function make(string $api = null): self
public static function make(?string $api = null): self
{
if (! $api) {
$api = \Kiwilan\Steward\StewardConfig::iframelyApi();
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Markdown/MarkdownFrontmatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protected function __construct(
/**
* @param array<string, mixed> | null $frontMatter
*/
public static function make(array $frontMatter = null): self
public static function make(?array $frontMatter = null): self
{
if (! $frontMatter) {
$frontMatter = [];
Expand Down
Loading

0 comments on commit fa658e0

Please sign in to comment.