Skip to content

Commit ccaff30

Browse files
author
dmitriy
committed
Added additional tools, updated components, docs.
1 parent e2f4fcb commit ccaff30

Some content is hidden

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

49 files changed

+9880
-2809
lines changed

.circleci/config.yml

+20
Original file line numberDiff line numberDiff line change
@@ -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

.github/workflows/ci.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,17 @@ jobs:
3434
run: make messenger-setup-transports
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+
'@Symfony' => true,
6+
'array_syntax' => ['syntax' => 'short'],
7+
])
8+
;

Makefile

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

148148
###> phpcs ###
149149
phpcs: ## Run PHP CodeSniffer
150-
@make exec-bash cmd="./vendor/bin/phpcs --version && ./vendor/bin/phpcs --standard=PSR2 --colors -p src"
150+
@make exec-bash cmd="./vendor/bin/phpcs --version && ./vendor/bin/phpcs --standard=PSR2 --colors -p src tests"
151151
###< phpcs ###
152152

153153
###> ecs ###
154154
ecs: ## Run Easy Coding Standard
155-
@make exec-bash cmd="error_reporting=0 ./vendor/bin/ecs --clear-cache check src"
155+
@make exec-bash cmd="./vendor/bin/ecs --version && ./vendor/bin/ecs --clear-cache check src tests"
156156

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

161161
###> phpmetrics ###
@@ -172,3 +172,27 @@ phpmetrics-process: ## Generates PhpMetrics static analysis, should be run insid
172172
@php ./vendor/bin/phpmetrics --version
173173
@./vendor/bin/phpmetrics --junit=reports/junit.xml --report-html=reports/phpmetrics .
174174
###< phpmetrics ###
175+
176+
###> php copy/paste detector ###
177+
phpcpd:
178+
@make exec cmd="php phpcpd.phar --fuzzy src tests"
179+
###< php copy/paste detector ###
180+
181+
###> php mess detector ###
182+
phpmd:
183+
@make exec cmd="php ./vendor/bin/phpmd src text phpmd_ruleset.xml --suffixes php --exclude *src/Migrations/*"
184+
###< php mess detector ###
185+
186+
###> PHPStan static analysis tool ###
187+
phpstan:
188+
@echo "\033[32mRunning PHPStan - PHP Static Analysis Tool\033[39m"
189+
@make exec cmd="bin/console cache:clear --env=test"
190+
@make exec cmd="./vendor/bin/phpstan --version"
191+
@make exec cmd="./vendor/bin/phpstan analyze src tests"
192+
###< PHPStan static analysis tool ###
193+
194+
###> Phpinsights PHP quality checks ###
195+
phpinsights:
196+
@echo "\033[32mRunning PHP Insights\033[39m"
197+
@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"
198+
###< Phpinsights PHP quality checks ###

bin/console

+17-13
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,33 @@ declare(strict_types = 1);
55
use App\Kernel;
66
use Symfony\Bundle\FrameworkBundle\Console\Application;
77
use Symfony\Component\Console\Input\ArgvInput;
8+
use Symfony\Component\Dotenv\Dotenv;
89
use Symfony\Component\ErrorHandler\Debug;
910

11+
set_time_limit(0);
12+
1013
if (!in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
11-
echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
14+
echo 'Warning: The console should be invoked via the CLI version of PHP, not the ' . PHP_SAPI . ' SAPI' . PHP_EOL;
1215
}
1316

14-
set_time_limit(0);
15-
16-
require dirname(__DIR__).'/vendor/autoload.php';
17+
require dirname(__DIR__) . '/vendor/autoload.php';
1718

