Skip to content

Commit 3a4c378

Browse files
committed
infra: add PHPStan, CS Fixer to codebase
1 parent 8fedbbd commit 3a4c378

File tree

3 files changed

+75
-16
lines changed

3 files changed

+75
-16
lines changed

.php_cs

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,6 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
use Symfony\CS\Config\Config;
13-
use Symfony\CS\Finder\DefaultFinder;
14-
use Symfony\CS\Fixer\Contrib\HeaderCommentFixer;
15-
use Symfony\CS\FixerInterface;
16-
17-
$finder = DefaultFinder::create()
18-
->in(__DIR__)
19-
;
20-
2112
$header = <<<EOF
2213
This file is part of the FOSOAuthServerBundle package.
2314
@@ -27,11 +18,53 @@ For the full copyright and license information, please view the LICENSE
2718
file that was distributed with this source code.
2819
EOF;
2920

30-
HeaderCommentFixer::setHeader($header);
21+
$finder = PhpCsFixer\Finder::create()
22+
->exclude('vendor')
23+
->in(__DIR__);
3124

32-
return Config::create()
33-
->level(FixerInterface::SYMFONY_LEVEL)
34-
->fixers(array('align_double_arrow', 'header_comment'))
35-
->finder($finder)
36-
->setUsingCache(true)
37-
;
25+
return PhpCsFixer\Config::create()
26+
->setRiskyAllowed(true)
27+
->setUsingCache(false)
28+
->setRules(
29+
[
30+
'@Symfony' => true,
31+
'@PHPUnit60Migration:risky' => true,
32+
'array_syntax' => ['syntax' => 'short'],
33+
'combine_consecutive_unsets' => true,
34+
'declare_strict_types' => true,
35+
'dir_constant' => true,
36+
'general_phpdoc_annotation_remove' => ['@author'],
37+
'header_comment' => ['header' => $header],
38+
'linebreak_after_opening_tag' => true,
39+
'mb_str_functions' => true,
40+
'modernize_types_casting' => true,
41+
// 'native_function_invocation' => true,
42+
'no_extra_consecutive_blank_lines' => ['continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block'],
43+
'no_multiline_whitespace_before_semicolons' => true,
44+
'no_php4_constructor' => true,
45+
'no_short_echo_tag' => true,
46+
'no_unreachable_default_argument_value' => true,
47+
'no_useless_else' => true,
48+
'no_useless_return' => true,
49+
'not_operator_with_space' => false,
50+
'not_operator_with_successor_space' => false,
51+
'ordered_class_elements' => true,
52+
'ordered_imports' => true,
53+
'php_unit_construct' => true,
54+
'php_unit_strict' => true,
55+
'phpdoc_add_missing_param_annotation' => true,
56+
'phpdoc_annotation_without_dot' => true,
57+
'phpdoc_inline_tag' => false,
58+
'phpdoc_no_empty_return' => false,
59+
'phpdoc_order' => true,
60+
'phpdoc_to_comment' => false,
61+
'psr4' => true,
62+
'random_api_migration' => true,
63+
'semicolon_after_instruction' => true,
64+
'single_import_per_statement' => true,
65+
'strict_comparison' => true,
66+
'strict_param' => true,
67+
'yoda_style' => false
68+
]
69+
)
70+
->setFinder($finder);

Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
QA_DOCKER_IMAGE=jakzal/phpqa:alpine
2+
QA_DOCKER_COMMAND=docker run -it --rm -v "$(shell pwd):/project" -w /project ${QA_DOCKER_IMAGE}
3+
4+
dist: cs-full phpstan
5+
ci: cs-full-check phpstan
6+
lint: cs-full-check phpstan
7+
8+
phpstan:
9+
sh -c "${QA_DOCKER_COMMAND} phpstan analyse --configuration phpstan.neon --level 0 ."
10+
11+
cs:
12+
sh -c "${QA_DOCKER_COMMAND} php-cs-fixer fix -vvv --diff"
13+
14+
cs-full:
15+
sh -c "${QA_DOCKER_COMMAND} php-cs-fixer fix -vvv --using-cache=false --diff"
16+
17+
cs-full-check:
18+
sh -c "${QA_DOCKER_COMMAND} php-cs-fixer fix -vvv --using-cache=false --diff --dry-run"
19+
20+
.PHONY: install install-dev install-lowest phpstan cs cs-full cs-full-checks docker-up down-down
21+
.PHONY: in-docker-install in-docker-install-dev in-docker-install-lowest in-docker-test in-docker-test-coverage

phpstan.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
parameters:
2+
autoload_files:
3+
- vendor/autoload.php
4+
excludes_analyse:
5+
- vendor/

0 commit comments

Comments
 (0)