Skip to content

Commit 0790602

Browse files
committed
minor #3889 DX: Cleanup - remove unused variables (kubawerlos, SpacePossum)
This PR was merged into the 2.12 branch. Discussion ---------- DX: Cleanup - remove unused variables Commits ------- 1917dcd PhpUnitExpectationFixerTest - add case with multiple candidates 8fa9513 Cleanup - remove unused variables
2 parents 7fc64e7 + 1917dcd commit 0790602

File tree

6 files changed

+28
-21
lines changed

6 files changed

+28
-21
lines changed

src/Fixer/ClassNotation/ClassDefinitionFixer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,9 @@ private function fixClassyDefinitionOpenSpacing(Tokens $tokens, array $classDefI
255255
{
256256
if ($classDefInfo['anonymousClass']) {
257257
if (false !== $classDefInfo['implements']) {
258-
$spacing = $classDefInfo['implements']['multiLine'] ? $spacing = $this->whitespacesConfig->getLineEnding() : ' ';
258+
$spacing = $classDefInfo['implements']['multiLine'] ? $this->whitespacesConfig->getLineEnding() : ' ';
259259
} elseif (false !== $classDefInfo['extends']) {
260-
$spacing = $classDefInfo['extends']['multiLine'] ? $spacing = $this->whitespacesConfig->getLineEnding() : ' ';
260+
$spacing = $classDefInfo['extends']['multiLine'] ? $this->whitespacesConfig->getLineEnding() : ' ';
261261
} else {
262262
$spacing = ' ';
263263
}

src/Fixer/DoctrineAnnotation/DoctrineAnnotationArrayAssignmentFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ protected function createConfigurationDefinition()
7676
protected function fixAnnotations(Tokens $tokens)
7777
{
7878
$scopes = [];
79-
foreach ($tokens as $index => $token) {
79+
foreach ($tokens as $token) {
8080
if ($token->isType(DocLexer::T_OPEN_PARENTHESIS)) {
8181
$scopes[] = 'annotation';
8282

src/Fixer/PhpUnit/PhpUnitExpectationFixer.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,6 @@ private function fixExpectation($tokens, $startIndex, $endIndex)
235235
}
236236

237237
$tokens->overrideRange($argBefore, $argBefore, $tokensOverrideArgBefore);
238-
239-
$limit = $tokens->count();
240238
}
241239

242240
$tokens[$index] = new Token([T_STRING, 'expectException']);

src/Tokenizer/Resolver/TypeShortNameResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function resolve(Tokens $tokens, $typeName)
4747
// For now only support one namespace per file:
4848
$namespaces = $this->getNamespacesFromTokens($tokens);
4949
if (1 === count($namespaces)) {
50-
foreach ($namespaces as $shortName => $fullName) {
50+
foreach ($namespaces as $fullName) {
5151
$matches = [];
5252
$regex = '/^\\\\?'.preg_quote($fullName, '/').'\\\\(?P<className>.+)$/';
5353
if (Preg::match($regex, $typeName, $matches)) {

src/Tokenizer/Tokens.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ public function setCode($code)
10431043
$transformers->transform($this);
10441044

10451045
$this->foundTokenKinds = [];
1046-
foreach ($this as $index => $token) {
1046+
foreach ($this as $token) {
10471047
$this->registerFoundToken($token);
10481048
}
10491049

tests/Fixer/PhpUnit/PhpUnitExpectationFixerTest.php

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -286,31 +286,40 @@ public function testMessyWhitespaces($expected, $input = null)
286286

287287
public function provideMessyWhitespacesCases()
288288
{
289-
return [
290-
[
291-
'<?php
292-
final class MyTest extends \PHPUnit_Framework_TestCase
293-
{
294-
function testFnc()
289+
$expectedTemplate =
290+
'
291+
function testFnc%d()
295292
{
296293
aaa();
297294
$this->expectException(\'RuntimeException\');
298295
$this->expectExceptionMessage(\'msg\'/*B*/);
299296
$this->expectExceptionCode(/*C*/123);
300297
zzz();
301298
}
302-
}',
303-
'<?php
304-
final class MyTest extends \PHPUnit_Framework_TestCase
305-
{
306-
function testFnc()
299+
';
300+
$inputTemplate =
301+
'
302+
function testFnc%d()
307303
{
308304
aaa();
309305
$this->setExpectedException(\'RuntimeException\', \'msg\'/*B*/, /*C*/123);
310306
zzz();
311307
}
312-
}',
313-
],
314-
];
308+
'
309+
;
310+
$input = $expected = '<?php
311+
final class MyTest extends \PHPUnit_Framework_TestCase
312+
{
313+
';
314+
315+
for ($i = 0; $i < 8; ++$i) {
316+
$expected .= sprintf($expectedTemplate, $i);
317+
$input .= sprintf($inputTemplate, $i);
318+
}
319+
320+
$expected .= "\n}";
321+
$input .= "\n}";
322+
323+
return [[$expected, $input]];
315324
}
316325
}

0 commit comments

Comments
 (0)