Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DX: Cleanup - remove unused variables #3889

Merged
merged 2 commits into from Jul 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Fixer/ClassNotation/ClassDefinitionFixer.php
Expand Up @@ -255,9 +255,9 @@ private function fixClassyDefinitionOpenSpacing(Tokens $tokens, array $classDefI
{
if ($classDefInfo['anonymousClass']) {
if (false !== $classDefInfo['implements']) {
$spacing = $classDefInfo['implements']['multiLine'] ? $spacing = $this->whitespacesConfig->getLineEnding() : ' ';
$spacing = $classDefInfo['implements']['multiLine'] ? $this->whitespacesConfig->getLineEnding() : ' ';
} elseif (false !== $classDefInfo['extends']) {
$spacing = $classDefInfo['extends']['multiLine'] ? $spacing = $this->whitespacesConfig->getLineEnding() : ' ';
$spacing = $classDefInfo['extends']['multiLine'] ? $this->whitespacesConfig->getLineEnding() : ' ';
} else {
$spacing = ' ';
}
Expand Down
Expand Up @@ -76,7 +76,7 @@ protected function createConfigurationDefinition()
protected function fixAnnotations(Tokens $tokens)
{
$scopes = [];
foreach ($tokens as $index => $token) {
foreach ($tokens as $token) {
if ($token->isType(DocLexer::T_OPEN_PARENTHESIS)) {
$scopes[] = 'annotation';

Expand Down
2 changes: 0 additions & 2 deletions src/Fixer/PhpUnit/PhpUnitExpectationFixer.php
Expand Up @@ -235,8 +235,6 @@ private function fixExpectation($tokens, $startIndex, $endIndex)
}

$tokens->overrideRange($argBefore, $argBefore, $tokensOverrideArgBefore);

$limit = $tokens->count();
}

$tokens[$index] = new Token([T_STRING, 'expectException']);
Expand Down
2 changes: 1 addition & 1 deletion src/Tokenizer/Resolver/TypeShortNameResolver.php
Expand Up @@ -47,7 +47,7 @@ public function resolve(Tokens $tokens, $typeName)
// For now only support one namespace per file:
$namespaces = $this->getNamespacesFromTokens($tokens);
if (1 === count($namespaces)) {
foreach ($namespaces as $shortName => $fullName) {
foreach ($namespaces as $fullName) {
$matches = [];
$regex = '/^\\\\?'.preg_quote($fullName, '/').'\\\\(?P<className>.+)$/';
if (Preg::match($regex, $typeName, $matches)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Tokenizer/Tokens.php
Expand Up @@ -1043,7 +1043,7 @@ public function setCode($code)
$transformers->transform($this);

$this->foundTokenKinds = [];
foreach ($this as $index => $token) {
foreach ($this as $token) {
$this->registerFoundToken($token);
}

Expand Down
37 changes: 23 additions & 14 deletions tests/Fixer/PhpUnit/PhpUnitExpectationFixerTest.php
Expand Up @@ -286,31 +286,40 @@ public function testMessyWhitespaces($expected, $input = null)

public function provideMessyWhitespacesCases()
{
return [
[
'<?php
final class MyTest extends \PHPUnit_Framework_TestCase
{
function testFnc()
$expectedTemplate =
'
function testFnc%d()
{
aaa();
$this->expectException(\'RuntimeException\');
$this->expectExceptionMessage(\'msg\'/*B*/);
$this->expectExceptionCode(/*C*/123);
zzz();
}
}',
'<?php
final class MyTest extends \PHPUnit_Framework_TestCase
{
function testFnc()
';
$inputTemplate =
'
function testFnc%d()
{
aaa();
$this->setExpectedException(\'RuntimeException\', \'msg\'/*B*/, /*C*/123);
zzz();
}
}',
],
];
'
;
$input = $expected = '<?php
final class MyTest extends \PHPUnit_Framework_TestCase
{
';

for ($i = 0; $i < 8; ++$i) {
$expected .= sprintf($expectedTemplate, $i);
$input .= sprintf($inputTemplate, $i);
}

$expected .= "\n}";
$input .= "\n}";

return [[$expected, $input]];
}
}