Skip to content

Commit

Permalink
引入php_cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Qsnh committed Sep 18, 2018
1 parent 955a925 commit 5c59743
Show file tree
Hide file tree
Showing 107 changed files with 1,520 additions and 499 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -11,3 +11,4 @@ npm-debug.log
yarn-error.log
.env
bower_components
.php_cs.cache
29 changes: 29 additions & 0 deletions .php_cs
@@ -0,0 +1,29 @@
<?php

$header = <<<EOF
This file is part of the Qsnh/meedu.
(c) XiaoTeng <616896861@qq.com>
This source file is subject to the MIT license that is bundled
with this source code in the file LICENSE.
EOF;

return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'header_comment' => ['header' => $header],
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => [
'sort_algorithm' => 'length',
],
'no_useless_else' => true,
'no_useless_return' => true,
'yoda_style' => false,
'not_operator_with_successor_space' => true,
])
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__ . '/app')
);
19 changes: 14 additions & 5 deletions app/Console/Commands/ApplicationInstallCommand.php
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the Qsnh/meedu.
*
* (c) XiaoTeng <616896861@qq.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace App\Console\Commands;

use App\Models\Administrator;
Expand All @@ -23,8 +32,6 @@ class ApplicationInstallCommand extends Command

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
Expand All @@ -39,14 +46,16 @@ public function __construct()
public function handle()
{
$action = $this->argument('action');
if (!$action) {
if (! $action) {
$this->warn('Please choice action.');

return;
}

$method = 'action'.implode('', array_map('ucfirst', explode('_', $action)));
if (!method_exists($this, $method)) {
if (! method_exists($this, $method)) {
$this->warn('action not exists.');

return;
}

Expand Down Expand Up @@ -80,6 +89,7 @@ public function actionAdministrator()

if ($passwordRepeat != $password) {
$this->warn('password not correct.');

return;
}

Expand All @@ -92,5 +102,4 @@ public function actionAdministrator()

$this->info('administrator create success.');
}

}
11 changes: 9 additions & 2 deletions app/Console/Commands/ClearCacheCommand.php
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the Qsnh/meedu.
*
* (c) XiaoTeng <616896861@qq.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace App\Console\Commands;

use Illuminate\Console\Command;
Expand All @@ -23,8 +32,6 @@ class ClearCacheCommand extends Command

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
Expand Down
15 changes: 10 additions & 5 deletions app/Console/Kernel.php
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the Qsnh/meedu.
*
* (c) XiaoTeng <616896861@qq.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
Expand All @@ -13,14 +22,12 @@ class Kernel extends ConsoleKernel
* @var array
*/
protected $commands = [
//
];

/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
* @param \Illuminate\Console\Scheduling\Schedule $schedule
*/
protected function schedule(Schedule $schedule)
{
Expand All @@ -30,8 +37,6 @@ protected function schedule(Schedule $schedule)

/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
Expand Down
14 changes: 9 additions & 5 deletions app/Events/AdministratorLoginSuccessEvent.php
@@ -1,15 +1,21 @@
<?php

/*
* This file is part of the Qsnh/meedu.
*
* (c) XiaoTeng <616896861@qq.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace App\Events;

use App\Models\Administrator;
use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class AdministratorLoginSuccessEvent
{
Expand All @@ -19,8 +25,6 @@ class AdministratorLoginSuccessEvent

/**
* Create a new event instance.
*
* @return void
*/
public function __construct(Administrator $administrator)
{
Expand Down
16 changes: 10 additions & 6 deletions app/Events/AtUserEvent.php
@@ -1,16 +1,22 @@
<?php

/*
* This file is part of the Qsnh/meedu.
*
* (c) XiaoTeng <616896861@qq.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace App\Events;

use App\User;
use Illuminate\Broadcasting\Channel;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class AtUserEvent implements ShouldQueue
{
Expand All @@ -26,8 +32,6 @@ class AtUserEvent implements ShouldQueue

/**
* Create a new event instance.
*
* @return void
*/
public function __construct(User $fromUser, $toUserNickName, $comment, $commentType)
{
Expand Down
14 changes: 9 additions & 5 deletions app/Events/PaymentSuccessEvent.php
@@ -1,15 +1,21 @@
<?php

/*
* This file is part of the Qsnh/meedu.
*
* (c) XiaoTeng <616896861@qq.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace App\Events;

use App\Models\RechargePayment;
use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class PaymentSuccessEvent
{
Expand All @@ -19,8 +25,6 @@ class PaymentSuccessEvent

/**
* Create a new event instance.
*
* @return void
*/
public function __construct($thirdId)
{
Expand Down
17 changes: 13 additions & 4 deletions app/Exceptions/Handler.php
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the Qsnh/meedu.
*
* (c) XiaoTeng <616896861@qq.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace App\Exceptions;

use Exception;
Expand Down Expand Up @@ -31,8 +40,7 @@ class Handler extends ExceptionHandler
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $exception
* @return void
* @param \Exception $exception
*/
public function report(Exception $exception)
{
Expand All @@ -42,8 +50,9 @@ public function report(Exception $exception)
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
*
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
Expand Down
11 changes: 9 additions & 2 deletions app/Exceptions/MeeduErrorResponseJsonException.php
@@ -1,15 +1,22 @@
<?php

/*
* This file is part of the Qsnh/meedu.
*
* (c) XiaoTeng <616896861@qq.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace App\Exceptions;

use Exception;

class MeeduErrorResponseJsonException extends Exception
{

public function render()
{
return exception_response($this);
}

}
19 changes: 12 additions & 7 deletions app/Exports/RechargePaymentExport.php
@@ -1,16 +1,22 @@
<?php

/*
* This file is part of the Qsnh/meedu.
*
* (c) XiaoTeng <616896861@qq.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace App\Exports;

use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\FromCollection;

class RechargePaymentExport implements FromCollection, WithMapping, WithHeadings
{

protected $result = null;

public function __construct($result)
Expand Down Expand Up @@ -41,7 +47,7 @@ public function map($row): array
];
}

public function headings() : array
public function headings(): array
{
return [
'#',
Expand All @@ -55,5 +61,4 @@ public function headings() : array
'支付时间',
];
}

}

0 comments on commit 5c59743

Please sign in to comment.