minor #34176 [4.3] Remove unused local variables (fancyweb)

This PR was merged into the 4.3 branch.

Discussion
----------

[4.3] Remove unused local variables

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Follow up of https://github.com/symfony/symfony/pull/34105 on 4.3.

Commits
-------

58161b8eec [4.3] Remove unused local variables
This commit is contained in:
Nicolas Grekas 2019-10-30 14:18:51 +01:00
commit e8b31ff608
29 changed files with 21 additions and 53 deletions

View File

@ -257,14 +257,11 @@ class SymfonyTestsListenerTrait
if (class_exists('PHPUnit_Util_Blacklist', false)) {
$Test = 'PHPUnit_Util_Test';
$BaseTestRunner = 'PHPUnit_Runner_BaseTestRunner';
$Warning = 'PHPUnit_Framework_Warning';
} else {
$Test = 'PHPUnit\Util\Test';
$BaseTestRunner = 'PHPUnit\Runner\BaseTestRunner';
$Warning = 'PHPUnit\Framework\Warning';
}
$className = \get_class($test);
$classGroups = $Test::getGroups($className);
$groups = $Test::getGroups($className, $test->getName(false));
if (null !== $this->reportUselessTests) {

View File

@ -57,8 +57,6 @@ class TransNode extends Node
}
list($msg, $defaults) = $this->compileString($this->getNode('body'), $defaults, (bool) $vars);
$method = !$this->hasNode('count') ? 'trans' : 'transChoice';
$compiler
->write('echo $this->env->getExtension(\'Symfony\Bridge\Twig\Extension\TranslationExtension\')->trans(')
->subcompile($msg)

View File

@ -997,8 +997,6 @@ class FrameworkExtension extends Extension
{
$loader->load('assets.xml');
$defaultVersion = null;
if ($config['version_strategy']) {
$defaultVersion = new Reference($config['version_strategy']);
} else {

View File

@ -98,11 +98,6 @@ class DelegatingLoader extends BaseDelegatingLoader
}
}
if (1 === substr_count($controller, ':')) {
$nonDeprecatedNotation = str_replace(':', '::', $controller);
// TODO deprecate this in 5.1
}
$route->setDefault('_controller', $controller);
}

View File

@ -18,14 +18,14 @@ class ContainerDumpTest extends AbstractWebTestCase
{
public function testContainerCompilationInDebug()
{
$client = $this->createClient(['test_case' => 'ContainerDump', 'root_config' => 'config.yml']);
$this->createClient(['test_case' => 'ContainerDump', 'root_config' => 'config.yml']);
$this->assertTrue(static::$container->has('serializer'));
}
public function testContainerCompilation()
{
$client = $this->createClient(['test_case' => 'ContainerDump', 'root_config' => 'config.yml', 'debug' => false]);
$this->createClient(['test_case' => 'ContainerDump', 'root_config' => 'config.yml', 'debug' => false]);
$this->assertTrue(static::$container->has('serializer'));
}

View File

@ -258,7 +258,6 @@ class SecurityDataCollectorTest extends TestCase
$eventDispatcher = $this->getMockBuilder(EventDispatcherInterface::class)->getMockForAbstractClass();
$decoratedVoter1 = new TraceableVoter($voter1, $eventDispatcher);
$decoratedVoter2 = new TraceableVoter($voter2, $eventDispatcher);
yield [
AccessDecisionManager::STRATEGY_AFFIRMATIVE,

View File

@ -87,8 +87,8 @@ abstract class AdapterTestCase extends CachePoolTest
$cache = $this->createCachePool(0, __FUNCTION__);
$v = $cache->get('k1', function () use (&$counter, $cache) {
$v = $cache->get('k2', function () use (&$counter) { return ++$counter; });
$v = $cache->get('k2', function () use (&$counter) { return ++$counter; });
$cache->get('k2', function () use (&$counter) { return ++$counter; });
$v = $cache->get('k2', function () use (&$counter) { return ++$counter; }); // ensure the callback is called once
return $v;
});

View File

@ -39,7 +39,7 @@ class NullAdapterTest extends TestCase
$adapter = $this->createCachePool();
$fetched = [];
$item = $adapter->get('myKey', function ($item) use (&$fetched) { $fetched[] = $item; });
$adapter->get('myKey', function ($item) use (&$fetched) { $fetched[] = $item; });
$this->assertCount(1, $fetched);
$item = $fetched[0];
$this->assertFalse($item->isHit());

View File

@ -31,8 +31,6 @@ class PdoDbalAdapterTest extends AdapterTestCase
}
self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache');
$pool = new PdoAdapter(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile]));
}
public static function tearDownAfterClass(): void

View File

