Skip to content

Commit 1bc0ba7

Browse files
authored
Merge pull request #262 from HuasoFoundries/enabling_psalm
Enabling psalm
2 parents f1bae70 + 07ec914 commit 1bc0ba7

File tree

242 files changed

+10525
-8512
lines changed

Some content is hidden

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

242 files changed

+10525
-8512
lines changed

.gitattributes

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
/tests export-ignore
2-
.gitattributes export-ignore
3-
.gitignore export-ignore
4-
.build_tests.php export-ignore
1+
.build_tests.php export-ignore
2+
.gitattributes export-ignore
3+
.gitignore export-ignore
4+
/.dependabot export-ignore
5+
/.editorconfig export-ignore
6+
/.gitattributes export-ignore
7+
/.github export-ignore
8+
/.gitignore export-ignore
9+
/.php_cs export-ignore
10+
/infection.json export-ignore
11+
/phpstan-baseline.neon export-ignore
12+
/phpstan.neon export-ignore
13+
/psalm-baseline.xml export-ignore
14+
/psalm.xml export-ignore
15+
/tests export-ignore

.gitignore

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,44 @@
11
selenium/tests/config.inc.php
22
tests/selenium/config.test.php
33
*sublime*
4-
.php.tools.ini
5-
.*.sh
6-
sftp-config*
7-
config.*.php*
8-
!config.inc.php-dist
9-
!tests/config*
104

11-
vendor
12-
!assets/vendor
135

