diff --git a/src/Commands/Commandable.php b/src/Commands/Commandable.php index 219b5a34..625f310d 100644 --- a/src/Commands/Commandable.php +++ b/src/Commands/Commandable.php @@ -45,7 +45,7 @@ public function askOnProduction(Closure $closure = null, bool $with_force = true $force = $this->option($option) ?? false; } - if ('local' !== config('app.env') && ! $force) { + if (config('app.env') !== 'local' && ! $force) { if ($this->confirm("You're on production, do you really want to continue?", true)) { $this->info('Confirmed.'); } else { diff --git a/src/Commands/TagCleanCommand.php b/src/Commands/TagCleanCommand.php index 027009f5..72c8dbbd 100644 --- a/src/Commands/TagCleanCommand.php +++ b/src/Commands/TagCleanCommand.php @@ -37,14 +37,14 @@ public function handle() foreach ($taggables as $row) { $model = $row->taggable_type::find($row->taggable_id); - if (null === $model) { + if ($model === null) { DB::table($taggables)->where('id', $row->id)->delete(); $this->warn("Deleted taggable entry: {$row->taggable_type} #{$row->taggable_id}"); } $tag = DB::table('tags')->find($row->tag_id); - if (null === $tag) { + if ($tag === null) { DB::table($taggables)->where('id', $row->id)->delete(); $this->warn("Deleted taggable entry: Tag #{$row->id}"); } diff --git a/src/Engines/SearchEngine.php b/src/Engines/SearchEngine.php index 3069a8bf..d40864be 100644 --- a/src/Engines/SearchEngine.php +++ b/src/Engines/SearchEngine.php @@ -36,7 +36,7 @@ public function __construct( */ public static function create(?string $q = '', bool $relevant = false, bool $opds = false, string|array $types = null): SearchEngine { - if ('string' === gettype($types)) { + if (gettype($types) === 'string') { $types = explode(',', $types); } diff --git a/src/Filament/Components/DescriptionInput.php b/src/Filament/Components/DescriptionInput.php index a46f5f2a..c95b094a 100644 --- a/src/Filament/Components/DescriptionInput.php +++ b/src/Filament/Components/DescriptionInput.php @@ -16,7 +16,7 @@ public static function make( int $width = 1, bool $required = false, ): Forms\Components\Textarea { - if (null === $helper && $metaField) { + if ($helper === null && $metaField) { $transGenerate = __('steward::filament.form_helper.generate'); $transMetaField = __('steward::filament.form_helper.meta_description'); $onlyOn = __('steward::filament.form_helper.only_on'); diff --git a/src/Filament/Components/NameInput.php b/src/Filament/Components/NameInput.php index 91b85c4e..1ea704b3 100644 --- a/src/Filament/Components/NameInput.php +++ b/src/Filament/Components/NameInput.php @@ -18,7 +18,7 @@ public static function make( int $width = 1, bool $required = true, ): Forms\Components\TextInput { - if (null === $helper) { + if ($helper === null) { $transGenerate = __('steward::filament.form_helper.generate'); $fieldName = __('steward::filament.form_helper.metalink').' '.__('steward::filament.form_helper.and').' '.__('steward::filament.form_helper.meta_title'); diff --git a/src/Filament/Config/FilamentForm.php b/src/Filament/Config/FilamentForm.php index cad8408e..4b40de33 100644 --- a/src/Filament/Config/FilamentForm.php +++ b/src/Filament/Config/FilamentForm.php @@ -33,7 +33,7 @@ public static function name( int $width = 1, bool $required = true, ) { - if (null === $helper) { + if ($helper === null) { $transGenerate = __('steward::filament.form_helper.generate'); $fieldName = __('steward::filament.form_helper.metalink').' and '.__('steward::filament.form_helper.meta_title'); @@ -82,7 +82,7 @@ public static function description( int $width = 1, bool $required = false, ) { - if (null === $helper && $metaField) { + if ($helper === null && $metaField) { $transGenerate = __('steward::filament.form_helper.generate'); $transMetaField = __('steward::filament.form_helper.meta_description'); $onlyOn = __('steward::filament.form_helper.only_on'); diff --git a/src/Filament/Pages/Auth/Login.php b/src/Filament/Pages/Auth/Login.php index 70da2059..3a20df83 100644 --- a/src/Filament/Pages/Auth/Login.php +++ b/src/Filament/Pages/Auth/Login.php @@ -10,7 +10,7 @@ public function mount(): void { parent::mount(); - if ('local' === config('app.env')) { + if (config('app.env') === 'local') { $this->form->fill([ 'email' => config('app.admin.email'), 'password' => config('app.admin.password'), diff --git a/src/Jobs/ProcessFavicon.php b/src/Jobs/ProcessFavicon.php index 01567160..3575c1a5 100644 --- a/src/Jobs/ProcessFavicon.php +++ b/src/Jobs/ProcessFavicon.php @@ -80,7 +80,7 @@ private function setIcon(string $path) return; } - $is_svg = 'svg' === File::extension($path); + $is_svg = File::extension($path) === 'svg'; if ($is_svg) { if (extension_loaded('imagick')) { diff --git a/src/Models/Submission.php b/src/Models/Submission.php index 429a0917..995e1ace 100644 --- a/src/Models/Submission.php +++ b/src/Models/Submission.php @@ -9,8 +9,8 @@ class Submission extends Model { - use HasFactory; use HasAttachment; + use HasFactory; use Mediable; protected $fillable = [ diff --git a/src/Services/Datayable/DatayableService.php b/src/Services/Datayable/DatayableService.php index a0f75ca6..c113a06f 100644 --- a/src/Services/Datayable/DatayableService.php +++ b/src/Services/Datayable/DatayableService.php @@ -66,6 +66,7 @@ public function merge(?array $json): array } $data = []; + /** @var DatayableItem $item */ foreach ($this->data as $key => $item) { $is_array = false; diff --git a/src/Services/DirectoryService.php b/src/Services/DirectoryService.php index fec7d1a7..6d094496 100644 --- a/src/Services/DirectoryService.php +++ b/src/Services/DirectoryService.php @@ -95,7 +95,7 @@ private function parseDirectory(string $directory): Generator if (! is_dir($path)) { yield $path; - } elseif ('.' != $value && '..' != $value) { + } elseif ($value != '.' && $value != '..') { yield from $this->parseDirectory($path); yield $path; diff --git a/src/Services/Image/ColorThief.php b/src/Services/Image/ColorThief.php index cb1be3c1..cd42940f 100644 --- a/src/Services/Image/ColorThief.php +++ b/src/Services/Image/ColorThief.php @@ -103,8 +103,9 @@ private function isTransparentType(): bool private function handleGif(): mixed { $handle = imagecreatefromgif($this->image); + // IF IMAGE IS TRANSPARENT (alpha=127) RETURN fff FOR WHITE - if (127 == imagecolorsforindex($handle, imagecolorstotal($handle) - 1)['alpha']) { + if (imagecolorsforindex($handle, imagecolorstotal($handle) - 1)['alpha'] == 127) { $this->useDefault = true; return null; diff --git a/src/Services/MarkdownService.php b/src/Services/MarkdownService.php index 38fff69e..8bec397f 100644 --- a/src/Services/MarkdownService.php +++ b/src/Services/MarkdownService.php @@ -313,7 +313,7 @@ private function getConfig(): Environment 'default_attributes' => [ Heading::class => [ 'class' => static function (Heading $node) { - if (1 === $node->getLevel()) { + if ($node->getLevel() === 1) { return 'title-main'; } }, diff --git a/src/Services/OpenGraph/OpenGraphItem.php b/src/Services/OpenGraph/OpenGraphItem.php index 208d21ca..ba255cd8 100644 --- a/src/Services/OpenGraph/OpenGraphItem.php +++ b/src/Services/OpenGraph/OpenGraphItem.php @@ -147,7 +147,7 @@ private function checkUrl(): string private function checkImage(): ?string { - if (0 === strpos($this->image, '/')) { + if (strpos($this->image, '/') === 0) { return "{$this->site_url}{$this->image}"; } diff --git a/src/Services/SlugService.php b/src/Services/SlugService.php index 140a0547..1cd4e1ad 100644 --- a/src/Services/SlugService.php +++ b/src/Services/SlugService.php @@ -82,10 +82,10 @@ private function setName(): string private function unique(string $name = null, int $counter = 0): string { - if (null === $name) { + if ($name === null) { $name = uniqid(); } - $updated_name = 0 == $counter ? $name : $name.'-'.$counter; + $updated_name = $counter == 0 ? $name : $name.'-'.$counter; if ($this->model->where($this->slugColumn, Str::slug($updated_name))->exists()) { return $this->unique($name, $counter + 1); diff --git a/src/Services/WikipediaService.php b/src/Services/WikipediaService.php index 03d56a46..40a4aba4 100644 --- a/src/Services/WikipediaService.php +++ b/src/Services/WikipediaService.php @@ -288,11 +288,12 @@ private function setQueries(): Collection } $lang = $this->language; + // If language attribute is unknown, set it to english. if ($this->languageAttribute && $this->attributeExistInModel($this->languageAttribute, $object)) { $lang = $object->{$this->languageAttribute}; - if ('unknown' === $lang || null === $lang) { + if ($lang === 'unknown' || $lang === null) { $lang = $this->language; } } diff --git a/src/Traits/HasBuilder.php b/src/Traits/HasBuilder.php index 1f2f2348..c0166ee6 100644 --- a/src/Traits/HasBuilder.php +++ b/src/Traits/HasBuilder.php @@ -78,7 +78,7 @@ public function getBuilderDataAttribute(): array */ private function checkArrayNested(mixed $array): mixed { - if (is_array($array) && 1 === count($array) && array_key_exists(0, $array)) { + if (is_array($array) && count($array) === 1 && array_key_exists(0, $array)) { return $array[0]; } diff --git a/src/Traits/HasGravatar.php b/src/Traits/HasGravatar.php index 6f89c6a5..c4430061 100644 --- a/src/Traits/HasGravatar.php +++ b/src/Traits/HasGravatar.php @@ -54,7 +54,7 @@ private function generateGravatar(string $email): string public static function bootHasGravatar() { static::creating(function (Model $model) { - if (null === $model->{$model->getGravatarColumn()}) { + if ($model->{$model->getGravatarColumn()} === null) { $model->{$model->getGravatarColumn()} = $model->generateGravatar($model->{$model->getGravatarEmailColumn()}); } }); diff --git a/src/Traits/HasTemplate.php b/src/Traits/HasTemplate.php index d5a94623..5302b11e 100644 --- a/src/Traits/HasTemplate.php +++ b/src/Traits/HasTemplate.php @@ -68,7 +68,7 @@ public function getTemplateDataAttribute(): array */ private function checkArrayNested(mixed $array): mixed { - if (is_array($array) && 1 === count($array) && array_key_exists(0, $array)) { + if (is_array($array) && count($array) === 1 && array_key_exists(0, $array)) { return $array[0]; } diff --git a/src/Traits/LazyEnum.php b/src/Traits/LazyEnum.php index cc8fa600..ea5f2d9e 100644 --- a/src/Traits/LazyEnum.php +++ b/src/Traits/LazyEnum.php @@ -77,7 +77,7 @@ public function getLabel(): ?string public static function getLocaleBaseName(): string { $class = new ReflectionClass(static::class); - $namespace = 'App\\Enums' === $class->getNamespaceName() ? '' : 'steward::'; + $namespace = $class->getNamespaceName() === 'App\\Enums' ? '' : 'steward::'; $class = $class->getShortName(); $class_slug = Str::kebab($class); $class_slug = str_replace('-enum', '', $class_slug); diff --git a/src/Traits/Mediable.php b/src/Traits/Mediable.php index 5a7402d2..acd469ea 100644 --- a/src/Traits/Mediable.php +++ b/src/Traits/Mediable.php @@ -40,7 +40,7 @@ public function getMediableAttribute(): object */ public function mediable(string $field = 'picture', bool $usePath = false): string|array|null { - if (null === $this->{$field}) { + if ($this->{$field} === null) { return \Kiwilan\Steward\StewardConfig::mediableDefault(); } $path = $usePath ? $field : $this->{$field}; diff --git a/tests/Data/Exports/BookExport.php b/tests/Data/Exports/BookExport.php index fae46df8..a11b17e1 100644 --- a/tests/Data/Exports/BookExport.php +++ b/tests/Data/Exports/BookExport.php @@ -12,7 +12,7 @@ use Maatwebsite\Excel\Concerns\WithMapping; use Spatie\QueryBuilder\QueryBuilder; -class BookExport implements FromQuery, WithHeadings, WithMapping, ShouldAutoSize +class BookExport implements FromQuery, ShouldAutoSize, WithHeadings, WithMapping { use Exportable; diff --git a/tests/Data/Models/Book.php b/tests/Data/Models/Book.php index 9967e230..48b31d96 100644 --- a/tests/Data/Models/Book.php +++ b/tests/Data/Models/Book.php @@ -16,8 +16,8 @@ class Book extends Model use HasSeo; use HasSlug; use HasTimeToRead; - use Queryable; use Publishable; + use Queryable; protected $slugColumn = 'slug_custom';