Skip to content

Commit 760b4c5

Browse files
committed
Update CS
1 parent e5cea1e commit 760b4c5

20 files changed

+62
-72
lines changed

build-cs/composer.lock

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpcs.xml

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0"?>
22
<ruleset name="Simple Downgrader Coding Standard">
3-
<config name="php_version" value="70200"/>
3+
<config name="php_version" value="70400"/>
44
<arg name="colors"/>
55
<arg name="extensions" value="php"/>
66
<arg name="encoding" value="utf-8"/>
@@ -115,5 +115,21 @@
115115
</rule>
116116
<rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
117117
<rule ref="Consistence.NamingConventions.ValidVariableName.NotCamelCaps"/>
118+
<rule ref="SlevomatCodingStandard.Functions.DisallowTrailingCommaInCall">
119+
<properties>
120+
<property name="onlySingleLine" value="true"/>
121+
</properties>
122+
</rule>
123+
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall">
124+
<properties>
125+
<property name="enable" value="true"/>
126+
</properties>
127+
</rule>
128+
<rule ref="SlevomatCodingStandard.Functions.RequireArrowFunction">
129+
<properties>
130+
<property name="enable" value="true"/>
131+
</properties>
132+
</rule>
133+
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration"/>
118134
<exclude-pattern>tests/*/data</exclude-pattern>
119135
</ruleset>

src/Console/DowngradeCommand.php

+6-11
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,15 @@ class DowngradeCommand extends Command
5555
private const STARTS_WITH_ASTERISK_REGEX = '#^\\*(.*?)[^*]$#';
5656
private const ENDS_WITH_ASTERISK_REGEX = '#^[^*](.*?)\\*$#';
5757

58-
/** @var Parser */
59-
private $parser;
58+
private Parser $parser;
6059

61-
/** @var PhpPrinter */
62-
private $printer;
60+
private PhpPrinter $printer;
6361

64-
/** @var Lexer */
65-
private $phpDocLexer;
62+
private Lexer $phpDocLexer;
6663

67-
/** @var PhpDocParser */
68-
private $phpDocParser;
64+
private PhpDocParser $phpDocParser;
6965

70-
/** @var NodeTraverser */
71-
private $cloningTraverser;
66+
private NodeTraverser $cloningTraverser;
7267

