Merge remote-tracking branch 'upstream/2021.03-rc' into notice

This commit is contained in:
Michael 2021-04-08 19:57:26 +00:00
commit 50c6735246
7 changed files with 2074 additions and 3 deletions

View file

@ -3,14 +3,14 @@ on: pull_request
jobs:
php-linters:
name: php${{ matrix.php-versions }} lint
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.3', '7.4', '8.0']
name: php${{ matrix.php-versions }} lint
steps:
- name: Checkout
uses: actions/checkout@master
uses: actions/checkout@v2
- name: Set up php${{ matrix.php-versions }}
uses: shivammathur/setup-php@master
with:
@ -18,3 +18,25 @@ jobs:
coverage: none
- name: Lint
run: bin/composer.phar run lint
php-cs-fixer:
name: php-cs check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get changed files
id: changes
uses: jitterbit/get-changed-files@v1
- name: Set up php
uses: shivammathur/setup-php@master
with:
php-version: 7.2
coverage: none
- name: Install dependencies
run: bin/composer.phar run cs:install
- name: Run coding standards check
run: |
if ! echo "${{ steps.changes.outputs.all }}" | grep -qE "^(\\.php_cs(\\.dist)?|composer\\.lock)$"; then EXTRA_ARGS=$(printf -- '--path-mode=intersection\n--\n%s' "${{ steps.changes.outputs.all }}"); else EXTRA_ARGS=''; fi
bin/dev/php-cs-fixer/vendor/bin/php-cs-fixer fix --config=.php_cs.dist -v --diff --diff-format=udiff --dry-run --stop-on-violation --using-cache=no ${EXTRA_ARGS}
shell: bash

3
.gitignore vendored
View file

@ -82,3 +82,6 @@ venv/
#Ignore temporary installed phpunit
/bin/phpunit
#Ignore cache file
.php_cs.cache

74
.php_cs.dist Normal file
View file

@ -0,0 +1,74 @@
<?php
declare(strict_types=1);
require_once __DIR__ . '/bin/dev/php-cs-fixer/vendor/autoload.php';
$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->notPath('bin/dev')
->notPath('config')
->notPath('doc')
->notPath('images')
->notPath('mods')
->notPath('spec')
->notPath('vendor')
->notPath('view/asset')
->notPath('lang')
->notPath('view/smarty3/compiled');
$config = new PhpCsFixer\Config();
return $config
->setRules([
'@PSR1' => true,
'@PSR2' => true,
'@PSR12' => true,
'align_multiline_comment' => true,
'array_indentation' => true,
'array_syntax' => [
'syntax' => 'short',
],
'binary_operator_spaces' => [
'default' => 'single_space',
'operators' => [
'=>' => 'align_single_space_minimal',
'=' => 'align_single_space_minimal',
],
],
'blank_line_after_namespace' => true,
'braces' => [
'position_after_anonymous_constructs' => 'same',
'position_after_control_structures' => 'same',
'position_after_functions_and_oop_constructs' => 'next',
],
'elseif' => true,
'encoding' => true,
'full_opening_tag' => true,
'function_declaration' => [
'closure_function_spacing' => 'one',
],
'indentation_type' => true,
'line_ending' => true,
'list_syntax' => [
'syntax' => 'long',
],
'lowercase_keywords' => true,
'method_argument_space' => [],
'no_closing_tag' => true,
'no_spaces_after_function_name' => true,
'no_spaces_inside_parenthesis' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_unused_imports' => true,
'single_blank_line_at_eof' => true,
'single_class_element_per_statement' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'switch_case_space' => true,
'visibility_required' => [
'elements' => ['property', 'method']
],
'new_with_braces' => true,
])
->setFinder($finder)
->setIndent("\t");

1
bin/dev/php-cs-fixer/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
vendor

View file

@ -0,0 +1,5 @@
{
"require": {
"friendsofphp/php-cs-fixer": "^2.18"
}
}

1963
bin/dev/php-cs-fixer/composer.lock generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -129,6 +129,9 @@
},
"scripts": {
"test": "phpunit",
"lint": "find . -name \\*.php -not -path './vendor/*' -not -path './view/asset/*' -print0 | xargs -0 -n1 php -l"
"lint": "find . -name \\*.php -not -path './vendor/*' -not -path './view/asset/*' -print0 | xargs -0 -n1 php -l",
"cs:install": "@composer install --working-dir=bin/dev/php-cs-fixer",
"cs:check": ["@cs:install", "bin/dev/php-cs-fixer/vendor/bin/php-cs-fixer fix --dry-run --diff"],
"cs:fix": ["@cs:install", "bin/dev/php-cs-fixer/vendor/bin/php-cs-fixer fix"]
}
}