diff --git a/app/Console/Commands/CreateConfigs.php b/app/Console/Commands/CreateConfigs.php index b29bbff70..096236152 100644 --- a/app/Console/Commands/CreateConfigs.php +++ b/app/Console/Commands/CreateConfigs.php @@ -18,8 +18,6 @@ class CreateConfigs extends Command protected $description = 'Create the config files'; public function __construct( - private readonly DatabaseSeeder $databaseSeeder, - private readonly SeederService $seederSvc, private readonly MigrationService $migrationSvc, ) { parent::__construct(); diff --git a/app/Console/Commands/DevInstall.php b/app/Console/Commands/DevInstall.php index 2dd26535d..e4d83d0b3 100644 --- a/app/Console/Commands/DevInstall.php +++ b/app/Console/Commands/DevInstall.php @@ -13,15 +13,6 @@ class DevInstall extends Command protected $signature = 'phpvms:dev-install {--reset-db} {--reset-configs}'; protected $description = 'Run a developer install and run the sample migration'; - private \DatabaseSeeder $databaseSeeder; - - public function __construct(\DatabaseSeeder $databaseSeeder) - { - parent::__construct(); - - $this->databaseSeeder = $databaseSeeder; - } - /** * Run dev related commands * diff --git a/app/Console/Cron.php b/app/Console/Cron.php index 4ea85fc65..342b00077 100644 --- a/app/Console/Cron.php +++ b/app/Console/Cron.php @@ -72,7 +72,7 @@ public function __construct(Schedule $scheduler) */ public function run(): array { - $events = $this->scheduler->dueEvents(app()) ?? []; + $events = $this->scheduler->dueEvents(app()); $run = []; diff --git a/app/Contracts/Controller.php b/app/Contracts/Controller.php index 8d13d7e5d..f10b756e3 100755 --- a/app/Contracts/Controller.php +++ b/app/Contracts/Controller.php @@ -64,12 +64,15 @@ public function getFromReq($request, $attrs_or_validations, $addtl_fields = null if ($request->filled($field)) { $fields[$field] = $request->input($field); } - } else { - /* @noinspection NestedPositiveIfStatementsInspection */ + } + /* $request is always a Request object according to PHPDoc + else { + // @noinspection NestedPositiveIfStatementsInspection if (array_key_exists($field, $request)) { $fields[$field] = $request[$field]; } } + */ } if (!empty($addtl_fields) && \is_array($addtl_fields)) { diff --git a/app/Contracts/Repository.php b/app/Contracts/Repository.php index 4ab8fc79d..d874e51fb 100644 --- a/app/Contracts/Repository.php +++ b/app/Contracts/Repository.php @@ -96,7 +96,7 @@ public function whereOrder($where, $sort_by, $order_by = 'asc') * * @param string $col * @param array $values - * @param string $sort_by + * @param string|array $sort_by * @param string $order_by * * @return $this diff --git a/app/Database/migrations_data/2023_05_16_174436_migrate_fare_capacity.php b/app/Database/migrations_data/2023_05_16_174436_migrate_fare_capacity.php index 322bee1d0..b83d55a11 100644 --- a/app/Database/migrations_data/2023_05_16_174436_migrate_fare_capacity.php +++ b/app/Database/migrations_data/2023_05_16_174436_migrate_fare_capacity.php @@ -1,6 +1,7 @@ id] = $fareSvc->getForSubfleet($subfleet); } - /** @var \App\Models\Fare $sf */ + /** @var ?Fare $sf */ $sf = $cached[$subfleet->id]->where('code', $fare->code)->first(); $fare->capacity = is_null($sf) ? $fare->count : $sf->capacity; $fare->save(); diff --git a/app/Exceptions/AssetNotFound.php b/app/Exceptions/AssetNotFound.php index ab301b279..58d1f321c 100644 --- a/app/Exceptions/AssetNotFound.php +++ b/app/Exceptions/AssetNotFound.php @@ -6,9 +6,7 @@ class AssetNotFound extends AbstractHttpException { - public function __construct( - private readonly Exception $exception - ) { + public function __construct(Exception $exception) { parent::__construct( 404, $exception->getMessage() diff --git a/app/Http/Controllers/Admin/AircraftController.php b/app/Http/Controllers/Admin/AircraftController.php index 6410b155c..020ee3162 100644 --- a/app/Http/Controllers/Admin/AircraftController.php +++ b/app/Http/Controllers/Admin/AircraftController.php @@ -161,9 +161,9 @@ public function show($id): View|RedirectResponse */ public function edit(int $id): View|RedirectResponse { - /** @var Aircraft $aircraft */ + /** @var ?Aircraft $aircraft */ $aircraft = $this->aircraftRepo - ->with(['airport', 'hub']) + ->with(['airport', 'home']) ->findWithoutFail($id); if (is_null($aircraft)) { @@ -176,8 +176,8 @@ public function edit(int $id): View|RedirectResponse $airports[$aircraft->airport->id] = $aircraft->airport->description; } - if ($aircraft->hub) { - $airports[$aircraft->hub->id] = $aircraft->hub->description; + if ($aircraft->home) { + $airports[$aircraft->home->id] = $aircraft->home->description; } return view('admin.aircraft.edit', [ @@ -201,7 +201,7 @@ public function edit(int $id): View|RedirectResponse */ public function update(int $id, UpdateAircraftRequest $request): RedirectResponse { - /** @var \App\Models\Aircraft $aircraft */ + /** @var ?Aircraft $aircraft */ $aircraft = $this->aircraftRepo->findWithoutFail($id); if (is_null($aircraft)) { @@ -225,7 +225,7 @@ public function update(int $id, UpdateAircraftRequest $request): RedirectRespons */ public function destroy(int $id): RedirectResponse { - /** @var \App\Models\Aircraft $aircraft */ + /** @var ?Aircraft $aircraft */ $aircraft = $this->aircraftRepo->findWithoutFail($id); if (is_null($aircraft)) { diff --git a/app/Http/Controllers/Admin/ExpenseController.php b/app/Http/Controllers/Admin/ExpenseController.php index ddf614774..b48bb6e1b 100644 --- a/app/Http/Controllers/Admin/ExpenseController.php +++ b/app/Http/Controllers/Admin/ExpenseController.php @@ -28,12 +28,10 @@ class ExpenseController extends Controller * * @param AirlineRepository $airlineRepo * @param ExpenseRepository $expenseRepo - * @param ImportService $importSvc */ public function __construct( private readonly AirlineRepository $airlineRepo, - private readonly ExpenseRepository $expenseRepo, - private readonly ImportService $importSvc + private readonly ExpenseRepository $expenseRepo ) { } diff --git a/app/Http/Controllers/Admin/FareController.php b/app/Http/Controllers/Admin/FareController.php index b8e890953..3f2048f48 100644 --- a/app/Http/Controllers/Admin/FareController.php +++ b/app/Http/Controllers/Admin/FareController.php @@ -11,7 +11,6 @@ use App\Models\Fare; use App\Repositories\FareRepository; use App\Services\ExportService; -use App\Services\ImportService; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Log; @@ -28,11 +27,9 @@ class FareController extends Controller * FareController constructor. * * @param FareRepository $fareRepo - * @param ImportService $importSvc */ public function __construct( - private readonly FareRepository $fareRepo, - private readonly ImportService $importSvc + private readonly FareRepository $fareRepo ) { } diff --git a/app/Http/Controllers/Admin/FlightController.php b/app/Http/Controllers/Admin/FlightController.php index b00e26a56..c190691d5 100644 --- a/app/Http/Controllers/Admin/FlightController.php +++ b/app/Http/Controllers/Admin/FlightController.php @@ -38,24 +38,20 @@ class FlightController extends Controller * FlightController constructor. * * @param AirlineRepository $airlineRepo - * @param AirportRepository $airportRepo * @param FareRepository $fareRepo * @param FlightRepository $flightRepo * @param FlightFieldRepository $flightFieldRepo * @param FareService $fareSvc * @param FlightService $flightSvc - * @param ImportService $importSvc * @param SubfleetRepository $subfleetRepo */ public function __construct( private readonly AirlineRepository $airlineRepo, - private readonly AirportRepository $airportRepo, private readonly FareRepository $fareRepo, private readonly FlightRepository $flightRepo, private readonly FlightFieldRepository $flightFieldRepo, private readonly FareService $fareSvc, private readonly FlightService $flightSvc, - private readonly ImportService $importSvc, private readonly SubfleetRepository $subfleetRepo ) { } @@ -198,7 +194,7 @@ public function show(string $id): RedirectResponse|View */ public function edit(string $id): RedirectResponse|View { - /** @var Flight $flight */ + /** @var ?Flight $flight */ $flight = $this->flightRepo ->with(['dpt_airport', 'arr_airport', 'alt_airport']) ->findWithoutFail($id); @@ -375,7 +371,7 @@ public function field_values(string $flight_id, Request $request): RedirectRespo $field->save(); } elseif ($request->isMethod('put')) { Log::info('Updating flight field, flight: '.$flight_id, $request->input()); - /** @var FlightFieldValue $field */ + /** @var ?FlightFieldValue $field */ $field = FlightFieldValue::where([ 'name' => $request->input('name'), 'flight_id' => $flight_id, diff --git a/app/Http/Controllers/Admin/SubfleetController.php b/app/Http/Controllers/Admin/SubfleetController.php index 3851863d2..7e487de47 100644 --- a/app/Http/Controllers/Admin/SubfleetController.php +++ b/app/Http/Controllers/Admin/SubfleetController.php @@ -178,7 +178,7 @@ public function show(int $id): RedirectResponse|View */ public function edit(int $id): RedirectResponse|View { - /** @var Subfleet $subfleet */ + /** @var ?Subfleet $subfleet */ $subfleet = $this->subfleetRepo ->with(['home', 'fares', 'ranks', 'typeratings']) ->findWithoutFail($id); diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index a976e8c09..6b8dbe9e8 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -35,7 +35,6 @@ class UserController extends Controller * UserController constructor. * * @param AirlineRepository $airlineRepo - * @param AirportRepository $airportRepo * @param PirepRepository $pirepRepo * @param RoleRepository $roleRepo * @param TypeRatingRepository $typeratingRepo @@ -44,7 +43,6 @@ class UserController extends Controller */ public function __construct( private readonly AirlineRepository $airlineRepo, - private readonly AirportRepository $airportRepo, private readonly PirepRepository $pirepRepo, private readonly RoleRepository $roleRepo, private readonly TypeRatingRepository $typeratingRepo, @@ -146,7 +144,7 @@ public function show(int $id): View */ public function edit(int $id): View|RedirectResponse { - /** @var User $user */ + /** @var ?User $user */ $user = $this->userRepo ->with(['awards', 'fields', 'rank', 'typeratings', 'home_airport', 'location']) ->findWithoutFail($id); diff --git a/app/Http/Controllers/Api/FlightController.php b/app/Http/Controllers/Api/FlightController.php index 8170829b3..783c6a2d1 100644 --- a/app/Http/Controllers/Api/FlightController.php +++ b/app/Http/Controllers/Api/FlightController.php @@ -158,7 +158,7 @@ public function briefing(string $id) 'id' => $id, ]; - /** @var SimBrief $simbrief */ + /** @var ?SimBrief $simbrief */ $simbrief = SimBrief::where($w)->first(); if ($simbrief === null) { diff --git a/app/Http/Controllers/Auth/OAuthController.php b/app/Http/Controllers/Auth/OAuthController.php index d1b6c23d5..46ac0b1c2 100644 --- a/app/Http/Controllers/Auth/OAuthController.php +++ b/app/Http/Controllers/Auth/OAuthController.php @@ -55,11 +55,6 @@ public function handleProviderCallback(string $provider, Request $request): View abort(404); } - if (!$providerUser) { - flash()->error('Provider '.$provider.' not found'); - return redirect(url('/login')); - } - // If a user is logged in we want to link the account if (Auth::check()) { $user = Auth::user(); @@ -86,7 +81,7 @@ public function handleProviderCallback(string $provider, Request $request): View return redirect(route('frontend.profile.index')); } - /** @var User $user */ + /** @var ?User $user */ $user = User::where($provider.'_id', $providerUser->getId())->orWhere('email', $providerUser->getEmail())->first(); if ($user) { diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 54a273c03..6323bfb57 100755 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -39,13 +39,11 @@ class RegisterController extends Controller * RegisterController constructor. * * @param AirlineRepository $airlineRepo - * @param AirportRepository $airportRepo * @param UserService $userService * @param HttpClient $httpClient */ public function __construct( private readonly AirlineRepository $airlineRepo, - private readonly AirportRepository $airportRepo, private readonly HttpClient $httpClient, private readonly UserService $userService, ) { @@ -70,7 +68,7 @@ public function showRegistrationForm(Request $request): View abort(403, 'Registrations are invite only'); } - /** @var Invite $invite */ + /** @var ?Invite $invite */ $invite = Invite::find($request->get('invite')); if (!$invite || $invite->token !== $request->get('token')) { abort(403, 'Invalid invite'); @@ -175,7 +173,7 @@ protected function create(Request $request): User abort(403, 'Registrations are invite only'); } - /** @var Invite $invite */ + /** @var ?Invite $invite */ $invite = Invite::find($request->get('invite')); if (!$invite || $invite->token !== base64_decode($request->get('invite_token'))) { abort(403, 'Invalid invite'); diff --git a/app/Http/Controllers/Frontend/DownloadController.php b/app/Http/Controllers/Frontend/DownloadController.php index c57369fff..2a991d6cb 100644 --- a/app/Http/Controllers/Frontend/DownloadController.php +++ b/app/Http/Controllers/Frontend/DownloadController.php @@ -114,9 +114,7 @@ public function show(string $id): RedirectResponse|StreamedResponse return redirect()->back(); } - /** - * @var File $file - */ + /** @var ?File $file */ $file = File::find($id); if (!$file) { Flash::error('File doesn\'t exist'); diff --git a/app/Http/Controllers/Frontend/FlightController.php b/app/Http/Controllers/Frontend/FlightController.php index bc8a5322e..b07000329 100644 --- a/app/Http/Controllers/Frontend/FlightController.php +++ b/app/Http/Controllers/Frontend/FlightController.php @@ -7,7 +7,6 @@ use App\Models\Enums\FlightType; use App\Models\Flight; use App\Repositories\AirlineRepository; -use App\Repositories\AirportRepository; use App\Repositories\Criteria\WhereCriteria; use App\Repositories\FlightRepository; use App\Repositories\SubfleetRepository; @@ -30,7 +29,6 @@ class FlightController extends Controller { /** * @param AirlineRepository $airlineRepo - * @param AirportRepository $airportRepo * @param FlightRepository $flightRepo * @param GeoService $geoSvc * @param ModuleService $moduleSvc @@ -40,7 +38,6 @@ class FlightController extends Controller */ public function __construct( private readonly AirlineRepository $airlineRepo, - private readonly AirportRepository $airportRepo, private readonly FlightRepository $flightRepo, private readonly GeoService $geoSvc, private readonly ModuleService $moduleSvc, @@ -161,11 +158,6 @@ public function search(Request $request): View /** @var Collection $bids */ $bids = Bid::where('user_id', Auth::id())->get(); foreach ($bids as $bid) { - if (!$bid->flight) { - $bid->delete(); - continue; - } - $saved_flights[$bid->flight_id] = $bid->id; } diff --git a/app/Http/Controllers/Frontend/HomeController.php b/app/Http/Controllers/Frontend/HomeController.php index cf828c8ba..d5a05ae1b 100644 --- a/app/Http/Controllers/Frontend/HomeController.php +++ b/app/Http/Controllers/Frontend/HomeController.php @@ -5,6 +5,7 @@ use App\Contracts\Controller; use App\Models\Enums\UserState; use App\Models\User; +use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\QueryException; use Illuminate\Support\Facades\Log; use Illuminate\View\View; @@ -19,18 +20,17 @@ class HomeController extends Controller public function index(): View { try { + /** @var Collection $users */ $users = User::with('home_airport')->where('state', '!=', UserState::DELETED)->orderBy('created_at', 'desc')->take(4)->get(); } catch (\PDOException $e) { Log::emergency($e); return view('system/errors/database_error', [ 'error' => $e->getMessage(), ]); - } catch (QueryException $e) { - return view('system/errors/not_installed'); } // No users - if (!$users) { + if ($users->isEmpty()) { return view('system/errors/not_installed'); } diff --git a/app/Http/Controllers/Frontend/PageController.php b/app/Http/Controllers/Frontend/PageController.php index c76ce229c..578f680ec 100644 --- a/app/Http/Controllers/Frontend/PageController.php +++ b/app/Http/Controllers/Frontend/PageController.php @@ -5,6 +5,7 @@ use App\Contracts\Controller; use App\Exceptions\PageNotFound; use App\Exceptions\Unauthorized; +use App\Models\Page; use App\Repositories\PageRepository; use Exception; use Illuminate\Support\Facades\Auth; @@ -29,7 +30,7 @@ public function __construct( */ public function show(string $slug): View { - /** @var \App\Models\Page $page */ + /** @var ?Page $page */ $page = $this->pageRepo->findWhere(['slug' => $slug])->first(); if (!$page) { throw new PageNotFound(new Exception('Page not found')); diff --git a/app/Http/Controllers/Frontend/PirepController.php b/app/Http/Controllers/Frontend/PirepController.php index aa2335cc8..6046d7b08 100644 --- a/app/Http/Controllers/Frontend/PirepController.php +++ b/app/Http/Controllers/Frontend/PirepController.php @@ -485,7 +485,7 @@ public function store(CreatePirepRequest $request): RedirectResponse */ public function edit(string $id): RedirectResponse|View { - /** @var Pirep $pirep */ + /** @var ?Pirep $pirep */ $pirep = $this->pirepRepo ->with(['dpt_airport', 'arr_airport', 'alt_airport']) ->findWithoutFail($id); @@ -567,7 +567,7 @@ public function update(string $id, UpdatePirepRequest $request): RedirectRespons /** @var User $user */ $user = Auth::user(); - /** @var Pirep $pirep */ + /** @var ?Pirep $pirep */ $pirep = $this->pirepRepo->findWithoutFail($id); if (is_null($pirep)) { Flash::error('Pirep not found'); diff --git a/app/Http/Controllers/Frontend/ProfileController.php b/app/Http/Controllers/Frontend/ProfileController.php index 60bfeaf98..67aa1baf9 100644 --- a/app/Http/Controllers/Frontend/ProfileController.php +++ b/app/Http/Controllers/Frontend/ProfileController.php @@ -33,12 +33,10 @@ class ProfileController extends Controller * ProfileController constructor. * * @param AirlineRepository $airlineRepo - * @param AirportRepository $airportRepo * @param UserRepository $userRepo */ public function __construct( private readonly AirlineRepository $airlineRepo, - private readonly AirportRepository $airportRepo, private readonly UserRepository $userRepo ) { } @@ -49,13 +47,9 @@ public function __construct( private function acarsEnabled(): bool { // Is the ACARS module enabled? - $acars_enabled = false; + /** @var ?\Nwidart\Modules\Module $acars */ $acars = Module::find('VMSAcars'); - if ($acars) { - $acars_enabled = $acars->isEnabled(); - } - - return $acars_enabled; + return $acars?->isEnabled() ?? false; } /** @@ -77,7 +71,7 @@ public function index(): View public function show(int $id): RedirectResponse|View { $with = ['airline', 'awards', 'current_airport', 'fields.field', 'home_airport', 'last_pirep', 'rank', 'typeratings']; - /** @var \App\Models\User $user */ + /** @var ?User $user */ $user = User::with($with)->where('id', $id)->first(); if (is_null($user)) { @@ -106,7 +100,7 @@ public function show(int $id): RedirectResponse|View */ public function edit(Request $request): RedirectResponse|View { - /** @var \App\Models\User $user */ + /** @var ?User $user */ $user = User::with('fields.field', 'location')->where('id', Auth::id())->first(); if (is_null($user)) { diff --git a/app/Http/Controllers/Frontend/SimBriefController.php b/app/Http/Controllers/Frontend/SimBriefController.php index 3ce0f30be..91247741c 100644 --- a/app/Http/Controllers/Frontend/SimBriefController.php +++ b/app/Http/Controllers/Frontend/SimBriefController.php @@ -53,7 +53,7 @@ public function generate(Request $request): RedirectResponse|View $flight_id = $request->input('flight_id'); $aircraft_id = $request->input('aircraft_id'); - /** @var Flight $flight */ + /** @var ?Flight $flight */ $flight = $this->flightRepo->with(['airline', 'arr_airport', 'dpt_airport', 'fares', 'subfleets'])->find($flight_id); if (!$flight) { @@ -187,7 +187,7 @@ public function generate(Request $request): RedirectResponse|View /** @var Fare $fare */ foreach ($all_fares as $fare) { - if ($fare->type !== FareType::PASSENGER || empty($fare->capacity)) { + if ($fare->type !== FareType::PASSENGER || !$fare->capacity) { continue; } @@ -274,7 +274,7 @@ public function briefing(string $id): RedirectResponse|View /** @var User $user */ $user = Auth::user(); - /** @var SimBrief $simbrief */ + /** @var ?SimBrief $simbrief */ $simbrief = SimBrief::with(['flight.airline', 'pirep.airline'])->find($id); if (!$simbrief) { flash()->error('SimBrief briefing not found'); diff --git a/app/Http/Resources/Flight.php b/app/Http/Resources/Flight.php index 01739aa15..efec61486 100644 --- a/app/Http/Resources/Flight.php +++ b/app/Http/Resources/Flight.php @@ -19,7 +19,7 @@ protected function setFields() { $return_values = new stdClass(); $field_values = $this->field_values; - if (!$field_values || $field_values->count() === 0) { + if ($field_values->count() === 0) { return $return_values; } diff --git a/app/Http/Resources/PirepComment.php b/app/Http/Resources/PirepComment.php index 2a3407f72..614436eb0 100644 --- a/app/Http/Resources/PirepComment.php +++ b/app/Http/Resources/PirepComment.php @@ -18,10 +18,6 @@ class PirepComment extends Resource */ public function toArray($request) { - if (!$this->user) { - return []; - } - $user = $this->user; return [ diff --git a/app/Listeners/AwardHandler.php b/app/Listeners/AwardHandler.php index 3ea652d25..d7255227c 100644 --- a/app/Listeners/AwardHandler.php +++ b/app/Listeners/AwardHandler.php @@ -45,7 +45,7 @@ public function checkForAwards($user): void foreach ($awards as $award) { /** @var \App\Contracts\Award $klass */ $klass = $award->getReference($award, $user); - $klass?->handle(); + $klass->handle(); } } } diff --git a/app/Models/Aircraft.php b/app/Models/Aircraft.php index bc4e617c4..cb957619c 100644 --- a/app/Models/Aircraft.php +++ b/app/Models/Aircraft.php @@ -36,9 +36,9 @@ * @property float $zfw * @property string $hex_code * @property string $selcal - * @property Airport $airport - * @property Airport $hub - * @property Airport $home + * @property ?Airport $airport + * @property ?Airport $hub + * @property ?Airport $home * @property Subfleet $subfleet * @property int $status * @property int $state diff --git a/app/Models/Airline.php b/app/Models/Airline.php index 0c3eb255c..483c44e4c 100644 --- a/app/Models/Airline.php +++ b/app/Models/Airline.php @@ -15,15 +15,15 @@ use Kyslik\ColumnSortable\Sortable; /** - * @property mixed $id - * @property string $code - * @property string $icao - * @property string $iata - * @property string $name - * @property string $callsign - * @property string $logo - * @property string $country - * @property Journal $journal + * @property mixed $id + * @property string $code + * @property string $icao + * @property string $iata + * @property string $name + * @property string $callsign + * @property string $logo + * @property string $country + * @property ?Journal $journal */ class Airline extends Model { diff --git a/app/Models/Casts/CommaDelimitedCast.php b/app/Models/Casts/CommaDelimitedCast.php index 5f8eec7b2..d1a2636c2 100644 --- a/app/Models/Casts/CommaDelimitedCast.php +++ b/app/Models/Casts/CommaDelimitedCast.php @@ -14,7 +14,7 @@ class CommaDelimitedCast implements CastsAttributes * @param mixed $value * @param array $attributes * - * @return mixed + * @return string[] */ public function get($model, string $key, $value, array $attributes) { diff --git a/app/Models/Casts/MoneyCast.php b/app/Models/Casts/MoneyCast.php index 956c3f1ef..c368e23b7 100644 --- a/app/Models/Casts/MoneyCast.php +++ b/app/Models/Casts/MoneyCast.php @@ -42,6 +42,6 @@ public function set($model, string $key, $value, array $attributes) ? $value : new Money($value); - return $value ? (int) $value->getAmount() : null; + return (int) $value->getAmount(); } } diff --git a/app/Models/Expense.php b/app/Models/Expense.php index 01c04ca66..1b524d27e 100644 --- a/app/Models/Expense.php +++ b/app/Models/Expense.php @@ -14,7 +14,7 @@ * @property float $amount * @property string $name * @property string $type - * @property string $flight_type + * @property string[] $flight_type * @property string $ref_model * @property string $ref_model_id * @property bool $charge_to_user diff --git a/app/Models/Fare.php b/app/Models/Fare.php index af4f76506..9249b450c 100644 --- a/app/Models/Fare.php +++ b/app/Models/Fare.php @@ -15,7 +15,7 @@ * @property string $code * @property int $capacity * @property int $count Only when merged with pivot - * @property FareType $type + * @property int $type * @property string $notes * @property bool $active */ diff --git a/app/Models/Flight.php b/app/Models/Flight.php index 84e247ffa..1e55b0375 100644 --- a/app/Models/Flight.php +++ b/app/Models/Flight.php @@ -49,10 +49,10 @@ * @property float $pilot_pay * @property Airport $dpt_airport * @property Airport $arr_airport - * @property Airport $alt_airport + * @property ?Airport $alt_airport * @property string $dpt_airport_id * @property string $arr_airport_id - * @property string $alt_airport_id + * @property ?string $alt_airport_id * @property int $event_id * @property int $user_id * @property int $active diff --git a/app/Models/Invite.php b/app/Models/Invite.php index 67af89553..5db43b9c8 100644 --- a/app/Models/Invite.php +++ b/app/Models/Invite.php @@ -6,12 +6,12 @@ use Illuminate\Database\Eloquent\Casts\Attribute; /** - * @property string $email - * @property string $token - * @property string $link - * @property int $usage_count - * @property int $usage_limit - * @property \Carbon\Carbon $expires_at + * @property ?string $email + * @property string $token + * @property string $link + * @property int $usage_count + * @property ?int $usage_limit + * @property ?\Carbon\Carbon $expires_at */ class Invite extends Model { diff --git a/app/Models/Pirep.php b/app/Models/Pirep.php index be5a3e5f3..ce9a4ce83 100644 --- a/app/Models/Pirep.php +++ b/app/Models/Pirep.php @@ -35,25 +35,25 @@ * @property string $flight_type * @property int $airline_id * @property int $user_id - * @property int $aircraft_id + * @property ?int $aircraft_id * @property int $event_id - * @property Aircraft $aircraft + * @property ?Aircraft $aircraft * @property Airline $airline * @property Airport $arr_airport * @property string $arr_airport_id * @property Airport $dpt_airport * @property string $dpt_airport_id - * @property Airport $alt_airport - * @property string $alt_airport_id - * @property Carbon $block_off_time - * @property Carbon $block_on_time + * @property ?Airport $alt_airport + * @property ?string $alt_airport_id + * @property ?Carbon $block_off_time + * @property ?Carbon $block_on_time * @property int $block_time * @property int $flight_time In minutes * @property int $planned_flight_time * @property Fuel $block_fuel * @property Fuel $fuel_used - * @property Distance $distance - * @property Distance $planned_distance + * @property ?Distance $distance + * @property ?Distance $planned_distance * @property float $progress_percent * @property int $level * @property string $route @@ -65,15 +65,15 @@ * @property int $state * @property int $source * @property string $source_name - * @property Carbon $submitted_at + * @property ?Carbon $submitted_at * @property Carbon $created_at * @property Carbon $updated_at * @property bool $read_only - * @property Acars $position + * @property ?Acars $position * @property Acars[] $acars * @property mixed $cancelled * @property PirepFare[] $fares - * @property SimBrief $simbrief + * @property ?SimBrief $simbrief */ class Pirep extends Model { diff --git a/app/Models/PirepFare.php b/app/Models/PirepFare.php index a3fbf68e6..c8b736e04 100644 --- a/app/Models/PirepFare.php +++ b/app/Models/PirepFare.php @@ -18,7 +18,7 @@ * @property int $capacity * @property Pirep $pirep * @property Fare|null $fare - * @property FareType $type + * @property int $type */ class PirepFare extends Model { diff --git a/app/Models/PirepFieldValue.php b/app/Models/PirepFieldValue.php index 7b9c87caa..211d29244 100644 --- a/app/Models/PirepFieldValue.php +++ b/app/Models/PirepFieldValue.php @@ -60,7 +60,7 @@ public function name(): Attribute public function readOnly(): Attribute { return Attribute::make( - get: fn ($_, $attrs) => $this->source === PirepFieldSource::ACARS + get: fn ($_, $attrs) => (int) $this->source === PirepFieldSource::ACARS ); } diff --git a/app/Models/Subfleet.php b/app/Models/Subfleet.php index 990c0e002..1fb4eac43 100644 --- a/app/Models/Subfleet.php +++ b/app/Models/Subfleet.php @@ -22,13 +22,13 @@ * @property string $simbrief_type * @property string $name * @property int $airline_id - * @property int $hub_id + * @property ?string $hub_id * @property int $ground_handling_multiplier * @property Collection $fares * @property float $cost_block_hour * @property float $cost_delay_minute * @property Airline $airline - * @property Airport $home + * @property ?Airport $home * @property int $fuel_type * @property Aircraft[] $aircraft */ diff --git a/app/Models/User.php b/app/Models/User.php index 455337fe5..01e67d46a 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -32,9 +32,9 @@ * @property mixed $timezone * @property string $ident * @property string $atc - * @property string $curr_airport_id - * @property string $home_airport_id - * @property File $avatar + * @property ?string $curr_airport_id + * @property ?string $home_airport_id + * @property ?File $avatar * @property Airline $airline * @property int $flights * @property int $flight_time @@ -42,9 +42,9 @@ * @property string $remember_token * @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $updated_at - * @property Rank $rank - * @property Journal $journal - * @property int $rank_id + * @property ?Rank $rank + * @property ?Journal $journal + * @property ?int $rank_id * @property string $discord_id * @property int $state * @property string $last_ip @@ -58,9 +58,9 @@ * @property Collection $roles * @property Collection $subfleets * @property Collection $typeratings - * @property Airport $home_airport - * @property Airport $current_airport - * @property Airport $location + * @property ?Airport $home_airport + * @property ?Airport $current_airport + * @property ?Airport $location * @property Bid[] $bids * * @mixin \Illuminate\Database\Eloquent\Builder @@ -290,7 +290,7 @@ public function gravatar($size = null) public function resolveAvatarUrl() { - /** @var File $avatar */ + /** @var ?File $avatar */ $avatar = $this->avatar; if (!$avatar) { return $this->gravatar(); diff --git a/app/Notifications/NotificationEventsHandler.php b/app/Notifications/NotificationEventsHandler.php index 6bdbe808f..dc052e2a3 100644 --- a/app/Notifications/NotificationEventsHandler.php +++ b/app/Notifications/NotificationEventsHandler.php @@ -28,7 +28,6 @@ */ class NotificationEventsHandler extends Listener { - private static $broadcastNotifyable; public static $callbacks = [ AwardAwarded::class => 'onAwardAwarded', @@ -43,11 +42,6 @@ class NotificationEventsHandler extends Listener Verified::class => 'onEmailVerified', ]; - public function __construct() - { - self::$broadcastNotifyable = app(Broadcast::class); - } - /** * Send a notification to all of the admins * diff --git a/app/Repositories/ExpenseRepository.php b/app/Repositories/ExpenseRepository.php index 8a4f8c394..f7132107e 100644 --- a/app/Repositories/ExpenseRepository.php +++ b/app/Repositories/ExpenseRepository.php @@ -3,6 +3,7 @@ namespace App\Repositories; use App\Contracts\Repository; +use App\Models\Enums\ExpenseType; use App\Models\Expense; use Illuminate\Support\Collection; use Prettus\Repository\Contracts\CacheableInterface; @@ -21,10 +22,10 @@ public function model() * Get all of the expenses for a given type, and also * include expenses for a given airline ID * - * @param $type - * @param null $airline_id - * @param null $ref_model - * @param mixed $ref_model_id + * @param int $type + * @param ?int $airline_id + * @param class-string|object|null $ref_model + * @param string|int $ref_model_id * * @return Collection */ diff --git a/app/Repositories/JournalRepository.php b/app/Repositories/JournalRepository.php index edff30632..d9a9adbb3 100644 --- a/app/Repositories/JournalRepository.php +++ b/app/Repositories/JournalRepository.php @@ -158,7 +158,7 @@ public function getBalance(Journal $journal = null, Carbon $date = null) * @param Carbon $date * @param Journal $journal * @param Carbon|null $start_date - * @param null $transaction_group + * @param ?string $transaction_group * * @throws \UnexpectedValueException * @throws \InvalidArgumentException @@ -197,7 +197,7 @@ public function getCreditBalanceBetween( * @param Carbon $date * @param Journal $journal * @param Carbon|null $start_date - * @param null $transaction_group + * @param string $transaction_group * * @throws \UnexpectedValueException * @throws \InvalidArgumentException @@ -236,7 +236,7 @@ public function getDebitBalanceBetween( * Return all transactions for a given object * * @param $object - * @param null $journal + * @param ?Journal $journal * @param Carbon|null $date * * @throws \UnexpectedValueException @@ -275,8 +275,8 @@ public function getAllForObject($object, $journal = null, Carbon $date = null) /** * Delete all transactions for a given object * - * @param $object - * @param null $journal + * @param $object + * @param ?Journal $journal * * @return void */ diff --git a/app/Repositories/KvpRepository.php b/app/Repositories/KvpRepository.php index 0a8459d3f..3627ed7a6 100644 --- a/app/Repositories/KvpRepository.php +++ b/app/Repositories/KvpRepository.php @@ -30,7 +30,7 @@ public function retrieve($key, $default = null) * @param string $key * @param mixed $default default value to return * - * @return array|string|null + * @return mixed */ public function get($key, $default = null) { diff --git a/app/Services/BidService.php b/app/Services/BidService.php index f18f3e502..a7745c39e 100644 --- a/app/Services/BidService.php +++ b/app/Services/BidService.php @@ -49,7 +49,7 @@ public function getBid(User $user, $bid_id): ?Bid 'flight.subfleets.fares', ]; - /** @var Bid $bid */ + /** @var ?Bid $bid */ $bid = Bid::with($with)->where(['id' => $bid_id])->first(); if ($bid === null) { return null; @@ -238,10 +238,11 @@ public function removeBidForPirep(Pirep $pirep) return; } + /** @var ?Bid $bid */ $bid = Bid::where([ 'user_id' => $pirep->user->id, 'flight_id' => $flight->id, - ]); + ])->first(); if ($bid) { Log::info('Bid for user: '.$pirep->user->ident.' on flight '.$flight->ident); diff --git a/app/Services/FareService.php b/app/Services/FareService.php index ff1ef1a04..252f4ea83 100644 --- a/app/Services/FareService.php +++ b/app/Services/FareService.php @@ -50,7 +50,7 @@ public function saveToPirep(Pirep $pirep, array $fares) /** * See if there's match with the provided fares, so we can copy the information over * - * @var PirepFare $pirep_fare + * @var ?PirepFare $pirep_fare */ $pirep_fare = $fares->where('fare_id', $fare->id)->first(); diff --git a/app/Services/Finance/PirepFinanceService.php b/app/Services/Finance/PirepFinanceService.php index 74baed60b..5ed1a8f52 100644 --- a/app/Services/Finance/PirepFinanceService.php +++ b/app/Services/Finance/PirepFinanceService.php @@ -201,7 +201,7 @@ public function payFuelCosts(Pirep $pirep): void // Get Aircraft Fuel Type from Subfleet // And set $fuel_cost according to type (Failsafe is Jet A) - $sf = $pirep->aircraft->subfleet; + $sf = $pirep->aircraft?->subfleet; if ($sf) { $fuel_type = $sf->fuel_type; } else { diff --git a/app/Services/FlightService.php b/app/Services/FlightService.php index ea3692132..4879fc63b 100644 --- a/app/Services/FlightService.php +++ b/app/Services/FlightService.php @@ -24,17 +24,13 @@ class FlightService extends Service * FlightService constructor. * * @param AirportService $airportSvc - * @param FareService $fareSvc * @param FlightRepository $flightRepo * @param NavdataRepository $navDataRepo - * - * @parma PirepRepository $pirepRepo - * + * @param PirepRepository $pirepRepo * @param UserService $userSvc */ public function __construct( private readonly AirportService $airportSvc, - private readonly FareService $fareSvc, private readonly FlightRepository $flightRepo, private readonly NavdataRepository $navDataRepo, private readonly PirepRepository $pirepRepo, @@ -156,16 +152,15 @@ public function filterSubfleets(User $user, Flight $flight) // Eager load some of the relationships needed //$flight->load(['flight.subfleets', 'flight.subfleets.aircraft', 'flight.subfleets.fares']); - /** @var \Illuminate\Support\Collection $subfleets */ $subfleets = $flight->subfleets; // If no subfleets assigned to a flight get users allowed subfleets - if ($subfleets === null || $subfleets->count() === 0) { + if ($subfleets->count() === 0) { $subfleets = $this->userSvc->getAllowableSubfleets($user); } // If subfleets are still empty return the flight - if ($subfleets === null || $subfleets->count() === 0) { + if ($subfleets->count() === 0) { return $flight; } diff --git a/app/Services/ImportExport/ExpenseExporter.php b/app/Services/ImportExport/ExpenseExporter.php index 12725058f..881035672 100644 --- a/app/Services/ImportExport/ExpenseExporter.php +++ b/app/Services/ImportExport/ExpenseExporter.php @@ -51,7 +51,7 @@ public function export($expense): array $ret['ref_model'] = ''; $ret['ref_model_id'] = ''; } else { - /** @var Aircraft|Airport|Subfleet $obj */ + /** @var Aircraft|Airport|Subfleet|null $obj */ $obj = $expense->getReferencedObject(); if (!$obj) { // bail out return $ret; diff --git a/app/Services/ImportService.php b/app/Services/ImportService.php index 2f2ea2a33..6590d8f81 100644 --- a/app/Services/ImportService.php +++ b/app/Services/ImportService.php @@ -24,16 +24,6 @@ class ImportService extends Service { - /** - * ImporterService constructor. - * - * @param FlightRepository $flightRepo - */ - public function __construct( - private readonly FlightRepository $flightRepo - ) { - } - /** * Throw a validation error back up because it will automatically show * itself under the CSV file upload, and nothing special needs to be done diff --git a/app/Services/Installer/SeederService.php b/app/Services/Installer/SeederService.php index 1d8fef685..2ac6028ff 100644 --- a/app/Services/Installer/SeederService.php +++ b/app/Services/Installer/SeederService.php @@ -188,9 +188,8 @@ private function addCounterGroup($name, $offset = null, $start_offset = 0): void ->first(); if ($group === null) { - $offset = (int) DB::table('settings')->max('offset'); - if ($offset === null) { - $offset = 0; + $offset = (int) DB::table('settings')->max('offset'); // If the query returns null then the variable worth 0 + if ($offset === 0) { $start_offset = 1; } else { $offset += 100; @@ -199,7 +198,7 @@ private function addCounterGroup($name, $offset = null, $start_offset = 0): void } else { // Now find the number to start from $start_offset = (int) DB::table('settings')->where('group', $name)->max('order'); - if ($start_offset === null) { + if ($start_offset === 0) { $start_offset = $offset + 1; } else { $start_offset++; diff --git a/app/Services/LegacyImporter/LedgerImporter.php b/app/Services/LegacyImporter/LedgerImporter.php index 55b351cd6..875ed4bd5 100644 --- a/app/Services/LegacyImporter/LedgerImporter.php +++ b/app/Services/LegacyImporter/LedgerImporter.php @@ -10,15 +10,6 @@ class LedgerImporter extends BaseImporter { protected $table = 'ledger'; - /** - * Legacy ID to the current ledger ref_model mapping - * - * @var array - */ - private static $legacy_paysource = [ - 1 => Pirep::class, - ]; - /** * {@inheritdoc} * diff --git a/app/Services/ModuleService.php b/app/Services/ModuleService.php index 15abe0184..3c64861ca 100644 --- a/app/Services/ModuleService.php +++ b/app/Services/ModuleService.php @@ -100,7 +100,7 @@ public function getAllModules(): array /** @var Module $module */ foreach ($moduleList as $module) { - /** @var \Nwidart\Modules\Module $moduleInstance */ + /** @var ?\Nwidart\Modules\Module $moduleInstance */ $moduleInstance = \Nwidart\Modules\Facades\Module::find($module->name); if (!$moduleInstance) { continue; @@ -129,7 +129,7 @@ public function isModuleActive(string $name): bool return false; } - /** @var \Nwidart\Modules\Module $moduleInstance */ + /** @var ?\Nwidart\Modules\Module $moduleInstance */ $moduleInstance = \Nwidart\Modules\Facades\Module::find($module->name); if (!$moduleInstance) { return false; diff --git a/app/Services/PirepService.php b/app/Services/PirepService.php index 41fc1e627..17e5da567 100644 --- a/app/Services/PirepService.php +++ b/app/Services/PirepService.php @@ -133,14 +133,14 @@ public function prefile(User $user, array $attrs, array $fields = [], array $far } // See if this aircraft is valid - /** @var Aircraft $aircraft */ + /** @var ?Aircraft $aircraft */ $aircraft = $this->aircraftRepo->findWithoutFail($pirep->aircraft_id); if ($aircraft === null) { throw new AircraftInvalid($aircraft); } // See if this aircraft is available for flight - /** @var Aircraft $aircraft */ + /** @var ?Aircraft $aircraft */ $aircraft = $this->aircraftRepo->where('id', $pirep->aircraft_id)->where('state', AircraftState::PARKED)->first(); if ($aircraft === null) { throw new AircraftNotAvailable($pirep->aircraft); @@ -181,7 +181,7 @@ public function prefile(User $user, array $attrs, array $fields = [], array $far // Check if there is a simbrief_id, update it to have the pirep_id // Keep the flight_id until the end of flight (pirep file) if (array_key_exists('simbrief_id', $attrs)) { - /** @var SimBrief $simbrief */ + /** @var ?SimBrief $simbrief */ $simbrief = SimBrief::find($attrs['simbrief_id']); if ($simbrief) { $this->simBriefSvc->attachSimbriefToPirep($pirep, $simbrief, true); @@ -304,7 +304,7 @@ public function file(Pirep $pirep, array $attrs = [], array $fields = [], array // Check if there is a simbrief_id, change it to be set to the PIREP // at the end of the flight when it's been filed if (array_key_exists('simbrief_id', $attrs)) { - /** @var SimBrief $simbrief */ + /** @var ?SimBrief $simbrief */ $simbrief = SimBrief::find($attrs['simbrief_id']); if ($simbrief) { $this->simBriefSvc->attachSimbriefToPirep($pirep, $simbrief); @@ -458,7 +458,7 @@ public function submit(Pirep $pirep) // visible at pireps.show blade uses this function so Simbrief also needs to // checked here too (to remove the flight_id and release the aircraft) if (!empty($pirep->simbrief)) { - /** @var SimBrief $simbrief */ + /** @var ?SimBrief $simbrief */ $simbrief = SimBrief::find($pirep->simbrief->id); if ($simbrief) { $this->simBriefSvc->attachSimbriefToPirep($pirep, $simbrief); @@ -766,6 +766,7 @@ public function handleDiversion(Pirep $pirep): void event(new PirepDiverted($pirep)); + /** @var ?Module $has_vmsacars */ $has_vmsacars = Module::find('VMSAcars'); if ($has_vmsacars && $flight) { diff --git a/app/Services/RoleService.php b/app/Services/RoleService.php index c6cd34ef3..3f041fca9 100644 --- a/app/Services/RoleService.php +++ b/app/Services/RoleService.php @@ -8,11 +8,6 @@ class RoleService extends Service { - public function __construct( - private readonly RoleRepository $roleRepo - ) { - } - /** * Update a role with the given attributes * diff --git a/app/Services/SimBriefService.php b/app/Services/SimBriefService.php index 15e27c800..b5876fbd6 100644 --- a/app/Services/SimBriefService.php +++ b/app/Services/SimBriefService.php @@ -131,7 +131,6 @@ public function getAcarsOFP(SimBriefXML $ofp) } } catch (GuzzleException $e) { Log::error('Simbrief HTTP Error: '.$e->getMessage()); - dd($e); return null; } diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 641d6ebe0..33daed33b 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -60,10 +60,10 @@ public function __construct( */ public function getUser($user_id): ?User { - /** @var User $user */ + /** @var ?User $user */ $user = $this->userRepo ->with(['airline', 'bids', 'rank']) - ->find($user_id); + ->findWithoutFail($user_id); if (!$user || $user->state === UserState::DELETED) { return null; diff --git a/app/Services/VersionService.php b/app/Services/VersionService.php index f7cf36cb1..4e7d729a3 100644 --- a/app/Services/VersionService.php +++ b/app/Services/VersionService.php @@ -78,6 +78,7 @@ private function getLatestVersionGithub() $releases = []; try { + /** @var array $releases */ $releases = $this->httpClient->get(config('phpvms.version_file'), [ 'headers' => [ 'Accept' => 'application/json', diff --git a/app/Support/HttpClient.php b/app/Support/HttpClient.php index 066d40754..fb134d3b8 100644 --- a/app/Support/HttpClient.php +++ b/app/Support/HttpClient.php @@ -117,7 +117,9 @@ public function download($uri, $local_path) $response = $this->httpClient->request('GET', $uri, $opts); $body = $response->getBody()->getContents(); - if ($response->getHeader('content-type') === 'application/json') { + $content_type = $response->getHeaderLine('content-type'); + + if (str_contains($content_type, 'application/json') !== false) { $body = \GuzzleHttp\json_decode($body); } diff --git a/app/Support/Metar.php b/app/Support/Metar.php index c7e36f418..33ec9b21a 100644 --- a/app/Support/Metar.php +++ b/app/Support/Metar.php @@ -269,6 +269,7 @@ class Metar implements \ArrayAccess /* * Trends time codes. */ + /* private static $trends_flag_codes = [ 'BECMG' => 'expected to arise soon', 'TEMPO' => 'expected to arise temporarily', @@ -276,16 +277,17 @@ class Metar implements \ArrayAccess 'PROV' => 'provisional forecast', 'CNL' => 'cancelled forecast', 'NIL' => 'nil forecast', - ]; + ];*/ /* * Trends time codes. */ + /* private static $trends_time_codes = [ 'AT' => 'at', 'FM' => 'from', 'TL' => 'until', - ]; + ];*/ /* * Interpretation of compass degrees codes. @@ -1485,6 +1487,7 @@ private function get_trends($part) // Ignore trends return true; + /* // Detects TAF on report if ($this->part <= 4) { $this->set_result_value('taf', true); @@ -1584,7 +1587,7 @@ private function get_trends($part) foreach ($debug as $message) { $this->set_debug('Recursion: '.$message); } - }*/ + }* end of commented code // Process parse errors if ($errors = $parser->errors()) { @@ -1623,6 +1626,7 @@ private function get_trends($part) $this->set_result_group('trends', $trend); return true; + */ } /** diff --git a/app/Support/Modules/DatabaseActivator.php b/app/Support/Modules/DatabaseActivator.php index 4bd673b24..229b74f48 100644 --- a/app/Support/Modules/DatabaseActivator.php +++ b/app/Support/Modules/DatabaseActivator.php @@ -18,13 +18,14 @@ class DatabaseActivator implements ActivatorInterface * Laravel config instance * * @var Config - */ - private $config; + * + private $config;*/ /** * @var Filesystem - */ + * private $files; + */ /** * The module path. @@ -40,18 +41,20 @@ class DatabaseActivator implements ActivatorInterface */ protected $paths = []; + /* /** * Array of modules activation statuses * * @var array - */ + * private $modulesStatuses; + */ - public function __construct(Container $app, $path = null) + public function __construct($path = null) { - $this->config = $app['config']; - $this->files = $app['files']; - $this->modulesStatuses = $this->getModulesStatuses(); + //$this->config = $app['config']; + //$this->files = $app['files']; + //$this->modulesStatuses = $this->getModulesStatuses(); $this->path = $path; } @@ -83,13 +86,14 @@ public function getModuleByName(string $name): ?\App\Models\Module * * @return array */ + /* private function getModulesStatuses(): array { try { if (app()->environment('production')) { $cache = config('cache.keys.MODULES'); $retVal = Cache::remember($cache['key'], $cache['time'], function () { - /** @var Collection $modules */ + /** @var Collection $modules * $modules = \App\Models\Module::select('name', 'enabled')->get(); $retValCache = []; @@ -100,7 +104,7 @@ private function getModulesStatuses(): array return $retValCache; }); } else { - /** @var Collection $modules */ + /** @var Collection $modules * $modules = \App\Models\Module::select('name', 'enabled')->get(); $retVal = []; @@ -113,6 +117,7 @@ private function getModulesStatuses(): array return []; } } + */ /** * {@inheritdoc} diff --git a/app/Support/Units/Altitude.php b/app/Support/Units/Altitude.php index 3cd44153e..52b939bad 100644 --- a/app/Support/Units/Altitude.php +++ b/app/Support/Units/Altitude.php @@ -14,7 +14,7 @@ class Altitude extends Unit ]; /** - * @param float $value + * @param float|self $value * @param string $unit * * @throws \PhpUnitsOfMeasure\Exception\NonNumericValue @@ -23,7 +23,7 @@ class Altitude extends Unit public function __construct($value, string $unit) { if (empty($value)) { - $value = 0; + $value = 0.; } $this->localUnit = setting('units.altitude'); diff --git a/app/Support/Units/Fuel.php b/app/Support/Units/Fuel.php index 31b7e57e0..8aea1fedd 100644 --- a/app/Support/Units/Fuel.php +++ b/app/Support/Units/Fuel.php @@ -13,7 +13,7 @@ class Fuel extends Unit ]; /** - * @param float $value + * @param float|self $value * @param string $unit * * @throws \PhpUnitsOfMeasure\Exception\NonNumericValue @@ -22,7 +22,7 @@ class Fuel extends Unit public function __construct($value, string $unit) { if (empty($value)) { - $value = 0; + $value = 0.; } $this->localUnit = setting('units.fuel'); diff --git a/app/Support/Units/Mass.php b/app/Support/Units/Mass.php index 120d35115..0897eec41 100644 --- a/app/Support/Units/Mass.php +++ b/app/Support/Units/Mass.php @@ -13,7 +13,7 @@ class Mass extends Unit ]; /** - * @param float $value + * @param float|self $value * @param string $unit * * @throws \PhpUnitsOfMeasure\Exception\NonNumericValue @@ -22,7 +22,7 @@ class Mass extends Unit public function __construct($value, string $unit) { if (empty($value)) { - $value = 0; + $value = 0.; } $this->localUnit = setting('units.weight'); diff --git a/app/Support/Units/Pressure.php b/app/Support/Units/Pressure.php index 751184cc9..ba7412623 100644 --- a/app/Support/Units/Pressure.php +++ b/app/Support/Units/Pressure.php @@ -16,7 +16,7 @@ class Pressure extends Unit ]; /** - * @param float $value + * @param float|self $value * @param string $unit * * @throws \PhpUnitsOfMeasure\Exception\NonNumericValue @@ -25,7 +25,7 @@ class Pressure extends Unit public function __construct($value, string $unit) { if (empty($value)) { - $value = 0; + $value = 0.; } $this->localUnit = setting('units.temperature'); diff --git a/app/Support/Units/Temperature.php b/app/Support/Units/Temperature.php index 759fb2422..f2c6a51bf 100644 --- a/app/Support/Units/Temperature.php +++ b/app/Support/Units/Temperature.php @@ -16,7 +16,7 @@ class Temperature extends Unit ]; /** - * @param float $value + * @param float|self $value * @param string $unit * * @throws \PhpUnitsOfMeasure\Exception\NonNumericValue @@ -25,7 +25,7 @@ class Temperature extends Unit public function __construct($value, string $unit) { if (empty($value)) { - $value = 0; + $value = 0.; } $this->localUnit = setting('units.temperature'); diff --git a/app/Support/Units/Time.php b/app/Support/Units/Time.php index 915ddd5d6..56560f63d 100644 --- a/app/Support/Units/Time.php +++ b/app/Support/Units/Time.php @@ -191,7 +191,7 @@ public static function minutesToHours($minutes) /** * @param $hours - * @param null $minutes + * @param ?int $minutes * * @return float|int */ diff --git a/app/Support/Units/Velocity.php b/app/Support/Units/Velocity.php index 46e0bcde2..03bb0c36b 100644 --- a/app/Support/Units/Velocity.php +++ b/app/Support/Units/Velocity.php @@ -16,7 +16,7 @@ class Velocity extends Unit ]; /** - * @param float $value + * @param float|self $value * @param string $unit * * @throws \PhpUnitsOfMeasure\Exception\NonNumericValue @@ -25,7 +25,7 @@ class Velocity extends Unit public function __construct($value, string $unit) { if (empty($value)) { - $value = 0; + $value = 0.; } $this->localUnit = setting('units.speed'); diff --git a/app/Support/Units/Volume.php b/app/Support/Units/Volume.php index 17fe1b63a..ec09a5400 100644 --- a/app/Support/Units/Volume.php +++ b/app/Support/Units/Volume.php @@ -16,7 +16,7 @@ class Volume extends Unit ]; /** - * @param float $value + * @param float|self $value * @param string $unit * * @throws \PhpUnitsOfMeasure\Exception\NonNumericValue @@ -25,7 +25,7 @@ class Volume extends Unit public function __construct($value, string $unit) { if (empty($value)) { - $value = 0; + $value = 0.; } $this->localUnit = setting('units.volume'); diff --git a/app/Support/Utils.php b/app/Support/Utils.php index 1be623841..8c4735387 100644 --- a/app/Support/Utils.php +++ b/app/Support/Utils.php @@ -90,7 +90,7 @@ public static function disableDebugToolbar() */ public static function installerEnabled() { - /** @var \Nwidart\Modules\Module $installer */ + /** @var ?\Nwidart\Modules\Module $installer */ $installer = Module::find('installer'); if (!$installer) { return false; diff --git a/app/Utils/ImporterDB.php b/app/Utils/ImporterDB.php index 5d6263dc6..7b6b9995a 100644 --- a/app/Utils/ImporterDB.php +++ b/app/Utils/ImporterDB.php @@ -215,7 +215,7 @@ public function readRows($table, $order_by = 'id', $start_offset = 0, $fields = * @param int $limit Number of rows to read * @param int $offset Where to start from * @param $order_by - * @param string $fields + * @param string|array $fields * * @return false|\PDOStatement|void */ diff --git a/phpstan.neon b/phpstan.neon index 842476b78..c382d73b0 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -7,7 +7,7 @@ parameters: - app/ # Level 9 is the highest level - level: 3 + level: 4 ignoreErrors: # Some Facades errors with nwidart laravel modules