Skip to content

Commit 1203390

Browse files
Remove unused code and unnecessary else branches
1 parent 5938c51 commit 1203390

File tree

44 files changed

+76
-132
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+76
-132
lines changed

src/Symfony/Bridge/Monolog/Formatter/ConsoleFormatter.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function format(LogRecord $record): mixed
114114
$extra = '';
115115
}
116116

117-
$formatted = strtr($this->options['format'], [
117+
return strtr($this->options['format'], [
118118
'%datetime%' => $record->datetime->format($this->options['date_format']),
119119
'%start_tag%' => \sprintf('<%s>', self::LEVEL_COLOR_MAP[$record->level->value]),
120120
'%level_name%' => \sprintf($this->options['level_name_format'], $record->level->getName()),
@@ -124,8 +124,6 @@ public function format(LogRecord $record): mixed
124124
'%context%' => $context,
125125
'%extra%' => $extra,
126126
]);
127-
128-
return $formatted;
129127
}
130128

131129
/**

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,6 @@ public function __construct(string $message, array $trace, string $file, bool $l
149149
if (($test instanceof TestCase || $test instanceof TestSuite) && ('trigger_error' !== $trace[$i - 2]['function'] || isset($trace[$i - 2]['class']))) {
150150
$this->originClass = \get_class($test);
151151
$this->originMethod = $test->getName();
152-
153-
return;
154152
}
155153
}
156154

src/Symfony/Bridge/PsrHttpMessage/Factory/PsrHttpFactory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ public function createResponse(Response $symfonyResponse): ResponseInterface
195195
}
196196

197197
$protocolVersion = $symfonyResponse->getProtocolVersion();
198-
$response = $response->withProtocolVersion($protocolVersion);
199198

200-
return $response;
199+
return $response->withProtocolVersion($protocolVersion);
201200
}
202201
}

src/Symfony/Bridge/Twig/Command/DebugCommand.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,15 +344,13 @@ private function getMetadata(string $type, mixed $entity): mixed
344344
}
345345

346346
// format args
347-
$args = array_map(function (\ReflectionParameter $param) {
347+
return array_map(function (\ReflectionParameter $param) {
348348
if ($param->isDefaultValueAvailable()) {
349349
return $param->getName().' = '.json_encode($param->getDefaultValue());
350350
}
351351

352352
return $param->getName();
353353
}, $args);
354-
355-
return $args;
356354
}
357355

358356
return null;

src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ public function enterNode(Node $node, Environment $env): Node
5050
$this->scope->set('domain', $node->getNode('expr'));
5151

5252
return $node;
53-
} else {
54-
$name = new AssignNameExpression(self::INTERNAL_VAR_NAME, $node->getTemplateLine());
55-
$this->scope->set('domain', new NameExpression(self::INTERNAL_VAR_NAME, $node->getTemplateLine()));
56-
57-
return new SetNode(false, new Node([$name]), new Node([$node->getNode('expr')]), $node->getTemplateLine());
5853
}
54+
55+
$name = new AssignNameExpression(self::INTERNAL_VAR_NAME, $node->getTemplateLine());
56+
$this->scope->set('domain', new NameExpression(self::INTERNAL_VAR_NAME, $node->getTemplateLine()));
57+
58+
return new SetNode(false, new Node([$name]), new Node([$node->getNode('expr')]), $node->getTemplateLine());
5959
}
6060

6161
if (!$this->scope->has('domain')) {

src/Symfony/Bundle/FrameworkBundle/Controller/ControllerResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ protected function instantiateController(string $class): object
2727
if ($controller instanceof AbstractController) {
2828
if (null === $previousContainer = $controller->setContainer($this->container)) {
2929
throw new \LogicException(\sprintf('"%s" has no container set, did you forget to define it as a service subscriber?', $class));
30-
} else {
31-
$controller->setContainer($previousContainer);
3230
}
31+
32+
$controller->setContainer($previousContainer);
3333
}
3434

3535
return $controller;

src/Symfony/Component/Config/Builder/ClassBuilder.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function build(): string
8282
}
8383
}
8484

85-
$content = strtr('<?php
85+
return strtr('<?php
8686
8787
namespace NAMESPACE;
8888
@@ -95,8 +95,6 @@ class CLASS IMPLEMENTS
9595
BODY
9696
}
9797
', ['NAMESPACE' => $this->namespace, 'REQUIRE' => $require, 'USE' => $use, 'CLASS' => $this->getName(), 'IMPLEMENTS' => $implements, 'BODY' => $body]);
98-
99-
return $content;
10098
}
10199

102100
public function addRequire(self $class): void

src/Symfony/Component/Console/Application.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,6 @@ public function complete(CompletionInput $input, CompletionSuggestions $suggesti
383383

384384
if (CompletionInput::TYPE_OPTION_NAME === $input->getCompletionType()) {
385385
$suggestions->suggestOptions($this->getDefinition()->getOptions());
386-
387-
return;
388386
}
389387
}
390388

src/Symfony/Component/Console/Helper/ProgressBar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ private function buildLine(): string
610610
{
611611
\assert(null !== $this->format);
612612

613-
$regex = "{%([a-z\-_]+)(?:\:([^%]+))?%}i";
613+
$regex = '{%([a-z\-_]+)(?:\:([^%]+))?%}i';
614614
$callback = function ($matches) {
615615
if ($formatter = $this->getPlaceholderFormatter($matches[1])) {
616616
$text = $formatter($this, $this->output);

src/Symfony/Component/Console/Helper/ProgressIndicator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ private function display(): void
171171
return;
172172
}
173173

174-
$this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) {
174+
$this->overwrite(preg_replace_callback('{%([a-z\-_]+)(?:\:([^%]+))?%}i', function ($matches) {
175175
if ($formatter = self::getPlaceholderFormatterDefinition($matches[1])) {
176176
return $formatter($this);
177177
}

0 commit comments

Comments
 (0)