10000 [4.3] Remove unused local variables · symfony/symfony@58161b8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 58161b8

Browse files
committed
[4.3] Remove unused local variables
1 parent 2b0a579 commit 58161b8

File tree

29 files changed

+21
-53
lines changed
  • Security/Http/Tests
  • Serializer/Normalizer
  • Validator/Tests
  • Yaml
  • 29 files changed

    +21
    -53
    lines changed

    src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

    Lines changed: 0 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -257,14 +257,11 @@ public function endTest($test, $time)
    257257
    if (class_exists('PHPUnit_Util_Blacklist', false)) {
    258258
    $Test = 'PHPUnit_Util_Test';
    259259
    $BaseTestRunner = 'PHPUnit_Runner_BaseTestRunner';
    260-
    $Warning = 'PHPUnit_Framework_Warning';
    261260
    } else {
    262261
    $Test = 'PHPUnit\Util\Test';
    263262
    $BaseTestRunner = 'PHPUnit\Runner\BaseTestRunner';
    264-
    $Warning = 'PHPUnit\Framework\Warning';
    265263
    }
    266264
    $className = \get_class($test);
    267-
    $classGroups = $Test::getGroups($className);
    268265
    $groups = $Test::getGroups($className, $test->getName(false));
    269266

    270267
    if (null !== $this->reportUselessTests) {

    src/Symfony/Bridge/Twig/Node/TransNode.php

    Lines changed: 0 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -57,8 +57,6 @@ public function compile(Compiler $compiler)
    5757
    }
    5858
    list($msg, $defaults) = $this->compileString($this->getNode('body'), $defaults, (bool) $vars);
    5959

    60-
    $method = !$this->hasNode('count') ? 'trans' : 'transChoice';
    61-
    6260
    $compiler
    6361
    ->write('echo $this->env->getExtension(\'Symfony\Bridge\Twig\Extension\TranslationExtension\')->trans(')
    6462
    ->subcompile($msg)

    src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

    Lines changed: 0 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -997,8 +997,6 @@ private function registerAssetsConfiguration(array $config, ContainerBuilder $co
    997997
    {
    998998
    $loader->load('assets.xml');
    999999

    1000-
    $defaultVersion = null;
    1001-
    10021000
    if ($config['version_strategy']) {
    10031001
    $defaultVersion = new Reference($config['version_strategy']);
    10041002
    } else {

    src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php

    Lines changed: 0 additions & 5 deletions
    Original file line numberDiff line numberDiff line change
    @@ -98,11 +98,6 @@ public function load($resource, $type = null)
    9898
    }
    9999
    }
    100100

    101-
    if (1 === substr_count($controller, ':')) {
    102-
    $nonDeprecatedNotation = str_replace(':', '::', $controller);
    103-
    // TODO deprecate this in 5.1
    104-
    }
    105-
    106101
    $route->setDefault('_controller', $controller);
    107102
    }
    108103

    src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDumpTest.php

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -18,14 +18,14 @@ class ContainerDumpTest extends AbstractWebTestCase
    1818
    {
    1919
    public function testContainerCompilationInDebug()
    2020
    {
    21-
    $client = $this->createClient(['test_case' => 'ContainerDump', 'root_config' => 'config.yml']);
    21+
    $this->createClient(['test_case' => 'ContainerDump', 'root_config' => 'config.yml']);
    2222

    2323
    $this->assertTrue(static::$container->has('serializer'));
    2424
    }
    2525

    2626
    public function testContainerCompilation()
    2727
    {
    28-
    $client = $this->createClient(['test_case' => 'ContainerDump', 'root_config' => 'config.yml', 'debug' => false]);
    28+
    $this->createClient(['test_case' => 'ContainerDump', 'root_config' => 'config.yml', 'debug' => false]);
    2929

    3030
    $this->assertTrue(static::$container->has('serializer'));
    3131
    }

    src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php

    Lines changed: 0 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -258,7 +258,6 @@ public function providerCollectDecisionLog(): \Generator
    258258

    259259
    $eventDispatcher = $this->getMockBuilder(EventDispatcherInterface::class)->getMockForAbstractClass();
    260260
    $decoratedVoter1 = new TraceableVoter($voter1, $eventDispatcher);
    261-
    $decoratedVoter2 = new TraceableVoter($voter2, $eventDispatcher);
    262261

    263262
    yield [
    264263
    AccessDecisionManager::STRATEGY_AFFIRMATIVE,

    src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -87,8 +87,8 @@ public function testRecursiveGet()
    8787
    $cache = $this->createCachePool(0, __FUNCTION__);
    8888

    8989
    $v = $cache->get('k1', function () use (&$counter, $cache) {
    90-
    $v = $cache->get('k2', function () use (&$counter) { return ++$counter; });
    91-
    $v = $cache->get('k2', function () use (&$counter) { return ++$counter; });
    90+
    $cache->get('k2', function () use (&$counter) { return ++$counter; });
    91+
    $v = $cache->get('k2', function () use (&$counter) { return ++$counter; }); // ensure the callback is called once
    9292

    9393
    return $v;
    9494
    });

    src/Symfony/Component/Cache/Tests/Adapter/NullAdapterTest.php

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -39,7 +39,7 @@ public function testGet()
    3939
    $adapter = $this->createCachePool();
    4040

    4141
    $fetched = [];
    42-
    $item = $adapter->get('myKey', function ($item) use (&$fetched) { $fetched[] = $item; });
    42+
    $adapter->get('myKey', function ($item) use (&$fetched) { $fetched[] = $item; });
    4343
    $this->assertCount(1, $fetched);
    4444
    $item = $fetched[0];
    4545
    $this->assertFalse($item->isHit());

    src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php

    Lines changed: 0 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -31,8 +31,6 @@ public static function setUpBeforeClass(): void
    3131
    }
    3232

    3333
    self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache');
    34-
    35-
    $pool = new PdoAdapter(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile]));
    3634
    }
    3735

    3836
    public static function tearDownAfterClass(): void

    src/Symfony/Component/Config/ResourceCheckerConfigCache.php

    Lines changed: 0 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -154,7 +154,6 @@ private function getMetaFile()
    154154

    155155
    private function safelyUnserialize($file)
    156156
    {
    157-
    $e = null;
    158157
    $meta = false;
    159158
    $content = file_get_contents($file);
    160159
    $signalingException = new \UnexpectedValueException();

    src/Symfony/Component/Console/Tests/Output/ConsoleSectionOutputTest.php

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -118,8 +118,8 @@ public function testOverwriteMultipleLines()
    118118
    public function testAddingMultipleSections()
    119119
    {
    120120
    $sections = [];
    121-
    $output1 = new ConsoleSectionOutput($this->stream, $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter());
    122-
    $output2 = new ConsoleSectionOutput($this->stream, $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter());
    121+
    new ConsoleSectionOutput($this->stream, $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter());
    122+
    new ConsoleSectionOutput($this->stream, $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter());
    123123

    124124
    $this->assertCount(2, $sections);
    125125
    }

    src/Symfony/Component/HttpClient/Response/ResponseTrait.php

    Lines changed: 0 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -104,7 +104,6 @@ public function getContent(bool $throw = true): string
    104104

    105105
    if (null === $this->content) {
    106106
    $content = null;
    107-
    $chunk = null;
    108107

    109108
    foreach (self::stream([$this]) as $chunk) {
    110109
    if (!$chunk->isLast()) {

    src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -27,7 +27,7 @@ class NativeFileSessionHandlerTest extends TestCase
    2727
    {
    2828
    public function testConstruct()
    2929
    {
    30-
    $storage = new NativeSessionStorage(['name' => 'TESTING'], new NativeFileSessionHandler(sys_get_temp_dir()));
    30+
    new NativeSessionStorage(['name' => 'TESTING'], new NativeFileSessionHandler(sys_get_temp_dir()));
    3131

    3232
    $this->assertEquals('user', ini_get('session.save_handler'));
    3333

    src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -364,7 +364,7 @@ public function testBindingsOnChildDefinitions()
    364364
    public function testNotTaggedControllerServiceReceivesLocatorArgument()
    365365
    {
    366366
    $container = new ContainerBuilder();
    367-
    $resolver = $container->register('argument_resolver.not_tagged_controller')->addArgument([]);
    367+
    $container->register('argument_resolver.not_tagged_controller')->addArgument([]);
    368368

    369369
    $pass = new RegisterControllerArgumentLocatorsPass();
    370370
    $pass->process($container);

    src/Symfony/Component/Mailer/Tests/SmtpEnvelopeTest.php

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -41,13 +41,13 @@ public function testConstructorWithAddressRecipients()
    4141
    public function testConstructorWithNoRecipients()
    4242
    {
    4343
    $this->expectException(\InvalidArgumentException::class);
    44-
    $e = new SmtpEnvelope(new Address('fabien@symfony.com'), []);
    44+
    new SmtpEnvelope(new Address('fabien@symfony.com'), []);
    4545
    }
    4646

    4747
    public function testConstructorWithWrongRecipients()
    4848
    {
    4949
    $this->expectException(\InvalidArgumentException::class);
    50-
    $e = new SmtpEnvelope(new Address('fabien@symfony.com'), ['lucas@symfony.com']);
    50+
    new SmtpEnvelope(new Address('fabien@symfony.com'), ['lucas@symfony.com']);
    5151
    }
    5252

    5353
    public function testSenderFromHeaders()

    src/Symfony/Component/Messenger/Transport/RedisExt/Connection.php

    Lines changed: 0 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -106,7 +106,6 @@ public function get(): ?array
    106106
    $messageId = '0'; // will receive consumers pending messages
    107107
    }
    108108

    109-
    $e = null;
    110109
    try {
    111110
    $messages = $this->connection->xreadgroup(
    112111
    $this->group,

    src/Symfony/Component/Messenger/Transport/Serialization/PhpSerializer.php

    Lines changed: 0 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -52,7 +52,6 @@ public function encode(Envelope $envelope): array
    5252

    5353
    private function safelyUnserialize($contents)
    5454
    {
    55-
    $e = null;
    5655
    $signalingException = new MessageDecodingFailedException(sprintf('Could not decode message using PHP serialization: %s.', $contents));
    5756
    $prevUnserializeHandler = ini_set('unserialize_callback_func', self::class.'::handleUnserializeCallback');
    5857
    $prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$prevErrorHandler, $signalingException) {

    src/Symfony/Component/Mime/CharacterStream.php

    Lines changed: 0 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -116,7 +116,6 @@ public function read(int $length): ?string
    116116
    if ($this->currentPos >= $this->charCount) {
    117117
    return null;
    118118
    }
    119-
    $ret = null;
    120119
    $length = ($this->currentPos + $length > $this->charCount) ? $this->charCount - $this->currentPos : $length;
    121120
    if ($this->fixedWidth > 0) {
    122121
    $len = $length * $this->fixedWidth;

    src/Symfony/Component/Mime/Tests/EmailTest.php

    Lines changed: 1 addition & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -320,8 +320,6 @@ public function testGenerateBody()
    320320
    $e->text('text content');
    321321
    $e->attach($file);
    322322
    $e->attach($image, 'test.gif');
    323-
    $fullhtml = new TextPart($content, 'utf-8', 'html');
    324-
    $inlinedimg = (new DataPart($image, 'test.gif'))->asInline();
    325323
    $body = $e->getBody();
    3 10000 26324
    $this->assertInstanceOf(MixedPart::class, $body);
    327325
    $this->assertCount(2, $related = $body->getParts());
    @@ -378,7 +376,7 @@ public function testSerialize()
    378376
    $e->from('fabien@symfony.com');
    379377
    $e->text($r);
    380378
    $e->html($r);
    381-
    $contents = file_get_contents($name = __DIR__.'/Fixtures/mimetypes/test', 'r');
    379+
    $name = __DIR__.'/Fixtures/mimetypes/test';
    382380
    $file = fopen($name, 'r');
    383381
    $e->attach($file, 'test');
    384382
    $expected = clone $e;

    src/Symfony/Component/Mime/Tests/Header/HeadersTest.php

    Lines changed: 0 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -173,8 +173,6 @@ public function testAllReturnsEmptyArrayIfNoneSet()
    173173

    174174
    public function testRemoveRemovesAllHeadersWithName()
    175175
    {
    176-
    $header0 = new UnstructuredHeader('X-Test', 'some@id');
    177-
    $header1 = new UnstructuredHeader('X-Test', 'other@id');
    178176
    $headers = new Headers();
    179177
    $headers->addIdHeader('X-Test', 'some@id');
    180178
    $headers->addIdHeader('X-Test', 'other@id');
    @@ -185,7 +183,6 @@ public function testRemoveRemovesAllHeadersWithName()
    185183

    186184
    public function testHasIsNotCaseSensitive()
    187185
    {
    188-
    $header = new IdentificationHeader('Message-ID', 'some@id');
    189186
    $headers = new Headers();
    190187
    $headers->addIdHeader('Message-ID', 'some@id');
    191188
    $this->assertTrue($headers->has('message-id'));
    @@ -209,7 +206,6 @@ public function testAllIsNotCaseSensitive()
    209206

    210207
    public function testRemoveIsNotCaseSensitive()
    211208
    {
    212-
    $header = new IdentificationHeader('Message-ID', 'some@id');
    213209
    $headers = new Headers();
    214210
    $headers->addIdHeader('Message-ID', 'some@id');
    215211
    $headers->remove('message-id');

    src/Symfony/Component/Mime/Tests/Header/IdentificationHeaderTest.php

    Lines changed: 3 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -103,7 +103,7 @@ public function testInvalidIdLeftThrowsException()
    103103
    {
    104104
    $this->expectException('Exception');
    105105
    $this->expectExceptionMessage('Email "a b c@d" does not comply with addr-spec of RFC 2822.');
    106-
    $header = new IdentificationHeader('References', 'a b c@d');
    106+
    new IdentificationHeader('References', 'a b c@d');
    107107
    }
    108108

    109109
    public function testIdRightCanBeDotAtom()
    @@ -139,7 +139,7 @@ public function testInvalidIdRightThrowsException()
    139139
    {
    140140
    $this->expectException('Exception');
    141141
    $this->expectExceptionMessage('Email "a@b c d" does not comply with addr-spec of RFC 2822.');
    142-
    $header = new IdentificationHeader('References', 'a@b c d');
    142+
    new IdentificationHeader('References', 'a@b c d');
    143143
    }
    144144

    145145
    public function testMissingAtSignThrowsException()
    @@ -149,7 +149,7 @@ public function testMissingAtSignThrowsException()
    149149
    /* -- RFC 2822, 3.6.4.
    150150
    msg-id = [CFWS] "<" id-left "@" id-right ">" [CFWS]
    151151
    */
    152-
    $header = new IdentificationHeader('References', 'abc');
    152+
    new IdentificationHeader('References', 'abc');
    153153
    }
    154154

    155155
    public function testSetBody()

    src/Symfony/Component/Mime/Tests/Header/PathHeaderTest.php

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -26,7 +26,7 @@ public function testSingleAddressCanBeSetAndFetched()
    2626
    public function testAddressMustComplyWithRfc2822()
    2727
    {
    2828
    $this->expectException('Exception');
    29-
    $header = new PathHeader('Return-Path', new Address('chr is@swiftmailer.org'));
    29+
    new PathHeader('Return-Path', new Address('chr is@swiftmailer.org'));
    3030
    }
    3131

    3232
    public function testValueIsAngleAddrWithValidAddress()

    src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php

    Expand all lines: src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php
    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -121,7 +121,7 @@ static function (\$condition, \$context, \$request) { // \$checkCondition
    121121
    }
    122122
    }
    123123
    EOF;
    124-
    $compiledRoutes[4] = $forDump ? $checkConditionCode .= ",\n" : eval('return '.$checkConditionCode.';');
    124+
    $compiledRoutes[4] = $forDump ? $checkConditionCode.",\n" : eval('return '.$checkConditionCode.';');
    125125
    } else {
    126126
    $compiledRoutes[4] = $forDump ? " null, // \$checkCondition\n" : null;
    127127
    }

    src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -25,7 +25,7 @@ public function testInvalidRouteParameter()
    2525
    public function testTryingToSetLocalesDirectly()
    2626
    {
    2727
    $this->expectException('BadMethodCallException');
    28-
    $route = new Route(['locales' => ['nl' => 'bar']]);
    28+
    new Route(['locales' => ['nl' => 'bar']]);
    2929
    }
    3030

    3131
    /**

    src/Symfony/Component/Routing/Tests/Generator/Dumper/CompiledUrlGeneratorDumperTest.php

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -194,7 +194,7 @@ public function testGenerateNonExistingRoute()
    194194
    file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump());
    195195

    196196
    $projectUrlGenerator = new CompiledUrlGenerator(require $this->testTmpFilepath, new RequestContext());
    197-
    $url = $projectUrlGenerator->generate('NonExisting', []);
    197+
    $projectUrlGenerator->generate('NonExisting', []);
    198198
    }
    199199

    200200
    public function testDumpForRouteWithDefaults()

    src/Symfony/Component/Security/Http/Tests/FirewallTest.php

    Lines changed: 0 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -14,7 +14,6 @@
    1414
    use PHPUnit\Framework\TestCase;
    1515
    use Symfony\Component\EventDispatcher\EventDispatcherInterface;
    1616
    use Symfony\Component\HttpFoundation\Request;
    17-
    use Symfony\Component\HttpFoundation\Response;
    1817
    use Symfony\Component\HttpKernel\Event\RequestEvent;
    1918
    use Symfony\Component\HttpKernel\HttpKernelInterface;
    2019
    use Symfony\Component\Security\Http\Firewall;
    @@ -52,8 +51,6 @@ public function testOnKernelRequestRegistersExceptionListener()
    5251

    5352
    public function testOnKernelRequestStopsWhenThereIsAResponse()
    5453
    {
    55-
    $response = new Response();
    56-
    5754
    $called = [];
    5855

    5956
    $first = function () use (&$called) {

    src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php

    Lines changed: 0 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -552,7 +552,6 @@ protected function createChildContext(array $parentContext, $attribute/*, ?strin
    552552
    {
    553553
    if (\func_num_args() < 3) {
    554554
    @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);
    555-
    $format = null;
    556555
    }
    557556
    if (isset($parentContext[self::ATTRIBUTES][$attribute])) {
    558557
    $parentContext[self::ATTRIBUTES] = $parentContext[self::ATTRIBUTES][$attribute];

    src/Symfony/Component/Validator/Tests/ConstraintViolationTest.php

    Lines changed: 2 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -14,7 +14,6 @@
    1414
    use PHPUnit\Framework\TestCase;
    1515
    use Symfony\Component\Validator\ConstraintViolation;
    1616
    use Symfony\Component\Validator\Tests\Fixtures\CustomArrayObject;
    17-
    use Symfony\Component\Validator\Tests\Fixtures\ToString;
    1817

    1918
    class ConstraintViolationTest extends TestCase
    2019
    {
    @@ -114,7 +113,7 @@ public function testToStringOmitsEmptyCodes()
    114113
    public function testMessageCannotBeArray()
    115114
    {
    116115
    $this->expectException(\TypeError::class);
    117-
    $violation = new ConstraintViolation(
    116+
    new ConstraintViolation(
    118117
    ['cannot be an array'],
    119118
    '',
    120119
    [],
    @@ -127,7 +126,7 @@ public function testMessageCannotBeArray()
    127126
    public function testMessageObjectMustBeStringable()
    128127
    {
    129128
    $this->expectException(\TypeError::class);
    130-
    $violation = new ConstraintViolation(
    129+
    new ConstraintViolation(
    131130
    new CustomArrayObject(),
    132131
    '',
    133132
    [],

    src/Symfony/Component/Yaml/Parser.php

    Lines changed: 0 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -85,7 +85,6 @@ public function parse(string $value, int $flags = 0)
    8585
    $this->refs = [];
    8686

    8787
    $mbEncoding = null;
    88-
    $data = null;
    8988

    9089
    if (2 /* MB_OVERLOAD_STRING */ & (int) ini_get('mbstring.func_overload')) {
    9190
    $mbEncoding = mb_internal_encoding();

    0 commit comments

    Comments
     (0)
    0