@ -154,7 +154,6 @@ class ResourceCheckerConfigCache implements ConfigCacheInterface
private function safelyUnserialize($file)
{
$e = null;
$meta = false;
$content = file_get_contents($file);
$signalingException = new \UnexpectedValueException();

View File

@ -118,8 +118,8 @@ class ConsoleSectionOutputTest extends TestCase
public function testAddingMultipleSections()
{
$sections = [];
$output1 = new ConsoleSectionOutput($this->stream, $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter());
$output2 = new ConsoleSectionOutput($this->stream, $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter());
new ConsoleSectionOutput($this->stream, $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter());
new ConsoleSectionOutput($this->stream, $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter());
$this->assertCount(2, $sections);
}

View File

@ -104,7 +104,6 @@ trait ResponseTrait
if (null === $this->content) {
$content = null;
$chunk = null;
foreach (self::stream([$this]) as $chunk) {
if (!$chunk->isLast()) {

View File

@ -27,7 +27,7 @@ class NativeFileSessionHandlerTest extends TestCase
{
public function testConstruct()
{
$storage = new NativeSessionStorage(['name' => 'TESTING'], new NativeFileSessionHandler(sys_get_temp_dir()));
new NativeSessionStorage(['name' => 'TESTING'], new NativeFileSessionHandler(sys_get_temp_dir()));
$this->assertEquals('user', ini_get('session.save_handler'));

View File

@ -364,7 +364,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
public function testNotTaggedControllerServiceReceivesLocatorArgument()
{
$container = new ContainerBuilder();
$resolver = $container->register('argument_resolver.not_tagged_controller')->addArgument([]);
$container->register('argument_resolver.not_tagged_controller')->addArgument([]);
$pass = new RegisterControllerArgumentLocatorsPass();
$pass->process($container);

View File

@ -41,13 +41,13 @@ class SmtpEnvelopeTest extends TestCase
public function testConstructorWithNoRecipients()
{
$this->expectException(\InvalidArgumentException::class);
$e = new SmtpEnvelope(new Address('fabien@symfony.com'), []);
new SmtpEnvelope(new Address('fabien@symfony.com'), []);
}
public function testConstructorWithWrongRecipients()
{
$this->expectException(\InvalidArgumentException::class);
$e = new SmtpEnvelope(new Address('fabien@symfony.com'), ['lucas@symfony.com']);
new SmtpEnvelope(new Address('fabien@symfony.com'), ['lucas@symfony.com']);
}
public function testSenderFromHeaders()

View File

@ -106,7 +106,6 @@ class Connection
$messageId = '0'; // will receive consumers pending messages
}
$e = null;
try {
$messages = $this->connection->xreadgroup(
$this->group,

View File

@ -52,7 +52,6 @@ class PhpSerializer implements SerializerInterface
private function safelyUnserialize($contents)
{
$e = null;
$signalingException = new MessageDecodingFailedException(sprintf('Could not decode message using PHP serialization: %s.', $contents));
$prevUnserializeHandler = ini_set('unserialize_callback_func', self::class.'::handleUnserializeCallback');
$prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$prevErrorHandler, $signalingException) {

View File

@ -116,7 +116,6 @@ final class CharacterStream
if ($this->currentPos >= $this->charCount) {
return null;
}
$ret = null;
$length = ($this->currentPos + $length > $this->charCount) ? $this->charCount - $this->currentPos : $length;
if ($this->fixedWidth > 0) {
$len = $length * $this->fixedWidth;

View File

@ -320,8 +320,6 @@ class EmailTest extends TestCase
$e->text('text content');
$e->attach($file);
$e->attach($image, 'test.gif');
$fullhtml = new TextPart($content, 'utf-8', 'html');
$inlinedimg = (new DataPart($image, 'test.gif'))->asInline();
$body = $e->getBody();
$this->assertInstanceOf(MixedPart::class, $body);
$this->assertCount(2, $related = $body->getParts());
@ -378,7 +376,7 @@ class EmailTest extends TestCase
$e->from('fabien@symfony.com');
$e->text($r);
$e->html($r);
$contents = file_get_contents($name = __DIR__.'/Fixtures/mimetypes/test', 'r');
$name = __DIR__.'/Fixtures/mimetypes/test';
$file = fopen($name, 'r');
$e->attach($file, 'test');
$expected = clone $e;

View File

@ -173,8 +173,6 @@ class HeadersTest extends TestCase
public function testRemoveRemovesAllHeadersWithName()
{
$header0 = new UnstructuredHeader('X-Test', 'some@id');
$header1 = new UnstructuredHeader('X-Test', 'other@id');
$headers = new Headers();
$headers->addIdHeader('X-Test', 'some@id');
$headers->addIdHeader('X-Test', 'other@id');
@ -185,7 +183,6 @@ class HeadersTest extends TestCase
public function testHasIsNotCaseSensitive()
{
$header = new IdentificationHeader('Message-ID', 'some@id');
$headers = new Headers();
$headers->addIdHeader('Message-ID', 'some@id');
$this->assertTrue($headers->has('message-id'));
@ -209,7 +206,6 @@ class HeadersTest extends TestCase
public function testRemoveIsNotCaseSensitive()
{
$header = new IdentificationHeader('Message-ID', 'some@id');
$headers = new Headers();
$headers->addIdHeader('Message-ID', 'some@id');
$headers->remove('message-id');

View File

@ -103,7 +103,7 @@ class IdentificationHeaderTest extends TestCase
{
$this->expectException('Exception');
$this->expectExceptionMessage('Email "a b c@d" does not comply with addr-spec of RFC 2822.');
$header = new IdentificationHeader('References', 'a b c@d');
new IdentificationHeader('References', 'a b c@d');
}
public function testIdRightCanBeDotAtom()
@ -139,7 +139,7 @@ class IdentificationHeaderTest extends TestCase
{
$this->expectException('Exception');
$this->expectExceptionMessage('Email "a@b c d" does not comply with addr-spec of RFC 2822.');
$header = new IdentificationHeader('References', 'a@b c d');
new IdentificationHeader('References', 'a@b c d');
}
public function testMissingAtSignThrowsException()
@ -149,7 +149,7 @@ class IdentificationHeaderTest extends TestCase
/* -- RFC 2822, 3.6.4.
msg-id = [CFWS] "<" id-left "@" id-right ">" [CFWS]
*/
$header = new IdentificationHeader('References', 'abc');
new IdentificationHeader('References', 'abc');
}
public function testSetBody()

View File

@ -26,7 +26,7 @@ class PathHeaderTest extends TestCase
public function testAddressMustComplyWithRfc2822()
{
$this->expectException('Exception');
$header = new PathHeader('Return-Path', new Address('chr is@swiftmailer.org'));
new PathHeader('Return-Path', new Address('chr is@swiftmailer.org'));
}
public function testValueIsAngleAddrWithValidAddress()

View File

@ -121,7 +121,7 @@ EOF;
}
}
EOF;
$compiledRoutes[4] = $forDump ? $checkConditionCode .= ",\n" : eval('return '.$checkConditionCode.';');
$compiledRoutes[4] = $forDump ? $checkConditionCode.",\n" : eval('return '.$checkConditionCode.';');
} else {
$compiledRoutes[4] = $forDump ? " null, // \$checkCondition\n" : null;
}

View File

@ -25,7 +25,7 @@ class RouteTest extends TestCase
public function testTryingToSetLocalesDirectly()
{
$this->expectException('BadMethodCallException');
$route = new Route(['locales' => ['nl' => 'bar']]);
new Route(['locales' => ['nl' => 'bar']]);
}
/**

View File

@ -194,7 +194,7 @@ class CompiledUrlGeneratorDumperTest extends TestCase
file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump());
$projectUrlGenerator = new CompiledUrlGenerator(require $this->testTmpFilepath, new RequestContext());
$url = $projectUrlGenerator->generate('NonExisting', []);
$projectUrlGenerator->generate('NonExisting', []);
}
public function testDumpForRouteWithDefaults()

View File

@ -14,7 +14,6 @@ namespace Symfony\Component\Security\Http\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Security\Http\Firewall;
@ -52,8 +51,6 @@ class FirewallTest extends TestCase
public function testOnKernelRequestStopsWhenThereIsAResponse()
{
$response = new Response();
$called = [];
$first = function () use (&$called) {

View File

@ -552,7 +552,6 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn
{
if (\func_num_args() < 3) {
@trigger_error(sprintf('Method "%s::%s()" will have a third "?string $format" argument in version 5.0; not defining it is deprecated since Symfony 4.3.', \get_class($this), __FUNCTION__), E_USER_DEPRECATED);
$format = null;
}
if (isset($parentContext[self::ATTRIBUTES][$attribute])) {
$parentContext[self::ATTRIBUTES] = $parentContext[self::ATTRIBUTES][$attribute];

View File

@ -14,7 +14,6 @@ namespace Symfony\Component\Validator\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Validator\ConstraintViolation;
use Symfony\Component\Validator\Tests\Fixtures\CustomArrayObject;
use Symfony\Component\Validator\Tests\Fixtures\ToString;
class ConstraintViolationTest extends TestCase
{
@ -114,7 +113,7 @@ EOF;
public function testMessageCannotBeArray()
{
$this->expectException(\TypeError::class);
$violation = new ConstraintViolation(
new ConstraintViolation(
['cannot be an array'],
'',
[],
@ -127,7 +126,7 @@ EOF;
public function testMessageObjectMustBeStringable()
{
$this->expectException(\TypeError::class);
$violation = new ConstraintViolation(
new ConstraintViolation(
new CustomArrayObject(),
'',
[],

View File

@ -85,7 +85,6 @@ class Parser
$this->refs = [];
$mbEncoding = null;
$data = null;
if (2 /* MB_OVERLOAD_STRING */ & (int) ini_get('mbstring.func_overload')) {
$mbEncoding = mb_internal_encoding();