Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Remove unused local variables #34105

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

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public function testSetDataToUninitializedEntityWithNonRequiredQueryBuilder()
public function testConfigureQueryBuilderWithNonQueryBuilderAndNonClosure()
{
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [
$this->factory->createNamed('name', static::TESTED_TYPE, null, [
'em' => 'default',
'class' => self::SINGLE_IDENT_CLASS,
'query_builder' => new \stdClass(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public function compile(Compiler $compiler)

preg_match('/_([^_]+)$/', $this->getAttribute('name'), $matches);

$label = null;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$label is assigned line 42 and only used in this code path.

$arguments = iterator_to_array($this->getNode('arguments'));
$blockNameSuffix = $matches[1];

Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/Twig/Tests/AppVariableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ public function testGetFlashes()
$flashMessages = $this->setFlashMessages();
$this->assertEquals($flashMessages, $this->appVariable->getFlashes([]));

$flashMessages = $this->setFlashMessages();
$this->setFlashMessages();
$this->assertEquals([], $this->appVariable->getFlashes('this-does-not-exist'));

$flashMessages = $this->setFlashMessages();
$this->setFlashMessages();
$this->assertEquals(
['this-does-not-exist' => []],
$this->appVariable->getFlashes(['this-does-not-exist'])
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function testLintFileNotReadable()
$filename = $this->createFile('');
unlink($filename);

$ret = $tester->execute(['filename' => [$filename]], ['decorated' => false]);
$tester->execute(['filename' => [$filename]], ['decorated' => false]);
}

public function testLintFileCompileTimeException()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function testTiming($template, $events)
$twig->addExtension(new StopwatchExtension($this->getStopwatch($events)));

try {
$nodes = $twig->render('template');
$twig->render('template');
} catch (RuntimeError $e) {
throw $e->getPrevious();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,21 @@ public function testTransUnknownKeyword()
{
$this->expectException('Twig\Error\SyntaxError');
$this->expectExceptionMessage('Unexpected token. Twig was looking for the "with", "from", or "into" keyword in "index" at line 3.');
$output = $this->getTemplate("{% trans \n\nfoo %}{% endtrans %}")->render();
$this->getTemplate("{% trans \n\nfoo %}{% endtrans %}")->render();
}

public function testTransComplexBody()
{
$this->expectException('Twig\Error\SyntaxError');
$this->expectExceptionMessage('A message inside a trans tag must be a simple text in "index" at line 2.');
$output = $this->getTemplate("{% trans %}\n{{ 1 + 2 }}{% endtrans %}")->render();
$this->getTemplate("{% trans %}\n{{ 1 + 2 }}{% endtrans %}")->render();
}

public function testTransChoiceComplexBody()
{
$this->expectException('Twig\Error\SyntaxError');
$this->expectExceptionMessage('A message inside a transchoice tag must be a simple text in "index" at line 2.');
$output = $this->getTemplate("{% transchoice count %}\n{{ 1 + 2 }}{% endtranschoice %}")->render();
$this->getTemplate("{% transchoice count %}\n{{ 1 + 2 }}{% endtranschoice %}")->render();
}

public function getTransTests()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,6 @@ private function renderEventListenerTable(EventDispatcherInterface $eventDispatc
$tableHeaders = ['Order', 'Callable', 'Priority'];
$tableRows = [];

$order = 1;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$order is directly reassigned by the foreach.

foreach ($eventListeners as $order => $listener) {
$tableRows[] = [sprintf('#%d', $order + 1), $this->formatCallable($listener), $eventDispatcher->getListenerPriority($event, $listener)];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1043,8 +1043,6 @@ private function registerAssetsConfiguration(array $config, ContainerBuilder $co
$container->getDefinition('assets.url_package')->setPrivate(true);
$container->getDefinition('assets.static_version_strategy')->setPrivate(true);

$defaultVersion = null;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$defaultVersion is always assigned in the if else block.


if ($config['version_strategy']) {
$defaultVersion = new Reference($config['version_strategy']);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,7 @@ public function testFileWhichDoesNotExist()
$this->expectException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
$controller = $this->createController();

/* @var BinaryFileResponse $response */
$response = $controller->file('some-file.txt', 'test.php');
$controller->file('some-file.txt', 'test.php');
}

public function testIsGranted()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function testAbstractConstraintValidator()
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('The service "my_abstract_constraint_validator" tagged "validator.constraint_validator" must not be abstract.');
$container = new ContainerBuilder();
$validatorFactory = $container->register('validator.validator_factory')
$container->register('validator.validator_factory')
->addArgument([]);

$container->register('my_abstract_constraint_validator')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public function testWorkflows()
*/
public function testDeprecatedWorkflowMissingType()
{
$container = $this->createContainerFromFile('workflows_without_type');
$this->createContainerFromFile('workflows_without_type');
}

public function testWorkflowCannotHaveBothTypeAndService()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class TestExtension extends Extension implements PrependExtensionInterface
public function load(array $configs, ContainerBuilder $container)
{
$configuration = $this->getConfiguration($configs, $container);
$config = $this->processConfiguration($configuration, $configs);
$this->processConfiguration($configuration, $configs);

$container->setAlias('test.annotation_reader', new Alias('annotation_reader', true));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function testFlash($config, $insulate)
}

// set flash
$crawler = $client->request('GET', '/session_setflash/Hello%20world.');
$client->request('GET', '/session_setflash/Hello%20world.');

// check flash displays on redirect
$this->assertStringContainsString('Hello world.', $client->followRedirect()->text());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public function testGetDefaultLocaleOmittingLocaleWithPsrContainer()
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('Missing third $defaultLocale argument.');
$container = $this->getMockBuilder(ContainerInterface::class)->getMock();
$translator = new Translator($container, new MessageFormatter());
new Translator($container, new MessageFormatter());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function testDefaultFailureHandler($serviceId, $defaultHandlerInjection)
$options['failure_handler'] = $serviceId;
}

list($container, $authProviderId, $listenerId, $entryPointId) = $this->callFactory('foo', $options, 'user_provider', 'entry_point');
list($container) = $this->callFactory('foo', $options, 'user_provider', 'entry_point');

$definition = $container->getDefinition('abstract_listener.foo');
$arguments = $definition->getArguments();
Expand Down Expand Up @@ -99,7 +99,7 @@ public function testDefaultSuccessHandler($serviceId, $defaultHandlerInjection)
$options['success_handler'] = $serviceId;
}

list($container, $authProviderId, $listenerId, $entryPointId) = $this->callFactory('foo', $options, 'user_provider', 'entry_point');
list($container) = $this->callFactory('foo', $options, 'user_provider', 'entry_point');

$definition = $container->getDefinition('abstract_listener.foo');
$arguments = $definition->getArguments();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function testCreateWithEntryPoint()
'authenticators' => ['authenticator123', 'authenticatorABC'],
'entry_point' => 'authenticatorABC',
];
list($container, $entryPointId) = $this->executeCreate($config, null);
list(, $entryPointId) = $this->executeCreate($config, null);
$this->assertEquals('authenticatorABC', $entryPointId);
}

Expand All @@ -172,7 +172,7 @@ private function executeCreate(array $config, $defaultEntryPointId)
$userProviderId = 'my_user_provider';

$factory = new GuardAuthenticationFactory();
list($providerId, $listenerId, $entryPointId) = $factory->create($container, $id, $config, $userProviderId, $defaultEntryPointId);
list(, , $entryPointId) = $factory->create($container, $id, $config, $userProviderId, $defaultEntryPointId);

return [$container, $entryPointId];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/BrowserKit/Tests/CookieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,6 @@ public function testConstructException()
{
$this->expectException('UnexpectedValueException');
$this->expectExceptionMessage('The cookie expiration time "string" is not valid.');
$cookie = new Cookie('foo', 'bar', 'string');
new Cookie('foo', 'bar', 'string');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function testTooLongNamespace()
{
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
$this->expectExceptionMessage('Namespace must be 26 chars max, 40 given ("----------------------------------------")');
$cache = $this->getMockBuilder(MaxIdLengthAdapter::class)
$this->getMockBuilder(MaxIdLengthAdapter::class)
->setConstructorArgs([str_repeat('-', 40)])
->getMock();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DelegatingLoaderTest extends TestCase
{
public function testConstructor()
{
$loader = new DelegatingLoader($resolver = new LoaderResolver());
new DelegatingLoader($resolver = new LoaderResolver());
$this->assertTrue(true, '__construct() takes a loader resolver as its first argument');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function testExistsKo()

$loadedClass = 123;

$res = new ClassExistenceResource('MissingFooClass', false);
new ClassExistenceResource('MissingFooClass', false);

$this->assertSame(123, $loadedClass);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function testResourceDoesNotExist()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessageRegExp('/The directory ".*" does not exist./');
$resource = new DirectoryResource('/____foo/foobar'.mt_rand(1, 999999));
new DirectoryResource('/____foo/foobar'.mt_rand(1, 999999));
}

public function testIsFresh()
Expand Down Expand Up @@ -165,7 +165,7 @@ public function testSerializeUnserialize()
{
$resource = new DirectoryResource($this->directory, '/\.(foo|xml)$/');

$unserialized = unserialize(serialize($resource));
unserialize(serialize($resource));

$this->assertSame(realpath($this->directory), $resource->getResource());
$this->assertSame('/\.(foo|xml)$/', $resource->getPattern());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function testResourceDoesNotExist()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessageRegExp('/The file ".*" does not exist./');
$resource = new FileResource('/____foo/foobar'.mt_rand(1, 999999));
new FileResource('/____foo/foobar'.mt_rand(1, 999999));
}

public function testIsFresh()
Expand All @@ -76,7 +76,7 @@ public function testIsFreshForDeletedResources()

public function testSerializeUnserialize()
{
$unserialized = unserialize(serialize($this->resource));
unserialize(serialize($this->resource));

$this->assertSame(realpath($this->file), $this->resource->getResource());
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Tests/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ public function testFindAlternativeExceptionMessageMultiple()

// Subnamespace + plural
try {
$a = $application->find('foo3:');
$application->find('foo3:');
$this->fail('->find() should throw an Symfony\Component\Console\Exception\CommandNotFoundException if a command is ambiguous because of a subnamespace, with alternatives');
} catch (\Exception $e) {
$this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function testCannotSetInvalidIndicatorCharacters()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('Must have at least 2 indicator value characters.');
$bar = new ProgressIndicator($this->getOutputStream(), null, 100, ['1']);
new ProgressIndicator($this->getOutputStream(), null, 100, ['1']);
}

public function testCannotStartAlreadyStartedIndicator()
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Debug/DebugClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ private function darwinRealpath($real)
}

if (isset($dirFiles[$file])) {
return $real .= $dirFiles[$file];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning an assignation is useless, $real is not passed by ref.

return $real.$dirFiles[$file];
}

$kFile = strtolower($file);
Expand All @@ -423,7 +423,7 @@ private function darwinRealpath($real)
self::$darwinCache[$kDir][1] = $dirFiles;
}

return $real .= $dirFiles[$kFile];
return $real.$dirFiles[$kFile];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ function () {},

// assertEquals() does not like NAN values.
$this->assertEquals($array[$i][0], 'float');
$this->assertNan($array[$i++][1]);
$this->assertNan($array[$i][1]);
}

public function testRecursionInArguments()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public function dump(array $options = [])
foreach ($ids as $id) {
$c .= ' '.$this->doExport($id)." => true,\n";
}
$files['removed-ids.php'] = $c .= "];\n";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The resulting $c is never reused so the assignation is useless.

$files['removed-ids.php'] = $c."];\n";
}

foreach ($this->generateServiceFiles() as $file => $c) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,28 @@ public function testProcess()
{
$container = new ContainerBuilder();

$a = $container
$container
->register('a')
->addArgument($ref1 = new Reference('b'))
;

$b = $container
$container
->register('b')
->addMethodCall('setA', [$ref2 = new Reference('a')])
;

$c = $container
$container
->register('c')
->addArgument($ref3 = new Reference('a'))
->addArgument($ref4 = new Reference('b'))
;

$d = $container
$container
->register('d')
->setProperty('foo', $ref5 = new Reference('b'))
;

$e = $container
$container
->register('e')
->setConfigurator([$ref6 = new Reference('b'), 'methodName'])
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testProcessRemovesAndInlinesRecursively()
->addArgument(new Reference('c'))
;

$b = $container
$container
->register('b', '\stdClass')
->addArgument(new Reference('c'))
->setPublic(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public function testBindings()
->setBindings(['a' => '1', 'b' => '2'])
;

$child = $container->setDefinition('child', new ChildDefinition('parent'))
$container->setDefinition('child', new ChildDefinition('parent'))
->setBindings(['b' => 'B', 'c' => 'C'])
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public function testAmbiguousChildDefinition()
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
$this->expectExceptionMessage('Service definition "App\Foo\Child" has a parent but no class, and its name looks like a FQCN. Either the class is missing or you want to inherit it from the parent service. To resolve this ambiguity, please rename this service to a non-FQCN (e.g. using dots), or create the missing class.');
$container = new ContainerBuilder();
$parent = $container->register('App\Foo', null);
$child = $container->setDefinition('App\Foo\Child', new ChildDefinition('App\Foo'));
$container->register('App\Foo', null);
$container->setDefinition('App\Foo\Child', new ChildDefinition('App\Foo'));

(new ResolveClassPass())->process($container);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ public function testNoClassFromGlobalNamespaceClassId()
$this->expectExceptionMessage('The definition for "DateTime" has no class attribute, and appears to reference a class or interface in the global namespace.');
$container = new ContainerBuilder();

$definition = $container->register(\DateTime::class);
$container->register(\DateTime::class);
$container->compile();
}

Expand Down Expand Up @@ -1295,7 +1295,7 @@ public function testNoClassFromNonClassId()
$this->expectExceptionMessage('The definition for "123_abc" has no class.');
$container = new ContainerBuilder();

$definition = $container->register('123_abc');
$container->register('123_abc');
$container->compile();
}

Expand All @@ -1305,7 +1305,7 @@ public function testNoClassFromNsSeparatorId()
$this->expectExceptionMessage('The definition for "\foo" has no class.');
$container = new ContainerBuilder();

$definition = $container->register('\\foo');
$container->register('\\foo');
$container->compile();
}

Expand Down
Loading