Skip to content

Commit

Permalink
Merge branch '2.8' into 3.1
Browse files Browse the repository at this point in the history
* 2.8:
  Relax 1 test failing with latest PHP versions
  bumped Symfony version to 2.8.10
  Remove usage of __CLASS__ outside of a class
  [HttpKernel] Fix variable conflicting name
  [Process] Fix double-fread() when reading unix pipes
  [Process] Fix AbstractPipes::write() for a situation seen on HHVM (at least)
  [Validator] Fix dockblock typehint in XmlFileLoader
  bumped Symfony version to 2.8.10
  updated VERSION for 2.8.9
  updated CHANGELOG for 2.8.9
  bumped Symfony version to 2.7.17
  updated VERSION for 2.7.16
  update CONTRIBUTORS for 2.7.16
  updated CHANGELOG for 2.7.16
  Minor fixes
  [Console] Overcomplete argument exception message tweak.
  fixed bad auto merge
  Console table cleanup
  undefined offset fix (#19406)
  [EventDispatcher] Removed unused variable

Conflicts:
	CHANGELOG-2.7.md
	CHANGELOG-3.0.md
	src/Symfony/Bridge/Swiftmailer/DataCollector/MessageDataCollector.php
	src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
	src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
	src/Symfony/Component/Console/Tests/Helper/LegacyDialogHelperTest.php
	src/Symfony/Component/Console/Tests/Helper/TableTest.php
	src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/legacy-container9.php
	src/Symfony/Component/EventDispatcher/Tests/AbstractEventDispatcherTest.php
	src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/LegacyPdoSessionHandlerTest.php
	src/Symfony/Component/HttpKernel/Kernel.php
  • Loading branch information
nicolas-grekas committed Aug 5, 2016
2 parents f9e638e + 36e6233 commit d177cfd
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 19 deletions.
35 changes: 18 additions & 17 deletions Helper/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ public static function getStyleDefinition($name)
self::$styles = self::initStyles();
}

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

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

/**
Expand All @@ -131,13 +131,7 @@ public static function getStyleDefinition($name)
*/
public function setStyle($name)
{
if ($name instanceof TableStyle) {
$this->style = $name;
} elseif (isset(self::$styles[$name])) {
$this->style = self::$styles[$name];
} else {
throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
}
$this->style = $this->resolveStyle($name);

return $this;
}
Expand All @@ -164,13 +158,7 @@ public function setColumnStyle($columnIndex, $name)
{
$columnIndex = intval($columnIndex);

if ($name instanceof TableStyle) {
$this->columnStyles[$columnIndex] = $name;
} elseif (isset(self::$styles[$name])) {
$this->columnStyles[$columnIndex] = self::$styles[$name];
} else {
throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
}
$this->columnStyles[$columnIndex] = $this->resolveStyle($name);

return $this;
}
Expand Down Expand Up @@ -701,4 +689,17 @@ private static function initStyles()
'symfony-style-guide' => $styleGuide,
);
}

private function resolveStyle($name)
{
if ($name instanceof TableStyle) {
return $name;
}

if (isset(self::$styles[$name])) {
return self::$styles[$name];
}

throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
}
}
7 changes: 6 additions & 1 deletion Input/ArgvInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,12 @@ private function parseArgument($token)

// unexpected argument
} else {
throw new RuntimeException('Too many arguments.');
$all = $this->definition->getArguments();
if (count($all)) {
throw new RuntimeException(sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all))));
}

throw new RuntimeException(sprintf('No arguments expected, got "%s".', $token));
}
}

Expand Down
19 changes: 19 additions & 0 deletions Tests/Helper/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,25 @@ public function testColumnWiths()
$this->assertEquals($expected, $this->getOutputContent($output));
}

/**
* @expectedException Symfony\Component\Console\Exception\InvalidArgumentException
* @expectedExceptionMessage Style "absent" is not defined.
*/
public function testIsNotDefinedStyleException()
{
$table = new Table($this->getOutputStream());
$table->setStyle('absent');
}

/**
* @expectedException \Symfony\Component\Console\Exception\InvalidArgumentException
* @expectedExceptionMessage Style "absent" is not defined.
*/
public function testGetStyleDefinition()
{
Table::getStyleDefinition('absent');
}

protected function getOutputStream()
{
return new StreamOutput($this->stream, StreamOutput::VERBOSITY_NORMAL, false);
Expand Down
12 changes: 11 additions & 1 deletion Tests/Input/ArgvInputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,17 @@ public function provideInvalidInput()
array(
array('cli.php', 'foo', 'bar'),
new InputDefinition(),
'Too many arguments.',
'No arguments expected, got "foo".',
),
array(
array('cli.php', 'foo', 'bar'),
new InputDefinition(array(new InputArgument('number'))),
'Too many arguments, expected arguments "number".',
),
array(
array('cli.php', 'foo', 'bar', 'zzz'),
new InputDefinition(array(new InputArgument('number'), new InputArgument('county'))),
'Too many arguments, expected arguments "number" "county".',
),
array(
array('cli.php', '--foo'),
Expand Down

0 comments on commit d177cfd

Please sign in to comment.