Skip to content

Commit fbfdfef

Browse files
author
dmitriy
committed
Added additional tools, updated components, docs.
1 parent 131ee49 commit fbfdfef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+13788
-2244
lines changed

.circleci/config.yml

+21-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
- checkout
1111

1212
- run:
13-
name: Start container and verify it's working
13+
name: Start containers and verify it's working
1414
command: |
1515
make start-test
1616
@@ -37,6 +37,26 @@ jobs:
3737
make ecs
3838
make phpcs
3939
40+
- run:
41+
name: Run PHP copy/paste detector
42+
command: |
43+
make phpcpd
44+
45+
- run:
46+
name: Run PHP mess detector
47+
command: |
48+
make phpmd
49+
50+
- run:
51+
name: Run PHPStan static analysis tool
52+
command: |
53+
make phpstan
54+
55+
- run:
56+
name: Run Phpinsights PHP quality checks
57+
command: |
58+
make phpinsights
59+
4060
- store_artifacts:
4161
path: reports
4262

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ bootstrap/cache
1010
.phpstorm.meta.php
1111
Dockerfile
1212
_ide_helper.php
13+
Dockerfile
1314
docker-compose.yml
1415
docker-compose-test-ci.yml
1516
docker-compose-staging.yml

.github/workflows/ci.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,17 @@ jobs:
3434
run: make seed
3535
- name: Run test suite
3636
run: make phpunit
37-
- name: Run coding standard
37+
- name: Run PHP coding standard
3838
run: make ecs
39-
- name: Run codeSniffer
39+
- name: Run PHP codeSniffer
4040
run: make phpcs
41+
- name: Run PHP copy/paste detector
42+
run: make phpcpd
43+
- name: Run PHP mess detector
44+
run: make phpmd
45+
- name: Run PHPStan static analysis tool
46+
run: make phpstan
47+
- name: Run Phpinsights PHP quality checks
48+
run: make phpinsights
4149
- name: Stop the docker images
4250
run: make stop-test

.gitlab-ci.yml

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ build:
3333
- make phpunit
3434
- make ecs
3535
- make phpcs
36+
- make phpcpd
37+
- make phpmd
38+
- make phpstan
39+
- make phpinsights
3640
- make stop-test
3741
artifacts:
3842
paths:

.php_cs.dist

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
return PhpCsFixer\Config::create()
4+
->setRules([
5+
'@PSR12' => true,
6+
'array_syntax' => ['syntax' => 'short'],
7+
])
8+
;

Makefile

+27-3
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,15 @@ report-code-coverage: ## update code coverage on coveralls.io. Note: COVERALLS_R
146146

147147
###> phpcs ###
148148
phpcs: ## Run PHP CodeSniffer
149-
@make exec-bash cmd="./vendor/bin/phpcs --version && ./vendor/bin/phpcs --standard=PSR2 --colors -p app"
149+
@make exec-bash cmd="./vendor/bin/phpcs --version && ./vendor/bin/phpcs --standard=PSR2 --colors -p app tests"
150150
###< phpcs ###
151151

152152
###> ecs ###
153153
ecs: ## Run Easy Coding Standard
154-
@make exec-bash cmd="error_reporting=0 ./vendor/bin/ecs --clear-cache check app"
154+
@make exec-bash cmd="./vendor/bin/ecs --version && ./vendor/bin/ecs --clear-cache check app tests"
155155

156156
ecs-fix: ## Run The Easy Coding Standard to fix issues
157-
@make exec-bash cmd="error_reporting=0 ./vendor/bin/ecs --clear-cache --fix check app"
157+
@make exec-bash cmd="./vendor/bin/ecs --version && ./vendor/bin/ecs --clear-cache --fix check app tests"
158158
###< ecs ###
159159

