Merge pull request #13824 from toddy15/php-cs-fixer

Update and install PHP-CS-Fixer
This commit is contained in:
Hypolite Petovan 2024-01-15 07:53:39 -05:00 committed by GitHub
commit 4c402f6af4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 1689 additions and 4 deletions

3
.gitignore vendored
View file

@ -83,8 +83,9 @@ venv/
#Ignore temporary installed phpunit #Ignore temporary installed phpunit
/bin/phpunit /bin/phpunit
#Ignore cache file #Ignore cache files
.php_cs.cache .php_cs.cache
.php-cs-fixer.cache
#ignore avatar picture cache path #ignore avatar picture cache path
/avatar /avatar

93
.php-cs-fixer.dist.php Normal file
View file

@ -0,0 +1,93 @@
<?php
/**
* @copyright Copyright (C) 2010-2024, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->notPath('addon')
->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',
'??' => '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,
'ternary_operator_spaces' => false,
'visibility_required' => [
'elements' => ['property', 'method']
],
'new_with_braces' => true,
])
->setFinder($finder)
->setIndent("\t");

View file

@ -6,6 +6,7 @@ require_once __DIR__ . '/bin/dev/php-cs-fixer/vendor/autoload.php';
$finder = PhpCsFixer\Finder::create() $finder = PhpCsFixer\Finder::create()
->in(__DIR__) ->in(__DIR__)
->notPath('addon')
->notPath('bin/dev') ->notPath('bin/dev')
->notPath('config') ->notPath('config')
->notPath('doc') ->notPath('doc')

View file

@ -135,7 +135,8 @@
"mockery/mockery": "^1.3", "mockery/mockery": "^1.3",
"mikey179/vfsstream": "^1.6", "mikey179/vfsstream": "^1.6",
"phpunit/phpunit": "^9", "phpunit/phpunit": "^9",
"dms/phpunit-arraysubset-asserts": "^0.3.1" "dms/phpunit-arraysubset-asserts": "^0.3.1",
"friendsofphp/php-cs-fixer": "^3.46"
}, },
"scripts": { "scripts": {
"test": "phpunit", "test": "phpunit",
@ -149,6 +150,8 @@
"cs:fix": [ "cs:fix": [
"@cs:install", "@cs:install",
"bin/dev/php-cs-fixer/vendor/bin/php-cs-fixer fix" "bin/dev/php-cs-fixer/vendor/bin/php-cs-fixer fix"
] ],
"cs:check-v3": "vendor/bin/php-cs-fixer check --diff",
"cs:fix-v3": "vendor/bin/php-cs-fixer fix"
} }
} }

1589
composer.lock generated

File diff suppressed because it is too large Load diff