1
0
mirror of synced 2024-12-05 03:06:02 +03:00

Added php code style fixer

This commit is contained in:
Ivan Lutokhin 2020-08-18 17:36:06 +03:00
parent db3a4d8756
commit 05fe5378ba
4 changed files with 79 additions and 2 deletions

2
.gitignore vendored
View File

@ -3,6 +3,8 @@ composer.phar
vendor vendor
.php_cs.cache
# IntelliJ project files # IntelliJ project files
*.iml *.iml
*.iws *.iws

56
.php_cs Normal file
View File

@ -0,0 +1,56 @@
<?php
require_once __DIR__ . '/vendor/autoload.php';
$finder = PhpCsFixer\Finder::create()
->files()
->name('*.php')
->in(__DIR__)
->exclude([
'vendor',
])
->ignoreDotFiles(true)
->ignoreVCS(true)
;
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
// exceptions
'single_line_throw' => false,
// php file
'concat_space' => ['spacing' => 'one'],
// namespace and imports
'ordered_imports' => true,
'global_namespace_import' => [
'import_classes' => false,
'import_constants' => false,
'import_functions' => false,
],
// standard functions and operators
'native_constant_invocation' => false,
'native_function_invocation' => false,
'modernize_types_casting' => true,
'is_null' => true,
// arrays
'array_syntax' => [
'syntax' => 'short',
],
// phpdoc
'phpdoc_annotation_without_dot' => false,
'phpdoc_summary' => false,
// logical operators
'logical_operators' => true,
])
->setFinder($finder)
->setCacheFile(__DIR__ . '.php_cs.cache')
;

18
.travis.yml Normal file
View File

@ -0,0 +1,18 @@
language: php
cache:
directories:
- $HOME/.composer/cache
php:
- '7.3'
before_script:
- flags="-o"
- composer install $flags
script:
- php vendor/bin/php-cs-fixer fix --diff --dry-run --using-cache no --config .php_cs
after_success:
- bash <(curl -s https://codecov.io/bash)

View File

@ -28,6 +28,7 @@
"symfony/validator": "^5.1" "symfony/validator": "^5.1"
}, },
"require-dev": { "require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.3" "doctrine/doctrine-fixtures-bundle": "^3.3",
"friendsofphp/php-cs-fixer": "^2.0"
} }
} }