Skip to content

Commit

Permalink
🩹 specify explicit nullable type to address PHP 8.4 deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKrisKrisu committed Jan 1, 2025
1 parent 1ce367e commit 68c8307
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/DataProviders/DataProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function fetchRawHafasTrip(string $tripId, string $lineName);

public function getStations(string $query, int $results);

public function getDepartures(Station $station, Carbon $when, int $duration = 15, TravelType $type = null, bool $localtime = false);
public function getDepartures(Station $station, Carbon $when, int $duration = 15, ?TravelType $type = null, bool $localtime = false);

public function getNearbyStations(float $latitude, float $longitude, int $results);

Expand Down
4 changes: 2 additions & 2 deletions app/DataProviders/Hafas.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private function fetchDepartures(
Station $station,
Carbon $when,
int $duration = 15,
TravelType $type = null,
?TravelType $type = null,
bool $skipTimeShift = false
) {
$time = $skipTimeShift ? $when : (clone $when)->shiftTimezone("Europe/Berlin");
Expand Down Expand Up @@ -195,7 +195,7 @@ public function getDepartures(
Station $station,
Carbon $when,
int $duration = 15,
TravelType $type = null,
?TravelType $type = null,
bool $localtime = false
): Collection {
try {
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/API/v1/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ public function __construct() {
}

public function sendResponse(
mixed $data = null,
$data = null,
int $code = 200,
array $additional = null
?array $additional = null
): JsonResponse {
$disclaimer = [
'message' => 'APIv1 is not officially released for use and is also not fully documented. Use at your own risk. Data fields may change at any time without notice.',
Expand All @@ -132,7 +132,7 @@ public function sendResponse(
return response()->json($response, $code);
}

public function sendError(array|string $error = null, int $code = 404, array $additional = null): JsonResponse {
public function sendError(array|string|null $error = null, int $code = 404, ?array $additional = null): JsonResponse {
$response = [
'message' => $error,
];
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Backend/LeaderboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ abstract class LeaderboardController extends Controller
{
public static function getLeaderboard(
string $orderBy = 'points',
Carbon $since = null,
Carbon $until = null,
?Carbon $since = null,
?Carbon $until = null,
int $limit = 20,
bool $onlyFollowings = false
): Collection {
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Backend/StatisticController.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public static function getUsedStations(User $user, Carbon $from, Carbon $until):
->whereIn('train_stopovers.id', $usedStationIds)->get();
}

public static function getPassedStations(User $user, Carbon $from = null, Carbon $to = null): Collection {
public static function getPassedStations(User $user, ?Carbon $from = null, ?Carbon $to = null): Collection {
$query = DB::table('train_checkins')
->join('train_stopovers', 'train_checkins.trip_id', '=', 'train_stopovers.trip_id')
->where('user_id', '=', $user->id)
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/StatusController.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ public static function createStatus(
User|Authenticatable $user,
Business $business,
StatusVisibility $visibility,
string $body = null,
Event $event = null
?string $body = null,
?Event $event = null
): Status {
if ($event !== null && !Carbon::now()->isBetween($event->checkin_start, $event->checkin_end)) {
Log::info('Event checkin was prevented because the event is not active anymore', [
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class UserController extends Controller
* @api v1
* @frontend
*/
public static function statusesForUser(User $user, int $limit = null): ?Paginator {
public static function statusesForUser(User $user, ?int $limit = null): ?Paginator {
Gate::authorize('view', $user);
return $user->statuses()
->join('train_checkins', 'statuses.id', '=', 'train_checkins.status_id')
Expand Down

0 comments on commit 68c8307

Please sign in to comment.