diff --git a/app/Console/Commands/AcarsReplay.php b/app/Console/Commands/AcarsReplay.php
index f52671d2..efb3f545 100644
--- a/app/Console/Commands/AcarsReplay.php
+++ b/app/Console/Commands/AcarsReplay.php
@@ -241,7 +241,7 @@ class AcarsReplay extends Command
*
* @return mixed
*/
- public function handle()
+ public function handle(): void
{
$files = $this->argument('files');
$manual_mode = $this->option('manual');
@@ -249,6 +249,7 @@ class AcarsReplay extends Command
if ($this->option('write-all')) {
$this->info('In "dump-all" mode, just writing it all in');
} else {
+ /** @noinspection NestedPositiveIfStatementsInspection */
if (!$manual_mode) {
$this->info('Going to send updates every 10s');
} else {
diff --git a/app/Console/Commands/ComposerCommand.php b/app/Console/Commands/ComposerCommand.php
index 086cb311..8b238f6a 100644
--- a/app/Console/Commands/ComposerCommand.php
+++ b/app/Console/Commands/ComposerCommand.php
@@ -33,6 +33,7 @@ class ComposerCommand extends Command
protected function postUpdate(): void
{
if (config('app.env') === 'dev') {
+ /** @noinspection NestedPositiveIfStatementsInspection */
if (class_exists(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class)) {
Artisan::call('ide-helper:generate');
Artisan::call('ide-helper:meta');
diff --git a/app/Console/Commands/Version.php b/app/Console/Commands/Version.php
index cd153de6..6742b97d 100644
--- a/app/Console/Commands/Version.php
+++ b/app/Console/Commands/Version.php
@@ -16,6 +16,7 @@ class Version extends Command
* Create the version number that gets written out
*
* @param mixed $cfg
+ * @return bool|string
*/
protected function createVersionNumber($cfg)
{
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
index 76008907..a7a88416 100755
--- a/app/Console/Kernel.php
+++ b/app/Console/Kernel.php
@@ -14,16 +14,6 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
*/
class Kernel extends ConsoleKernel
{
- protected $commands = [
- /*Commands\AcarsReplay::class,
- Commands\CreateDatabase::class,
- Commands\DevCommands::class,
- Commands\YamlImport::class,
- Commands\ImportFromClassic::class,
- Commands\NavdataImport::class,
- Commands\TestApi::class,*/
- ];
-
/**
* Define the application's command schedule.
*
diff --git a/app/Console/Services/Importer.php b/app/Console/Services/Importer.php
index 305868be..09975504 100644
--- a/app/Console/Services/Importer.php
+++ b/app/Console/Services/Importer.php
@@ -43,7 +43,7 @@ class Importer
/**
* @var array
*/
- private $creds = [];
+ private $creds;
/**
* Hold the instance of the console logger
@@ -55,8 +55,8 @@ class Importer
/**
* CONSTANTS
*/
- const BATCH_READ_ROWS = 300;
- const SUBFLEET_NAME = 'Imported Aircraft';
+ public const BATCH_READ_ROWS = 300;
+ public const SUBFLEET_NAME = 'Imported Aircraft';
/**
* Importer constructor.
@@ -140,11 +140,12 @@ class Importer
}
/**
- * @param string $message
+ * @param string|array $message
*/
protected function info($message)
{
if (\is_array($message)) {
+ /** @noinspection ForgottenDebugOutputInspection */
print_r($message);
} else {
$this->log->writeln(''.$message.'');
diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php
index 4d0ea56b..0f620ecd 100755
--- a/app/Exceptions/Handler.php
+++ b/app/Exceptions/Handler.php
@@ -28,21 +28,6 @@ class Handler extends ExceptionHandler
\Illuminate\Validation\ValidationException::class,
];
- /**
- * Report or log an exception.
- * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
- *
- * @param \Exception $exception
- *
- * @throws Exception
- *
- * @return void
- */
- public function report(Exception $exception)
- {
- parent::report($exception);
- }
-
/**
* Create an error message
*
diff --git a/app/Facades/Utils.php b/app/Facades/Utils.php
index 6a17e0bd..67bba325 100644
--- a/app/Facades/Utils.php
+++ b/app/Facades/Utils.php
@@ -13,7 +13,7 @@ class Utils extends Facade
/**
* @return string
*/
- protected static function getFacadeAccessor()
+ protected static function getFacadeAccessor(): string
{
return 'utils';
}
@@ -25,7 +25,7 @@ class Utils extends Facade
*
* @return bool
*/
- public static function isObject($obj)
+ public static function isObject($obj): bool
{
if (!$obj) {
return false;
@@ -42,14 +42,15 @@ class Utils extends Facade
* Download a URI. If a file is given, it will save the downloaded
* content into that file
*
- * @param $uri
- * @param null $file
+ * @param string $uri
+ * @param null $file
*
* @throws \RuntimeException
+ * @throws \GuzzleHttp\Exception\GuzzleException
*
* @return string
*/
- public static function downloadUrl($uri, $file = null)
+ public static function downloadUrl($uri, $file = null): string
{
$opts = [];
if ($file !== null) {
@@ -72,12 +73,16 @@ class Utils extends Facade
*
* @return string
*/
- public static function generateApiKey()
+ public static function generateApiKey(): string
{
$key = substr(sha1(time().mt_rand()), 0, 20);
return $key;
}
+ /**
+ * @param string $minutes
+ * @return array
+ */
public static function minutesToTimeParts($minutes): array
{
$hours = floor($minutes / 60);
@@ -95,9 +100,10 @@ class Utils extends Facade
/**
* Convert seconds to an array of hours, minutes, seconds
*
- * @param $seconds
+ * @param int $seconds
*
* @return array['h', 'm', 's']
+ * @throws \Exception
*/
public static function secondsToTimeParts($seconds): array
{
@@ -117,10 +123,11 @@ class Utils extends Facade
/**
* Convert seconds to HH MM format
*
- * @param $seconds
+ * @param int $seconds
* @param bool $incl_sec
*
* @return string
+ * @throws \Exception
*/
public static function secondsToTimeString($seconds, $incl_sec = false): string
{
@@ -191,7 +198,7 @@ class Utils extends Facade
*
* @return int
*/
- public static function setDays(int $datefield, array $day_enums)
+ public static function setDays(int $datefield, array $day_enums): int
{
foreach ($day_enums as $day) {
$datefield |= $day;
@@ -208,7 +215,7 @@ class Utils extends Facade
*
* @return bool
*/
- public static function hasDay(int $datefield, int $day_enum)
+ public static function hasDay(int $datefield, int $day_enum): bool
{
return ($datefield & $day_enum) === $datefield;
}
diff --git a/app/Http/Controllers/Admin/AircraftController.php b/app/Http/Controllers/Admin/AircraftController.php
index 817debf3..eccee88a 100644
--- a/app/Http/Controllers/Admin/AircraftController.php
+++ b/app/Http/Controllers/Admin/AircraftController.php
@@ -45,8 +45,6 @@ class AircraftController extends Controller
*
* @param Request $request
*
- * @throws \Prettus\Repository\Exceptions\RepositoryException
- *
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index(Request $request)
@@ -101,6 +99,8 @@ class AircraftController extends Controller
* Display the specified Aircraft.
*
* @param mixed $id
+ *
+ * @return mixed
*/
public function show($id)
{
@@ -120,6 +120,8 @@ class AircraftController extends Controller
* Show the form for editing the specified Aircraft.
*
* @param mixed $id
+ *
+ * @return mixed
*/
public function edit($id)
{
@@ -143,6 +145,8 @@ class AircraftController extends Controller
* @param mixed $id
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
+ *
+ * @return mixed
*/
public function update($id, UpdateAircraftRequest $request)
{
@@ -164,6 +168,8 @@ class AircraftController extends Controller
* Remove the specified Aircraft from storage.
*
* @param mixed $id
+ *
+ * @return mixed
*/
public function destroy($id)
{
@@ -187,7 +193,7 @@ class AircraftController extends Controller
*
* @throws \League\Csv\Exception
*
- * @return \Symfony\Component\HttpFoundation\BinaryFileResponse
+ * @return mixed
*/
public function export(Request $request)
{
@@ -207,7 +213,7 @@ class AircraftController extends Controller
*
* @throws \Illuminate\Validation\ValidationException
*
- * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+ * @return mixed
*/
public function import(Request $request)
{
@@ -254,7 +260,7 @@ class AircraftController extends Controller
*
* @throws \Exception
*
- * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+ * @return mixed
*/
public function expenses($id, Request $request)
{
diff --git a/app/Http/Controllers/Admin/DashboardController.php b/app/Http/Controllers/Admin/DashboardController.php
index be9cba0b..5edd4805 100644
--- a/app/Http/Controllers/Admin/DashboardController.php
+++ b/app/Http/Controllers/Admin/DashboardController.php
@@ -45,7 +45,7 @@ class DashboardController extends Controller
* S3 and then using the semver library to do the comparison. Just show
* a session flash file on this page that'll get cleared right away
*
- * @throws \RuntimeException
+ * @throws \GuzzleHttp\Exception\GuzzleException
*/
protected function checkNewVersion()
{
@@ -65,7 +65,10 @@ class DashboardController extends Controller
/**
* Show the admin dashboard
*
- * @throws \RuntimeException
+ * @param Request $request
+ * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+ * @throws \GuzzleHttp\Exception\GuzzleException
+ * @throws \GuzzleHttp\Exception\GuzzleException
*/
public function index(Request $request)
{
diff --git a/app/Http/Controllers/Admin/FlightController.php b/app/Http/Controllers/Admin/FlightController.php
index b0299713..3f970486 100644
--- a/app/Http/Controllers/Admin/FlightController.php
+++ b/app/Http/Controllers/Admin/FlightController.php
@@ -100,7 +100,7 @@ class FlightController extends Controller
}
Log::info('PIREP Custom Fields', $custom_fields);
- $this->flightSvc->updateCustomFields($flight->id, $custom_fields);
+ $this->flightSvc->updateCustomFields($flight, $custom_fields);
}
/**
@@ -483,6 +483,9 @@ class FlightController extends Controller
* Get all the fares that haven't been assigned to a given subfleet
*
* @param mixed $flight
+ *
+ * @return mixed
+ * @return array
*/
protected function getAvailFares($flight)
{
diff --git a/app/Http/Controllers/Admin/PirepFieldController.php b/app/Http/Controllers/Admin/PirepFieldController.php
index 7325b6e5..c67d6f29 100644
--- a/app/Http/Controllers/Admin/PirepFieldController.php
+++ b/app/Http/Controllers/Admin/PirepFieldController.php
@@ -129,6 +129,7 @@ class PirepFieldController extends Controller
*
* @param mixed $id
*
+ * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \Prettus\Validator\Exceptions\ValidatorException
*/
public function update($id, UpdatePirepFieldRequest $request)
diff --git a/app/Http/Controllers/Admin/SubfleetController.php b/app/Http/Controllers/Admin/SubfleetController.php
index c0702b36..1809f9da 100644
--- a/app/Http/Controllers/Admin/SubfleetController.php
+++ b/app/Http/Controllers/Admin/SubfleetController.php
@@ -90,6 +90,7 @@ class SubfleetController extends Controller
* Get all the fares that haven't been assigned to a given subfleet
*
* @param mixed $subfleet
+ * @return array
*/
protected function getAvailFares($subfleet)
{
@@ -268,6 +269,7 @@ class SubfleetController extends Controller
* @param Request $request
*
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
+ * @throws \League\Csv\CannotInsertRecord
*/
public function export(Request $request)
{
diff --git a/app/Http/Controllers/Api/AcarsController.php b/app/Http/Controllers/Api/AcarsController.php
index ff2b2ea1..56280f97 100644
--- a/app/Http/Controllers/Api/AcarsController.php
+++ b/app/Http/Controllers/Api/AcarsController.php
@@ -15,7 +15,6 @@ use App\Models\Pirep;
use App\Repositories\AcarsRepository;
use App\Repositories\PirepRepository;
use App\Services\GeoService;
-use App\Services\PirepService;
use Auth;
use Carbon\Carbon;
use Illuminate\Http\Request;
@@ -29,7 +28,6 @@ class AcarsController extends Controller
private $acarsRepo;
private $geoSvc;
private $pirepRepo;
- private $pirepSvc;
/**
* AcarsController constructor.
@@ -37,18 +35,15 @@ class AcarsController extends Controller
* @param AcarsRepository $acarsRepo
* @param GeoService $geoSvc
* @param PirepRepository $pirepRepo
- * @param PirepService $pirepSvc
*/
public function __construct(
AcarsRepository $acarsRepo,
GeoService $geoSvc,
- PirepRepository $pirepRepo,
- PirepService $pirepSvc
+ PirepRepository $pirepRepo
) {
$this->geoSvc = $geoSvc;
$this->acarsRepo = $acarsRepo;
$this->pirepRepo = $pirepRepo;
- $this->pirepSvc = $pirepSvc;
}
/**
diff --git a/app/Http/Controllers/Api/PirepController.php b/app/Http/Controllers/Api/PirepController.php
index d47e7911..4db7ffd0 100644
--- a/app/Http/Controllers/Api/PirepController.php
+++ b/app/Http/Controllers/Api/PirepController.php
@@ -222,6 +222,7 @@ class PirepController extends Controller
$pirep = new Pirep($attrs);
// See if this user is at the current airport
+ /** @noinspection NotOptimalIfConditionsInspection */
if (setting('pilots.only_flights_from_current')
&& $user->curr_airport_id !== $pirep->dpt_airport_id) {
throw new UserNotAtAirport();
@@ -234,6 +235,7 @@ class PirepController extends Controller
}
// See if this aircraft is at the departure airport
+ /** @noinspection NotOptimalIfConditionsInspection */
if (setting('pireps.only_aircraft_at_dpt_airport')
&& $pirep->aircraft_id !== $pirep->dpt_airport_id) {
throw new AircraftNotAtAirport();
diff --git a/app/Http/Controllers/Api/UserController.php b/app/Http/Controllers/Api/UserController.php
index b86392a6..5b833993 100644
--- a/app/Http/Controllers/Api/UserController.php
+++ b/app/Http/Controllers/Api/UserController.php
@@ -29,7 +29,6 @@ class UserController extends Controller
private $flightRepo;
private $flightSvc;
private $pirepRepo;
- private $subfleetRepo;
private $userRepo;
private $userSvc;
@@ -39,7 +38,6 @@ class UserController extends Controller
* @param FlightRepository $flightRepo
* @param FlightService $flightSvc
* @param PirepRepository $pirepRepo
- * @param SubfleetRepository $subfleetRepo
* @param UserRepository $userRepo
* @param UserService $userSvc
*/
@@ -47,14 +45,12 @@ class UserController extends Controller
FlightRepository $flightRepo,
FlightService $flightSvc,
PirepRepository $pirepRepo,
- SubfleetRepository $subfleetRepo,
UserRepository $userRepo,
UserService $userSvc
) {
$this->flightRepo = $flightRepo;
$this->flightSvc = $flightSvc;
$this->pirepRepo = $pirepRepo;
- $this->subfleetRepo = $subfleetRepo;
$this->userRepo = $userRepo;
$this->userSvc = $userSvc;
}
diff --git a/app/Http/Controllers/Frontend/AirportController.php b/app/Http/Controllers/Frontend/AirportController.php
index cfc34388..f9039252 100644
--- a/app/Http/Controllers/Frontend/AirportController.php
+++ b/app/Http/Controllers/Frontend/AirportController.php
@@ -28,6 +28,9 @@ class AirportController extends Controller
* Show the airport
*
* @param mixed $id
+ *
+ * @return mixed
+ * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
*/
public function show($id, Request $request)
{
diff --git a/app/Http/Controllers/Frontend/DownloadController.php b/app/Http/Controllers/Frontend/DownloadController.php
index 28aa0e38..3d1972e9 100644
--- a/app/Http/Controllers/Frontend/DownloadController.php
+++ b/app/Http/Controllers/Frontend/DownloadController.php
@@ -54,7 +54,10 @@ class DownloadController extends Controller
/**
* Show the application dashboard.
*
- * @param mixed $id
+ * @param string $id
+ *
+ * @return mixed
+ * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Symfony\Component\HttpFoundation\StreamedResponse
*/
public function show($id)
{
diff --git a/app/Http/Controllers/Frontend/PirepController.php b/app/Http/Controllers/Frontend/PirepController.php
index a494af7b..a9538837 100644
--- a/app/Http/Controllers/Frontend/PirepController.php
+++ b/app/Http/Controllers/Frontend/PirepController.php
@@ -284,6 +284,7 @@ class PirepController extends Controller
}
// is the aircraft in the right place?
+ /** @noinspection NotOptimalIfConditionsInspection */
if (setting('pireps.only_aircraft_at_dpt_airport')
&& $pirep->aircraft_id !== $pirep->dpt_airport_id) {
return $this->flashError(
@@ -356,7 +357,7 @@ class PirepController extends Controller
// set the custom fields
foreach ($pirep->fields as $field) {
- if ($field->slug == null) {
+ if ($field->slug === null) {
$field->slug = str_slug($field->name);
}
diff --git a/app/Http/Middleware/EncryptCookies.php b/app/Http/Middleware/EncryptCookies.php
index 3aa15f8d..15a20c00 100755
--- a/app/Http/Middleware/EncryptCookies.php
+++ b/app/Http/Middleware/EncryptCookies.php
@@ -11,7 +11,5 @@ class EncryptCookies extends BaseEncrypter
*
* @var array
*/
- protected $except = [
- //
- ];
+ protected $except = [];
}
diff --git a/app/Http/Middleware/MeasureExecutionTime.php b/app/Http/Middleware/MeasureExecutionTime.php
index b83329d6..59139ce0 100644
--- a/app/Http/Middleware/MeasureExecutionTime.php
+++ b/app/Http/Middleware/MeasureExecutionTime.php
@@ -21,7 +21,7 @@ class MeasureExecutionTime
{
// Get the response
$response = $next($request);
- if (!defined('LUMEN_START')) {
+ if (!\defined('LUMEN_START')) {
return $response;
}
diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php
index 0faba9ee..9c26fd50 100755
--- a/app/Http/Middleware/VerifyCsrfToken.php
+++ b/app/Http/Middleware/VerifyCsrfToken.php
@@ -11,6 +11,5 @@ class VerifyCsrfToken extends BaseVerifier
*
* @var array
*/
- protected $except = [
- ];
+ protected $except = [];
}
diff --git a/app/Http/Requests/Acars/CommentRequest.php b/app/Http/Requests/Acars/CommentRequest.php
index 83feded9..1493c185 100644
--- a/app/Http/Requests/Acars/CommentRequest.php
+++ b/app/Http/Requests/Acars/CommentRequest.php
@@ -5,16 +5,11 @@ namespace App\Http\Requests\Acars;
use App\Interfaces\FormRequest;
/**
- * Class FileRequest
+ * Class CommentRequest
*/
class CommentRequest extends FormRequest
{
- public function authorize()
- {
- return true; // Anyone can comment
- }
-
- public function rules()
+ public function rules(): array
{
$rules = [
'comment' => 'required',
diff --git a/app/Http/Requests/Acars/PositionRequest.php b/app/Http/Requests/Acars/PositionRequest.php
index 5aef5163..d637ca4d 100644
--- a/app/Http/Requests/Acars/PositionRequest.php
+++ b/app/Http/Requests/Acars/PositionRequest.php
@@ -3,7 +3,6 @@
namespace App\Http\Requests\Acars;
use App\Interfaces\FormRequest;
-use App\Models\Acars;
use App\Models\Pirep;
use Auth;
diff --git a/app/Http/Requests/Acars/PrefileRequest.php b/app/Http/Requests/Acars/PrefileRequest.php
index 14d7c989..8344bbb2 100644
--- a/app/Http/Requests/Acars/PrefileRequest.php
+++ b/app/Http/Requests/Acars/PrefileRequest.php
@@ -3,7 +3,6 @@
namespace App\Http\Requests\Acars;
use App\Interfaces\FormRequest;
-use App\Models\Pirep;
/**
* Class PrefileRequest
diff --git a/app/Http/Resources/AcarsLog.php b/app/Http/Resources/AcarsLog.php
index 3d86cf23..3c2bfb02 100644
--- a/app/Http/Resources/AcarsLog.php
+++ b/app/Http/Resources/AcarsLog.php
@@ -10,15 +10,5 @@ use Illuminate\Http\Resources\Json\Resource;
*/
class AcarsLog extends Resource
{
- public function toArray($request)
- {
- return parent::toArray($request);
- /*return [
- 'id' => $this->id,
- 'name' => $this->name,
- 'log' => $this->log,
- 'lat' => $this->lat,
- 'lon' => $this->lon,
- ];*/
- }
+
}
diff --git a/app/Http/Resources/AcarsRoute.php b/app/Http/Resources/AcarsRoute.php
index 9e756683..89cc09f2 100644
--- a/app/Http/Resources/AcarsRoute.php
+++ b/app/Http/Resources/AcarsRoute.php
@@ -10,16 +10,5 @@ use Illuminate\Http\Resources\Json\Resource;
*/
class AcarsRoute extends Resource
{
- public function toArray($request)
- {
- return parent::toArray($request);
- /*return [
- 'id' => $this->id,
- 'name' => $this->name,
- 'order' => $this->order,
- 'nav_type' => $this->nav_type,
- 'lat' => $this->lat,
- 'lon' => $this->lon,
- ];*/
- }
+
}
diff --git a/app/Http/Resources/Aircraft.php b/app/Http/Resources/Aircraft.php
index aa410fca..aa62694b 100644
--- a/app/Http/Resources/Aircraft.php
+++ b/app/Http/Resources/Aircraft.php
@@ -6,8 +6,5 @@ use Illuminate\Http\Resources\Json\Resource;
class Aircraft extends Resource
{
- public function toArray($request)
- {
- return parent::toArray($request);
- }
+
}
diff --git a/app/Http/Resources/Airport.php b/app/Http/Resources/Airport.php
index 53b95ef9..0a255653 100644
--- a/app/Http/Resources/Airport.php
+++ b/app/Http/Resources/Airport.php
@@ -6,8 +6,5 @@ use Illuminate\Http\Resources\Json\Resource;
class Airport extends Resource
{
- public function toArray($request)
- {
- return parent::toArray($request);
- }
+
}
diff --git a/app/Http/Resources/Response.php b/app/Http/Resources/Response.php
index bbf0cc65..0c285709 100644
--- a/app/Http/Resources/Response.php
+++ b/app/Http/Resources/Response.php
@@ -9,15 +9,5 @@ use Illuminate\Http\Resources\Json\Resource;
*/
class Response extends Resource
{
- /**
- * Transform the resource into an array.
- *
- * @param \Illuminate\Http\Request $request
- *
- * @return array
- */
- public function toArray($request)
- {
- return parent::toArray($request);
- }
+
}
diff --git a/app/Interfaces/Award.php b/app/Interfaces/Award.php
index 389cc4aa..2301e126 100644
--- a/app/Interfaces/Award.php
+++ b/app/Interfaces/Award.php
@@ -96,7 +96,7 @@ abstract class Award
$e->getTrace()
);
- return;
+ return false;
}
return $award;
diff --git a/app/Interfaces/Controller.php b/app/Interfaces/Controller.php
index 4cd35885..ee539c25 100755
--- a/app/Interfaces/Controller.php
+++ b/app/Interfaces/Controller.php
@@ -62,6 +62,7 @@ abstract class Controller extends \Illuminate\Routing\Controller
$fields[$field] = $request->input($field);
}
} else {
+ /** @noinspection NestedPositiveIfStatementsInspection */
if (array_key_exists($field, $request)) {
$fields[$field] = $request[$field];
}
diff --git a/app/Interfaces/Enum.php b/app/Interfaces/Enum.php
index 72778b30..2db997c2 100644
--- a/app/Interfaces/Enum.php
+++ b/app/Interfaces/Enum.php
@@ -138,7 +138,7 @@ abstract class Enum
*/
final public function equals(self $enum): bool
{
- return $this->getValue() === $enum->getValue() && get_called_class() == get_class($enum);
+ return $this->getValue() === $enum->getValue() && static::class === \get_class($enum);
}
/**
@@ -161,7 +161,7 @@ abstract class Enum
}
throw new \BadMethodCallException(
- "No static method or enum constant '$name' in class ".get_called_class()
+ "No static method or enum constant '$name' in class ".static::class
);
}
}
diff --git a/app/Interfaces/ImportExport.php b/app/Interfaces/ImportExport.php
index 0b25a15b..72c584ef 100644
--- a/app/Interfaces/ImportExport.php
+++ b/app/Interfaces/ImportExport.php
@@ -51,7 +51,7 @@ class ImportExport
*
* @param $code
*
- * @return Airline
+ * @return \Illuminate\Database\Eloquent\Model
*/
public function getAirline($code)
{
diff --git a/app/Interfaces/Repository.php b/app/Interfaces/Repository.php
index 89e5cabf..26aa6236 100644
--- a/app/Interfaces/Repository.php
+++ b/app/Interfaces/Repository.php
@@ -15,7 +15,7 @@ abstract class Repository extends \Prettus\Repository\Eloquent\BaseRepository
*
* @return mixed|null
*/
- public function findWithoutFail($id, $columns = ['*'])
+ public function findWithoutFail($id, array $columns = ['*'])
{
try {
return $this->find($id, $columns);
diff --git a/app/Models/Acars.php b/app/Models/Acars.php
index dffba7b7..f3bcdfe8 100644
--- a/app/Models/Acars.php
+++ b/app/Models/Acars.php
@@ -87,7 +87,7 @@ class Acars extends Model
public function getDistanceAttribute()
{
if (!array_key_exists('distance', $this->attributes)) {
- return;
+ return 0;
}
try {
@@ -127,7 +127,7 @@ class Acars extends Model
public function getFuelAttribute()
{
if (!array_key_exists('fuel', $this->attributes)) {
- return;
+ return 0;
}
try {
diff --git a/app/Models/Award.php b/app/Models/Award.php
index 4a3dce33..9f624759 100755
--- a/app/Models/Award.php
+++ b/app/Models/Award.php
@@ -34,8 +34,8 @@ class Award extends Model
/**
* Get the referring object
*
- * @param Award|null $award
- * @param User|null $user
+ * @param self $award
+ * @param User|null $user
*
* @return null
*/
diff --git a/app/Models/Flight.php b/app/Models/Flight.php
index f5e65d34..9dd9dce2 100644
--- a/app/Models/Flight.php
+++ b/app/Models/Flight.php
@@ -104,6 +104,7 @@ class Flight extends Model
*/
public static function findByDays(array $days)
{
+ /** @noinspection DynamicInvocationViaScopeResolutionInspection */
$flights = self::where('active', true);
foreach ($days as $day) {
$flights = $flights->where('days', '&', $day);
@@ -139,7 +140,7 @@ class Flight extends Model
public function getDistanceAttribute()
{
if (!array_key_exists('distance', $this->attributes)) {
- return;
+ return 0;
}
try {
diff --git a/app/Models/Observers/AircraftObserver.php b/app/Models/Observers/AircraftObserver.php
index 05b3138e..0c9d8f14 100644
--- a/app/Models/Observers/AircraftObserver.php
+++ b/app/Models/Observers/AircraftObserver.php
@@ -12,6 +12,7 @@ class AircraftObserver
{
/**
* @param Aircraft $aircraft
+ * @throws \Exception
*/
public function creating(Aircraft $aircraft): void
{
diff --git a/app/Models/Pirep.php b/app/Models/Pirep.php
index e908169b..493524cd 100644
--- a/app/Models/Pirep.php
+++ b/app/Models/Pirep.php
@@ -21,9 +21,9 @@ use PhpUnitsOfMeasure\Exception\NonStringUnitName;
* @property string flight_number
* @property string route_code
* @property string route_leg
- * @property int airline_id
- * @property int user_id
- * @property int aircraft_id
+ * @property int airline_id
+ * @property int user_id
+ * @property int aircraft_id
* @property Aircraft aircraft
* @property Airline airline
* @property Airport arr_airport
@@ -32,13 +32,13 @@ use PhpUnitsOfMeasure\Exception\NonStringUnitName;
* @property string dpt_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 float distance
- * @property float planned_distance
+ * @property int block_time
+ * @property int flight_time In minutes
+ * @property int planned_flight_time
+ * @property float distance
+ * @property float planned_distance
* @property string route
- * @property int score
+ * @property int score
* @property User user
* @property Flight|null flight
* @property Collection fields
@@ -50,6 +50,7 @@ use PhpUnitsOfMeasure\Exception\NonStringUnitName;
* @property bool read_only
* @property Acars position
* @property Acars[] acars
+ * @property mixed cancelled
*/
class Pirep extends Model
{
@@ -160,25 +161,29 @@ class Pirep extends Model
/**
* Return the block off time in carbon format
*
- * @return Carbon
+ * @return Carbon|null
*/
public function getBlockOffTimeAttribute()
{
if (array_key_exists('block_off_time', $this->attributes)) {
return new Carbon($this->attributes['block_off_time']);
}
+
+ return null;
}
/**
* Return the block on time
*
- * @return Carbon
+ * @return Carbon|null
*/
public function getBlockOnTimeAttribute()
{
if (array_key_exists('block_on_time', $this->attributes)) {
return new Carbon($this->attributes['block_on_time']);
}
+
+ return null;
}
/**
@@ -191,6 +196,8 @@ class Pirep extends Model
if (array_key_exists('submitted_at', $this->attributes)) {
return new Carbon($this->attributes['submitted_at']);
}
+
+ return null;
}
/**
@@ -201,7 +208,7 @@ class Pirep extends Model
public function getDistanceAttribute()
{
if (!array_key_exists('distance', $this->attributes)) {
- return;
+ return 0;
}
try {
@@ -249,7 +256,7 @@ class Pirep extends Model
public function getFuelUsedAttribute()
{
if (!array_key_exists('fuel_used', $this->attributes)) {
- return;
+ return 0;
}
try {
@@ -271,7 +278,7 @@ class Pirep extends Model
public function getPlannedDistanceAttribute()
{
if (!array_key_exists('planned_distance', $this->attributes)) {
- return;
+ return 0;
}
try {
@@ -401,7 +408,7 @@ class Pirep extends Model
/**
* Return if this is cancelled or not
*/
- public function getCancelledAttribute()
+ public function getCancelledAttribute(): bool
{
return $this->state === PirepState::CANCELLED;
}
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
index 165f6ad3..77bc4f50 100755
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -64,6 +64,7 @@ class AppServiceProvider extends ServiceProvider
if ($this->app->environment() === 'dev') {
// Only load the IDE helper if it's included. This lets use distribute the
// package without any dev dependencies
+ /** @noinspection NestedPositiveIfStatementsInspection */
if (class_exists(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class)) {
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
}
diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php
index 12e9f337..6f0382f9 100755
--- a/app/Providers/RouteServiceProvider.php
+++ b/app/Providers/RouteServiceProvider.php
@@ -16,18 +16,6 @@ class RouteServiceProvider extends ServiceProvider
*/
protected $namespace = 'App\Http\Controllers';
- /**
- * Define your route model bindings, pattern filters, etc.
- *
- * @return void
- */
- public function boot()
- {
- //
-
- parent::boot();
- }
-
/**
* Define the routes for the application.
*
diff --git a/app/Repositories/SettingRepository.php b/app/Repositories/SettingRepository.php
index bfa60142..0f542c25 100644
--- a/app/Repositories/SettingRepository.php
+++ b/app/Repositories/SettingRepository.php
@@ -51,25 +51,15 @@ class SettingRepository extends Repository implements CacheableInterface
case 'bool':
case 'boolean':
$value = $setting->value;
- if ($value === 'true' || $value === '1') {
- $value = true;
- } elseif ($value === 'false' || $value === '0') {
- $value = false;
- }
-
- return (bool) $value;
- break;
+ return $value === 'true' || $value === '1' || $value === 1;
case 'date':
return Carbon::parse($setting->value);
- break;
case 'int':
case 'integer':
case 'number':
return (int) $setting->value;
- break;
case 'float':
return (float) $setting->value;
- break;
default:
return $setting->value;
}
@@ -80,6 +70,7 @@ class SettingRepository extends Repository implements CacheableInterface
*
* @param mixed $key
* @param mixed $value
+ * @return null
*/
public function save($key, $value)
{
diff --git a/app/Services/DatabaseService.php b/app/Services/DatabaseService.php
index f3f43104..70b492ba 100644
--- a/app/Services/DatabaseService.php
+++ b/app/Services/DatabaseService.php
@@ -70,6 +70,7 @@ class DatabaseService extends Service
// see if this table uses a UUID as the PK
// if no ID is specified
if (\in_array($table, $this->uuid_tables, true)) {
+ /** @noinspection NestedPositiveIfStatementsInspection */
if (!array_key_exists('id', $row)) {
$row['id'] = Uuid::generate()->string;
}
diff --git a/app/Services/FareService.php b/app/Services/FareService.php
index 5bdc1cd7..bb8a0abd 100644
--- a/app/Services/FareService.php
+++ b/app/Services/FareService.php
@@ -165,7 +165,7 @@ class FareService extends Service
$subfleet->fares()->syncWithoutDetaching([$fare->id]);
// modify any pivot values?
- if (count($override) > 0) {
+ if (\count($override) > 0) {
$subfleet->fares()->updateExistingPivot($fare->id, $override);
}
diff --git a/app/Services/Finance/PirepFinanceService.php b/app/Services/Finance/PirepFinanceService.php
index e4169e92..2dc07134 100644
--- a/app/Services/Finance/PirepFinanceService.php
+++ b/app/Services/Finance/PirepFinanceService.php
@@ -24,7 +24,6 @@ class PirepFinanceService extends Service
private $expenseRepo;
private $fareSvc;
private $journalRepo;
- private $pirepSvc;
/**
* FinanceService constructor.
@@ -32,18 +31,15 @@ class PirepFinanceService extends Service
* @param ExpenseRepository $expenseRepo
* @param FareService $fareSvc
* @param JournalRepository $journalRepo
- * @param PirepService $pirepSvc
*/
public function __construct(
ExpenseRepository $expenseRepo,
FareService $fareSvc,
- JournalRepository $journalRepo,
- PirepService $pirepSvc
+ JournalRepository $journalRepo
) {
$this->expenseRepo = $expenseRepo;
$this->fareSvc = $fareSvc;
$this->journalRepo = $journalRepo;
- $this->pirepSvc = $pirepSvc;
}
/**
@@ -288,6 +284,7 @@ class PirepFinanceService extends Service
.$expense->name.'", A='.$expense->amount);
// If an airline_id is filled, then see if it matches
+ /** @noinspection NotOptimalIfConditionsInspection */
if (filled($expense->airline_id) && $expense->airline_id !== $pirep->airline_id) {
Log::info('Finance: Expense has an airline ID and it doesn\'t match, skipping');
continue;
diff --git a/app/Services/FlightService.php b/app/Services/FlightService.php
index 89f75faf..a5d409bf 100644
--- a/app/Services/FlightService.php
+++ b/app/Services/FlightService.php
@@ -17,7 +17,6 @@ use Log;
*/
class FlightService extends Service
{
- private $fareSvc;
private $flightRepo;
private $navDataRepo;
private $userSvc;
@@ -25,18 +24,15 @@ class FlightService extends Service
/**
* FlightService constructor.
*
- * @param FareService $fareSvc
* @param FlightRepository $flightRepo
* @param NavdataRepository $navdataRepo
* @param UserService $userSvc
*/
public function __construct(
- FareService $fareSvc,
FlightRepository $flightRepo,
NavdataRepository $navdataRepo,
UserService $userSvc
) {
- $this->fareSvc = $fareSvc;
$this->flightRepo = $flightRepo;
$this->navDataRepo = $navdataRepo;
$this->userSvc = $userSvc;
@@ -128,19 +124,11 @@ class FlightService extends Service
// Return any flights that have the same route code and leg
// If this list is > 0, then this has a duplicate
$found_flights = $found_flights->filter(function ($value, $key) use ($flight) {
- if ($flight->route_code === $value->route_code
- && $flight->route_leg === $value->route_leg) {
- return true;
- }
-
- return false;
+ return $flight->route_code === $value->route_code
+ && $flight->route_leg === $value->route_leg;
});
- if ($found_flights->count() === 0) {
- return false;
- }
-
- return true;
+ return !($found_flights->count() === 0);
}
/**
@@ -191,9 +179,7 @@ class FlightService extends Service
return collect();
}
- $route_points = array_map(function ($point) {
- return strtoupper($point);
- }, explode(' ', $flight->route));
+ $route_points = array_map('strtoupper', explode(' ', $flight->route));
$route = $this->navDataRepo->findWhereIn('id', $route_points);
@@ -251,6 +237,7 @@ class FlightService extends Service
throw new BidExists('A bid already exists for this flight');
}
} else {
+ /** @noinspection NestedPositiveIfStatementsInspection */
if ($flight->has_bid === true) {
Log::info('Bid exists, flight='.$flight->id.'; no entry in bids table, cleaning up');
}
diff --git a/app/Services/GeoService.php b/app/Services/GeoService.php
index cb8cca6b..8500c367 100644
--- a/app/Services/GeoService.php
+++ b/app/Services/GeoService.php
@@ -253,6 +253,9 @@ class GeoService extends Service
* Return a single feature point for the
*
* @param mixed $pireps
+ *
+ * @return mixed
+ * @return \GeoJson\Feature\FeatureCollection
*/
public function getFeatureForLiveFlights($pireps)
{
diff --git a/app/Services/ImportExport/AircraftExporter.php b/app/Services/ImportExport/AircraftExporter.php
index 554e7d4e..b5f92483 100644
--- a/app/Services/ImportExport/AircraftExporter.php
+++ b/app/Services/ImportExport/AircraftExporter.php
@@ -4,7 +4,6 @@ namespace App\Services\ImportExport;
use App\Interfaces\ImportExport;
use App\Models\Aircraft;
-use App\Models\Flight;
/**
* The flight importer can be imported or export. Operates on rows
diff --git a/app/Services/ImportExport/AircraftImporter.php b/app/Services/ImportExport/AircraftImporter.php
index 24d66b55..eac8e9d5 100644
--- a/app/Services/ImportExport/AircraftImporter.php
+++ b/app/Services/ImportExport/AircraftImporter.php
@@ -54,6 +54,7 @@ class AircraftImporter extends ImportExport
* @param int $index
*
* @return bool
+ * @throws \Exception
*/
public function import(array $row, $index): bool
{
diff --git a/app/Services/Metar/AviationWeather.php b/app/Services/Metar/AviationWeather.php
index 092a70a5..91b38e71 100644
--- a/app/Services/Metar/AviationWeather.php
+++ b/app/Services/Metar/AviationWeather.php
@@ -34,7 +34,7 @@ class AviationWeather extends Metar
try {
$res = Http::get($url, []);
$xml = simplexml_load_string($res);
- if (count($xml->data->METAR->raw_text) == 0) {
+ if (\count($xml->data->METAR->raw_text) === 0) {
return '';
}
return $xml->data->METAR->raw_text->__toString();
diff --git a/app/Services/PirepService.php b/app/Services/PirepService.php
index 7e094469..53389684 100644
--- a/app/Services/PirepService.php
+++ b/app/Services/PirepService.php
@@ -31,23 +31,19 @@ class PirepService extends Service
{
private $geoSvc;
private $pilotSvc;
- private $pirepRepo;
/**
* PirepService constructor.
*
* @param GeoService $geoSvc
- * @param PirepRepository $pirepRepo
* @param UserService $pilotSvc
*/
public function __construct(
GeoService $geoSvc,
- PirepRepository $pirepRepo,
UserService $pilotSvc
) {
$this->geoSvc = $geoSvc;
$this->pilotSvc = $pilotSvc;
- $this->pirepRepo = $pirepRepo;
}
/**
@@ -200,6 +196,7 @@ class PirepService extends Service
* Submit the PIREP. Figure out its default state
*
* @param Pirep $pirep
+ * @throws \Exception
*/
public function submit(Pirep $pirep)
{
@@ -306,6 +303,7 @@ class PirepService extends Service
* @param Pirep $pirep
*
* @return Pirep
+ * @throws \Exception
*/
public function accept(Pirep $pirep): Pirep
{
diff --git a/app/Support/ICAO.php b/app/Support/ICAO.php
index 2c20f294..affdf22d 100644
--- a/app/Support/ICAO.php
+++ b/app/Support/ICAO.php
@@ -14,6 +14,7 @@ class ICAO
* @param null $country
*
* @return string
+ * @throws \Exception
*/
public static function createHexCode($country = null)
{
diff --git a/app/Support/Metar.php b/app/Support/Metar.php
index 0a98a928..37fe7e10 100644
--- a/app/Support/Metar.php
+++ b/app/Support/Metar.php
@@ -438,6 +438,7 @@ class Metar implements \ArrayAccess
if (array_key_exists('cavok', $this->result) && $this->result['cavok']) {
$this->result['category'] = 'VFR';
} else {
+ /** @noinspection NestedPositiveIfStatementsInspection */
if (array_key_exists('cloud_height', $this->result) && array_key_exists('visibility', $this->result)) {
if ($this->result['cloud_height']['ft'] > 3000 && $this->result['visibility']['nmi'] > 5) {
$this->result['category'] = 'VFR';
@@ -566,6 +567,7 @@ class Metar implements \ArrayAccess
* Decodes TAF code if present.
*
* @param mixed $part
+ * @return bool
*/
private function get_taf($part)
{
@@ -770,6 +772,7 @@ class Metar implements \ArrayAccess
if ($found[1] === 'CAVOK' || $found[1] === '9999') {
$this->set_result_value('visibility', new Distance(10000, 'm'));
$this->set_result_value('visibility_report', 'Greater than 10 km');
+ /** @noinspection NotOptimalIfConditionsInspection */
if ($found[1] === 'CAVOK') {
$this->set_result_value('cavok', true);
$this->method += 4; // can skip the next 4 methods: visibility_min, runway_vr, present_weather, clouds
@@ -887,7 +890,7 @@ class Metar implements \ArrayAccess
];
// Runway past tendency
- if (isset($found[8]) && isset(static::$rvr_tendency_codes[$found[8]])) {
+ if (isset($found[8], static::$rvr_tendency_codes[$found[8]])) {
$observed['tendency'] = $found[8];
}
@@ -1002,7 +1005,7 @@ class Metar implements \ArrayAccess
}
}
// Type
- if (isset($found[6]) && !empty($found[6]) && isset(static::$cloud_type_codes[$found[6]]) && $found[4] != 'VV') {
+ if (isset($found[6], static::$cloud_type_codes[$found[6]]) && !empty($found[6]) && $found[4] !== 'VV') {
$observed['type'] = $found[6];
}
@@ -1204,13 +1207,13 @@ class Metar implements \ArrayAccess
// Build runways report
$report = [];
- if (null !== $observed['deposits']) {
+ if ($observed['deposits'] !== null) {
$report[] = static::$runway_deposits_codes[$observed['deposits']];
if (null !== $observed['deposits_extent']) {
$report[] = 'contamination '.static::$runway_deposits_extent_codes[$observed['deposits_extent']];
}
- if (null !== $observed['deposits_depth']) {
+ if ($observed['deposits_depth'] !== null) {
if ($observed['deposits_depth'] === '99') {
$report[] = 'runway closed';
} elseif (isset(static::$runway_deposits_depth_codes[$observed['deposits_depth']])) {
@@ -1221,7 +1224,7 @@ class Metar implements \ArrayAccess
}
}
- if (null !== $observed['friction']) {
+ if ($observed['friction'] !== null) {
if (isset(static::$runway_friction_codes[$observed['friction']])) {
$report[] = 'a braking action is '.static::$runway_friction_codes[$observed['friction']];
} else {
@@ -1385,7 +1388,7 @@ class Metar implements \ArrayAccess
while ($this->part < \count($this->raw_parts)) {
if (preg_match($r, $this->raw_parts[$this->part], $found)) {
// Get trend flag
- if (isset($found[2]) && isset(static::$trends_flag_codes[$found[2]])) {
+ if (isset($found[2], static::$trends_flag_codes[$found[2]])) {
$trend['flag'] = $found[2];
} // Get PROBpp formatted period
@@ -1393,7 +1396,7 @@ class Metar implements \ArrayAccess
$trend['probability'] = $found[4];
} // Get AT, FM, TL formatted period
- elseif (isset($found[8]) && isset(static::$trends_time_codes[$found[5]])) {
+ elseif (isset($found[8], static::$trends_time_codes[$found[5]])) {
$trend['period']['flag'] = $found[5];
if (!empty($found[6])) {
$trend['period']['day'] = (int) $found[6];
@@ -1512,7 +1515,7 @@ class Metar implements \ArrayAccess
$remarks = [];
// Get all parts after
- while ($this->part < count($this->raw_parts)) {
+ while ($this->part < \count($this->raw_parts)) {
if (isset($this->raw_parts[$this->part])) {
$remarks[] = $this->raw_parts[$this->part];
}
@@ -1582,11 +1585,11 @@ class Metar implements \ArrayAccess
}
}
- if (null !== $observed['characteristics']) {
+ if ($observed['characteristics'] !== null) {
$report[] = static::$weather_char_codes[$observed['characteristics']];
}
- if (null !== $observed['types']) {
+ if ($observed['types'] !== null) {
foreach ($observed['types'] as $code) {
$report[] = static::$weather_type_codes[$code];
}
diff --git a/app/Support/TimezonelistExtended.php b/app/Support/TimezonelistExtended.php
index a3554385..57b3b69c 100644
--- a/app/Support/TimezonelistExtended.php
+++ b/app/Support/TimezonelistExtended.php
@@ -15,20 +15,20 @@ class TimezonelistExtended extends Timezonelist
* @param bool $htmlencode
*
* @return string
+ * @throws \Exception
+ * @throws \Exception
*/
protected function formatTimezone($timezone, $continent, $htmlencode = true)
{
$time = new \DateTimeImmutable(null, new DateTimeZone($timezone));
$offset = $time->format('P');
if ($htmlencode) {
- $offset = str_replace('-', ' − ', $offset);
- $offset = str_replace('+', ' + ', $offset);
+ $offset = str_replace(['-', '+'], array(' − ', ' + '), $offset);
}
- $timezone = substr($timezone, strlen($continent) + 1);
- $timezone = str_replace('St_', 'St. ', $timezone);
- $timezone = str_replace('_', ' ', $timezone);
- $formatted = '(GMT/UTC'.$offset.')'.self::WHITESPACE_SEP.$timezone;
- return $formatted;
+ $timezone = substr($timezone, \strlen($continent) + 1);
+ $timezone = str_replace(['St_', '_'], array('St. ', ' '), $timezone);
+
+ return '(GMT/UTC'.$offset.')'.self::WHITESPACE_SEP.$timezone;
}
/**
@@ -46,7 +46,7 @@ class TimezonelistExtended extends Timezonelist
// Attributes for select element
$attrSet = '';
if (!empty($attr)) {
- if (is_array($attr)) {
+ if (\is_array($attr)) {
foreach ($attr as $attr_name => $attr_value) {
$attrSet .= ' '.$attr_name.'="'.$attr_value.'"';
}
@@ -59,7 +59,7 @@ class TimezonelistExtended extends Timezonelist
// Add popular timezones
$listbox .= '';
@@ -70,7 +70,7 @@ class TimezonelistExtended extends Timezonelist
$listbox .= '