Add PHP-CS-Fixer integration (#1148)

* Add PHP-CS-Fixer checks

* Remove composer.lock to early catch FC break on CI

* Travis: cache dependencies

* Enable code-coverage only for latest build

* Remove Symfony-specific PHP-Doc rules

* Apply coding-standards fix
This commit is contained in:
Filippo Tessarotto 2017-09-14 12:29:03 +02:00 committed by Marcus Bointon
parent add60c3e54
commit 8550acd0e4
7 changed files with 62 additions and 3741 deletions

2
.gitignore vendored
View File

@ -5,3 +5,5 @@ test/testbootstrap.php
build/
vendor/
*.pem
composer.lock
.php_cs.cache

32
.php_cs Normal file
View File

@ -0,0 +1,32 @@
<?php
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => false,
'concat_space' => ['spacing' => 'one'],
'heredoc_to_nowdoc' => true,
'method_argument_space' => true,
'no_extra_consecutive_blank_lines' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block'],
'no_php4_constructor' => true,
'no_short_echo_tag' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_imports' => true,
'php_unit_fqcn_annotation' => false,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_order' => true,
'phpdoc_summary' => false,
'psr4' => false,
'semicolon_after_instruction' => true,
'simplified_null_return' => true,
])
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__ . '/src')
->in(__DIR__ . '/test')
)
;

View File

@ -1,18 +1,28 @@
language: php
php:
- 7.1
- 7.0
- 5.6
- 5.5
matrix:
include:
- php: 7.1
env: CODE_COVERAGE=1
- php: 7.0
- php: 5.6
- php: 5.5
env: CS_CHECK=1
- php: hhvm
dist: trusty
cache:
directories:
- $HOME/.composer
before_install:
- sudo apt-get update -qq
- sudo apt-get install -y -qq postfix
install:
- composer install
- if [ "$CODE_COVERAGE" != 1 ]; then phpenv config-rm xdebug.ini || true; fi
before_script:
- sudo service postfix stop
- smtp-sink -d "%d.%H.%M.%S" localhost:2500 1000 &
@ -28,8 +38,11 @@ before_script:
else
echo 'sendmail_path = "/usr/sbin/sendmail -t -i "' > $(php --ini|grep -m 1 "ini files in:"|cut -d ":" -f 2)/sendmail.ini
fi
script:
- ./vendor/bin/phpunit --configuration ./travis.phpunit.xml.dist --bootstrap ./vendor/autoload.php
- if [ "$CS_CHECK" = 1 ]; then ./vendor/bin/php-cs-fixer --diff --dry-run --verbose fix; fi
after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover ../build/logs/clover.xml
- if [ "$CODE_COVERAGE" = 1 ]; then wget https://scrutinizer-ci.com/ocular.phar; fi
- if [ "$CODE_COVERAGE" = 1 ]; then php ocular.phar code-coverage:upload --format=php-clover ../build/logs/clover.xml; fi

View File

@ -24,6 +24,7 @@
"ext-ctype": "*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.2",
"phpdocumentor/phpdocumentor": "2.*",
"phpunit/phpunit": "4.*",
"zendframework/zend-serializer": "2.7.*",

3727
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1106,7 +1106,7 @@ class PHPMailer
*
* @param string $address
* @param string $name
* @param bool $auto Whether to also set the Sender address, defaults to true
* @param bool $auto Whether to also set the Sender address, defaults to true
*
* @throws Exception
*

View File

@ -133,9 +133,9 @@ class POP3
/**
* Simple static wrapper for all-in-one POP before SMTP.
*
* @param string $host The hostname to connect to
* @param int|bool $port The port number to connect to
* @param int|bool $timeout The timeout value
* @param string $host The hostname to connect to
* @param int|bool $port The port number to connect to
* @param int|bool $timeout The timeout value
* @param string $username
* @param string $password
* @param int $debug_level
@ -160,9 +160,9 @@ class POP3
* A connect, login, disconnect sequence
* appropriate for POP-before SMTP authorisation.
*
* @param string $host The hostname to connect to
* @param int|bool $port The port number to connect to
* @param int|bool $timeout The timeout value
* @param string $host The hostname to connect to
* @param int|bool $port The port number to connect to
* @param int|bool $timeout The timeout value
* @param string $username
* @param string $password
* @param int $debug_level