StyleCI fixes (#2416)

* Env for travis

* Apply fixes from StyleCI (#7)
This commit is contained in:
David Bomba 2018-10-05 21:40:02 +10:00 committed by GitHub
parent 5ddade85a5
commit 537b53859f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 804 additions and 566 deletions

View File

@ -20,6 +20,7 @@ class Kernel extends ConsoleKernel
* Define the application's command schedule. * Define the application's command schedule.
* *
* @param \Illuminate\Console\Scheduling\Schedule $schedule * @param \Illuminate\Console\Scheduling\Schedule $schedule
*
* @return void * @return void
*/ */
protected function schedule(Schedule $schedule) protected function schedule(Schedule $schedule)

View File

@ -30,6 +30,7 @@ class Handler extends ExceptionHandler
* Report or log an exception. * Report or log an exception.
* *
* @param \Exception $exception * @param \Exception $exception
*
* @return void * @return void
*/ */
public function report(Exception $exception) public function report(Exception $exception)
@ -42,6 +43,7 @@ class Handler extends ExceptionHandler
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Exception $exception * @param \Exception $exception
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function render($request, Exception $exception) public function render($request, Exception $exception)

View File

@ -2,11 +2,11 @@
namespace App\Http\Controllers\Auth; namespace App\Http\Controllers\Auth;
use App\User;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\User;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
class RegisterController extends Controller class RegisterController extends Controller
{ {
@ -44,6 +44,7 @@ class RegisterController extends Controller
* Get a validator for an incoming registration request. * Get a validator for an incoming registration request.
* *
* @param array $data * @param array $data
*
* @return \Illuminate\Contracts\Validation\Validator * @return \Illuminate\Contracts\Validation\Validator
*/ */
protected function validator(array $data) protected function validator(array $data)
@ -59,6 +60,7 @@ class RegisterController extends Controller
* Create a new user instance after a valid registration. * Create a new user instance after a valid registration.
* *
* @param array $data * @param array $data
*
* @return \App\User * @return \App\User
*/ */
protected function create(array $data) protected function create(array $data)

View File

@ -2,10 +2,10 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController class Controller extends BaseController
{ {

View File

@ -10,6 +10,7 @@ class Authenticate extends Middleware
* Get the path the user should be redirected to when they are not authenticated. * Get the path the user should be redirected to when they are not authenticated.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
*
* @return string * @return string
*/ */
protected function redirectTo($request) protected function redirectTo($request)

View File

@ -13,6 +13,7 @@ class RedirectIfAuthenticated
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Closure $next * @param \Closure $next
* @param string|null $guard * @param string|null $guard
*
* @return mixed * @return mixed
*/ */
public function handle($request, Closure $next, $guard = null) public function handle($request, Closure $next, $guard = null)

View File

@ -2,8 +2,8 @@
namespace App\Http\Middleware; namespace App\Http\Middleware;
use Illuminate\Http\Request;
use Fideloper\Proxy\TrustProxies as Middleware; use Fideloper\Proxy\TrustProxies as Middleware;
use Illuminate\Http\Request;
class TrustProxies extends Middleware class TrustProxies extends Middleware
{ {

View File

@ -3,16 +3,15 @@
namespace App\Models\Traits; namespace App\Models\Traits;
/** /**
* Class CalculatesInvoiceTotals * Class CalculatesInvoiceTotals.
*/ */
class CalculatesInvoiceTotals class CalculatesInvoiceTotals
{ {
protected $invoice; protected $invoice;
/** /**
* InvoiceTotals constructor. * InvoiceTotals constructor.
*
* @param $invoice * @param $invoice
*/ */
public function __construct($invoice) public function __construct($invoice)
@ -20,16 +19,11 @@ class CalculatesInvoiceTotals
$this->invoice = $invoice; $this->invoice = $invoice;
} }
public function calculate() public function calculate()
{ {
} }
private function sumLineItems() private function sumLineItems()
{ {
} }
} }

View File

@ -2,7 +2,6 @@
namespace App\Providers; namespace App\Providers;
use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider class AuthServiceProvider extends ServiceProvider

View File

@ -2,8 +2,8 @@
namespace App\Providers; namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Broadcast; use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\ServiceProvider;
class BroadcastServiceProvider extends ServiceProvider class BroadcastServiceProvider extends ServiceProvider
{ {

View File

@ -2,10 +2,10 @@
namespace App\Providers; namespace App\Providers;
use Illuminate\Support\Facades\Event;
use Illuminate\Auth\Events\Registered; use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification; use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
class EventServiceProvider extends ServiceProvider class EventServiceProvider extends ServiceProvider
{ {

View File

@ -2,8 +2,8 @@
namespace App\Providers; namespace App\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider class RouteServiceProvider extends ServiceProvider
{ {

View File

@ -2,9 +2,8 @@
namespace App; namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable class User extends Authenticatable
{ {

View File

@ -3,19 +3,18 @@
namespace App\Utils; namespace App\Utils;
/** /**
* Class NumberHelper * Class NumberHelper.
* @package App\Utils
*/ */
class NumberHelper class NumberHelper
{ {
/** /**
* @param float $value * @param float $value
* @param int $precision * @param int $precision
*
* @return float * @return float
*/ */
public static function roundValue(float $value, int $precision = 2) : float public static function roundValue(float $value, int $precision = 2) : float
{ {
return round($value, $precision, PHP_ROUND_HALF_UP); return round($value, $precision, PHP_ROUND_HALF_UP);
} }
} }

30
c3.php
View File

@ -1,8 +1,9 @@
<?php <?php
// @codingStandardsIgnoreFile // @codingStandardsIgnoreFile
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
/** /**
* C3 - Codeception Code Coverage * C3 - Codeception Code Coverage.
* *
* @author tiger * @author tiger
*/ */
@ -16,7 +17,7 @@ if (isset($_COOKIE['CODECEPTION_CODECOVERAGE'])) {
} }
if ($cookie) { if ($cookie) {
foreach ($cookie as $key => $value) { foreach ($cookie as $key => $value) {
$_SERVER["HTTP_X_CODECEPTION_" . strtoupper($key)] = $value; $_SERVER['HTTP_X_CODECEPTION_'.strtoupper($key)] = $value;
} }
} }
} }
@ -85,6 +86,7 @@ if (file_exists($config_file)) {
} else { } else {
__c3_error(sprintf("Codeception config file '%s' not found", $config_file)); __c3_error(sprintf("Codeception config file '%s' not found", $config_file));
} }
try { try {
\Codeception\Configuration::config($config_file); \Codeception\Configuration::config($config_file);
} catch (\Exception $e) { } catch (\Exception $e) {
@ -125,18 +127,21 @@ if (!defined('C3_CODECOVERAGE_MEDIATE_STORAGE')) {
unlink($path.'.tar'); unlink($path.'.tar');
rename($path.'.tar.gz', $path.'.tar'); rename($path.'.tar.gz', $path.'.tar');
} }
return $path.'.tar'; return $path.'.tar';
} }
function __c3_build_clover_report(PHP_CodeCoverage $codeCoverage, $path) function __c3_build_clover_report(PHP_CodeCoverage $codeCoverage, $path)
{ {
$writer = new PHP_CodeCoverage_Report_Clover(); $writer = new PHP_CodeCoverage_Report_Clover();
$writer->process($codeCoverage, $path.'.clover.xml'); $writer->process($codeCoverage, $path.'.clover.xml');
return $path.'.clover.xml'; return $path.'.clover.xml';
} }
function __c3_build_crap4j_report(PHP_CodeCoverage $codeCoverage, $path) function __c3_build_crap4j_report(PHP_CodeCoverage $codeCoverage, $path)
{ {
$writer = new PHP_CodeCoverage_Report_Crap4j(); $writer = new PHP_CodeCoverage_Report_Crap4j();
$writer->process($codeCoverage, $path.'.crap4j.xml'); $writer->process($codeCoverage, $path.'.crap4j.xml');
return $path.'.crap4j.xml'; return $path.'.crap4j.xml';
} }
function __c3_build_phpunit_report(PHP_CodeCoverage $codeCoverage, $path) function __c3_build_phpunit_report(PHP_CodeCoverage $codeCoverage, $path)
@ -160,6 +165,7 @@ if (!defined('C3_CODECOVERAGE_MEDIATE_STORAGE')) {
unlink($path.'.tar'); unlink($path.'.tar');
rename($path.'.tar.gz', $path.'.tar'); rename($path.'.tar.gz', $path.'.tar');
} }
return $path.'.tar'; return $path.'.tar';
} }
function __c3_send_file($filename) function __c3_send_file($filename)
@ -167,11 +173,13 @@ if (!defined('C3_CODECOVERAGE_MEDIATE_STORAGE')) {
if (!headers_sent()) { if (!headers_sent()) {
readfile($filename); readfile($filename);
} }
return __c3_exit(); return __c3_exit();
} }
/** /**
* @param $filename * @param $filename
* @param bool $lock Lock the file for writing? * @param bool $lock Lock the file for writing?
*
* @return [null|PHP_CodeCoverage|\SebastianBergmann\CodeCoverage\CodeCoverage, resource] * @return [null|PHP_CodeCoverage|\SebastianBergmann\CodeCoverage\CodeCoverage, resource]
*/ */
function __c3_factory($filename, $lock = false) function __c3_factory($filename, $lock = false)
@ -189,12 +197,13 @@ if (!defined('C3_CODECOVERAGE_MEDIATE_STORAGE')) {
$phpCoverage = unserialize(file_get_contents($filename)); $phpCoverage = unserialize(file_get_contents($filename));
} }
return array($phpCoverage, $file); return [$phpCoverage, $file];
} else { } else {
$phpCoverage = new PHP_CodeCoverage(); $phpCoverage = new PHP_CodeCoverage();
} }
if (isset($_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_SUITE'])) { if (isset($_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_SUITE'])) {
$suite = $_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_SUITE']; $suite = $_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_SUITE'];
try { try {
$settings = \Codeception\Configuration::suiteSettings($suite, \Codeception\Configuration::config()); $settings = \Codeception\Configuration::suiteSettings($suite, \Codeception\Configuration::config());
} catch (Exception $e) { } catch (Exception $e) {
@ -203,6 +212,7 @@ if (!defined('C3_CODECOVERAGE_MEDIATE_STORAGE')) {
} else { } else {
$settings = \Codeception\Configuration::config(); $settings = \Codeception\Configuration::config();
} }
try { try {
\Codeception\Coverage\Filter::setup($phpCoverage) \Codeception\Coverage\Filter::setup($phpCoverage)
->whiteList($settings) ->whiteList($settings)
@ -210,14 +220,14 @@ if (!defined('C3_CODECOVERAGE_MEDIATE_STORAGE')) {
} catch (Exception $e) { } catch (Exception $e) {
__c3_error($e->getMessage()); __c3_error($e->getMessage());
} }
return array($phpCoverage, $file);
return [$phpCoverage, $file];
} }
function __c3_exit() function __c3_exit()
{ {
if (!isset($_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_DEBUG'])) { if (!isset($_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_DEBUG'])) {
exit; exit;
} }
return null;
} }
function __c3_clear() function __c3_clear()
{ {
@ -238,9 +248,10 @@ if ($requested_c3_report) {
$route = ltrim(strrchr($_SERVER['REQUEST_URI'], '/'), '/'); $route = ltrim(strrchr($_SERVER['REQUEST_URI'], '/'), '/');
if ($route === 'clear') { if ($route === 'clear') {
__c3_clear(); __c3_clear();
return __c3_exit(); return __c3_exit();
} }
list($codeCoverage, ) = __c3_factory($complete_report); list($codeCoverage) = __c3_factory($complete_report);
switch ($route) { switch ($route) {
case 'html': case 'html':
try { try {
@ -248,6 +259,7 @@ if ($requested_c3_report) {
} catch (Exception $e) { } catch (Exception $e) {
__c3_error($e->getMessage()); __c3_error($e->getMessage());
} }
return __c3_exit(); return __c3_exit();
case 'clover': case 'clover':
try { try {
@ -255,6 +267,7 @@ if ($requested_c3_report) {
} catch (Exception $e) { } catch (Exception $e) {
__c3_error($e->getMessage()); __c3_error($e->getMessage());
} }
return __c3_exit(); return __c3_exit();
case 'crap4j': case 'crap4j':
try { try {
@ -262,6 +275,7 @@ if ($requested_c3_report) {
} catch (Exception $e) { } catch (Exception $e) {
__c3_error($e->getMessage()); __c3_error($e->getMessage());
} }
return __c3_exit(); return __c3_exit();
case 'serialized': case 'serialized':
try { try {
@ -269,6 +283,7 @@ if ($requested_c3_report) {
} catch (Exception $e) { } catch (Exception $e) {
__c3_error($e->getMessage()); __c3_error($e->getMessage());
} }
return __c3_exit(); return __c3_exit();
case 'phpunit': case 'phpunit':
try { try {
@ -276,10 +291,11 @@ if ($requested_c3_report) {
} catch (Exception $e) { } catch (Exception $e) {
__c3_error($e->getMessage()); __c3_error($e->getMessage());
} }
return __c3_exit(); return __c3_exit();
} }
} else { } else {
list($codeCoverage, ) = __c3_factory(null); list($codeCoverage) = __c3_factory(null);
$codeCoverage->start(C3_CODECOVERAGE_TESTNAME); $codeCoverage->start(C3_CODECOVERAGE_TESTNAME);
if (!array_key_exists('HTTP_X_CODECEPTION_CODECOVERAGE_DEBUG', $_SERVER)) { if (!array_key_exists('HTTP_X_CODECEPTION_CODECOVERAGE_DEBUG', $_SERVER)) {
register_shutdown_function( register_shutdown_function(

View File

@ -1,8 +1,8 @@
<?php <?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateUsersTable extends Migration class CreateUsersTable extends Migration
{ {

View File

@ -1,8 +1,8 @@
<?php <?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePasswordResetsTable extends Migration class CreatePasswordResetsTable extends Migration
{ {

View File

@ -1,12 +1,10 @@
<?php <?php
/** /**
* Laravel - A PHP Framework For Web Artisans * Laravel - A PHP Framework For Web Artisans.
* *
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com> * @author Taylor Otwell <taylor@laravel.com>
*/ */
define('LARAVEL_START', microtime(true)); define('LARAVEL_START', microtime(true));
/* /*

View File

@ -1,12 +1,10 @@
<?php <?php
/** /**
* Laravel - A PHP Framework For Web Artisans * Laravel - A PHP Framework For Web Artisans.
* *
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com> * @author Taylor Otwell <taylor@laravel.com>
*/ */
$uri = urldecode( $uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
); );

View File

@ -4,17 +4,14 @@ namespace Tests\Unit;
use App\Utils\NumberHelper; use App\Utils\NumberHelper;
use Tests\TestCase; use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
class NumberTest extends TestCase class NumberTest extends TestCase
{ {
public function testRoundingThreeLow() public function testRoundingThreeLow()
{ {
$rounded = NumberHelper::roundValue(3.144444444444, 3); $rounded = NumberHelper::roundValue(3.144444444444, 3);
$this->assertEquals(3.144, $rounded); $this->assertEquals(3.144, $rounded);
} }
public function testRoundingThreeHigh() public function testRoundingThreeHigh()
@ -22,7 +19,6 @@ class NumberTest extends TestCase
$rounded = NumberHelper::roundValue(3.144944444444, 3); $rounded = NumberHelper::roundValue(3.144944444444, 3);
$this->assertEquals(3.145, $rounded); $this->assertEquals(3.145, $rounded);
} }
public function testRoundingTwoLow() public function testRoundingTwoLow()

View File

@ -1,4 +1,5 @@
<?php <?php
// This is global bootstrap for autoloading // This is global bootstrap for autoloading
use Codeception\Util\Fixtures; use Codeception\Util\Fixtures;

File diff suppressed because it is too large Load Diff