Skip to content

Commit

Permalink
chore: run rector
Browse files Browse the repository at this point in the history
  • Loading branch information
daveroverts committed Feb 26, 2025
1 parent 1d3f27e commit 4ee1aa4
Show file tree
Hide file tree
Showing 95 changed files with 282 additions and 365 deletions.
2 changes: 1 addition & 1 deletion app/Console/Commands/EventCleanupReservationsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function handle()
}
EventCleanupReservationsJob::dispatch($event);
} else {
$this->withProgressBar(nextEvents(), function ($event) {
$this->withProgressBar(nextEvents(), function ($event): void {
EventCleanupReservationsJob::dispatch($event);
});
}
Expand Down
2 changes: 1 addition & 1 deletion app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Handler extends ExceptionHandler
*/
public function register(): void
{
$this->reportable(function (Throwable $e) {
$this->reportable(function (Throwable $e): void {
//
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ public function create(): View
$airportLink = new AirportLink();
$airportLinkTypes = AirportLinkType::pluck('name', 'id');
$airports = Airport::all(['id', 'icao', 'iata', 'name'])->keyBy('id')
->map(function ($airport) {
->map(fn ($airport) =>
/** @var Airport $airport */
return "$airport->icao | $airport->name | $airport->iata";
});
"$airport->icao | $airport->name | $airport->iata");
return view('airportLink.admin.form', compact('airportLink', 'airportLinkTypes', 'airports'));
}

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected function verifyLogin(Request $request)
$accessToken = $this->provider->getAccessToken('authorization_code', [
'code' => $request->input('code')
]);
} catch (IdentityProviderException $e) {
} catch (IdentityProviderException) {
flashMessage('error', 'Login failed', 'Something went wrong, please try again');
return to_route('home');
}
Expand Down
14 changes: 6 additions & 8 deletions app/Http/Controllers/Booking/BookingAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ public function create(Event $event, Request $request): View
{
$bulk = $request->bulk;
$airports = Airport::all(['id', 'icao', 'iata', 'name'])->keyBy('id')
->map(function ($airport) {
->map(fn ($airport) =>
/** @var Airport $airport */
return "$airport->icao | $airport->name | $airport->iata";
});
"$airport->icao | $airport->name | $airport->iata");

return view('booking.admin.create', compact('event', 'airports', 'bulk'));
}
Expand All @@ -63,7 +62,7 @@ public function store(StoreBooking $request): RedirectResponse
}
$time->second = 0;

if (!Flight::whereHas('booking', function ($query) use ($request) {
if (!Flight::whereHas('booking', function ($query) use ($request): void {
$query->where('event_id', $request->id);
})->where([
'ctot' => $time,
Expand Down Expand Up @@ -123,10 +122,9 @@ public function edit(Booking $booking): View|RedirectResponse
{
if ($booking->event->endEvent >= now()) {
$airports = Airport::all(['id', 'icao', 'iata', 'name'])->keyBy('id')
->map(function ($airport) {
->map(fn ($airport) =>
/** @var Airport $airport */
return "$airport->icao | $airport->name | $airport->iata";
});
"$airport->icao | $airport->name | $airport->iata");
$flight = $booking->flights()->first();
return view('booking.admin.edit', compact('booking', 'airports', 'flight'));
}
Expand Down Expand Up @@ -258,7 +256,7 @@ public function adminAutoAssign(AutoAssign $request, Event $event): RedirectResp
{
// @TODO Optimise this, for now it's a ugly fix
$bookings = $event->bookings()
->with(['flights' => function ($query) {
->with(['flights' => function ($query): void {
$query->orderBy('ctot');
}]);

Expand Down
16 changes: 8 additions & 8 deletions app/Http/Controllers/Booking/BookingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,21 +174,21 @@ public function update(UpdateBooking $request, Booking $booking): RedirectRespon
public function validateSELCAL($selcal, $eventId): ?string
{
// Separate characters
$char1 = substr($selcal, 0, 1);
$char2 = substr($selcal, 1, 1);
$char3 = substr($selcal, 3, 1);
$char4 = substr($selcal, 4, 1);
$char1 = substr((string) $selcal, 0, 1);
$char2 = substr((string) $selcal, 1, 1);
$char3 = substr((string) $selcal, 3, 1);
$char4 = substr((string) $selcal, 4, 1);

// Check if SELCAL has valid format
if (!preg_match("/[ABCDEFGHJKLMPQRS]{2}[-][ABCDEFGHJKLMPQRS]{2}/", $selcal)) {
if (!preg_match("/[ABCDEFGHJKLMPQRS]{2}[-][ABCDEFGHJKLMPQRS]{2}/", (string) $selcal)) {
return null;
}

// Check if each character is unique
if (substr_count($selcal, $char1) > 1 || substr_count($selcal, $char2) > 1 || substr_count(
$selcal,
if (substr_count((string) $selcal, $char1) > 1 || substr_count((string) $selcal, $char2) > 1 || substr_count(
(string) $selcal,
$char3
) > 1 || substr_count($selcal, $char4) > 1) {
) > 1 || substr_count((string) $selcal, $char4) > 1) {
return null;
}

Expand Down
12 changes: 5 additions & 7 deletions app/Http/Controllers/Event/EventAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ public function create(): View
{
$event = new Event();
$airports = Airport::all(['id', 'icao', 'iata', 'name'])->keyBy('id')
->map(function ($airport) {
->map(fn ($airport) =>
/** @var Airport $airport */
return "$airport->icao | $airport->name | $airport->iata";
});
"$airport->icao | $airport->name | $airport->iata");
$eventTypes = EventType::pluck('name', 'id');
return view('event.admin.form', compact('event', 'airports', 'eventTypes'));
}
Expand Down Expand Up @@ -83,10 +82,9 @@ public function show(Event $event): View
public function edit(Event $event): View
{
$airports = Airport::all(['id', 'icao', 'iata', 'name'])->keyBy('id')
->map(function ($airport) {
->map(fn ($airport) =>
/** @var Airport $airport */
return "$airport->icao | $airport->name | $airport->iata";
});
"$airport->icao | $airport->name | $airport->iata");
$eventTypes = EventType::pluck('name', 'id');
return view('event.admin.form', compact('event', 'airports', 'eventTypes'));
}
Expand Down Expand Up @@ -141,7 +139,7 @@ public function sendEmail(SendEmail $request, Event $event): JsonResponse|Redire
return response()->json(['success' => __('Email has been sent to yourself')]);
} else {
/* @var User $users */
$users = User::whereHas('bookings', function (Builder $query) use ($event) {
$users = User::whereHas('bookings', function (Builder $query) use ($event): void {
$query->where('event_id', $event->id);
$query->where('status', BookingStatus::BOOKED->value);
})->get();
Expand Down
5 changes: 2 additions & 3 deletions app/Http/Controllers/EventLink/EventLinkAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ public function create(): View
->orderBy('startEvent')
->get(['id', 'name', 'startEvent'])
->keyBy('id')
->map(function ($event) {
->map(fn ($event) =>
/** @var Event $event */
return "$event->name [{$event->startEvent->format('d-m-Y')}]";
});
"$event->name [{$event->startEvent->format('d-m-Y')}]");

return view('eventLink.admin.form', compact('eventLink', 'eventLinkTypes', 'events'));
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/OAuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static function updateToken($token): ?AccessToken
return $controller->getAccessToken('refresh_token', [
'refresh_token' => $token->getRefreshToken()
]);
} catch (IdentityProviderException $e) {
} catch (IdentityProviderException) {
return null;
}
}
Expand Down
12 changes: 5 additions & 7 deletions app/Http/View/Composers/EventsComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ public function __construct()
$this->events = Event::where('endEvent', '>', now())
->orderBy('startEvent')
->where('is_online', true)
->where(function ($query) {
->where(function ($query): void {
/** @var Builder $query */
$query->where('show_on_homepage', true)
->when(auth()->id(), function ($query, $userId) {
return $query->orWhereHas('bookings', function ($query) use ($userId) {
/** @var Builder $query */
$query->where('user_id', $userId);
});
});
->when(auth()->id(), fn ($query, $userId) => $query->orWhereHas('bookings', function ($query) use ($userId): void {
/** @var Builder $query */
$query->where('user_id', $userId);
}));
})->get();
}

Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/EventCleanupReservationsJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function handle(): void
{
$this->event->bookings()
->whereStatus(BookingStatus::RESERVED->value)
->each(function (Booking $booking) {
->each(function (Booking $booking): void {
if (now()->greaterThanOrEqualTo($booking->updated_at->addMinutes(10))) {
$booking->status = BookingStatus::UNASSIGNED;
$booking->user_id = null;
Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/ImportAirportsJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function handle(): void
file_get_contents('https://raw.githubusercontent.com/mborsetti/airportsdata/main/airportsdata/airports.csv')
);
(new AirportsImport())->queue($file)->chain([
function () use ($file) {
function () use ($file): void {
Storage::delete($file);
}
]);
Expand Down
19 changes: 7 additions & 12 deletions app/Livewire/Bookings.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Bookings extends Component

public function setFilter($filter): void
{
$this->filter = strtolower($filter);
$this->filter = strtolower((string) $filter);

unset($this->bookings);
}
Expand Down Expand Up @@ -79,17 +79,12 @@ public function bookings()
'flights.airportDep',
'flights.airportArr',
])
->withWhereHas('flights', function (Builder|HasMany $query) {
switch ($this->filter) {
case 'departures':
$query->where('dep', $this->event->dep)->orderBy('ctot');
break;
case 'arrivals':
$query->where('arr', $this->event->arr)->orderBy('eta');
break;
default:
$query->orderBy('eta')->orderBy('ctot');
}
->withWhereHas('flights', function (Builder|HasMany $query): void {
match ($this->filter) {
'departures' => $query->where('dep', $this->event->dep)->orderBy('ctot'),
'arrivals' => $query->where('arr', $this->event->arr)->orderBy('eta'),
default => $query->orderBy('eta')->orderBy('ctot'),
};
})
->get()
->sortBy(function ($booking) {
Expand Down
6 changes: 3 additions & 3 deletions app/Models/Airport.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Airport extends Model
*/
protected static function booted()
{
static::addGlobalScope('order', function (Builder $builder) {
static::addGlobalScope('order', function (Builder $builder): void {
$builder->orderBy('icao');
});
}
Expand Down Expand Up @@ -99,12 +99,12 @@ public function links(): HasMany

public function setIcaoAttribute($value): void
{
$this->attributes['icao'] = strtoupper($value);
$this->attributes['icao'] = strtoupper((string) $value);
}

public function setIataAttribute($value): void
{
$this->attributes['iata'] = strtoupper($value);
$this->attributes['iata'] = strtoupper((string) $value);
}

public function getFullNameAttribute(): string
Expand Down
2 changes: 1 addition & 1 deletion app/Models/AirportLinkType.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class AirportLinkType extends Model
*/
protected static function booted()
{
static::addGlobalScope('order', function (Builder $builder) {
static::addGlobalScope('order', function (Builder $builder): void {
$builder->orderBy('name');
});
}
Expand Down
10 changes: 5 additions & 5 deletions app/Models/Booking.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Booking extends Model
public static function boot(): void
{
parent::boot();
self::creating(function ($model) {
self::creating(function ($model): void {
$model->uuid = (string)Str::uuid();
});
}
Expand Down Expand Up @@ -118,17 +118,17 @@ public function getHasReceivedFinalInformationEmailAttribute(): bool

public function setCallsignAttribute($value): void
{
$this->attributes['callsign'] = !empty($value) ? strtoupper($value) : null;
$this->attributes['callsign'] = !empty($value) ? strtoupper((string) $value) : null;
}

public function setActypeAttribute($value): void
{
$this->attributes['acType'] = !empty($value) ? strtoupper($value) : null;
$this->attributes['acType'] = !empty($value) ? strtoupper((string) $value) : null;
}

public function setSelcalAttribute($value): void
{
$this->attributes['selcal'] = !empty($value) ? strtoupper($value) : null;
$this->attributes['selcal'] = !empty($value) ? strtoupper((string) $value) : null;
}

public function airportDep(): HasOne
Expand Down Expand Up @@ -170,7 +170,7 @@ public function airportCtot($orderBy, $withAbbr = true): string
public function uniqueAirports(): Collection
{
$airports = collect();
$this->flights()->each(function ($flight) use ($airports) {
$this->flights()->each(function ($flight) use ($airports): void {
/* @var Flight $flight */
$airports->push($flight->airportDep);
$airports->push($flight->airportArr);
Expand Down
2 changes: 1 addition & 1 deletion app/Models/EventType.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class EventType extends Model
*/
protected static function booted()
{
static::addGlobalScope('order', function (Builder $builder) {
static::addGlobalScope('order', function (Builder $builder): void {
$builder->orderBy('name');
});
}
Expand Down
4 changes: 2 additions & 2 deletions app/Models/Flight.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ public function getFormattedNotesAttribute(): string

public function setRouteAttribute($value): void
{
$this->attributes['route'] = !empty($value) ? strtoupper($value) : null;
$this->attributes['route'] = !empty($value) ? strtoupper((string) $value) : null;
}

public function setOceanictrackAttribute($value): void
{
$this->attributes['oceanicTrack'] = !empty($value) ? strtoupper($value) : null;
$this->attributes['oceanicTrack'] = !empty($value) ? strtoupper((string) $value) : null;
}

public function booking(): BelongsTo
Expand Down
9 changes: 3 additions & 6 deletions app/Notifications/BookingCancelled.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,19 @@ public function __construct(public Event $event)
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
public function via(mixed $notifiable)
{
return ['mail'];
}

/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return MailMessage
*/
public function toMail($notifiable)
public function toMail(mixed $notifiable)
{
$eventName = $this->event->name;
$subject = $eventName . ': ' . __('Booking cancelled');
Expand All @@ -54,10 +52,9 @@ public function toMail($notifiable)
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
public function toArray(mixed $notifiable)
{
return [
'event_id' => $this->event->id,
Expand Down
Loading

0 comments on commit 4ee1aa4

Please sign in to comment.