7368
public function __construct(Parser $parser, PhpPrinter $printer, Lexer $phpDocLexer, PhpDocParser $phpDocParser)
7469
{
@@ -190,7 +185,7 @@ private function createDowngradeVisitors(int $phpVersionId): array
190185
$visitors[] = new DowngradePropertyPromotionVisitor(
191186
$this->phpDocLexer,
192187
$this->phpDocParser,
193-
$phpDocEditor
188+
$phpDocEditor,
194189
);
195190
$visitors[] = new DowngradeMixedTypeVisitor($typeDowngraderHelper);
196191
$visitors[] = new DowngradeStaticReturnTypeVisitor($typeDowngraderHelper);

src/Php/PhpPrinter.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ class PhpPrinter extends Standard
1414

1515
public const FUNC_ARGS_TRAILING_COMMA_ATTRIBUTE = 'trailing_comma';
1616

17-
/** @var string */
18-
private $indentCharacter = ' ';
17+
private string $indentCharacter = ' ';
1918

20-
/** @var int */
21-
private $indentSize = 4;
19+
private int $indentSize = 4;
2220

2321
protected function resetState(): void
2422
{

src/Php/PhpPrinterIndentationDetectorVisitor.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,11 @@
1717
class PhpPrinterIndentationDetectorVisitor extends NodeVisitorAbstract
1818
{
1919

20-
/** @var string */
21-
public $indentCharacter = ' ';
20+
public string $indentCharacter = ' ';
2221

23-
/** @var int */
24-
public $indentSize = 4;
22+
public int $indentSize = 4;
2523

26-
/** @var TokenStream */
27-
private $origTokens;
24+
private TokenStream $origTokens;
2825

2926
public function __construct(TokenStream $origTokens)
3027
{

src/PhpDoc/PhpDocEditor.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,11 @@
1616
class PhpDocEditor
1717
{
1818

19-
/** @var Lexer */
20-
private $lexer;
19+
private Lexer $lexer;
2120

22-
/** @var PhpDocParser */
23-
private $phpDocParser;
21+
private PhpDocParser $phpDocParser;
2422

25-
/** @var Printer */
26-
private $printer;
23+
private Printer $printer;
2724

2825
public function __construct(Printer $printer, Lexer $lexer, PhpDocParser $phpDocParser)
2926
{

src/Visitor/DowngradeMixedTypeVisitor.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
class DowngradeMixedTypeVisitor extends NodeVisitorAbstract
1111
{
1212

13-
/** @var TypeDowngraderHelper */
14-
private $typeDowngraderHelper;
13+
private TypeDowngraderHelper $typeDowngraderHelper;
1514

1615
public function __construct(TypeDowngraderHelper $typeDowngraderHelper)
1716
{

src/Visitor/DowngradePropertyPromotionVisitor.php

+6-9
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,11 @@
2020
class DowngradePropertyPromotionVisitor extends NodeVisitorAbstract
2121
{
2222

23-
/** @var Lexer */
24-
private $lexer;
23+
private Lexer $lexer;
2524

26-
/** @var PhpDocParser */
27-
private $phpDocParser;
25+
private PhpDocParser $phpDocParser;
2826

29-
/** @var PhpDocEditor */
30-
private $phpDocEditor;
27+
private PhpDocEditor $phpDocEditor;
3128

3229
public function __construct(
3330
Lexer $lexer,
@@ -87,7 +84,7 @@ public function enterNode(Node $node)
8784
'comments' => $p->getComments(),
8885
],
8986
$p->type,
90-
$p->attrGroups
87+
$p->attrGroups,
9188
);
9289
if (array_key_exists($p->var->name, $phpDocParams)) {
9390
$this->phpDocEditor->edit($propertyNode, static function (\PHPStan\PhpDocParser\Ast\Node $phpDocNode) use ($phpDocParams, $p) {
@@ -102,8 +99,8 @@ public function enterNode(Node $node)
10299
array_unshift($methodStmts, new Node\Stmt\Expression(
103100
new Node\Expr\Assign(
104101
new Node\Expr\PropertyFetch(new Node\Expr\Variable('this'), $p->var->name),
105-
$p->var
106-
)
102+
$p->var,
103+
),
107104
));
108105
$p->flags = 0;
109106
$p->setAttribute('comments', []);

src/Visitor/DowngradePureIntersectionTypeVisitor.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
class DowngradePureIntersectionTypeVisitor extends NodeVisitorAbstract
1313
{
1414

15-
/** @var TypeDowngraderHelper */
16-
private $typeDowngraderHelper;
15+
private TypeDowngraderHelper $typeDowngraderHelper;
1716

1817
public function __construct(TypeDowngraderHelper $typeDowngraderHelper)
1918
{

src/Visitor/DowngradeReadonlyPromotedPropertyVisitor.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
class DowngradeReadonlyPromotedPropertyVisitor extends NodeVisitorAbstract
1414
{
1515

16-
/** @var PhpDocEditor */
17-
private $phpDocEditor;
16+
private PhpDocEditor $phpDocEditor;
1817

1918
public function __construct(PhpDocEditor $phpDocEditor)
2019
{

src/Visitor/DowngradeReadonlyPropertyVisitor.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
class DowngradeReadonlyPropertyVisitor extends NodeVisitorAbstract
1313
{
1414

15-
/** @var PhpDocEditor */
16-
private $phpDocEditor;
15+
private PhpDocEditor $phpDocEditor;
1716

1817
public function __construct(PhpDocEditor $phpDocEditor)
1918
{

src/Visitor/DowngradeStaticReturnTypeVisitor.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
class DowngradeStaticReturnTypeVisitor extends NodeVisitorAbstract
1111
{
1212

13-
/** @var TypeDowngraderHelper */
14-
private $typeDowngraderHelper;
13+
private TypeDowngraderHelper $typeDowngraderHelper;
1514

1615
public function __construct(TypeDowngraderHelper $typeDowngraderHelper)
1716
{

src/Visitor/DowngradeTrailingCommasInClosureUsesVisitor.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
class DowngradeTrailingCommasInClosureUsesVisitor extends NodeVisitorAbstract implements TokensAwareVisitor
1313
{
1414

15-
/** @var FollowedByCommaAnalyser */
16-
private $followedByCommaAnalyzer;
15+
private FollowedByCommaAnalyser $followedByCommaAnalyzer;
1716

1817
/** @var Token[] */
19-
private $tokens;
18+
private array $tokens;
2019

2120
public function __construct(FollowedByCommaAnalyser $followedByCommaAnalyzer)
2221
{

src/Visitor/DowngradeTrailingCommasInFunctionCallsVisitor.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
class DowngradeTrailingCommasInFunctionCallsVisitor extends NodeVisitorAbstract implements TokensAwareVisitor
1313
{
1414

15-
/** @var FollowedByCommaAnalyser */
16-
private $followedByCommaAnalyzer;
15+
private FollowedByCommaAnalyser $followedByCommaAnalyzer;
1716

1817
/** @var Token[] */
19-
private $tokens;
18+
private array $tokens;
2019

2120
public function __construct(FollowedByCommaAnalyser $followedByCommaAnalyser)
2221
{

src/Visitor/DowngradeTrailingCommasInParametersVisitor.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
class DowngradeTrailingCommasInParametersVisitor extends NodeVisitorAbstract implements TokensAwareVisitor
1313
{
1414

15-
/** @var FollowedByCommaAnalyser */
16-
private $followedByCommaAnalyzer;
15+
private FollowedByCommaAnalyser $followedByCommaAnalyzer;
1716

1817
/** @var Token[] */
19-
private $tokens;
18+
private array $tokens;
2019

2120
public function __construct(FollowedByCommaAnalyser $followedByCommaAnalyser)
2221
{

src/Visitor/DowngradeUnionTypeVisitor.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
class DowngradeUnionTypeVisitor extends NodeVisitorAbstract
1414
{
1515

16-
/** @var TypeDowngraderHelper */
17-
private $typeDowngraderHelper;
16+
private TypeDowngraderHelper $typeDowngraderHelper;
1817

1918
public function __construct(TypeDowngraderHelper $typeDowngraderHelper)
2019
{

src/Visitor/ImmediateScopeVariablesVisitor.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ class ImmediateScopeVariablesVisitor extends NodeVisitorAbstract
1515
{
1616

1717
/** @var list<Variable> */
18-
private $variables = [];
18+
private array $variables = [];
1919

2020
/** @var list<array<string, true>> */
21-
private $parametersStack = [];
21+
private array $parametersStack = [];
2222

2323
/**
2424
* @return list<Variable>

src/Visitor/TypeDowngraderHelper.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
class TypeDowngraderHelper
2020
{
2121

22-
/** @var PhpDocEditor */
23-
private $phpDocEditor;
22+
private PhpDocEditor $phpDocEditor;
2423

2524
public function __construct(PhpDocEditor $phpDocEditor)
2625
{
@@ -51,7 +50,7 @@ public function downgradeType(Node $node, callable $callable): ?Node
5150
$phpDocNode->children[] = new PhpDocTagNode('@var', new VarTagValueNode(
5251
$resultType,
5352
'',
54-
''
53+
'',
5554
));
5655

5756
return $phpDocNode;
@@ -122,7 +121,7 @@ public function downgradeType(Node $node, callable $callable): ?Node
122121
}
123122
$phpDocNode->children[] = new PhpDocTagNode('@return', new ReturnTagValueNode(
124123
$resultType,
125-
''
124+
'',
126125
));
127126

128127
return $phpDocNode;

tests/Visitor/AbstractVisitorTestCase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function createPhpDocEditor(): PhpDocEditor
7474
return new PhpDocEditor(
7575
new Printer(),
7676
new Lexer(new ParserConfig([])),
77-
$this->createPhpDocParser()
77+
$this->createPhpDocParser(),
7878
);
7979
}
8080

tests/Visitor/DowngradePropertyPromotionVisitorTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ protected function getVisitor(): NodeVisitor
1414
return new DowngradePropertyPromotionVisitor(
1515
new Lexer(new ParserConfig([])),
1616
$this->createPhpDocParser(),
17-
$this->createPhpDocEditor()
17+
$this->createPhpDocEditor(),
1818
);
1919
}
2020

0 commit comments

Comments
 (0)