Skip to content

Commit 50a3a58

Browse files
committed
Merge branch '2.15' into 2.16
2 parents 9ac66c1 + befd688 commit 50a3a58

15 files changed

+82
-9
lines changed

src/Fixer/ClassNotation/ClassAttributesSeparationFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ private function fixSpaceBelowClassMethod(Tokens $tokens, $classEndIndex, $eleme
229229
*/
230230
private function fixSpaceAboveClassElement(Tokens $tokens, $classStartIndex, $elementIndex)
231231
{
232-
static $methodAttr = [T_PRIVATE, T_PROTECTED, T_PUBLIC, T_ABSTRACT, T_FINAL, T_STATIC, T_STRING, T_NS_SEPARATOR, T_VAR, CT::T_NULLABLE_TYPE];
232+
static $methodAttr = [T_PRIVATE, T_PROTECTED, T_PUBLIC, T_ABSTRACT, T_FINAL, T_STATIC, T_STRING, T_NS_SEPARATOR, T_VAR, CT::T_NULLABLE_TYPE, CT::T_ARRAY_TYPEHINT];
233233

234234
$nonWhiteAbove = null;
235235

src/Fixer/ClassNotation/SingleClassElementPerStatementFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ private function expandElement(Tokens $tokens, $type, $startIndex, $endIndex)
209209
private function getModifiersSequences(Tokens $tokens, $type, $startIndex, $endIndex)
210210
{
211211
if ('property' === $type) {
212-
$tokenKinds = [T_PUBLIC, T_PROTECTED, T_PRIVATE, T_STATIC, T_VAR, T_STRING, T_NS_SEPARATOR, CT::T_NULLABLE_TYPE];
212+
$tokenKinds = [T_PUBLIC, T_PROTECTED, T_PRIVATE, T_STATIC, T_VAR, T_STRING, T_NS_SEPARATOR, CT::T_NULLABLE_TYPE, CT::T_ARRAY_TYPEHINT];
213213
} else {
214214
$tokenKinds = [T_PUBLIC, T_PROTECTED, T_PRIVATE, T_CONST];
215215
}

src/Fixer/Phpdoc/PhpdocVarAnnotationCorrectOrderFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens)
5252
}
5353

5454
$newContent = Preg::replace(
55-
'/(@(?:type|var)\s*)(\$\S+)(\s+)([^\$](?:[^<\s]|<[^>]*>)*)(\s|\*)/i',
55+
'/(@(?:type|var)\s*)(\$\S+)(\h+)([^\$](?:[^<\s]|<[^>]*>)*)(\s|\*)/i',
5656
'$1$4$3$2$5',
5757
$token->getContent()
5858
);

src/Fixer/StringNotation/ExplicitStringVariableFixer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens)
9292
$nextIndex = $index + 1;
9393
$squareBracketCount = 0;
9494
while (!$this->isStringPartToken($tokens[$nextIndex])) {
95-
if ($tokens[$nextIndex]->isGivenKind(T_VARIABLE) && 1 !== $squareBracketCount) {
95+
if ($tokens[$nextIndex]->isGivenKind(T_CURLY_OPEN)) {
96+
$nextIndex = $tokens->getNextTokenOfKind($nextIndex, [[CT::T_CURLY_CLOSE]]);
97+
} elseif ($tokens[$nextIndex]->isGivenKind(T_VARIABLE) && 1 !== $squareBracketCount) {
9698
$distinctVariableIndex = $nextIndex;
9799
$variableTokens[$distinctVariableIndex] = [
98100
'tokens' => [$nextIndex => $tokens[$nextIndex]],

src/Tokenizer/TokensAnalyzer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ public function isConstantInvocation($index)
331331
$prevIndex = $this->tokens->getPrevMeaningfulToken($prevIndex);
332332
}
333333

334-
if ($this->tokens[$prevIndex]->isGivenKind([CT::T_CONST_IMPORT, T_EXTENDS, CT::T_FUNCTION_IMPORT, T_IMPLEMENTS, T_INSTANCEOF, T_INSTEADOF, T_NAMESPACE, T_NEW, CT::T_NULLABLE_TYPE, T_USE, CT::T_USE_TRAIT])) {
334+
if ($this->tokens[$prevIndex]->isGivenKind([CT::T_CONST_IMPORT, T_EXTENDS, CT::T_FUNCTION_IMPORT, T_IMPLEMENTS, T_INSTANCEOF, T_INSTEADOF, T_NAMESPACE, T_NEW, CT::T_NULLABLE_TYPE, CT::T_TYPE_COLON, T_USE, CT::T_USE_TRAIT])) {
335335
return false;
336336
}
337337

@@ -353,7 +353,7 @@ public function isConstantInvocation($index)
353353
$checkIndex = $this->tokens->getPrevMeaningfulToken($checkIndex);
354354
}
355355

356-
if ($this->tokens[$checkIndex]->isGivenKind([T_EXTENDS, CT::T_GROUP_IMPORT_BRACE_OPEN, T_IMPLEMENTS, CT::T_USE_TRAIT])) {
356+
if ($this->tokens[$checkIndex]->isGivenKind([T_EXTENDS, CT::T_GROUP_IMPORT_BRACE_OPEN, T_IMPLEMENTS, T_USE, CT::T_USE_TRAIT])) {
357357
return false;
358358
}
359359
}

tests/Fixer/ClassNotation/ClassAttributesSeparationFixerTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,5 +1115,19 @@ class Foo {
11151115
var ? Foo\Bar $qux;
11161116
}',
11171117
];
1118+
1119+
yield [
1120+
'<?php
1121+
class Foo {
1122+
private array $foo;
1123+
1124+
private array $bar;
1125+
}',
1126+
'<?php
1127+
class Foo {
1128+
private array $foo;
1129+
private array $bar;
1130+
}',
1131+
];
11181132
}
11191133
}

tests/Fixer/ClassNotation/NoNullPropertyInitializationFixerTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,5 +220,8 @@ public function provideFix74Cases()
220220
yield [
221221
'<?php class Foo { protected ? string $bar = null; }',
222222
];
223+
yield [
224+
'<?php class Foo { protected ? array $bar = null; }',
225+
];
223226
}
224227
}

tests/Fixer/ClassNotation/OrderedClassElementsFixerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -862,13 +862,13 @@ class Foo {
862862
'<?php
863863
class Foo {
864864
public string $bar;
865-
public iterable $baz;
865+
public array $baz;
866866
public ?int $foo;
867867
public ? Foo\Bar $qux;
868868
}',
869869
'<?php
870870
class Foo {
871-
public iterable $baz;
871+
public array $baz;
872872
public ? Foo\Bar $qux;
873873
public string $bar;
874874
public ?int $foo;

tests/Fixer/ClassNotation/ProtectedToPrivateFixerTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ public function provideFix74Cases()
162162
'<?php final class Foo { private ?string $foo; }',
163163
'<?php final class Foo { protected ?string $foo; }',
164164
];
165+
yield [
166+
'<?php final class Foo { private array $foo; }',
167+
'<?php final class Foo { protected array $foo; }',
168+
];
165169
}
166170

167171
private function getAttributesAndMethods($original)

tests/Fixer/ClassNotation/SingleClassElementPerStatementFixerTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,5 +874,14 @@ public function provideTestFix74Cases()
874874
var ? Foo\Bar $foo, $bar;
875875
}',
876876
];
877+
yield [
878+
'<?php class Foo {
879+
var array $foo;
880+
var array $bar;
881+
}',
882+
'<?php class Foo {
883+
var array $foo, $bar;
884+
}',
885+
];
877886
}
878887
}

0 commit comments

Comments
 (0)