mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
chore: added new rector rules (#974)
This commit is contained in:
@@ -40,7 +40,7 @@ class IndexAction
|
||||
$this->filter($builder, $query, $schema, $scope);
|
||||
|
||||
// special case: only apply HasFilter to top-level models
|
||||
if (! empty($schema->allowedIncludes())) {
|
||||
if (filled($schema->allowedIncludes())) {
|
||||
$hasFilter = new HasFilter($schema->allowedIncludes());
|
||||
foreach ($query->getFilterCriteria() as $criteria) {
|
||||
if ($criteria->shouldFilter($hasFilter, $scope)) {
|
||||
|
||||
@@ -43,7 +43,7 @@ class StoreTrackAction
|
||||
|
||||
$track = $storeAction->store($builder, $trackParameters);
|
||||
|
||||
if (! empty($nextHashid) && empty($previousHashid)) {
|
||||
if (filled($nextHashid) && blank($previousHashid)) {
|
||||
/** @var PlaylistTrack $next */
|
||||
$next = PlaylistTrack::query()
|
||||
->with(PlaylistTrack::RELATION_PREVIOUS)
|
||||
@@ -56,7 +56,7 @@ class StoreTrackAction
|
||||
$insertAction->insertBefore($playlist, $track, $next);
|
||||
}
|
||||
|
||||
if (! empty($previousHashid) && empty($nextHashid)) {
|
||||
if (filled($previousHashid) && blank($nextHashid)) {
|
||||
/** @var PlaylistTrack $previous */
|
||||
$previous = PlaylistTrack::query()
|
||||
->with(PlaylistTrack::RELATION_NEXT)
|
||||
@@ -69,7 +69,7 @@ class StoreTrackAction
|
||||
$insertAction->insertAfter($playlist, $track, $previous);
|
||||
}
|
||||
|
||||
if (empty($nextHashid) && empty($previousHashid)) {
|
||||
if (blank($nextHashid) && blank($previousHashid)) {
|
||||
$insertAction = new InsertTrackAction();
|
||||
|
||||
$insertAction->insert($playlist, $track);
|
||||
|
||||
@@ -40,13 +40,13 @@ class UpdateTrackAction
|
||||
|
||||
$updateAction->update($track, $trackParameters);
|
||||
|
||||
if (! empty($nextHashid) || ! empty($previousHashid)) {
|
||||
if (filled($nextHashid) || filled($previousHashid)) {
|
||||
$removeAction = new RemoveTrackAction();
|
||||
|
||||
$removeAction->remove($playlist, $track);
|
||||
}
|
||||
|
||||
if (! empty($nextHashid) && empty($previousHashid)) {
|
||||
if (filled($nextHashid) && blank($previousHashid)) {
|
||||
$next = PlaylistTrack::query()
|
||||
->with(PlaylistTrack::RELATION_PREVIOUS)
|
||||
->where(PlaylistTrack::ATTRIBUTE_PLAYLIST, $playlist->getKey())
|
||||
@@ -58,7 +58,7 @@ class UpdateTrackAction
|
||||
$insertAction->insertBefore($playlist, $track, $next);
|
||||
}
|
||||
|
||||
if (! empty($previousHashid) && empty($nextHashid)) {
|
||||
if (filled($previousHashid) && blank($nextHashid)) {
|
||||
$previous = PlaylistTrack::query()
|
||||
->with(PlaylistTrack::RELATION_NEXT)
|
||||
->where(PlaylistTrack::ATTRIBUTE_PLAYLIST, $playlist->getKey())
|
||||
|
||||
@@ -22,7 +22,7 @@ class AttachImageAction
|
||||
foreach ($facets as $facet) {
|
||||
$image = Arr::get($fields, $facet->name);
|
||||
|
||||
if (empty($image)) {
|
||||
if (blank($image)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ class BackfillAnimeAction extends BackfillWikiAction
|
||||
$id = Arr::get($studio, 'id');
|
||||
$name = Arr::get($studio, 'name');
|
||||
|
||||
if (empty($name) || empty($id)) {
|
||||
if (blank($name) || blank($id)) {
|
||||
Log::info("Skipping empty studio of name '$name' and id '$id''");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class AllowAudioStreams
|
||||
{
|
||||
public function resolve(?User $user): bool
|
||||
{
|
||||
if (! empty($user?->can(SpecialPermission::BYPASS_FEATURE_FLAGS->value))) {
|
||||
if (filled($user?->can(SpecialPermission::BYPASS_FEATURE_FLAGS->value))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ class AllowDumpDownloading
|
||||
{
|
||||
public function resolve(?User $user): bool
|
||||
{
|
||||
if (! empty($user?->can(SpecialPermission::BYPASS_FEATURE_FLAGS->value))) {
|
||||
if (filled($user?->can(SpecialPermission::BYPASS_FEATURE_FLAGS->value))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ class AllowExternalProfileManagement
|
||||
{
|
||||
public function resolve(?User $user): bool
|
||||
{
|
||||
if (! empty($user?->can(SpecialPermission::BYPASS_FEATURE_FLAGS->value))) {
|
||||
if (filled($user?->can(SpecialPermission::BYPASS_FEATURE_FLAGS->value))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ class AllowPlaylistManagement
|
||||
{
|
||||
public function resolve(?User $user): bool
|
||||
{
|
||||
if (! empty($user?->can(SpecialPermission::BYPASS_FEATURE_FLAGS->value))) {
|
||||
if (filled($user?->can(SpecialPermission::BYPASS_FEATURE_FLAGS->value))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ class AllowReport
|
||||
{
|
||||
public function resolve(?User $user): bool
|
||||
{
|
||||
if (! empty($user?->can(SpecialPermission::BYPASS_FEATURE_FLAGS->value))) {
|
||||
if (filled($user?->can(SpecialPermission::BYPASS_FEATURE_FLAGS->value))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ class AllowScriptDownloading
|
||||
{
|
||||
public function resolve(?User $user): bool
|
||||
{
|
||||
if (! empty($user?->can(SpecialPermission::BYPASS_FEATURE_FLAGS->value))) {
|
||||
if (filled($user?->can(SpecialPermission::BYPASS_FEATURE_FLAGS->value))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ class AllowVideoStreams
|
||||
{
|
||||
public function resolve(?User $user): bool
|
||||
{
|
||||
if (! empty($user?->can(SpecialPermission::BYPASS_FEATURE_FLAGS->value))) {
|
||||
if (filled($user?->can(SpecialPermission::BYPASS_FEATURE_FLAGS->value))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ class FeaturedTheme extends BaseResource
|
||||
->rules([
|
||||
fn (Get $get): Closure => (fn (): array => [
|
||||
Rule::when(
|
||||
! empty($get(FeaturedThemeModel::RELATION_ENTRY)) && ! empty($get(FeaturedThemeModel::RELATION_VIDEO)),
|
||||
filled($get(FeaturedThemeModel::RELATION_ENTRY)) && filled($get(FeaturedThemeModel::RELATION_VIDEO)),
|
||||
[
|
||||
Rule::exists(AnimeThemeEntryVideo::class, AnimeThemeEntryVideo::ATTRIBUTE_ENTRY)
|
||||
->where(AnimeThemeEntryVideo::ATTRIBUTE_VIDEO, $get(FeaturedThemeModel::RELATION_VIDEO)),
|
||||
@@ -121,7 +121,7 @@ class FeaturedTheme extends BaseResource
|
||||
->rules([
|
||||
fn (Get $get): Closure => (fn (): array => [
|
||||
Rule::when(
|
||||
! empty($get(FeaturedThemeModel::RELATION_ENTRY)) && ! empty($get(FeaturedThemeModel::RELATION_VIDEO)),
|
||||
filled($get(FeaturedThemeModel::RELATION_ENTRY)) && filled($get(FeaturedThemeModel::RELATION_VIDEO)),
|
||||
[
|
||||
Rule::exists(AnimeThemeEntryVideo::class, AnimeThemeEntryVideo::ATTRIBUTE_VIDEO)
|
||||
->where(AnimeThemeEntryVideo::ATTRIBUTE_ENTRY, $get(FeaturedThemeModel::RELATION_ENTRY)),
|
||||
|
||||
@@ -104,7 +104,7 @@ class Track extends BaseResource
|
||||
->rules([
|
||||
fn (Get $get): Closure => (fn (): array => [
|
||||
Rule::when(
|
||||
! empty($get(TrackModel::RELATION_ENTRY)) && ! empty($get(TrackModel::RELATION_VIDEO)),
|
||||
filled($get(TrackModel::RELATION_ENTRY)) && filled($get(TrackModel::RELATION_VIDEO)),
|
||||
[
|
||||
Rule::exists(AnimeThemeEntryVideo::class, AnimeThemeEntryVideo::ATTRIBUTE_ENTRY)
|
||||
->where(AnimeThemeEntryVideo::ATTRIBUTE_VIDEO, $get(TrackModel::RELATION_VIDEO)),
|
||||
@@ -119,7 +119,7 @@ class Track extends BaseResource
|
||||
->rules([
|
||||
fn (Get $get): Closure => (fn (): array => [
|
||||
Rule::when(
|
||||
! empty($get(TrackModel::RELATION_ENTRY)) && ! empty($get(TrackModel::RELATION_VIDEO)),
|
||||
filled($get(TrackModel::RELATION_ENTRY)) && filled($get(TrackModel::RELATION_VIDEO)),
|
||||
[
|
||||
Rule::exists(AnimeThemeEntryVideo::class, AnimeThemeEntryVideo::ATTRIBUTE_VIDEO)
|
||||
->where(AnimeThemeEntryVideo::ATTRIBUTE_ENTRY, $get(TrackModel::RELATION_ENTRY)),
|
||||
|
||||
@@ -283,19 +283,19 @@ class Theme extends BaseResource
|
||||
$slug = Str::of('');
|
||||
$type = $get(ThemeModel::ATTRIBUTE_TYPE);
|
||||
|
||||
if (! empty($type) || $type !== null) {
|
||||
if (filled($type) || $type !== null) {
|
||||
$slug = $slug->append($type->name);
|
||||
}
|
||||
|
||||
if ($slug->isNotEmpty() && $type !== ThemeType::IN) {
|
||||
$sequence = $get(ThemeModel::ATTRIBUTE_SEQUENCE);
|
||||
$slug = $slug->append(strval(empty($sequence) ? 1 : $sequence));
|
||||
$slug = $slug->append(strval(blank($sequence) ? 1 : $sequence));
|
||||
}
|
||||
|
||||
if ($slug->isNotEmpty()) {
|
||||
$group = $get(ThemeModel::ATTRIBUTE_GROUP);
|
||||
|
||||
if (! empty($group)) {
|
||||
if (filled($group)) {
|
||||
$slug = $slug->append('-'.Group::query()->find(intval($group))->slug);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class PlaylistTrackEntryIdField extends Field implements CreatableField, Require
|
||||
'integer',
|
||||
Rule::exists(AnimeThemeEntry::class, AnimeThemeEntry::ATTRIBUTE_ID),
|
||||
Rule::when(
|
||||
! empty($videoId),
|
||||
filled($videoId),
|
||||
[
|
||||
Rule::exists(AnimeThemeEntryVideo::class, AnimeThemeEntryVideo::ATTRIBUTE_ENTRY)
|
||||
->where(AnimeThemeEntryVideo::ATTRIBUTE_VIDEO, $videoId),
|
||||
|
||||
@@ -59,7 +59,7 @@ class PlaylistTrackVideoIdField extends Field implements CreatableField, Require
|
||||
'integer',
|
||||
Rule::exists(Video::class, Video::ATTRIBUTE_ID),
|
||||
Rule::when(
|
||||
! empty($entryId),
|
||||
filled($entryId),
|
||||
[
|
||||
Rule::exists(AnimeThemeEntryVideo::class, AnimeThemeEntryVideo::ATTRIBUTE_VIDEO)
|
||||
->where(AnimeThemeEntryVideo::ATTRIBUTE_ENTRY, $entryId),
|
||||
|
||||
@@ -56,14 +56,14 @@ class HasCriteria extends Criteria
|
||||
$filterPart = $filterParts->pop();
|
||||
|
||||
// Set logical operator
|
||||
if (empty($field) && BinaryLogicalOperator::unstrictCoerce($filterPart) instanceof BinaryLogicalOperator) {
|
||||
if (blank($field) && BinaryLogicalOperator::unstrictCoerce($filterPart) instanceof BinaryLogicalOperator) {
|
||||
$logicalOperator = BinaryLogicalOperator::unstrictCoerce($filterPart);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Set count
|
||||
if (
|
||||
empty($field)
|
||||
blank($field)
|
||||
&& filter_var($filterPart, FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE) !== null
|
||||
) {
|
||||
$count = filter_var($filterPart, FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE);
|
||||
@@ -71,13 +71,13 @@ class HasCriteria extends Criteria
|
||||
}
|
||||
|
||||
// Set comparison operator
|
||||
if (empty($field) && ComparisonOperator::unstrictCoerce($filterPart) instanceof ComparisonOperator) {
|
||||
if (blank($field) && ComparisonOperator::unstrictCoerce($filterPart) instanceof ComparisonOperator) {
|
||||
$comparisonOperator = ComparisonOperator::unstrictCoerce($filterPart);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Set found has param
|
||||
if (empty($field) && $filterPart === HasCriteria::PARAM_VALUE) {
|
||||
if (blank($field) && $filterPart === HasCriteria::PARAM_VALUE) {
|
||||
$field = $filterPart;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,19 +39,19 @@ class WhereCriteria extends Criteria
|
||||
$filterPart = $filterParts->pop();
|
||||
|
||||
// Set logical operator
|
||||
if (empty($field) && BinaryLogicalOperator::unstrictCoerce($filterPart) instanceof BinaryLogicalOperator) {
|
||||
if (blank($field) && BinaryLogicalOperator::unstrictCoerce($filterPart) instanceof BinaryLogicalOperator) {
|
||||
$logicalOperator = BinaryLogicalOperator::unstrictCoerce($filterPart);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Set comparison operator
|
||||
if (empty($field) && ComparisonOperator::unstrictCoerce($filterPart) instanceof ComparisonOperator) {
|
||||
if (blank($field) && ComparisonOperator::unstrictCoerce($filterPart) instanceof ComparisonOperator) {
|
||||
$comparisonOperator = ComparisonOperator::unstrictCoerce($filterPart);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Set field
|
||||
if (empty($field)) {
|
||||
if (blank($field)) {
|
||||
$field = Str::lower($filterPart);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,19 +48,19 @@ class WhereInCriteria extends Criteria
|
||||
$filterPart = $filterParts->pop();
|
||||
|
||||
// Set Not
|
||||
if (empty($field) && UnaryLogicalOperator::unstrictCoerce($filterPart) instanceof UnaryLogicalOperator) {
|
||||
if (blank($field) && UnaryLogicalOperator::unstrictCoerce($filterPart) instanceof UnaryLogicalOperator) {
|
||||
$not = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Set operator
|
||||
if (empty($field) && BinaryLogicalOperator::unstrictCoerce($filterPart) instanceof BinaryLogicalOperator) {
|
||||
if (blank($field) && BinaryLogicalOperator::unstrictCoerce($filterPart) instanceof BinaryLogicalOperator) {
|
||||
$operator = BinaryLogicalOperator::unstrictCoerce($filterPart);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Set field
|
||||
if (empty($field)) {
|
||||
if (blank($field)) {
|
||||
$field = Str::lower($filterPart);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class FeaturedThemeEntryIdField extends Field implements CreatableField, Selecta
|
||||
'integer',
|
||||
Rule::exists(AnimeThemeEntry::class, AnimeThemeEntry::ATTRIBUTE_ID),
|
||||
Rule::when(
|
||||
! empty($videoId),
|
||||
filled($videoId),
|
||||
[
|
||||
Rule::exists(AnimeThemeEntryVideo::class, AnimeThemeEntryVideo::ATTRIBUTE_ENTRY)
|
||||
->where(AnimeThemeEntryVideo::ATTRIBUTE_VIDEO, $this->resolveVideoId($request)),
|
||||
@@ -58,7 +58,7 @@ class FeaturedThemeEntryIdField extends Field implements CreatableField, Selecta
|
||||
'integer',
|
||||
Rule::exists(AnimeThemeEntry::class, AnimeThemeEntry::ATTRIBUTE_ID),
|
||||
Rule::when(
|
||||
! empty($videoId),
|
||||
filled($videoId),
|
||||
[
|
||||
Rule::exists(AnimeThemeEntryVideo::class, AnimeThemeEntryVideo::ATTRIBUTE_ENTRY)
|
||||
->where(AnimeThemeEntryVideo::ATTRIBUTE_VIDEO, $this->resolveVideoId($request)),
|
||||
|
||||
@@ -33,7 +33,7 @@ class FeaturedThemeVideoIdField extends Field implements CreatableField, Selecta
|
||||
'integer',
|
||||
Rule::exists(Video::class, Video::ATTRIBUTE_ID),
|
||||
Rule::when(
|
||||
! empty($entryId),
|
||||
filled($entryId),
|
||||
[
|
||||
Rule::exists(AnimeThemeEntryVideo::class, AnimeThemeEntryVideo::ATTRIBUTE_VIDEO)
|
||||
->where(AnimeThemeEntryVideo::ATTRIBUTE_ENTRY, $this->resolveEntryId($request)),
|
||||
@@ -58,7 +58,7 @@ class FeaturedThemeVideoIdField extends Field implements CreatableField, Selecta
|
||||
'integer',
|
||||
Rule::exists(Video::class, Video::ATTRIBUTE_ID),
|
||||
Rule::when(
|
||||
! empty($entryId),
|
||||
filled($entryId),
|
||||
[
|
||||
Rule::exists(AnimeThemeEntryVideo::class, AnimeThemeEntryVideo::ATTRIBUTE_VIDEO)
|
||||
->where(AnimeThemeEntryVideo::ATTRIBUTE_ENTRY, $this->resolveEntryId($request)),
|
||||
|
||||
@@ -58,7 +58,7 @@ class TrackEntryIdField extends Field implements CreatableField, FilterableField
|
||||
'integer',
|
||||
Rule::exists(AnimeThemeEntry::class, AnimeThemeEntry::ATTRIBUTE_ID),
|
||||
Rule::when(
|
||||
! empty($videoId),
|
||||
filled($videoId),
|
||||
[
|
||||
Rule::exists(AnimeThemeEntryVideo::class, AnimeThemeEntryVideo::ATTRIBUTE_ENTRY)
|
||||
->where(AnimeThemeEntryVideo::ATTRIBUTE_VIDEO, $videoId),
|
||||
|
||||
@@ -58,7 +58,7 @@ class TrackVideoIdField extends Field implements CreatableField, FilterableField
|
||||
'integer',
|
||||
Rule::exists(Video::class, Video::ATTRIBUTE_ID),
|
||||
Rule::when(
|
||||
! empty($entryId),
|
||||
filled($entryId),
|
||||
[
|
||||
Rule::exists(AnimeThemeEntryVideo::class, AnimeThemeEntryVideo::ATTRIBUTE_VIDEO)
|
||||
->where(AnimeThemeEntryVideo::ATTRIBUTE_ENTRY, $this->resolveEntryId($request)),
|
||||
|
||||
@@ -72,7 +72,7 @@ abstract class EloquentSchema extends Schema
|
||||
|
||||
$appendPath = Str::of('');
|
||||
foreach (explode('.', $allowedInclude->path()) as $path) {
|
||||
$appendPath = $appendPath->append(empty($appendPath->__toString()) ? '' : '.', $path);
|
||||
$appendPath = $appendPath->append(blank($appendPath->__toString()) ? '' : '.', $path);
|
||||
|
||||
$stringAppendPath = $appendPath->__toString();
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ class ScopeParser
|
||||
*/
|
||||
public static function parse(string $scope): Scope
|
||||
{
|
||||
if (empty($scope)) {
|
||||
if (blank($scope)) {
|
||||
return new GlobalScope();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Models\Auth\User;
|
||||
use Closure;
|
||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||
use GraphQL\Language\Parser;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
@@ -58,7 +59,7 @@ class RateLimitPerQuery
|
||||
|
||||
foreach (range(1, $hits) as $_) {
|
||||
if (RateLimiter::tooManyAttempts($key, 80)) {
|
||||
return response()->json([
|
||||
return new JsonResponse([
|
||||
'message' => 'Too many requests',
|
||||
], 429);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class UserExceedsReportLimit
|
||||
$user = $request->user('sanctum');
|
||||
|
||||
abort_if(intval($user?->reports->where(Report::ATTRIBUTE_STATUS, ApprovableStatus::PENDING->value)->count()) >= $reportLimit
|
||||
&& empty($user?->can(SpecialPermission::BYPASS_FEATURE_FLAGS->value)), 403, "User cannot have more than '$reportLimit' outstanding reports.");
|
||||
&& blank($user?->can(SpecialPermission::BYPASS_FEATURE_FLAGS->value)), 403, "User cannot have more than '$reportLimit' outstanding reports.");
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class PlaylistExceedsTrackLimit
|
||||
$user = $request->user('sanctum');
|
||||
|
||||
abort_if(intval($playlist?->tracks()?->count()) >= $trackLimit
|
||||
&& empty($user?->can(SpecialPermission::BYPASS_FEATURE_FLAGS->value)), 403, "Playlists cannot contain more than '$trackLimit' tracks.");
|
||||
&& blank($user?->can(SpecialPermission::BYPASS_FEATURE_FLAGS->value)), 403, "Playlists cannot contain more than '$trackLimit' tracks.");
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class UserExceedsExternalProfileLimit
|
||||
$user = $request->user('sanctum');
|
||||
|
||||
abort_if(intval($user?->externalprofiles()?->count()) >= $profileLimit
|
||||
&& empty($user?->can(SpecialPermission::BYPASS_FEATURE_FLAGS->value)), 403, "User cannot have more than '$profileLimit' external profiles.");
|
||||
&& blank($user?->can(SpecialPermission::BYPASS_FEATURE_FLAGS->value)), 403, "User cannot have more than '$profileLimit' external profiles.");
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class UserExceedsPlaylistLimit
|
||||
$user = $request->user('sanctum');
|
||||
|
||||
abort_if(intval($user?->playlists()?->count()) >= $playlistLimit
|
||||
&& empty($user?->can(SpecialPermission::BYPASS_FEATURE_FLAGS->value)), 403, "User cannot have more than '$playlistLimit' playlists.");
|
||||
&& blank($user?->can(SpecialPermission::BYPASS_FEATURE_FLAGS->value)), 403, "User cannot have more than '$playlistLimit' playlists.");
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ abstract class ReadRequest extends BaseRequest
|
||||
{
|
||||
$schema = $this->schema();
|
||||
|
||||
if (empty($schema->allowedIncludes())) {
|
||||
if (blank($schema->allowedIncludes())) {
|
||||
return $this->prohibit(IncludeParser::param());
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ class SearchRequest extends ReadRequest
|
||||
|
||||
$resourceIncludes = $resourceSchema->allowedIncludes();
|
||||
|
||||
if (! empty($resourceIncludes)) {
|
||||
if (filled($resourceIncludes)) {
|
||||
$types[] = $resourceSchema->type();
|
||||
|
||||
$param = Str::of(IncludeParser::param())->append('.')->append($resourceSchema->type())->__toString();
|
||||
|
||||
@@ -168,7 +168,7 @@ class AnimeThemeEntry extends BaseModel implements HasResources, InteractsWithSc
|
||||
$array['theme'] = $theme->toSearchableArray();
|
||||
|
||||
// Overwrite version with readable format "v{#}"
|
||||
$array['version'] = Str::of(empty($this->version) ? '1' : $this->version)->prepend('v')->__toString();
|
||||
$array['version'] = Str::of(blank($this->version) ? '1' : $this->version)->prepend('v')->__toString();
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ class Song extends BaseModel implements HasResources, SoftDeletable
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
if (empty($this->title)) {
|
||||
if (blank($this->title)) {
|
||||
return strval($this->getKey());
|
||||
}
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ class Video extends BaseModel implements HasAggregateLikes, HasAggregateViews, L
|
||||
if ($this->source === VideoSource::BD || $this->source === VideoSource::DVD) {
|
||||
$tags[] = $this->source->localize();
|
||||
}
|
||||
if (! empty($this->resolution) && $this->resolution !== 720) {
|
||||
if (filled($this->resolution) && $this->resolution !== 720) {
|
||||
$tags[] = strval($this->resolution);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ class ModerationRule implements ValidationRule
|
||||
|
||||
$flagged = Arr::get($response, 'results.0.flagged');
|
||||
|
||||
if (! empty($flagged)) {
|
||||
if (filled($flagged)) {
|
||||
$fail(__('validation.moderation', ['attribute' => $attribute]));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
|
||||
@@ -21,7 +21,7 @@ readonly class ResourceSiteMatchesLinkRule implements ValidationRule
|
||||
{
|
||||
$domain = ResourceSite::getDomain($value);
|
||||
|
||||
if (! empty($domain) && $domain !== Uri::of($this->link)->host()) {
|
||||
if (filled($domain) && $domain !== Uri::of($this->link)->host()) {
|
||||
$fail(__('validation.resource_link_site_mismatch'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class ExtraneousChaptersFormatRule extends SubmissionRule
|
||||
return;
|
||||
}
|
||||
|
||||
if (! empty($this->chapters())) {
|
||||
if (filled($this->chapters())) {
|
||||
$fail(__('validation.submission.format_extraneous_chapters'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ abstract class Schema implements SchemaInterface
|
||||
|
||||
$appendPath = Str::of('');
|
||||
foreach (explode('.', $allowedInclude->path()) as $path) {
|
||||
$appendPath = $appendPath->append(empty($appendPath->__toString()) ? '' : '.', $path);
|
||||
$appendPath = $appendPath->append(blank($appendPath->__toString()) ? '' : '.', $path);
|
||||
|
||||
$stringAppendPath = $appendPath->__toString();
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class ImportModelsSeeder extends Seeder
|
||||
public function run(): void
|
||||
{
|
||||
$driver = Config::get('scout.driver');
|
||||
if (empty($driver)) {
|
||||
if (blank($driver)) {
|
||||
$this->command->info('No driver configured for Scout. Skipping models importing.');
|
||||
|
||||
return;
|
||||
|
||||
+11
-1
@@ -6,11 +6,15 @@ use Rector\Caching\ValueObject\Storage\FileCacheStorage;
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector;
|
||||
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
|
||||
use RectorLaravel\Rector\Empty_\EmptyToBlankAndFilledFuncRector;
|
||||
use RectorLaravel\Rector\FuncCall\RemoveDumpDataDeadCodeRector;
|
||||
use RectorLaravel\Rector\MethodCall\ResponseHelperCallToJsonResponseRector;
|
||||
use RectorLaravel\Set\LaravelSetList;
|
||||
use RectorLaravel\Set\LaravelSetProvider;
|
||||
|
||||
return RectorConfig::configure()
|
||||
->withSetProviders(LaravelSetProvider::class)
|
||||
->withComposerBased(laravel: true)
|
||||
->withSets([
|
||||
LaravelSetList::LARAVEL_ARRAYACCESS_TO_METHOD_CALL,
|
||||
LaravelSetList::LARAVEL_ARRAY_STR_FUNCTION_TO_STATIC_CALL,
|
||||
@@ -22,7 +26,13 @@ return RectorConfig::configure()
|
||||
LaravelSetList::LARAVEL_IF_HELPERS,
|
||||
LaravelSetList::LARAVEL_LEGACY_FACTORIES_TO_CLASSES,
|
||||
])
|
||||
->withComposerBased(laravel: true)
|
||||
->withRules([
|
||||
ResponseHelperCallToJsonResponseRector::class,
|
||||
EmptyToBlankAndFilledFuncRector::class,
|
||||
])
|
||||
->withConfiguredRule(RemoveDumpDataDeadCodeRector::class, [
|
||||
'dd', 'dump', 'var_dump',
|
||||
])
|
||||
->withCache(
|
||||
cacheDirectory: '/tmp/rector',
|
||||
cacheClass: FileCacheStorage::class,
|
||||
|
||||
Reference in New Issue
Block a user