10000 Merge branch '2.8' into 3.0 · l-vo/symfony@ca71e74 · GitHub
[go: up one dir, main page]

Skip to content

Commit ca71e74

Browse files
committed
Merge branch '2.8' into 3.0
* 2.8: Minor fixes [Console] Overcomplete argument exception message tweak. fixed bad auto merge Console table cleanup undefined offset fix (symfony#19406) [EventDispatcher] Removed unused variable
2 parents 1d5f391 + ec1808f commit ca71e74

File tree

19 files changed

+68
-47
lines changed

19 files changed

+68
-47
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
use Symfony\Component\Finder\Finder;
2424
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
2525
use Symfony\Component\Config\FileLocator;
26-
use Symfony\Component\Validator\Validation;
2726

2827
/**
2928
* FrameworkExtension.

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/SessionController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function welcomeAction(Request $request, $name = null)
4545

4646
public function logoutAction(Request $request)
4747
{
48-
$request->getSession('session')->invalidate();
48+
$request->getSession()->invalidate();
4949

5050
return new Response('Session cleared.');
5151
}

src/Symfony/Bundle/SecurityBundle/Command/UserPasswordEncoderCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
105105

106106
return 1;
107107
}
108-
$passwordQuestion = $this->createPasswordQuestion($input, $output);
108+
$passwordQuestion = $this->createPasswordQuestion();
109109
$password = $io->askQuestion($passwordQuestion);
110110
}
111111

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

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ public static function getStyleDefinition($name)
108108
self::$styles = self::initStyles();
109109
}
110110

111-
if (!self::$styles[$name]) {
112-
throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
111+
if (isset(self::$styles[$name])) {
112+
return self::$styles[$name];
113113
}
114114

115-
return self::$styles[$name];
115+
throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
116116
}
117117

118118
/**
@@ -124,13 +124,7 @@ public static function getStyleDefinition($name)
124124
*/
125125
public function setStyle($name)
126126
{
127-
if ($name instanceof TableStyle) {
128-
$this->style = $name;
129-
} elseif (isset(self::$styles[$name])) {
130-
$this->style = self::$styles[$name];
131-
} else {
132-
throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
133-
}
127+
$this->style = $this->resolveStyle($name);
134128

135129
return $this;
136130
}
@@ -157,13 +151,7 @@ public function setColumnStyle($columnIndex, $name)
157151
{
158152
$columnIndex = intval($columnIndex);
159153

160-
if ($name instanceof TableStyle) {
161-
$this->columnStyles[$columnIndex] = $name;
162-
} elseif (isset(self::$styles[$name])) {
163-
$this->columnStyles[$columnIndex] = self::$styles[$name];
164-
} else {
165-
throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
166-
}
154+
$this->columnStyles[$columnIndex] = $this->resolveStyle($name);
167155

168156
return $this;
169157
}
@@ -660,4 +648,17 @@ private static function initStyles()
660648
'symfony-style-guide' => $styleGuide,
661649
);
662650
}
651+
652+
private function resolveStyle($name)
653+
{
654+
if ($name instanceof TableStyle) {
655+
return $name;
656+
}
657+
658+
if (isset(self::$styles[$name])) {
659+
return self::$styles[$name];
660+
}
661+
662+
throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
663+
}
663664
}

src/Symfony/Component/Console/Input/ArgvInput.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,12 @@ private function parseArgument($token)
176176

177177
// unexpected argument
178178
} else {
179-
throw new RuntimeException('Too many arguments.');
179+
$all = $this->definition->getArguments();
180+
if (count($all)) {
181+
throw new RuntimeException(sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all))));
182+
}
183+
184+
throw new RuntimeException(sprintf('No arguments expected, got "%s".', $token));
180185
}
181186
}
182187

src/Symfony/Component/Console/Tests/Helper/TableTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,25 @@ public function testColumnStyle()
631631
$this->assertEquals($expected, $this->getOutputContent($output));
632632
}
633633

634+
/**
635+
* @expectedException Symfony\Component\Console\Exception\InvalidArgumentException
636+
* @expectedExceptionMessage Style "absent" is not defined.
637+
*/
638+
public function testIsNotDefinedStyleException()
639+
{
640+
$table = new Table($this->getOutputStream());
641+
$table->setStyle('absent');
642+
}
643+
644+
/**
645+
* @expectedException \Symfony\Component\Console\Exception\InvalidArgumentException
646+
* @expectedExceptionMessage Style "absent" is not defined.
647+
*/
648+
public function testGetStyleDefinition()
649+
{
650+
Table::getStyleDefinition('absent');
651+
}
652+
634653
protected function getOutputStream()
635654
{
636655
return new StreamOutput($this->stream, StreamOutput::VERBOSITY_NORMAL, false);

src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php

Lines changed: 11 additions & 1 deletion
< 17AE td data-grid-cell-id="diff-c93e36761d0be7b6754e2308740e2fb173b9a44b4c2b11fb4f0f68e235579e38-185-185-0" data-selected="false" role="gridcell" style="background-color:var(--bgColor-default);text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative diff-line-number-neutral left-side">185
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,17 @@ public function provideInvalidInput()
183183
array(
184184
array('cli.php', 'foo', 'bar'),
185
new InputDefinition(),
186-
'Too many arguments.',
186+
'No arguments expected, got "foo".',
187+
),
188+
array(
189+
array('cli.php', 'foo', 'bar'),
190+
new InputDefinition(array(new InputArgument('number'))),
191+
'Too many arguments, expected arguments "number".',
192+
),
193+
array(
194+
array('cli.php', 'foo', 'bar', 'zzz'),
195+
new InputDefinition(array(new InputArgument('number'), new InputArgument('county'))),
196+
'Too many arguments, expected arguments "number" "county".',
187197
),
188198
array(
189199
array('cli.php', '--foo'),

src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Symfony\Component\Debug\DebugClassLoader;
1515
use Symfony\Component\Debug\ErrorHandler;
16-
use Symfony\Component\Debug\Exception\ContextErrorException;
1716

1817
class DebugClassLoaderTest extends \PHPUnit_Framework_TestCase
1918
{

src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\DependencyInjection\Compiler;
1313

1414
use Symfony\Component\DependencyInjection\Alias;
15-
use Symfony\Component\DependencyInjection\Definition;
1615
use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
1716
use Symfony\Component\DependencyInjection\Reference;
1817
use Symfony\Component\DependencyInjection\ContainerBuilder;

src/Symfony/Component/DependencyInjection/Tests/Compiler/ReplaceAliasByActualDefinitionPassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function testProcess()
4848

4949
$this->assertTrue($container->has('container'));
5050

51-
$resolvedFactory = $aDefinition->getFactory(false);
51+
$resolvedFactory = $aDefinition->getFactory();
5252
$this->assertSame('b_alias', (string) $resolvedFactory[0]);
5353
}
5454

0 commit comments

Comments
 (0)
0