raspisms/tests/php-cs-fixer/php_cs.config

61 lines
1.9 KiB
Plaintext

<?php
$header = <<<'EOF'
This file is part of RaspiSMS.
(c) Pierre-Lin Bonnemaison <plebwebsas@gmail.com>
This source file is subject to the GPL-3.0 license that is bundled
with this source code in the file LICENSE.
EOF;
$finder = PhpCsFixer\Finder::create()
->exclude('tests/Fixtures')
->in(__DIR__)
->append([__DIR__.'/php-cs-fixer'])
->in(__DIR__ . '/../../controllers/')
->in(__DIR__ . '/../../models/')
->in(__DIR__ . '/../../daemons/')
->in(__DIR__ . '/../../adapters/')
;
$config = PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@PHP56Migration' => true,
'@PHPUnit60Migration:risky' => true,
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' => false,
'header_comment' => ['header' => $header],
'list_syntax' => ['syntax' => 'long'],
'array_syntax' => ['syntax' => 'short'],
'mb_str_functions' => true,
'method_separation' => true,
'concat_space' => ['spacing' => 'one'],
'braces' => [
'position_after_anonymous_constructs' => 'next',
'position_after_control_structures' => 'next',
'position_after_functions_and_oop_constructs' => 'next'
],
])
->setFinder($finder)
;
// special handling of fabbot.io service if it's using too old PHP CS Fixer version
if (false !== getenv('FABBOT_IO')) {
try {
PhpCsFixer\FixerFactory::create()
->registerBuiltInFixers()
->registerCustomFixers($config->getCustomFixers())
->useRuleSet(new PhpCsFixer\RuleSet($config->getRules()));
} catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) {
$config->setRules([]);
} catch (UnexpectedValueException $e) {
$config->setRules([]);
} catch (InvalidArgumentException $e) {
$config->setRules([]);
}
}
return $config;