-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
.php_cs.dist
102 lines (86 loc) · 2.84 KB
/
.php_cs.dist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
declare(strict_types=1);
namespace Tarantool\Queue;
use PhpCsFixer\Config;
use PhpCsFixer\Fixer\ConstantNotation\NativeConstantInvocationFixer;
use PhpCsFixer\Fixer\FixerInterface;
use PhpCsFixer\Fixer\FunctionNotation\NativeFunctionInvocationFixer;
use PhpCsFixer\Tokenizer\Tokens;
final class FilterableFixer implements FixerInterface
{
private $fixer;
private $pathRegex;
public function __construct(FixerInterface $fixer, string $pathRegex)
{
$this->fixer = $fixer;
$this->pathRegex = $pathRegex;
}
public function isCandidate(Tokens $tokens) : bool
{
return $this->fixer->isCandidate($tokens);
}
public function isRisky() : bool
{
return $this->fixer->isRisky();
}
public function fix(\SplFileInfo $file, Tokens $tokens) : void
{
$this->fixer->fix($file, $tokens);
}
public function getName() : string
{
return (new \ReflectionClass($this))->getShortName().'/'.$this->fixer->getName();
}
public function getPriority() : int
{
return $this->fixer->getPriority();
}
public function supports(\SplFileInfo $file) : bool
{
if (1 !== preg_match($this->pathRegex, $file->getRealPath())) {
return false;
}
return $this->fixer->supports($file);
}
};
$header = <<<EOF
This file is part of the tarantool/queue package.
(c) Eugene Leonovich <gen.work@gmail.com>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
EOF;
return Config::create()
->setUsingCache(false)
->setRiskyAllowed(true)
->registerCustomFixers([
new FilterableFixer(new NativeConstantInvocationFixer(), '/\bsrc\b/'),
new FilterableFixer(new NativeFunctionInvocationFixer(), '/\bsrc\b/'),
])
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => ['operators' => ['=' => null, '=>' => null]],
'declare_strict_types' => true,
'native_constant_invocation' => false,
'native_function_invocation' => false,
'FilterableFixer/native_constant_invocation' => true,
'FilterableFixer/native_function_invocation' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_imports' => [
'sort_algorithm' => 'alpha',
'imports_order' => ['class', 'function', 'const'],
],
'phpdoc_order' => true,
'phpdoc_align' => false,
'return_type_declaration' => ['space_before' => 'one'],
'strict_comparison' => true,
'header_comment' => [
'comment_type' => 'PHPDoc',
'header' => $header,
'location' => 'after_open',
'separate' => 'both',
],
])
;