Skip to content

Commit

Permalink
Add php-cs-fixer & PHPCompatibility check to workflow (#2744)
Browse files Browse the repository at this point in the history
* PHP-CS-Fixer fixes

Signed-off-by: Sven Reichel <github-sr@hotmail.com>

* Updated workflow

Signed-off-by: Sven Reichel <github-sr@hotmail.com>

* Added php-cs-fixer workflow

Signed-off-by: Sven Reichel <github-sr@hotmail.com>

* 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 <kiatsiong.ng@gmail.com>

* Update lib/Varien/Db/Adapter/Pdo/Mysql.php

Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>

* 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 <kiatsiong.ng@gmail.com>

Signed-off-by: Sven Reichel <github-sr@hotmail.com>
Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>
  • Loading branch information
sreichel and kiatng authored Nov 29, 2022
1 parent 1f65685 commit 7fe65ad
Show file tree
Hide file tree
Showing 255 changed files with 13,432 additions and 3,233 deletions.
23 changes: 16 additions & 7 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
'Environment':
- .github/*
- .github/**/*
- .phpstorm.meta.php/*
- .travis.yml

'phpstan':
- .github/phpstan.neon
- .github/phpstan-baseline.neon
- .github/phpstan_experimental_level.neon

'htaccess':
- .htaccess

'composer':
- composer.json
- composer.lock

'downloader':
- downloader/*
Expand Down Expand Up @@ -603,3 +597,18 @@
# Add Documentation Label
'Documentation':
- '*.md'

'PHPStorm':
- .phpstorm.meta.php/*

'phpcs':
- .github/phpcs*.xml
- .github/workflows/phpcs.yml

'php-cs-fixer':
- .github/php-cs-fixer*.php
- .github/workflows/php-cs-fixer.yml

'phpstan':
- .github/phpstan*.neon
- .github/workflows/phpstan.yml
106 changes: 106 additions & 0 deletions .github/php-cs-fixer-ruleset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?php
/*
* This document has been generated with
* https://mlocati.github.io/php-cs-fixer-configurator/#version:3.4.0|configurator
* you can change this configuration by importing this file.
*/
$config = new PhpCsFixer\Config();
return $config
->setRules([
// There MUST be one blank line after the namespace declaration.
'blank_line_after_namespace' => true,
// Ensure there is no code on the same line as the PHP open tag and it is followed by a blank line.
'blank_line_after_opening_tag' => true,
// The body of each structure MUST be enclosed by braces. Braces should be properly placed. Body of braces should be properly indented.
'braces' => true,
// Whitespace around the keywords of a class, trait or interfaces definition should be one space.
'class_definition' => true,
// Remove extra spaces in a nullable typehint.
'compact_nullable_typehint' => true,
// The PHP constants `true`, `false`, and `null` MUST be written using the correct casing.
'constant_case' => true,
// Equal sign in declare statement should be surrounded by spaces or not following configuration.
'declare_equal_normalize' => true,
// The keyword `elseif` should be used instead of `else if` so that all control keywords look like single words.
'elseif' => true,
// PHP code MUST use only UTF-8 without BOM (remove BOM).
'encoding' => true,
// PHP code must use the long `<?php` tags or short-echo `<?=` tags and not other tag variations.
'full_opening_tag' => true,
// Spaces should be properly placed in a function declaration.
'function_declaration' => true,
// Code MUST use configured indentation type.
'indentation_type' => true,
// All PHP files must use same line ending.
'line_ending' => true,
// Cast should be written in lower case.
'lowercase_cast' => true,
// PHP keywords MUST be in lower case.
'lowercase_keywords' => true,
// Class static references `self`, `static` and `parent` MUST be in lower case.
'lowercase_static_reference' => true,
// 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.
'method_argument_space' => true,
// All instances created with new keyword must be followed by braces.
'new_with_braces' => true,
// There should be no empty lines after class opening brace.
'no_blank_lines_after_class_opening' => true,
// There must be a comment when fall-through is intentional in a non-empty case body.
'no_break_comment' => true,
// The closing `? >` tag MUST be omitted from files containing only PHP.
'no_closing_tag' => true,
// Remove leading slashes in `use` clauses.
'no_leading_import_slash' => true,
// There must be no space around double colons (also called Scope Resolution Operator or Paamayim Nekudotayim).
'no_space_around_double_colon' => true,
// When making a method or function call, there MUST NOT be a space between the method or function name and the opening parenthesis.
'no_spaces_after_function_name' => true,
// There MUST NOT be a space after the opening parenthesis. There MUST NOT be a space before the closing parenthesis.
'no_spaces_inside_parenthesis' => true,
// Remove trailing whitespace at the end of non-blank lines.
'no_trailing_whitespace' => true,
// There MUST be no trailing spaces inside comment or PHPDoc.
'no_trailing_whitespace_in_comment' => true,
// Remove trailing whitespace at the end of blank lines.
'no_whitespace_in_blank_line' => true,
// Orders the elements of classes/interfaces/traits.
'ordered_class_elements' => false,
// Ordering `use` statements.
'ordered_imports' => true,
// There should be one or no space before colon, and one space after it in return type declarations, according to configuration.
'return_type_declaration' => true,
// Cast `(boolean)` and `(integer)` should be written as `(bool)` and `(int)`, `(double)` and `(real)` as `(float)`, `(binary)` as `(string)`.
'short_scalar_cast' => true,
// A PHP file without end tag must always end with a single empty line feed.
'single_blank_line_at_eof' => true,
// There should be exactly one blank line before a namespace declaration.
'single_blank_line_before_namespace' => true,
// There MUST NOT be more than one property or constant declared per statement.
'single_class_element_per_statement' => true,
// There MUST be one use keyword per declaration.
'single_import_per_statement' => true,
// Each namespace use MUST go on its own line and there MUST be one blank line after the use statements block.
'single_line_after_imports' => true,
// Each trait `use` must be done as single statement.
'single_trait_insert_per_statement' => true,
// A case should be followed by a colon and not a semicolon.
'switch_case_semicolon_to_colon' => true,
// Removes extra spaces between colon and case value.
'switch_case_space' => true,
// Standardize spaces around ternary operator.
'ternary_operator_spaces' => true,
// 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.
'visibility_required' => true,
])
->setFinder(
PhpCsFixer\Finder::create()
->in([
'app/code/core/Mage/',
'lib/Mage/',
'lib/Magento/',
'lib/Varien/'
])
->name('*.php')
->ignoreDotFiles(true)
->ignoreVCS(true)
);
Loading

0 comments on commit 7fe65ad

Please sign in to comment.