Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel 5.8 Update #308

Merged
merged 16 commits into from
May 12, 2019
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
_ide_helper.php
.php_cs.cache
.phpstorm.meta.php
/vendor
node_modules/
Expand Down
37 changes: 37 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in('app')
->in('config');

return PhpCsFixer\Config::create()
->setHideProgress(true)
->setUsingCache(false)
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'strict_param' => true,
'no_php4_constructor' => true,
'no_extra_blank_lines' => true,
'no_superfluous_elseif' => true,
'single_line_comment_style' => false,
'simple_to_complex_string_variable' => true,
'array_syntax' => [
'syntax' => 'short',
],
'binary_operator_spaces' => [
'align_double_arrow' => true,
],
/*
'blank_line_before_statement' => [
'statements' => [
'declare',
'for',
'return',
'throw',
'try',
],
],
*/
])
->setFinder($finder);
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ install:
- composer install --dev --no-interaction --verbose

script:
- vendor/bin/php-cs-fixer fix --config=.php_cs -v --dry-run --diff --using-cache=no
- php artisan database:create --reset
- php artisan migrate:refresh --seed
- cp .travis/phpunit.travis.xml phpunit.xml
Expand Down
3 changes: 3 additions & 0 deletions .travis/deploy_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,15 @@ if [ "$TRAVIS" = "true" ]; then
.dpl
.eslintignore
.eslintrc
.php_cs
.php_cs.cache
.phpstorm.meta.php
.styleci.yml
env.php
config.php
docker-compose.yml
Makefile
phpcs.xml
phpunit.xml
phpvms.iml
Procfile
Expand Down
8 changes: 8 additions & 0 deletions .travis/phpunit.travis.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
<listener class="NunoMaduro\Collision\Adapters\Phpunit\Listener"/>
</listeners>
<php>
<env name="APP_ENV" value="test"/>
<env name="APP_KEY" value="base64:ve66Z5Kt/zTN3p++0zOPu854PHfZkwJE5VuoFAlzHtI="/>
<env name="APP_DEBUG" value="true"/>
<env name="APP_LOG_LEVEL" value="debug"/>
<env name="DB_CONNECTION" value="memory"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
<ini name="error_reporting" value="E_ALL"/>
<ini name="display_errors" value="On"/>
<ini name="display_startup_errors" value="On"/>
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ test:
#php artisan database:create --reset
vendor/bin/phpunit --debug --verbose

.PHONY: phpcs
phpcs:
@vendor/bin/php-cs-fixer fix --config=.php_cs -v --diff --dry-run

.PHONY:
phpstan:
vendor/bin/phpstan analyse -c phpstan.neon -v --level 2 app
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ A full development environment can be brought up using Docker:
```bash
composer install
npm install
docker-compose build
docker-compose up
```

Expand Down
4 changes: 2 additions & 2 deletions app/Console/Commands/ImportCsv.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ public function handle()
$type = $this->argument('type');
$file = $this->argument('file');

if (\in_array($type, ['flight', 'flights'])) {
if (\in_array($type, ['flight', 'flights'], true)) {
$status = $this->importer->importFlights($file);
} elseif ($type === 'aircraft') {
$status = $this->importer->importAircraft($file);
} elseif (\in_array($type, ['airport', 'airports'])) {
} elseif (\in_array($type, ['airport', 'airports'], true)) {
$status = $this->importer->importAirports($file);
} elseif ($type === 'subfleet') {
$status = $this->importer->importSubfleets($file);
Expand Down
17 changes: 13 additions & 4 deletions app/Console/Services/Importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,8 @@ protected function importAircraft()
['icao' => $row->icao,
'subfleet_id' => $subfleet->id,
'active' => $row->enabled,
]);
]
);

$this->addMapping('aircraft', $row->id, $aircraft->id);

Expand Down Expand Up @@ -682,14 +683,22 @@ protected function getUserState($state)
// Decide which state they will be in accordance with v7
if ($state === $phpvms_classic_states['ACTIVE']) {
return UserState::ACTIVE;
} elseif ($state === $phpvms_classic_states['INACTIVE']) {
}

