Add php-cs-fixer to build

This commit is contained in:
Nabeel Shahzad 2019-05-12 13:26:44 -05:00
parent 75eaec2f11
commit 88957f4071
25 changed files with 480 additions and 65 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
_ide_helper.php
.php_cs.cache
.phpstorm.meta.php
/vendor
node_modules/

21
.php_cs Normal file
View File

@ -0,0 +1,21 @@
<?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,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'align_double_arrow' => true,
],
]
)
->setFinder($finder);

View File

@ -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

View File

@ -62,11 +62,13 @@ if [ "$TRAVIS" = "true" ]; then
.eslintignore
.eslintrc
.phpstorm.meta.php
.php_cs.cache
.styleci.yml
env.php
config.php
docker-compose.yml
Makefile
phpcs.xml
phpunit.xml
phpvms.iml
Procfile

View File

@ -70,7 +70,7 @@ test:
.PHONY: phpcs
phpcs:
@vendor/bin/phpcs -s --standard=phpcs.xml --colors
@vendor/bin/php-cs-fixer fix --config=.php_cs -v --dry-run --diff
.PHONY:
phpstan:

View File

@ -36,11 +36,11 @@ class ImportCsv extends Command
$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);

View File

@ -18,7 +18,9 @@ class BidExists extends HttpException
parent::__construct(
409,
'A bid already exists for this flight',
$previous, $headers, $code
$previous,
$headers,
$code
);
}
}

View File

@ -28,7 +28,8 @@ class InternalError extends ValidationException
$validator = Validator::make([], []);
$validator->errors()->add(
$field ?? static::FIELD,
$message ?? static::MESSAGE);
$message ?? static::MESSAGE
);
parent::__construct($validator);
}

View File

@ -18,7 +18,9 @@ class PirepCancelled extends HttpException
parent::__construct(
400,
'PIREP has been cancelled, updates are not allowed',
$previous, $headers, $code
$previous,
$headers,
$code
);
}
}

View File

@ -232,7 +232,9 @@ class AircraftController extends Controller
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);

View File

@ -229,7 +229,9 @@ class AirportController extends Controller
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);

View File

@ -229,7 +229,9 @@ class ExpenseController extends Controller
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);

View File

@ -204,7 +204,9 @@ class FareController extends Controller
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);

View File

@ -285,7 +285,8 @@ class FlightController extends Controller
$input['flight_time'] = Time::init(
$input['minutes'],
$input['hours'])->getMinutes();
$input['hours']
)->getMinutes();
$input['active'] = get_truth_state($input['active']);
@ -355,7 +356,9 @@ class FlightController extends Controller
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);

View File

@ -365,7 +365,8 @@ class PirepController extends Controller
// Fix the time
$attrs['flight_time'] = Time::init(
$attrs['minutes'],
$attrs['hours'])->getMinutes();
$attrs['hours']
)->getMinutes();
$pirep = $this->pirepRepo->update($attrs, $id);

View File

@ -304,7 +304,9 @@ class SubfleetController extends Controller
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);

View File

@ -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]
);
}

View File

@ -406,7 +406,8 @@ class PirepController extends Controller
// Fix the time
$attrs['flight_time'] = Time::init(
$attrs['minutes'],
$attrs['hours'])->getMinutes();
$attrs['hours']
)->getMinutes();
$pirep = $this->pirepRepo->update($attrs, $id);

View File

@ -108,8 +108,10 @@ class NotificationEvents extends Listener
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);
}

View File

@ -114,7 +114,8 @@ class Acars extends Model
{
if ($value instanceof Distance) {
$this->attributes['distance'] = $value->toUnit(
config('phpvms.internal_units.distance'));
config('phpvms.internal_units.distance')
);
} else {
$this->attributes['distance'] = $value;
}

View File

@ -76,15 +76,19 @@ Route::group([
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');
});

View File

