Skip to content

Commit 0ea9643

Browse files
authored
Cleanup (#548)
1 parent 60465a0 commit 0ea9643

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Fixer/NoDuplicatedArrayKeyFixer.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,11 @@ private function fixArray(Tokens $tokens, int $index): void
102102

103103
private function getKeyContentIfPossible(Tokens $tokens, ArrayElementAnalysis $arrayElementAnalysis): ?string
104104
{
105-
if ($arrayElementAnalysis->getKeyStartIndex() === null || $arrayElementAnalysis->getKeyEndIndex() === null) {
105+
if ($arrayElementAnalysis->getKeyStartIndex() === null) {
106106
return null;
107107
}
108108

109+
/** @var int $keyEndIndex */
109110
$keyEndIndex = $arrayElementAnalysis->getKeyEndIndex();
110111

111112
$content = '';
@@ -116,9 +117,11 @@ private function getKeyContentIfPossible(Tokens $tokens, ArrayElementAnalysis $a
116117
if ($token->isWhitespace() || $token->isComment()) {
117118
continue;
118119
}
120+
119121
if ($token->equalsAny([[\T_VARIABLE], '('])) {
120122
return null;
121123
}
124+
122125
$content .= $token->getContent();
123126
}
124127

tests/Fixer/StringableInterfaceFixerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function __toString() { return "Foo"; }
9696
',
9797
];
9898

99-
yield 'aaa' => [
99+
yield [
100100
'<?php namespace FooNamespace;
101101
class Foo implements Bar\Stringable, \Stringable
102102
{

0 commit comments

Comments
 (0)