if ($state === $phpvms_classic_states['INACTIVE']) {
// TODO: Make an inactive state?
return UserState::REJECTED;
} elseif ($state === $phpvms_classic_states['BANNED']) {
}

if ($state === $phpvms_classic_states['BANNED']) {
return UserState::SUSPENDED;
} elseif ($state === $phpvms_classic_states['ON_LEAVE']) {
}

if ($state === $phpvms_classic_states['ON_LEAVE']) {
return UserState::ON_LEAVE;
}

$this->error('Unknown status: '.$state);
return UserState::ACTIVE;
}
}
4 changes: 3 additions & 1 deletion app/Exceptions/BidExists.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public function __construct(
parent::__construct(
409,
'A bid already exists for this flight',
$previous, $headers, $code
$previous,
$headers,
$code
);
}
}
3 changes: 2 additions & 1 deletion app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Validation\ValidationException;
use Log;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

/**
Expand Down Expand Up @@ -134,7 +135,7 @@ protected function unauthenticated($request, AuthenticationException $exception)
*
* @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
*/
protected function renderHttpException(HttpException $e)
protected function renderHttpException(HttpExceptionInterface $e)
{
$status = $e->getStatusCode();
view()->replaceNamespace('errors', [
Expand Down
3 changes: 2 additions & 1 deletion app/Exceptions/InternalError.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public function __construct(string $message = null, $field = null)
$validator = Validator::make([], []);
$validator->errors()->add(
$field ?? static::FIELD,
$message ?? static::MESSAGE);
$message ?? static::MESSAGE
);

parent::__construct($validator);
}
Expand Down
4 changes: 3 additions & 1 deletion app/Exceptions/PirepCancelled.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public function __construct(
parent::__construct(
400,
'PIREP has been cancelled, updates are not allowed',
$previous, $headers, $code
$previous,
$headers,
$code
);
}
}
4 changes: 3 additions & 1 deletion app/Http/Controllers/Admin/AircraftController.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ public function import(Request $request)
if ($request->isMethod('post')) {
ImportRequest::validate($request);
$path = Storage::putFileAs(
'import', $request->file('csv_file'), 'import_aircraft.csv'
'import',
$request->file('csv_file'),
'import_aircraft.csv'
);

$path = storage_path('app/'.$path);
Expand Down
4 changes: 3 additions & 1 deletion app/Http/Controllers/Admin/AirportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ public function import(Request $request)
if ($request->isMethod('post')) {
ImportRequest::validate($request);
$path = Storage::putFileAs(
'import', $request->file('csv_file'), 'import_airports.csv'
'import',
$request->file('csv_file'),
'import_airports.csv'
);

$path = storage_path('app/'.$path);
Expand Down
4 changes: 3 additions & 1 deletion app/Http/Controllers/Admin/ExpenseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ public function import(Request $request)
if ($request->isMethod('post')) {
ImportRequest::validate($request);
$path = Storage::putFileAs(
'import', $request->file('csv_file'), 'import_expenses.csv'
'import',
$request->file('csv_file'),
'import_expenses.csv'
);

$path = storage_path('app/'.$path);
Expand Down
4 changes: 3 additions & 1 deletion app/Http/Controllers/Admin/FareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ public function import(Request $request)
if ($request->isMethod('post')) {
ImportRequest::validate($request);
$path = Storage::putFileAs(
'import', $request->file('csv_file'), 'import_fares.csv'
'import',
$request->file('csv_file'),
'import_fares.csv'
);

$path = storage_path('app/'.$path);
Expand Down
7 changes: 5 additions & 2 deletions app/Http/Controllers/Admin/FlightController.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ public function update($id, UpdateFlightRequest $request)

$input['flight_time'] = Time::init(
$input['minutes'],
$input['hours'])->getMinutes();
$input['hours']
)->getMinutes();

$input['active'] = get_truth_state($input['active']);

Expand Down Expand Up @@ -355,7 +356,9 @@ public function import(Request $request)

if ($request->isMethod('post')) {
$path = Storage::putFileAs(
'import', $request->file('csv_file'), 'import_flights.csv'
'import',
$request->file('csv_file'),
'import_flights.csv'
);

$path = storage_path('app/'.$path);
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Admin/PirepController.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,8 @@ public function update($id, UpdatePirepRequest $request)
// Fix the time
$attrs['flight_time'] = Time::init(
$attrs['minutes'],
$attrs['hours'])->getMinutes();
$attrs['hours']
)->getMinutes();

$pirep = $this->pirepRepo->update($attrs, $id);

Expand Down
4 changes: 3 additions & 1 deletion app/Http/Controllers/Admin/SubfleetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,9 @@ public function import(Request $request)
ImportRequest::validate($request);

$path = Storage::putFileAs(
'import', $request->file('csv_file'), 'import_subfleets.csv'
'import',
$request->file('csv_file'),
'import_subfleets.csv'
);

$path = storage_path('app/'.$path);
Expand Down
8 changes: 6 additions & 2 deletions app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,13 @@ protected function sendLoginResponse(Request $request)
// Redirect to one of the error pages
if ($user->state === UserState::PENDING) {
return view('auth.pending');
} elseif ($user->state === UserState::REJECTED) {
}

if ($user->state === UserState::REJECTED) {
return view('auth.rejected');
} elseif ($user->state === UserState::SUSPENDED) {
}

if ($user->state === UserState::SUSPENDED) {
return view('auth.suspended');
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Auth/ResetPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class ResetPasswordController extends Controller
*/
public function showResetForm(Request $request, $token = null)
{
return view('auth.passwords.reset',
return view(
'auth.passwords.reset',
['token' => $token, 'email' => $request->email]
);
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Frontend/PirepController.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,8 @@ public function update($id, UpdatePirepRequest $request)
// Fix the time
$attrs['flight_time'] = Time::init(
$attrs['minutes'],
$attrs['hours'])->getMinutes();
$attrs['hours']
)->getMinutes();

$pirep = $this->pirepRepo->update($attrs, $id);

Expand Down
6 changes: 4 additions & 2 deletions app/Listeners/NotificationEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@ public function onUserStateChange(UserStateChanged $event): void

if ($event->old_state === UserState::PENDING) {
if ($event->user->state === UserState::ACTIVE) {
$email = new \App\Mail\UserRegistered($event->user,
'Your registration has been accepted!');
$email = new \App\Mail\UserRegistered(
$event->user,
'Your registration has been accepted!'
);
} elseif ($event->user->state === UserState::REJECTED) {
$email = new \App\Mail\UserRejected($event->user);
}
Expand Down
3 changes: 2 additions & 1 deletion app/Models/Acars.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ public function setDistanceAttribute($value): void
{
if ($value instanceof Distance) {
$this->attributes['distance'] = $value->toUnit(
config('phpvms.internal_units.distance'));
config('phpvms.internal_units.distance')
);
} else {
$this->attributes['distance'] = $value;
}
Expand Down
14 changes: 9 additions & 5 deletions app/Routes/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,19 @@
Route::resource('subfleets', 'SubfleetController');

Route::resource('users', 'UserController');
Route::get('users/{id}/regen_apikey',
'UserController@regen_apikey')->name('users.regen_apikey');
Route::get(
'users/{id}/regen_apikey',
'UserController@regen_apikey'
)->name('users.regen_apikey');

// defaults
Route::get('', ['uses' => 'DashboardController@index']);
Route::get('/', ['uses' => 'DashboardController@index']);

Route::get('dashboard', ['uses' => 'DashboardController@index', 'name' => 'dashboard']);
Route::match(['get', 'post', 'delete'],
'dashboard/news', ['uses' => 'DashboardController@news'])
->name('dashboard.news');
Route::match(
['get', 'post', 'delete'],
'dashboard/news',
['uses' => 'DashboardController@news']
)->name('dashboard.news');
});
Loading