@ -625,7 +625,6 @@ class Metar implements \ArrayAccess
$minute = (int) $found[3];
if ($this->result['observed_date'] === null) {
// Take one month, if the observed day is greater than the current day
if ($day > date('j')) {
$month = date('n') - 1;

377
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "a2ba5f306c64642928b51fcb4c1876cc",
"content-hash": "1b80cec722a0aa7bf522c55475111621",
"packages": [
{
"name": "akaunting/money",
@ -857,6 +857,74 @@
],
"time": "2019-01-28T20:25:53+00:00"
},
{
"name": "doctrine/annotations",
"version": "v1.6.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/annotations.git",
"reference": "53120e0eb10355388d6ccbe462f1fea34ddadb24"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/annotations/zipball/53120e0eb10355388d6ccbe462f1fea34ddadb24",
"reference": "53120e0eb10355388d6ccbe462f1fea34ddadb24",
"shasum": ""
},
"require": {
"doctrine/lexer": "1.*",
"php": "^7.1"
},
"require-dev": {
"doctrine/cache": "1.*",
"phpunit/phpunit": "^6.4"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.6.x-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
}
],
"description": "Docblock Annotations Parser",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"annotations",
"docblock",
"parser"
],
"time": "2019-03-25T19:12:02+00:00"
},
{
"name": "doctrine/inflector",
"version": "v1.3.0",
@ -1135,6 +1203,99 @@
],
"time": "2019-03-17T18:48:37+00:00"
},
{
"name": "friendsofphp/php-cs-fixer",
"version": "v2.15.0",
"source": {
"type": "git",
"url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git",
"reference": "adfab51ae979ee8b0fcbc55aa231ec2786cb1f91"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/adfab51ae979ee8b0fcbc55aa231ec2786cb1f91",
"reference": "adfab51ae979ee8b0fcbc55aa231ec2786cb1f91",
"shasum": ""
},
"require": {
"composer/semver": "^1.4",
"composer/xdebug-handler": "^1.2",
"doctrine/annotations": "^1.2",
"ext-json": "*",
"ext-tokenizer": "*",
"php": "^5.6 || ^7.0",
"php-cs-fixer/diff": "^1.3",
"symfony/console": "^3.4.17 || ^4.1.6",
"symfony/event-dispatcher": "^3.0 || ^4.0",
"symfony/filesystem": "^3.0 || ^4.0",
"symfony/finder": "^3.0 || ^4.0",
"symfony/options-resolver": "^3.0 || ^4.0",
"symfony/polyfill-php70": "^1.0",
"symfony/polyfill-php72": "^1.4",
"symfony/process": "^3.0 || ^4.0",
"symfony/stopwatch": "^3.0 || ^4.0"
},
"require-dev": {
"johnkary/phpunit-speedtrap": "^1.1 || ^2.0 || ^3.0",
"justinrainbow/json-schema": "^5.0",
"keradus/cli-executor": "^1.2",
"mikey179/vfsstream": "^1.6",
"php-coveralls/php-coveralls": "^2.1",
"php-cs-fixer/accessible-object": "^1.0",
"php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.1",
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.1",
"phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1",
"phpunitgoodpractices/traits": "^1.8",
"symfony/phpunit-bridge": "^4.0"
},
"suggest": {
"ext-mbstring": "For handling non-UTF8 characters in cache signature.",
"php-cs-fixer/phpunit-constraint-isidenticalstring": "For IsIdenticalString constraint.",
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "For XmlMatchesXsd constraint.",
"symfony/polyfill-mbstring": "When enabling `ext-mbstring` is not possible."
},
"bin": [
"php-cs-fixer"
],
"type": "application",
"extra": {
"branch-alias": {
"dev-master": "2.15-dev"
}
},
"autoload": {
"psr-4": {
"PhpCsFixer\\": "src/"
},
"classmap": [
"tests/Test/AbstractFixerTestCase.php",
"tests/Test/AbstractIntegrationCaseFactory.php",
"tests/Test/AbstractIntegrationTestCase.php",
"tests/Test/Assert/AssertTokensTrait.php",
"tests/Test/IntegrationCase.php",
"tests/Test/IntegrationCaseFactory.php",
"tests/Test/IntegrationCaseFactoryInterface.php",
"tests/Test/InternalIntegrationCaseFactory.php",
"tests/TestCase.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Dariusz Rumiński",
"email": "dariusz.ruminski@gmail.com"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
}
],
"description": "A tool to automatically fix PHP code style",
"time": "2019-05-06T07:13:51+00:00"
},
{
"name": "fzaninotto/faker",
"version": "v1.8.0",
@ -2985,6 +3146,57 @@
],
"time": "2018-07-02T15:55:56+00:00"
},
{
"name": "php-cs-fixer/diff",
"version": "v1.3.0",
"source": {
"type": "git",
"url": "https://github.com/PHP-CS-Fixer/diff.git",
"reference": "78bb099e9c16361126c86ce82ec4405ebab8e756"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/78bb099e9c16361126c86ce82ec4405ebab8e756",
"reference": "78bb099e9c16361126c86ce82ec4405ebab8e756",
"shasum": ""
},
"require": {
"php": "^5.6 || ^7.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7.23 || ^6.4.3",
"symfony/process": "^3.3"
},
"type": "library",
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Kore Nordmann",
"email": "mail@kore-nordmann.de"
},
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
},
{
"name": "SpacePossum"
}
],
"description": "sebastian/diff v2 backport support for PHP5.6",
"homepage": "https://github.com/PHP-CS-Fixer",
"keywords": [
"diff"
],
"time": "2018-02-15T16:58:55+00:00"
},
{
"name": "php-http/discovery",
"version": "1.6.1",
@ -4885,6 +5097,60 @@
],
"time": "2019-01-16T20:31:39+00:00"
},
{
"name": "symfony/options-resolver",
"version": "v4.2.8",
"source": {
"type": "git",
"url": "https://github.com/symfony/options-resolver.git",
"reference": "fd4a5f27b7cd085b489247b9890ebca9f3e10044"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/fd4a5f27b7cd085b489247b9890ebca9f3e10044",
"reference": "fd4a5f27b7cd085b489247b9890ebca9f3e10044",
"shasum": ""
},
"require": {
"php": "^7.1.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\OptionsResolver\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony OptionsResolver Component",
"homepage": "https://symfony.com",
"keywords": [
"config",
"configuration",
"options"
],
"time": "2019-04-10T16:20:36+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.11.0",
@ -5123,6 +5389,65 @@
],
"time": "2019-02-06T07:57:58+00:00"
},
{
"name": "symfony/polyfill-php70",
"version": "v1.11.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php70.git",
"reference": "bc4858fb611bda58719124ca079baff854149c89"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/bc4858fb611bda58719124ca079baff854149c89",
"reference": "bc4858fb611bda58719124ca079baff854149c89",
"shasum": ""
},
"require": {
"paragonie/random_compat": "~1.0|~2.0|~9.99",
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.11-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Php70\\": ""
},
"files": [
"bootstrap.php"
],
"classmap": [
"Resources/stubs"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"shim"
],
"time": "2019-02-06T07:57:58+00:00"
},
{
"name": "symfony/polyfill-php72",
"version": "v1.11.0",
@ -5450,6 +5775,56 @@
"homepage": "https://symfony.com",
"time": "2019-04-28T07:09:27+00:00"
},
{
"name": "symfony/stopwatch",
"version": "v4.2.8",
"source": {
"type": "git",
"url": "https://github.com/symfony/stopwatch.git",
"reference": "b1a5f646d56a3290230dbc8edf2a0d62cda23f67"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/stopwatch/zipball/b1a5f646d56a3290230dbc8edf2a0d62cda23f67",
"reference": "b1a5f646d56a3290230dbc8edf2a0d62cda23f67",
"shasum": ""
},
"require": {
"php": "^7.1.3",
"symfony/contracts": "^1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Stopwatch\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Stopwatch Component",
"homepage": "https://symfony.com",
"time": "2019-01-16T20:31:39+00:00"
},
{
"name": "symfony/translation",
"version": "v4.2.8",

View File

@ -10,15 +10,15 @@ return [
|--------------------------------------------------------------------------
| Define available themes. Format:
|
| 'theme-name' => [
| 'extends' => 'theme-to-extend', // optional
| 'views-path' => 'path-to-views', // defaults to: resources/views/theme-name
| 'asset-path' => 'path-to-assets', // defaults to: public/theme-name
| 'theme-name' => [
| 'extends' => 'theme-to-extend', // optional
| 'views-path' => 'path-to-views', // defaults to: resources/views/theme-name
| 'asset-path' => 'path-to-assets', // defaults to: public/theme-name
|
| // You can add your own custom keys
| // Use Theme::getSetting('key') & Theme::setSetting('key', 'value') to access them
| 'key' => 'value',
| ],
| // You can add your own custom keys
| // Use Theme::getSetting('key') & Theme::setSetting('key', 'value') to access them
| 'key' => 'value',
| ],
|
|--------------------------------------------------------------------------
*/
@ -29,37 +29,37 @@ return [
'extends' => 'false',
],
// Add your themes here. These settings will override theme.json settings defined for each theme
// Add your themes here. These settings will override theme.json settings defined for each theme
/*
|---------------------------[ Example Structure ]--------------------------
|
| // Full theme Syntax:
| // Full theme Syntax:
|
| 'example1' => [
| 'extends' => null, // doesn't extend any theme
| 'views-path' => example, // = resources/views/example_theme
| 'asset-path' => example, // = public/example_theme
| ],
| 'example1' => [
| 'extends' => null, // doesn't extend any theme
| 'views-path' => example, // = resources/views/example_theme
| 'asset-path' => example, // = public/example_theme
| ],
|
| // Use all Defaults:
| // Use all Defaults:
|
| 'example2', // Assets =\public\example2, Views =\resources\views\example2
| // Note that if you use all default values, you can omit declaration completely.
| // i.e. defaults will be used when you call Theme::set('undefined-theme')
| 'example2', // Assets =\public\example2, Views =\resources\views\example2
| // Note that if you use all default values, you can omit declaration completely.
| // i.e. defaults will be used when you call Theme::set('undefined-theme')
|
|
| // This theme shares the views with example2 but defines its own assets in \public\example3
| // This theme shares the views with example2 but defines its own assets in \public\example3
|
| 'example3' => [
| 'views-path' => 'example',
| ],
| 'example3' => [
| 'views-path' => 'example',
| ],
|
| // This theme extends example1 and may override SOME views\assets in its own paths
| // This theme extends example1 and may override SOME views\assets in its own paths
|
| 'example4' => [
| 'extends' => 'example1',
| ],
| 'example4' => [
| 'extends' => 'example1',
| ],
|
|--------------------------------------------------------------------------
*/

View File

@ -1,12 +0,0 @@
<?xml version="1.0"?>
<ruleset name="phpvms">
<description>phpvms coding standard</description>
<rule ref="PSR2">
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
<exclude name="PEAR.NamingConventions.ValidClassName.Invalid"/>
<exclude name="Generic.NamingConventions.CamelCapsFunctionName.Invalid"/>
<exclude name="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace"/>
</rule>
<file>app/</file>
</ruleset>