18-
if (!class_exists(Application::class)) {
19-
throw new LogicException('You need to add "symfony/framework-bundle" as a Composer dependency.');
19+
if (!class_exists(Application::class) || !class_exists(Dotenv::class)) {
20+
throw new LogicException('You need to add "symfony/framework-bundle" and "symfony/dotenv" as Composer dependencies.');
2021
}
2122

2223
$input = new ArgvInput();
23-
if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) {
24-
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
24+
$env = $input->getParameterOption(['--env', '-e'], null, true);
25+
26+
if ($env) {
27+
putenv('APP_ENV=' . $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
2528
}
2629

2730
if ($input->hasParameterOption('--no-debug', true)) {
28-
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
31+
putenv('APP_DEBUG=' . $_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
2932
}
3033

31-
require dirname(__DIR__).'/config/bootstrap.php';
34+
require dirname(__DIR__) . '/config/bootstrap.php';
3235

3336
if ($_SERVER['APP_DEBUG']) {
3437
umask(0000);
@@ -38,6 +41,7 @@ if ($_SERVER['APP_DEBUG']) {
3841
}
3942
}
4043

41-
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
42-
$application = new Application($kernel);
43-
$application->run($input);
44+
$kernel = new Kernel($_SERVER['APP_ENV'], (bool)$_SERVER['APP_DEBUG']);
45+
46+
/** @noinspection PhpUnhandledExceptionInspection */
47+
(new Application($kernel))->run($input);

bitbucket-pipelines.yml

+4
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,8 @@ pipelines:
1919
- make phpunit
2020
- make ecs
2121
- make phpcs
22+
- make phpcpd
23+
- make phpmd
24+
- make phpstan
25+
- make phpinsights
2226
- make stop-test

composer.json

+20-13
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@
3131
"ext-mbstring": "*",
3232
"ext-pdo": "*",
3333
"ext-pdo_mysql": "*",
34-
"doctrine/doctrine-migrations-bundle": "^2.2",
34+
"doctrine/doctrine-migrations-bundle": "^3.0",
3535
"easycorp/easy-log-handler": "1.0.*",
36-
"jmose/command-scheduler-bundle": "^2.2",
37-
"sensio/framework-extra-bundle": "^5.5",
38-
"sensiolabs/security-checker": "^6.0",
36+
"jmose/command-scheduler-bundle": "^3.0",
37+
"sensio/framework-extra-bundle": "^5.6",
3938
"symfony/apache-pack": "^1.0",
4039
"symfony/asset": "4.4.*",
4140
"symfony/config": "4.4.*",
@@ -49,7 +48,7 @@
4948
"symfony/intl": "4.4.*",
5049
"symfony/mailer": "4.4.*",
5150
"symfony/messenger": "4.4.*",
52-
"symfony/monolog-bundle": "^3.5",
51+
"symfony/monolog-bundle": "^3.6",
5352
"symfony/orm-pack": "*",
5453
"symfony/process": "4.4.*",
5554
"symfony/routing": "4.4.*",
@@ -76,11 +75,14 @@
7675
"require-dev": {
7776
"bamarni/composer-bin-plugin": "^1.4",
7877
"doctrine/doctrine-fixtures-bundle": "^3.3",
79-
"ergebnis/composer-normalize": "^2.6",
78+
"ergebnis/composer-normalize": "^2.9",
8079
"roave/security-advisories": "dev-master",
81-
"symfony/debug-pack": "*",
82-
"symfony/maker-bundle": "^1.20",
83-
"symfony/requirements-checker": "^1.1"
80+
"sensiolabs/security-checker": "^6.0",
81+
"symfony/debug-bundle": "4.4.*",
82+
"symfony/maker-bundle": "^1.22",
83+
"symfony/requirements-checker": "^2.0",
84+
"symfony/var-dumper": "4.4.*",
85+
"symfony/web-profiler-bundle": "4.4.*"
8486
},
8587
"config": {
8688
"platform": {
@@ -108,28 +110,33 @@
108110
"autoload-dev": {
109111
"psr-4": {
110112
"App\\Tests\\": "tests/",
111-
"PHPUnit\\": "tools/01_phpunit/vendor/phpunit/phpunit/src/",
113+
"PHPUnit\\": "tools/01_phpunit/vendor/phpunit/phpunit/src",
112114
"Symfony\\Component\\BrowserKit\\": "tools/01_phpunit/vendor/symfony/browser-kit",
113-
"Symfony\\Bridge\\PhpUnit\\": "tools/01_phpunit/vendor/symfony/phpunit-bridge"
115+
"Symfony\\Bridge\\PhpUnit\\": "tools/01_phpunit/vendor/symfony/phpunit-bridge",
116+
"PHPMD\\": "tools/06_phpmd/vendor/phpmd/phpmd/src/bin",
117+
"PhpCsFixer\\": "tools/03_ecs/vendor/friendsofphp/php-cs-fixer/src",
118+
"SlevomatCodingStandard\\": "tools/03_ecs/vendor/slevomat/coding-standard/SlevomatCodingStandard",
119+
"Symplify\\CodingStandard\\": "tools/03_ecs/vendor/symplify/coding-standard/src"
114120
}
115121
},
116122
"prefer-stable": true,
117123
"scripts": {
118124
"post-install-cmd": [
119125
"if test -d vendor/symfony/requirements-checker; then ./vendor/bin/requirements-checker; fi",
126+
"if test -d vendor/sensiolabs/security-checker; then ./vendor/bin/security-checker security:check; fi",
120127
"if test -d vendor/bamarni/composer-bin-plugin; then composer bin all install; fi",
121128
"@auto-scripts"
122129
],
123130
"post-update-cmd": [
124131
"if test -d vendor/symfony/requirements-checker; then ./vendor/bin/requirements-checker; fi",
132+
"if test -d vendor/sensiolabs/security-checker; then ./vendor/bin/security-checker security:check; fi",
125133
"if test -d vendor/bamarni/composer-bin-plugin; then composer bin all update; fi",
126134
"@auto-scripts"
127135
],
128136
"auto-scripts": {
129137
"cache:clear": "symfony-cmd",
130138
"cache:warmup": "symfony-cmd",
131-
"assets:install %PUBLIC_DIR%": "symfony-cmd",
132-
"security-checker security:check": "script"
139+
"assets:install %PUBLIC_DIR%": "symfony-cmd"
133140
}
134141
},
135142
"support": {

0 commit comments

Comments
 (0)