Skip to content

Commit 7fe65ad

Browse files
sreichelkiatng
andauthored
Add php-cs-fixer & PHPCompatibility check to workflow (#2744)
* PHP-CS-Fixer fixes Signed-off-by: Sven Reichel <[email protected]> * Updated workflow Signed-off-by: Sven Reichel <[email protected]> * Added php-cs-fixer workflow Signed-off-by: Sven Reichel <[email protected]> * Added PHPCompatibility check * PHPCompatibility check can fail * Fixes: Node.js 12 actions are deprecated * Fixes: PSR12.ControlStructures.ControlStructureSpacing.LineIndent * Fixes: PSR12.ControlStructures.ControlStructureSpacing.CloseParenthesisLine * Dond check CM_Redis every time * Add .php-cs-fixer.cache to .gitignore * Fixes class name (wrong place ... i know) * Minor fixes * Combined workflows * Added app/Mage.php and files from root to rulesets * Remove unused phpstan_experimental_level.neon * Updated phpstan.neon (for upcoming commits) * Set PhpStan level to 5 (from 3) * Update phpstan to v1.9.2 * Updated phpstan-baseline.neon * Updated phpstan-baseline.neon * Update app/code/core/Mage/Tag/Model/Resource/Tag.php Co-authored-by: Ng Kiat Siong <[email protected]> * Update lib/Varien/Db/Adapter/Pdo/Mysql.php Co-authored-by: Ng Kiat Siong <[email protected]> * Set workflow include paths (skip other files) * Updated labeler.yml * Removed travis label * Improved workflow (#26) * Fixed grep modifier to get correct count * Updated ECG sniff baseline * Added Mage_Centinal to PhpStan checks * Added Mage_PaypalUk to PhpStan checks * Update app/code/core/Mage/Paypal/Model/Config.php Co-authored-by: Ng Kiat Siong <[email protected]> Signed-off-by: Sven Reichel <[email protected]> Co-authored-by: Ng Kiat Siong <[email protected]>
1 parent 1f65685 commit 7fe65ad

File tree

255 files changed

+13432
-3233
lines changed

Some content is hidden

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

255 files changed

+13432
-3233
lines changed

.github/labeler.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
'Environment':
22
- .github/*
33
- .github/**/*
4-
- .phpstorm.meta.php/*
5-
- .travis.yml
6-
7-
'phpstan':
8-
- .github/phpstan.neon
9-
- .github/phpstan-baseline.neon
10-
- .github/phpstan_experimental_level.neon
114

125
'htaccess':
136
- .htaccess
147

158
'composer':
169
- composer.json
10+
- composer.lock
1711

1812
'downloader':
1913
- downloader/*
@@ -603,3 +597,18 @@
603597
# Add Documentation Label
604598
'Documentation':
605599
- '*.md'
600+
601+
'PHPStorm':
602+
- .phpstorm.meta.php/*
603+
604+
'phpcs':
605+
- .github/phpcs*.xml
606+
- .github/workflows/phpcs.yml
607+
608+
'php-cs-fixer':
609+
- .github/php-cs-fixer*.php
610+
- .github/workflows/php-cs-fixer.yml
611+
612+
'phpstan':
613+
- .github/phpstan*.neon
614+
- .github/workflows/phpstan.yml

.github/php-cs-fixer-ruleset.php

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<?php
2+
/*
3+
* This document has been generated with
4+
* https://mlocati.github.io/php-cs-fixer-configurator/#version:3.4.0|configurator
5+
* you can change this configuration by importing this file.
6+
*/
7+
$config = new PhpCsFixer\Config();
8+
return $config
9+
->setRules([
10+
// There MUST be one blank line after the namespace declaration.
11+
'blank_line_after_namespace' => true,
12+
// Ensure there is no code on the same line as the PHP open tag and it is followed by a blank line.
13+
'blank_line_after_opening_tag' => true,
14+
// The body of each structure MUST be enclosed by braces. Braces should be properly placed. Body of braces should be properly indented.
15+
'braces' => true,
16+
// Whitespace around the keywords of a class, trait or interfaces definition should be one space.
17+
'class_definition' => true,
18+
// Remove extra spaces in a nullable typehint.
19+
'compact_nullable_typehint' => true,
20+
// The PHP constants `true`, `false`, and `null` MUST be written using the correct casing.
21+
'constant_case' => true,
22+
// Equal sign in declare statement should be surrounded by spaces or not following configuration.
23+
'declare_equal_normalize' => true,
24+
// The keyword `elseif` should be used instead of `else if` so that all control keywords look like single words.
25+
'elseif' => true,
26+
// PHP code MUST use only UTF-8 without BOM (remove BOM).
27+
'encoding' => true,
28+
// PHP code must use the long `<?php` tags or short-echo `<?=` tags and not other tag variations.
29+
'full_opening_tag' => true,
30+
// Spaces should be properly placed in a function declaration.
31+
'function_declaration' => true,
32+
// Code MUST use configured indentation type.
33+
'indentation_type' => true,
34+
// All PHP files must use same line ending.
35+
'line_ending' => true,
36+
// Cast should be written in lower case.
37+
'lowercase_cast' => true,
38+
// PHP keywords MUST be in lower case.
39+
'lowercase_keywords' => true,
40+
// Class static references `self`, `static` and `parent` MUST be in lower case.
41+
'lowercase_static_reference' => true,
42+
// In method arguments and method call, there MUST NOT be a space before each comma and there MUST be one space after each comma. Argument lists MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list MUST be on the next line, and there MUST be only one argument per line.
43+
'method_argument_space' => true,
44+
// All instances created with new keyword must be followed by braces.
45+
'new_with_braces' => true,
46+
// There should be no empty lines after class opening brace.
47+
'no_blank_lines_after_class_opening' => true,
48+
// There must be a comment when fall-through is intentional in a non-empty case body.
49+
'no_break_comment' => true,
50+
// The closing `? >` tag MUST be omitted from files containing only PHP.
51+
'no_closing_tag' => true,
52+
// Remove leading slashes in `use` clauses.
53+
'no_leading_import_slash' => true,
54+
// There must be no space around double colons (also called Scope Resolution Operator or Paamayim Nekudotayim).
55+
'no_space_around_double_colon' => true,
56+
// When making a method or function call, there MUST NOT be a space between the method or function name and the opening parenthesis.
57+
'no_spaces_after_function_name' => true,
58+
// There MUST NOT be a space after the opening parenthesis. There MUST NOT be a space before the closing parenthesis.
59+
'no_spaces_inside_parenthesis' => true,
60+
// Remove trailing whitespace at the end of non-blank lines.
61+
'no_trailing_whitespace' => true,
62+
// There MUST be no trailing spaces inside comment or PHPDoc.
63+
'no_trailing_whitespace_in_comment' => true,
64+
// Remove trailing whitespace at the end of blank lines.
65+
'no_whitespace_in_blank_line' => true,
66+
// Orders the elements of classes/interfaces/traits.
67+
'ordered_class_elements' => false,
68+
// Ordering `use` statements.
69+
'ordered_imports' => true,
70+
// There should be one or no space before colon, and one space after it in return type declarations, according to configuration.
71+
'return_type_declaration' => true,
72+
// Cast `(boolean)` and `(integer)` should be written as `(bool)` and `(int)`, `(double)` and `(real)` as `(float)`, `(binary)` as `(string)`.
73+
'short_scalar_cast' => true,
74+
// A PHP file without end tag must always end with a single empty line feed.
75+
'single_blank_line_at_eof' => true,
76+
// There should be exactly one blank line before a namespace declaration.
77+
'single_blank_line_before_namespace' => true,
78+
// There MUST NOT be more than one property or constant declared per statement.
79+
'single_class_element_per_statement' => true,
80+
// There MUST be one use keyword per declaration.
81+
'single_import_per_statement' => true,
82+
// Each namespace use MUST go on its own line and there MUST be one blank line after the use statements block.
83+
'single_line_after_imports' => true,
84+
// Each trait `use` must be done as single statement.
85+
'single_trait_insert_per_statement' => true,
86+
// A case should be followed by a colon and not a semicolon.
87+
'switch_case_semicolon_to_colon' => true,
88+
// Removes extra spaces between colon and case value.
89+
'switch_case_space' => true,
90+
// Standardize spaces around ternary operator.
91+
'ternary_operator_spaces' => true,
92+
// Visibility MUST be declared on all properties and methods; `abstract` and `final` MUST be declared before the visibility; `static` MUST be declared after the visibility.
93+
'visibility_required' => true,
94+
])
95+
->setFinder(
96+
PhpCsFixer\Finder::create()
97+
->in([
98+
'app/code/core/Mage/',
99+
'lib/Mage/',
100+
'lib/Magento/',
101+
'lib/Varien/'
102+
])
103+
->name('*.php')
104+
->ignoreDotFiles(true)
105+
->ignoreVCS(true)
106+
);

0 commit comments

Comments
 (0)