8000 minor #25898 [minor] SCA: reduce repetitive method calls (sequential … · symfony/symfony@1b92f06 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1b92f06

Browse files
committed
minor #25898 [minor] SCA: reduce repetitive method calls (sequential and in loop) (kalessil)
This PR was merged into the 2.7 branch. Discussion ---------- [minor] SCA: reduce repetitive method calls (sequential and in loop) | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Commits ------- 6093722 SCA: get rid of repetitive calls
2 parents 73cbb01 + 6093722 commit 1b92f06

File tree

6 files changed

+18
-12
lines changed

6 files changed

+18
-12
lines changed

src/Symfony/Bundle/FrameworkBundle/Console/Application.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ public function __construct(KernelInterface $kernel)
3535

3636
parent::__construct('Symfony', Kernel::VERSION.' - '.$kernel->getName().'/'.$kernel->getEnvironment().($kernel->isDebug() ? '/debug' : ''));
3737

38-
$this->getDefinition()->addOption(new InputOption('--shell', '-s', InputOption::VALUE_NONE, 'Launch the shell.'));
39-
$this->getDefinition()->addOption(new InputOption('--process-isolation', null, InputOption::VALUE_NONE, 'Launch commands from shell as a separate process.'));
40-
$this->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', $kernel->getEnvironment()));
41-
$this->getDefinition()->addOption(new InputOption('--no-debug', null, InputOption::VALUE_NONE, 'Switches off debug mode.'));
38+
$inputDefinition = $this->getDefinition();
39+
$inputDefinition->addOption(new InputOption('--shell', '-s', InputOption::VALUE_NONE, 'Launch the shell.'));
40+
$inputDefinition->addOption(new InputOption('--process-isolation', null, InputOption::VALUE_NONE, 'Launch commands from shell as a separate process.'));
41+
$inputDefinition->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', $kernel->getEnvironment()));
42+
$inputDefinition->addOption(new InputOption('--no-debug', null, InputOption::VALUE_NONE, 'Switches off debug mode.'));
4243
}
4344

4445
/**

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,10 @@ protected function write($content, $decorated = false)
110110
protected function renderTable(Table $table, $decorated = false)
111111
{
112112
if (!$decorated) {
113-
$table->getStyle()->setCellRowFormat('%s');
114-
$table->getStyle()->setCellRowContentFormat('%s');
115-
$table->getStyle()->setCellHeaderFormat('%s');
113+
$tableStyle = $table->getStyle();
114+
$tableStyle->setCellRowFormat('%s');
115+
$tableStyle->setCellRowContentFormat('%s');
116+
$tableStyle->setCellHeaderFormat('%s');
116117
}
117118

118119
$table->render();

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,9 @@ private function registerTemplatingConfiguration(array $config, $ide, ContainerB
467467
if (1 === count($engines)) {
468468
$container->setAlias('templating', (string) reset($engines));
469469
} else {
470+
$templateEngineDefinition = $container->getDefinition('templating.engine.delegating');
470471
foreach ($engines as $engine) {
471-
$container->getDefinition('templating.engine.delegating')->addMethodCall('addEngine', array($engine));
472+
$templateEngineDefinition->addMethodCall('addEngine', array($engine));
472473
}
473474
$container->setAlias('templating', 'templating.engine.delegating');
474475
}

src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ public function __construct(HttpKernelInterface $kernel, $cacheDir = null)
5252
protected function forward(Request $request, $raw = false, Response $entry = null)
5353
{
5454
$this->getKernel()->boot();
55-
$this->getKernel()->getContainer()->set('cache', $this);
56-
$this->getKernel()->getContainer()->set($this->getSurrogate()->getName(), $this->getSurrogate());
55+
$container = $this->getKernel()->getContainer();
56+
$container->set('cache', $this);
57+
$container->set($this->getSurrogate()->getName(), $this->getSurrogate());
5758

5859
return parent::forward($request, $raw, $entry);
5960
}

src/Symfony/Component/HttpKernel/EventListener/AddRequestFormatsListener.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ public function __construct(array $formats)
3434
*/
3535
public function onKernelRequest(GetResponseEvent $event)
3636
{
37+
$request = $event->getRequest();
3738
foreach ($this->formats as $format => $mimeTypes) {
38-
$event->getRequest()->setFormat($format, $mimeTypes);
39+
$request->setFormat($format, $mimeTypes);
3940
}
4041
}
4142

src/Symfony/Component/Validator/ExecutionContext.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,9 @@ public function validate($value, $subPath = '', $groups = null, $traverse = fals
197197
{
198198
$propertyPath = $this->getPropertyPath($subPath);
199199

200+
$visitor = $this->globalContext->getVisitor();
200201
foreach ($this->resolveGroups($groups) as $group) {
201-
$this->globalContext->getVisitor()->validate($value, $group, $propertyPath, $traverse, $deep);
202+
$visitor->validate($value, $group, $propertyPath, $traverse, $deep);
202203
}
203204
}
204205

0 commit comments

Comments
 (0)
0