160160
###> phpmetrics ###
@@ -171,3 +171,27 @@ phpmetrics-process: ## Generates PhpMetrics static analysis, should be run insid
171171
@php ./vendor/bin/phpmetrics --version
172172
@./vendor/bin/phpmetrics --junit=reports/junit.xml --report-html=reports/phpmetrics .
173173
###< phpmetrics ###
174+
175+
###> php copy/paste detector ###
176+
phpcpd:
177+
@make exec cmd="php phpcpd.phar --fuzzy app tests"
178+
###< php copy/paste detector ###
179+
180+
###> php mess detector ###
181+
phpmd:
182+
@make exec cmd="php ./vendor/bin/phpmd app text phpmd_ruleset.xml --suffixes php"
183+
###< php mess detector ###
184+
185+
###> PHPStan static analysis tool ###
186+
phpstan:
187+
@echo "\033[32mRunning PHPStan - PHP Static Analysis Tool\033[39m"
188+
@make exec cmd="php artisan cache:clear --env=test"
189+
@make exec cmd="./vendor/bin/phpstan --version"
190+
@make exec cmd="./vendor/bin/phpstan analyze app tests"
191+
###< PHPStan static analysis tool ###
192+
193+
###> Phpinsights PHP quality checks ###
194+
phpinsights:
195+
@echo "\033[32mRunning PHP Insights\033[39m"
196+
@make exec cmd="php -d error_reporting=0 ./vendor/bin/phpinsights analyse --no-interaction --min-quality=100 --min-complexity=85 --min-architecture=100 --min-style=100"
197+
###< Phpinsights PHP quality checks ###

app/Console/Commands/DbWaitDatabase.php

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
declare(strict_types=1);
2+
declare(strict_types = 1);
33

44
namespace App\Console\Commands;
55

@@ -11,8 +11,6 @@ class DbWaitDatabase extends Command
1111
{
1212
/**
1313
* Wait sleep time for db connection in seconds
14-
*
15-
* @var int
1614
*/
1715
private const WAIT_SLEEP_TIME = 2;
1816

@@ -32,20 +30,16 @@ class DbWaitDatabase extends Command
3230

3331
/**
3432
* Execute the console command.
35-
*
36-
* @param DB $db
37-
*
38-
* @return integer
3933
*/
40-
public function handle(DB $db): int
34+
public function handle(DB $database): int
4135
{
4236
for ($i = 0; $i < 60; $i += self::WAIT_SLEEP_TIME) {
4337
try {
44-
$db::select('SHOW TABLES');
38+
$database::select('SHOW TABLES');
4539
$this->info('Connection to the database is ok!');
4640

4741
return 0;
48-
} catch (QueryException $e) {
42+
} catch (QueryException $exception) {
4943
$this->comment('Trying to connect to the database seconds:' . $i);
5044
sleep(self::WAIT_SLEEP_TIME);
5145

app/Console/Kernel.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types = 1);
23

34
namespace App\Console;
45

@@ -16,8 +17,7 @@ class Kernel extends ConsoleKernel
1617

1718
/**
1819
* Define the application's command schedule.
19-
*
20-
* @param \Illuminate\Console\Scheduling\Schedule $schedule
20+
* @phpcsSuppress SlevomatCodingStandard.Functions.UnusedParameter
2121
*/
2222
protected function schedule(Schedule $schedule): void
2323
{

app/Exceptions/Handler.php

+3-22
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
2+
declare(strict_types = 1);
23

34
namespace App\Exceptions;
45

5-
use Exception;
66
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
77

88
class Handler extends ExceptionHandler
@@ -25,28 +25,9 @@ class Handler extends ExceptionHandler
2525
];
2626

2727
/**
28-
* Report or log an exception.
29-
*
30-
* @param \Exception $exception
31-
*
32-
* @throws \Exception
33-
*/
34-
public function report(Exception $exception): void
35-
{
36-
parent::report($exception);
37-
}
38-
39-
/**
40-
* Render an exception into an HTTP response.
41-
*
42-
* @param \Illuminate\Http\Request $request
43-
* @param \Exception $exception
44-
* @return \Symfony\Component\HttpFoundation\Response
45-
*
46-
* @throws \Exception
28+
* Register the exception handling callbacks for the application.
4729
*/
48-
public function render($request, Exception $exception)
30+
public function register(): void
4931
{
50-
return parent::render($request, $exception);
5132
}
5233
}

app/Http/Controllers/Auth/ConfirmPasswordController.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types = 1);
23

34
namespace App\Http\Controllers\Auth;
45

app/Http/Controllers/Auth/ForgotPasswordController.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types = 1);
23

