Add php cs fixer and some rule sets.

This commit is contained in:
James Cole 2022-10-30 12:21:41 +01:00
parent 914dc8596b
commit 8edfb1460c
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
6 changed files with 2093 additions and 0 deletions

1
.ci/php-cs-fixer/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
vendor

View File

@ -0,0 +1,31 @@
<?php
/*
* .php-cs-fixer.php
* Copyright (c) 2022 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* 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/>.
*/
$finder = PhpCsFixer\Finder::create();
$config = new PhpCsFixer\Config();
return $config->setRules([
'@PSR12' => true,
'strict_param' => true,
'array_syntax' => ['syntax' => 'short'],
])
->setFinder($finder)
;

View File

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

2047
.ci/php-cs-fixer/composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -23,9 +23,17 @@
# Install composer packages
#composer install --no-scripts --no-ansi
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# enable test .env file.
# cp .ci/.env.ci .env
# clean up php code
cd $SCRIPT_DIR/php-cs-fixer
composer update
./vendor/bin/php-cs-fixer fix $SCRIPT_DIR/../app/Console --config $SCRIPT_DIR/php-cs-fixer/.php-cs-fixer.php --allow-risky=yes
cd $SCRIPT_DIR/..
# Do static code analysis.
# ./vendor/bin/phpstan analyse -c .ci/phpstan.neon --no-progress
./vendor/bin/phpstan analyse -c .ci/phpstan.neon

1
.gitignore vendored
View File

@ -6,3 +6,4 @@
npm-debug.log
yarn-error.log
.env
.php-cs-fixer.cache