Code cleanup from inspection results
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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('<info>'.$message.'</info>');
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,5 @@ class EncryptCookies extends BaseEncrypter
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
protected $except = [];
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class MeasureExecutionTime
|
||||
{
|
||||
// Get the response
|
||||
$response = $next($request);
|
||||
if (!defined('LUMEN_START')) {
|
||||
if (!\defined('LUMEN_START')) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,5 @@ class VerifyCsrfToken extends BaseVerifier
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
];
|
||||
protected $except = [];
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Http\Requests\Acars;
|
||||
|
||||
use App\Interfaces\FormRequest;
|
||||
use App\Models\Acars;
|
||||
use App\Models\Pirep;
|
||||
use Auth;
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Http\Requests\Acars;
|
||||
|
||||
use App\Interfaces\FormRequest;
|
||||
use App\Models\Pirep;
|
||||
|
||||
/**
|
||||
* Class PrefileRequest
|
||||
|
||||
@@ -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,
|
||||
];*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
];*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,8 +6,5 @@ use Illuminate\Http\Resources\Json\Resource;
|
||||
|
||||
class Aircraft extends Resource
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return parent::toArray($request);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,8 +6,5 @@ use Illuminate\Http\Resources\Json\Resource;
|
||||
|
||||
class Airport extends Resource
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return parent::toArray($request);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ abstract class Award
|
||||
$e->getTrace()
|
||||
);
|
||||
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
return $award;
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class ImportExport
|
||||
*
|
||||
* @param $code
|
||||
*
|
||||
* @return Airline
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
*/
|
||||
public function getAirline($code)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -12,6 +12,7 @@ class AircraftObserver
|
||||
{
|
||||
/**
|
||||
* @param Aircraft $aircraft
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function creating(Aircraft $aircraft): void
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -54,6 +54,7 @@ class AircraftImporter extends ImportExport
|
||||
* @param int $index
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function import(array $row, $index): bool
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -14,6 +14,7 @@ class ICAO
|
||||
* @param null $country
|
||||
*
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function createHexCode($country = null)
|
||||
{
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
@@ -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 .= '<optgroup label="General">';
|
||||
foreach ($this->popularTimezones as $key => $value) {
|
||||
$selected_attr = ($selected == $key) ? ' selected="selected"' : '';
|
||||
$selected_attr = ($selected === $key) ? ' selected="selected"' : '';
|
||||
$listbox .= '<option value="'.$key.'"'.$selected_attr.'>'.$value.'</option>';
|
||||
}
|
||||
$listbox .= '</optgroup>';
|
||||
@@ -70,7 +70,7 @@ class TimezonelistExtended extends Timezonelist
|
||||
$listbox .= '<optgroup label="'.$continent.'">';
|
||||
// create option tags
|
||||
foreach ($timezones as $timezone) {
|
||||
$selected_attr = ($selected == $timezone) ? ' selected="selected"' : '';
|
||||
$selected_attr = ($selected === $timezone) ? ' selected="selected"' : '';
|
||||
$listbox .= '<option value="'.$timezone.'"'.$selected_attr.'>';
|
||||
$listbox .= $this->formatTimezone($timezone, $continent, $htmlencode);
|
||||
$listbox .= '</option>';
|
||||
|
||||
@@ -111,7 +111,7 @@ if (!function_exists('skin_view')) {
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
function skin_view($template, array $vars = [], $merge_data = [])
|
||||
function skin_view($template, array $vars = [], array $merge_data = [])
|
||||
{
|
||||
// Add the current skin name so we don't need to hardcode it in the templates
|
||||
// Makes it a bit easier to create a new skin by modifying an existing one
|
||||
@@ -149,7 +149,7 @@ if (!function_exists('setting')) {
|
||||
* set
|
||||
*/
|
||||
if (!function_exists('public_asset')) {
|
||||
function public_asset($path, $parameters = [], $secure = null)
|
||||
function public_asset($path, array $parameters = [], $secure = null)
|
||||
{
|
||||
$publicBaseUrl = app()->publicUrlPath();
|
||||
$path = $publicBaseUrl.$path;
|
||||
@@ -174,7 +174,7 @@ if (!function_exists('show_datetime')) {
|
||||
*/
|
||||
function show_datetime(\Carbon\Carbon $date = null)
|
||||
{
|
||||
if (empty($date)) {
|
||||
if ($date === null) {
|
||||
return '-';
|
||||
}
|
||||
|
||||
|
||||
@@ -103,10 +103,10 @@ class application extends Illuminate\Foundation\Application
|
||||
return $this->basePath.DS.'config'.($path ? DS.$path : $path);
|
||||
}
|
||||
|
||||
public function environmentPath()
|
||||
/*public function environmentPath()
|
||||
{
|
||||
return $this->environmentPath ?: $this->basePath;
|
||||
}
|
||||
}*/
|
||||
|
||||
public function langPath()
|
||||
{
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
"homepage": "http://www.phpvms.net",
|
||||
"require": {
|
||||
"php": ">=7.1",
|
||||
"ext-calendar": "*",
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"ext-pdo": "*",
|
||||
"laravel/framework": "^5.6",
|
||||
"laravelcollective/html": "5.6.x",
|
||||
"prettus/l5-repository": "2.6.x",
|
||||
|
||||
@@ -259,6 +259,7 @@ class InstallerController extends Controller
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
* @throws \RuntimeException
|
||||
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function usersetup(Request $request)
|
||||
{
|
||||
|
||||
@@ -2,14 +2,13 @@
|
||||
|
||||
namespace Modules\Installer\Providers;
|
||||
|
||||
use App\Services\ModuleService;
|
||||
use Illuminate\Database\Eloquent\Factory;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Route;
|
||||
|
||||
|
||||
class InstallerServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected $defer = false;
|
||||
protected $moduleSvc;
|
||||
|
||||
/**
|
||||
@@ -17,7 +16,7 @@ class InstallerServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->moduleSvc = app('App\Services\ModuleService');
|
||||
$this->moduleSvc = app(ModuleService::class);
|
||||
|
||||
$this->registerRoutes();
|
||||
$this->registerTranslations();
|
||||
@@ -78,9 +77,15 @@ class InstallerServiceProvider extends ServiceProvider
|
||||
$sourcePath => $viewPath
|
||||
],'views');
|
||||
|
||||
$this->loadViewsFrom(array_merge(array_map(function ($path) {
|
||||
return $path . '/modules/installer';
|
||||
}, \Config::get('view.paths')), [$sourcePath]), 'installer');
|
||||
$paths = array_map(
|
||||
function ($path) {
|
||||
return $path.'/modules/installer';
|
||||
},
|
||||
\Config::get('view.paths')
|
||||
);
|
||||
|
||||
$paths[] = $sourcePath;
|
||||
$this->loadViewsFrom($paths, 'installer');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,7 +116,7 @@ class InstallerServiceProvider extends ServiceProvider
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*/
|
||||
public function provides()
|
||||
public function provides(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class RequirementsService extends Service
|
||||
$extensions = [];
|
||||
foreach(config('installer.extensions') as $ext) {
|
||||
$pass = true;
|
||||
if(!extension_loaded($ext)) {
|
||||
if(!\extension_loaded($ext)) {
|
||||
$pass = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,13 @@
|
||||
|
||||
namespace Modules\Sample\Providers;
|
||||
|
||||
use App\Services\ModuleService;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Database\Eloquent\Factory;
|
||||
use Route;
|
||||
|
||||
|
||||
class SampleServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected $defer = false;
|
||||
protected $moduleSvc;
|
||||
|
||||
/**
|
||||
@@ -17,7 +16,7 @@ class SampleServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->moduleSvc = app('App\Services\ModuleService');
|
||||
$this->moduleSvc = app(ModuleService::class);
|
||||
|
||||
$this->registerRoutes();
|
||||
$this->registerTranslations();
|
||||
@@ -121,9 +120,15 @@ class SampleServiceProvider extends ServiceProvider
|
||||
$sourcePath => $viewPath
|
||||
],'views');
|
||||
|
||||
$this->loadViewsFrom(array_merge(array_map(function ($path) {
|
||||
return $path . '/modules/sample';
|
||||
}, \Config::get('view.paths')), [$sourcePath]), 'sample');
|
||||
$paths = array_map(
|
||||
function ($path) {
|
||||
return $path.'/modules/sample';
|
||||
},
|
||||
\Config::get('view.paths')
|
||||
);
|
||||
|
||||
$paths[] = $sourcePath;
|
||||
$this->loadViewsFrom($paths, 'sample');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,7 +159,7 @@ class SampleServiceProvider extends ServiceProvider
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*/
|
||||
public function provides()
|
||||
public function provides(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -3,13 +3,10 @@
|
||||
namespace Modules\Vacentral\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Database\Eloquent\Factory;
|
||||
use Route;
|
||||
|
||||
use App\Services\ModuleService;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected $defer = false;
|
||||
protected $moduleSvc;
|
||||
|
||||
/**
|
||||
@@ -17,7 +14,7 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->moduleSvc = app('App\Services\ModuleService');
|
||||
$this->moduleSvc = app(ModuleService::class);
|
||||
$this->registerConfig();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace Modules\Vacentral\Providers;
|
||||
|
||||
use App\Events\PirepAccepted;
|
||||
use App\Events\TestEvent;
|
||||
use Modules\Vacentral\Listeners\PirepAcceptedEventListener;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
|
||||
@@ -15,12 +14,4 @@ class EventServiceProvider extends ServiceProvider
|
||||
protected $listen = [
|
||||
PirepAccepted::class => [PirepAcceptedEventListener::class],
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any events for your application.
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
parent::boot();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
|
||||
|
||||
return [
|
||||
'401' => [
|
||||
401 => [
|
||||
'title' => 'Unauthorized Access',
|
||||
'message' => 'Well, this is embarrassing, you are not authorized to access or perform this function. '.
|
||||
'Click <a href=":link">here</a> to go back to the home page.',
|
||||
],
|
||||
'404' => [
|
||||
404 => [
|
||||
'title' => 'Page Not Found',
|
||||
'message' => 'Well, this is embarrassing, the page you requested does not exist.'.
|
||||
'Click <a href=":link">here</a> to go back to the home page.',
|
||||
],
|
||||
'503' => [
|
||||
503 => [
|
||||
'title' => 'Internal Error',
|
||||
'message' => 'An Error Occured',
|
||||
],
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
|
||||
|
||||
return [
|
||||
'401' => [
|
||||
401 => [
|
||||
'title' => 'Acceso no autorizado',
|
||||
'message' => 'Bueno, esto es embarazoso, no estás autorizado a acceder o realizar esta acción. '.
|
||||
'Clic <a href=":link">aquí</a> para retroceder a la página de inicio.',
|
||||
],
|
||||
'404' => [
|
||||
404 => [
|
||||
'title' => 'Página no encontrada',
|
||||
'message' => 'Bueno, esto es embarazoso, la página solicitada no existe.'.
|
||||
'Clic <a href=":link">aquí</a> para retroceder a la página de inicio.',
|
||||
],
|
||||
'503' => [
|
||||
503 => [
|
||||
'title' => 'Error interno',
|
||||
'message' => 'Ocurrió un error',
|
||||
],
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
|
||||
|
||||
return [
|
||||
'401' => [
|
||||
401 => [
|
||||
'title' => 'Non Autorizzato',
|
||||
'message' => 'Beh, è imbarazzante, non sei autorizzato ad accedere o ad eseguire questa funzionalità. '.
|
||||
'Clicca <a href=":link">qui</a> per tornare alla home page.',
|
||||
],
|
||||
'404' => [
|
||||
404 => [
|
||||
'title' => 'Page Not Found',
|
||||
'message' => 'Beh, è imbarazzante, la pagina che hai richiesto non esiste.'.
|
||||
'Clicca <a href=":link">qui</a> per tornare alla home page.',
|
||||
],
|
||||
'503' => [
|
||||
503 => [
|
||||
'title' => 'Internal Error',
|
||||
'message' => 'Torniamo subito.',
|
||||
],
|
||||
|
||||
@@ -24,7 +24,7 @@ class AcarsTest extends TestCase
|
||||
* @param $points
|
||||
* @param array $addtl_fields
|
||||
*/
|
||||
protected function allPointsInRoute($route, $points, $addtl_fields = [])
|
||||
protected function allPointsInRoute($route, $points, array $addtl_fields = [])
|
||||
{
|
||||
if (empty($addtl_fields)) {
|
||||
$addtl_fields = [];
|
||||
@@ -40,7 +40,7 @@ class AcarsTest extends TestCase
|
||||
$addtl_fields
|
||||
);
|
||||
|
||||
$this->assertEquals(\count($route), \count($points));
|
||||
$this->assertCount(\count($route), $points);
|
||||
foreach ($route as $idx => $point) {
|
||||
$this->assertHasKeys($points[$idx], $fields);
|
||||
foreach ($fields as $f) {
|
||||
@@ -556,6 +556,7 @@ class AcarsTest extends TestCase
|
||||
|
||||
/**
|
||||
* Test publishing multiple, batched updates
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testMultipleAcarsPositionUpdates()
|
||||
{
|
||||
|
||||
@@ -71,6 +71,9 @@ class ApiTest extends TestCase
|
||||
$this->assertTrue(array_key_exists('user', $response['data'][0]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testGetAirlines()
|
||||
{
|
||||
$size = \random_int(5, 10);
|
||||
@@ -134,6 +137,7 @@ class ApiTest extends TestCase
|
||||
|
||||
/**
|
||||
* Test getting the subfleets
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testGetSubfleets()
|
||||
{
|
||||
|
||||
@@ -123,6 +123,7 @@ class FlightTest extends TestCase
|
||||
|
||||
/**
|
||||
* Get the flight's route
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testFlightRoute()
|
||||
{
|
||||
@@ -398,7 +399,7 @@ class FlightTest extends TestCase
|
||||
$req->assertStatus(200);
|
||||
|
||||
$body = $req->json()['data'];
|
||||
$this->assertEquals(1, count($body['bids']));
|
||||
$this->assertCount(1, $body['bids']);
|
||||
$this->assertEquals($flight->id, $body['bids'][0]['flight_id']);
|
||||
|
||||
$req = $this->get('/api/users/'.$user->id.'/bids', $headers);
|
||||
@@ -435,7 +436,7 @@ class FlightTest extends TestCase
|
||||
|
||||
$body = $req->json()['data'];
|
||||
$this->assertEquals($user->id, $body['id']);
|
||||
$this->assertEquals(0, count($body['bids']));
|
||||
$this->assertCount(0, $body['bids']);
|
||||
|
||||
$req = $this->get('/api/users/'.$user->id.'/bids', $headers);
|
||||
$req->assertStatus(200);
|
||||
|
||||
@@ -35,6 +35,7 @@ class GeoTest extends TestCase
|
||||
|
||||
/**
|
||||
* Make sure the departure airports/sid/star are all filtered out
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testGetCoords()
|
||||
{
|
||||
|
||||
@@ -228,6 +228,7 @@ class ImporterTest extends TestCase
|
||||
|
||||
/**
|
||||
* Test exporting all the flights to a file
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function testAircraftExporter(): void
|
||||
{
|
||||
|
||||
@@ -49,6 +49,9 @@ class PIREPTest extends TestCase
|
||||
return $saved_route;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testAddPirep()
|
||||
{
|
||||
$user = factory(App\Models\User::class)->create();
|
||||
@@ -59,7 +62,11 @@ class PIREPTest extends TestCase
|
||||
]);
|
||||
|
||||
$pirep = $this->pirepSvc->create($pirep, []);
|
||||
$this->pirepSvc->saveRoute($pirep);
|
||||
try {
|
||||
$this->pirepSvc->saveRoute($pirep);
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check the initial state info
|
||||
|
||||
@@ -9,6 +9,7 @@ class RegistrationTest extends TestCase
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testRegistration()
|
||||
{
|
||||
|
||||
@@ -59,10 +59,11 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
|
||||
{
|
||||
if ($user !== null) {
|
||||
$headers['x-api-key'] = $user->api_key;
|
||||
} else {
|
||||
if ($this->user !== null) {
|
||||
$headers['x-api-key'] = $this->user->api_key;
|
||||
}
|
||||
return $headers;
|
||||
}
|
||||
|
||||
if ($this->user !== null) {
|
||||
$headers['x-api-key'] = $this->user->api_key;
|
||||
}
|
||||
|
||||
return $headers;
|
||||
@@ -90,7 +91,7 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
|
||||
* @param $obj
|
||||
* @param array $keys
|
||||
*/
|
||||
public function assertHasKeys($obj, $keys = [])
|
||||
public function assertHasKeys($obj, array $keys = []): void
|
||||
{
|
||||
foreach ($keys as $key) {
|
||||
$this->assertArrayHasKey($key, $obj);
|
||||
|
||||
@@ -57,6 +57,7 @@ trait TestData
|
||||
* @param null $airport_id
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createSubfleetWithAircraft($aircraft_count = null, $airport_id = null)
|
||||
{
|
||||
|
||||
@@ -14,6 +14,9 @@ class UtilsTest extends TestCase
|
||||
$this->assertNotNull($carbon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testSecondsToTimeParts()
|
||||
{
|
||||
$t = Utils::secondsToTimeParts(3600);
|
||||
|
||||
Reference in New Issue
Block a user