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+ /*
90173try {
91174 PhpCsFixer\FixerFactory::create()
92175 ->registerBuiltInFixers()
98181 $config->setRules([]);
99182} catch (InvalidArgumentException $e) {
100183 $config->setRules([]);
101- }
102-
184+ }
185+ */
103186return $ config ;
0 commit comments