34
namespace App\Http\Controllers\Auth;
45

app/Http/Controllers/Auth/LoginController.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types = 1);
23

34
namespace App\Http\Controllers\Auth;
45

app/Http/Controllers/Auth/RegisterController.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types = 1);
23

34
namespace App\Http\Controllers\Auth;
45

@@ -42,7 +43,6 @@ public function __construct()
4243
/**
4344
* Get a validator for an incoming registration request.
4445
*
45-
* @param array $data
4646
* @return \Illuminate\Contracts\Validation\Validator
4747
*/
4848
protected function validator(array $data)
@@ -57,7 +57,6 @@ protected function validator(array $data)
5757
/**
5858
* Create a new user instance after a valid registration.
5959
*
60-
* @param array $data
6160
* @return \App\User
6261
*/
6362
protected function create(array $data)

app/Http/Controllers/Auth/ResetPasswordController.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types = 1);
23

34
namespace App\Http\Controllers\Auth;
45

app/Http/Controllers/Auth/VerificationController.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types = 1);
23

34
namespace App\Http\Controllers\Auth;
45

app/Http/Controllers/Controller.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types = 1);
23

34
namespace App\Http\Controllers;
45

app/Http/Kernel.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types = 1);
23

34
namespace App\Http;
45

app/Http/Middleware/Authenticate.php

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types = 1);
23

34
namespace App\Http\Middleware;
45

@@ -17,5 +18,7 @@ protected function redirectTo($request)
1718
if (!$request->expectsJson()) {
1819
return route('login');
1920
}
21+
22+
return null;
2023
}
2124
}

app/Http/Middleware/CheckForMaintenanceMode.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types = 1);
23

34
namespace App\Http\Middleware;
45

app/Http/Middleware/EncryptCookies.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types = 1);
23

34
namespace App\Http\Middleware;
45

app/Http/Middleware/RedirectIfAuthenticated.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types = 1);
23

34
namespace App\Http\Middleware;
45

@@ -12,7 +13,6 @@ class RedirectIfAuthenticated
1213
* Handle an incoming request.
1314
*
1415
* @param \Illuminate\Http\Request $request
15-
* @param \Closure $next
1616
* @param string|null $guard
1717
* @return mixed
1818
*/

app/Http/Middleware/TrimStrings.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types = 1);
23

34
namespace App\Http\Middleware;
45

app/Http/Middleware/TrustProxies.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types = 1);
23

34
namespace App\Http\Middleware;
45

app/Http/Middleware/VerifyCsrfToken.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types = 1);
23

34
namespace App\Http\Middleware;
45

app/Providers/AppServiceProvider.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types = 1);
23

34
namespace App\Providers;
45

app/Providers/AuthServiceProvider.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types = 1);
23

34
namespace App\Providers;
45

app/Providers/BroadcastServiceProvider.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types = 1);
23

34
namespace App\Providers;
45

app/Providers/EventServiceProvider.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types = 1);
23

34
namespace App\Providers;
45

app/Providers/RouteServiceProvider.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types = 1);
23

34
namespace App\Providers;
45

@@ -9,8 +10,6 @@ class RouteServiceProvider extends ServiceProvider
910
{
1011
/**
1112
* The path to the "home" route for your application.
12-
*
13-
* @var string
1413
*/
1514
public const HOME = '/home';
1615

app/User.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types = 1);
23

34
namespace App;
45

0 commit comments

Comments
 (0)