14-
*.log
6+
7+
8+
9+
###> deploy files
1510
fabfile*
16-
/.idea/*
1711
phppga
18-
.php_cs.cache
12+
.*.sh
13+
14+
15+
###> editor specific files
16+
/.idea/*
17+
sublime-*
18+
.php.tools.ini
1919

20-
playground
21-
node_modules
2220

21+
###> temp and generated files
2322
temp/sessions/*
23+
playground
24+
*.log
25+
tests/_output
26+
27+
###> Vendor files
28+
node_modules
29+
vendor
30+
!assets/vendor
2431

25-
config.inc.php
32+
###> Config files other tan examples
2633
config.yml
27-
tests/_output
28-
debug.*.php
34+
.configs/
35+
sftp-config*
36+
config.*.php*
37+
!config.inc.php-dist
38+
!tests/config*
39+
40+
41+
###> cache for linters and fixers
42+
.build
43+
.php_cs.cache
44+
.phpunit.result.cache

.php_cs

Lines changed: 154 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,142 @@
11
<?php
22

3-
$composerinfo = json_decode(file_get_contents('composer.json'));
4-
$version = $composerinfo->version;
5-
6-
$header = "PHPPgAdmin v$version";
7-
8-
$rules=[
9-
'no_php4_constructor'=>true,
10-
'@PHP56Migration' => true,
11-
'@PHPUnit60Migration:risky' => true,
12-
'@Symfony' => true,
13-
'@Symfony:risky' => false,
14-
'@PSR1'=>true,
15-
'@PSR2'=>true,
16-
'align_multiline_comment' => true,
17-
'array_syntax' => ['syntax' => 'short'],
18-
'blank_line_before_statement' => true,
19-
'combine_consecutive_issets' => true,
20-
'combine_consecutive_unsets' => true,
21-
'compact_nullable_typehint' => true,
22-
'escape_implicit_backslashes' => true,
23-
'explicit_indirect_variable' => true,
24-
'no_whitespace_in_blank_line'=> true,
25-
'no_unused_imports'=>true,
26-
'elseif'=>true,
27-
'explicit_string_variable' => true,
28-
'final_internal_class' => true,
29-
'modernize_types_casting'=>true,
30-
'header_comment' => ['commentType'=>'PHPDoc','header' => $header],
31-
'heredoc_to_nowdoc' => true,
32-
'phpdoc_no_package' => false,
33-
'list_syntax' => ['syntax' => 'long'],
34-
'method_chaining_indentation' => true,
35-
'method_argument_space' => ['ensure_fully_multiline' => true],
36-
'multiline_comment_opening_closing' => true,
37-
'no_extra_blank_lines' => ['tokens' => ['break', 'case', 'continue', 'curly_brace_block', 'default', 'extra', 'parenthesis_brace_block', 'return', 'square_brace_block', 'switch', 'throw', 'use', 'useTrait', 'use_trait']],
38-
'no_null_property_initialization' => true,
39-
'no_short_echo_tag' => true,
40-
'no_superfluous_elseif' => true,
41-
'no_unneeded_curly_braces' => true,
42-
'no_unneeded_final_method' => true,
43-
'no_unreachable_default_argument_value' => true,
44-
'no_useless_else' => true,
45-
'no_useless_return' => true,
46-
'ordered_class_elements' => false,
47-
'ordered_imports' => true,
48-
'php_unit_strict' => true,
49-
'php_unit_test_annotation' => true,
50-
'php_unit_test_class_requires_covers' => true,
51-
'phpdoc_add_missing_param_annotation' => true,
52-
'phpdoc_align'=>true,
53-
'phpdoc_order' => true,
54-
'phpdoc_separation'=>true,
55-
'phpdoc_scalar'=>true,
56-
'phpdoc_trim'=>true,
57-
'phpdoc_types_order' => true,
58-
'semicolon_after_instruction' => true,
59-
'single_line_comment_style' => false,
60-
'strict_comparison' => false,
61-
'strict_param' => true,
62-
'single_quote'=>true,
63-
'yoda_style' => false,
64-
'binary_operator_spaces' => [
65-
'align_double_arrow' => true,
66-
'align_equals' => true
67-
]
3+
declare(strict_types=1);
684

5+
/**
6+
* PHPPgAdmin vv6.0.0-RC8-16-g13de173f
7+
*/
8+
9+
use Ergebnis\PhpCsFixer\Config;
10+
11+
$composerinfo = \json_decode(\file_get_contents('composer.json'));
12+
13+
14+
$tags = [
15+
'master' => trim(shell_exec('git describe --tags master')),
16+
17+
'develop' => trim(shell_exec('git describe --tags develop')),
6918
];
70-
71-
$config = PhpCsFixer\Config::create()
19+
20+
$current_branch = \trim(\shell_exec('git rev-parse --abbrev-ref HEAD'));
21+
22+
$version = $tags[$current_branch] ?? $tags['develop'];
23+
24+
25+
$composer_tags = $composerinfo->extra->current_tags;
26+
var_dump($composerinfo->extra->current_tags);
27+
if (
28+
\array_key_exists( trim($current_branch), $tags) &&
29+
($tags['master'] !== $composer_tags->master
30+
|| $tags['develop'] !== $composer_tags->develop)
31+
) {
32+
$composerinfo->extra->current_tags->master = $tags['master'];
33+
$composerinfo->extra->current_tags->develop = $tags['develop'];
34+
$composerinfo->extra->version = $version;
35+
\file_put_contents('composer.json', \json_encode($composerinfo));
36+
}
37+
38+
$header = "PHPPgAdmin {$version}";
39+
;
40+
41+
$rules = [
42+
'no_php4_constructor' => true,
43+
'@PHP56Migration' => true,
44+
'@PHPUnit60Migration:risky' => true,
45+
'@Symfony' => true,
46+
'@Symfony:risky' => false,
47+
'@PSR1' => true,
48+
'@PSR2' => true,
49+
'align_multiline_comment' => true,
50+
'array_syntax' => ['syntax' => 'short'],
51+
'blank_line_before_statement' => true,
52+
'combine_consecutive_issets' => true,
53+
'combine_consecutive_unsets' => true,
54+
'compact_nullable_typehint' => true,
55+
'escape_implicit_backslashes' => true,
56+
'explicit_indirect_variable' => true,
57+
'no_whitespace_in_blank_line' => true,
58+
'no_unused_imports' => true,
59+
'elseif' => true,
60+
'explicit_string_variable' => true,
61+
'final_internal_class' => true,
62+
'modernize_types_casting' => true,
63+
'header_comment' => ['commentType' => 'PHPDoc', 'header' => $header],
64+
'heredoc_to_nowdoc' => true,
65+
'phpdoc_no_package' => false,
66+
'list_syntax' => ['syntax' => 'long'],
67+
'method_chaining_indentation' => true,
68+
'method_argument_space' => ['ensure_fully_multiline' => true],
69+
'multiline_comment_opening_closing' => true,
70+
'no_extra_blank_lines' => ['tokens' => ['break', 'case', 'continue', 'curly_brace_block', 'default', 'extra', 'parenthesis_brace_block', 'return', 'square_brace_block', 'switch', 'throw', 'use', 'useTrait', 'use_trait']],
71+
'no_null_property_initialization' => true,
72+
'no_short_echo_tag' => true,
73+
'no_superfluous_elseif' => true,
74+
'no_unneeded_curly_braces' => true,
75+
'no_unneeded_final_method' => true,
76+
'no_unreachable_default_argument_value' => true,
77+
'no_useless_else' => true,
78+
'no_useless_return' => true,
79+
'ordered_class_elements' => false,
80+
'ordered_imports' => true,
81+
'php_unit_strict' => true,
82+
'php_unit_test_annotation' => true,
83+
'php_unit_test_class_requires_covers' => true,
84+
'phpdoc_add_missing_param_annotation' => true,
85+
'phpdoc_align' => true,
86+
'phpdoc_order' => true,
87+
'phpdoc_separation' => true,
88+
'phpdoc_scalar' => true,
89+
'phpdoc_trim' => true,
90+
'phpdoc_types_order' => true,
91+
'semicolon_after_instruction' => true,
92+
'single_line_comment_style' => false,
93+
'strict_comparison' => false,
94+
'strict_param' => true,
95+
'single_quote' => true,
96+
'yoda_style' => false,
97+
'binary_operator_spaces' => [
98+
'align_double_arrow' => true,
99+
'align_equals' => true,
100+
],
101+
];
102+
103+
$config = Config\Factory::fromRuleSet(new Config\RuleSet\Php71($header),[
104+
'declare_strict_types' => false,
105+
'header_comment' => ['commentType' => 'PHPDoc', 'header' => $header],
106+
'escape_implicit_backslashes' => false,
107+
'final_class'=>false,
108+
'final_internal_class' => false,
109+
'final_public_method_for_abstract_class' => false,
110+
'final_static_access' => false,
111+
'global_namespace_import' => false,
112+
'fully_qualified_strict_types' => false,
113+
'visibility_required' => [
114+
'elements' => [
115+
'method',
116+
'property',
117+
],
118+
],
119+
]);
120+
121+
122+
$config->getFinder()
123+
->ignoreDotFiles(false)
124+
->in(__DIR__.'/src/decorators')
125+
->exclude([
126+
'.build',
127+
'.configs',
128+
'__pycache__',
129+
'assets',
130+
'docs',
131+
'node_modules',
132+
'temp',
133+
'tests',
134+
'vendor',
135+
'.github',
136+
])
137+
->name('.php_cs');
138+
139+
/*$config = PhpCsFixer\Config::create()
72140
->setRiskyAllowed(true)
73141
->setRules($rules)
74142
->setFinder(
@@ -83,10 +151,25 @@ $config = PhpCsFixer\Config::create()
83151
->in(__DIR__.'/src/traits')
84152
->in(__DIR__.'/src/database/databasetraits')
85153
->in(__DIR__.'/tests')
86-
87-
);
154+
->exclude([
155+
'.build',
156+
'.configs',
157+
'__pycache__',
158+
'assets',
159+
'docs',
160+
'node_modules',
161+
'temp',
162+
'tests',
163+
'vendor',
164+
'.github',
165+
])
166+
->name('.php_cs')
167+
168+
);*/
169+
$config->setCacheFile(__DIR__ . '/.build/php-cs-fixer/php_cs.cache');
88170

89171
// special handling of fabbot.io service if it's using too old PHP CS Fixer version
172+
/*
90173
try {
91174
PhpCsFixer\FixerFactory::create()
92175
->registerBuiltInFixers()
@@ -98,6 +181,6 @@ try {
98181
$config->setRules([]);
99182
} catch (InvalidArgumentException $e) {
100183
$config->setRules([]);
101-
}
102-
184+
}
185+
*/
103186
return $config;

.psalm.log

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
------------------------------
2+
339 errors found
3+
------------------------------
4+
1617 other issues found.
5+
You can hide them with --show-info=false
6+
------------------------------
7+
Psalm can automatically fix 97 issues.
8+
Run Psalm again with
9+
--alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType --dry-run
10+
to see what it can fix.
11+
------------------------------
12+
13+
Checks took 14.46 seconds and used 203.375MB of memory
14+
Psalm was able to infer types for 81.7737% of the codebase
15+

0 commit comments

Comments
 (0)