Merge branch '2.8'

* 2.8:
  [Translation] avoid freshness check based on content *inside* the cache.
  [Translator] Cache does not take fallback locales into consideration
  [Translator] Cache does not take fallback locales into consideration
  [VarDumper] Fix call site detection
  [Form] Cleanup deprecation notices
  [Console] Made output docopt compatible
  [Process] Fix volatile test
  Remove some useless @group annotations
  Removed useless strtolower call
  [Validator] Use strict comparisons in loaders
  CS: Use "self" keyword instead of class name if possible

Conflicts:
	.travis.yml
	src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php
	src/Symfony/Component/Form/FormTypeExtensionInterface.php
	src/Symfony/Component/Form/FormTypeInterface.php
This commit is contained in:
Fabien Potencier 2015-04-10 09:30:08 +02:00
commit 37bc0abc41
104 changed files with 605 additions and 466 deletions

View File

@ -46,6 +46,6 @@ install:
script:
- if [ "$deps" = "no" ]; then echo "$components" | parallel --gnu --keep-order 'echo -e "\\nRunning {} tests"; phpunit --exclude-group tty,benchmark,intl-data {} || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
- if [ "$deps" = "no" ]; then echo -e "\\nRunning tests requiring tty"; phpunit --group tty || (echo -e "\\e[41mKO\\e[0m tty group" && $(exit 1)); fi;
- if [ "$deps" = "high" ]; then echo "$components" | parallel --gnu --keep-order -j25% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source update; phpunit --exclude-group tty,benchmark,intl-data || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
- if [ "$deps" = "low" ]; then echo "$components" | parallel --gnu --keep-order -j25% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source --prefer-lowest --prefer-stable update; phpunit --exclude-group tty,benchmark,intl-data || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
- if [ "$deps" = "2.7" ]; then echo "$components" | parallel --gnu --keep-order -j25% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source update; phpunit --exclude-group tty,benchmark,intl-data,legacy || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
- if [ "$deps" = "high" ]; then echo "$components" | parallel --gnu --keep-order -j10% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source update; phpunit --exclude-group tty,benchmark,intl-data || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
- if [ "$deps" = "low" ]; then echo "$components" | parallel --gnu --keep-order -j10% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source --prefer-lowest --prefer-stable update; phpunit --exclude-group tty,benchmark,intl-data || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
- if [ "$deps" = "2.7" ]; then echo "$components" | parallel --gnu --keep-order -j10% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source update; phpunit --exclude-group tty,benchmark,intl-data,legacy || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;

View File

@ -336,9 +336,6 @@ class UniqueEntityValidatorTest extends AbstractConstraintValidatorTest
$this->assertNoViolation();
}
/**
* @group GH-1635
*/
public function testAssociatedEntity()
{
$constraint = new UniqueEntity(array(
@ -395,7 +392,6 @@ class UniqueEntityValidatorTest extends AbstractConstraintValidatorTest
/**
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
* @expectedExceptionMessage Associated entities are not allowed to have more than one identifier field
* @group GH-1635
*/
public function testAssociatedCompositeEntity()
{

View File

@ -11,9 +11,6 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
/**
* @group functional
*/
class FragmentTest extends WebTestCase
{
/**

View File

@ -11,9 +11,6 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
/**
* @group functional
*/
class ProfilerTest extends WebTestCase
{
/**

View File

@ -11,9 +11,6 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
/**
* @group functional
*/
class SessionTest extends WebTestCase
{
/**

View File

@ -11,9 +11,6 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
/**
* @group functional
*/
class SubRequestsTest extends WebTestCase
{
public function testStateAfterSubRequest()

View File

@ -255,12 +255,17 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
__DIR__.'/../Fixtures/Resources/translations/messages.fr.yml',
),
);
$catalogueHash = sha1(serialize(array(
'resources' => array(),
'fallback_locales' => array(),
)));
// prime the cache
$translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir, 'resource_files' => $resourceFiles), 'yml');
$this->assertFalse(file_exists($this->tmpDir.'/catalogue.fr.php'));
$translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir, 'resource_files' => $resourceFiles), 'yml');
$this->assertFalse(file_exists($this->tmpDir.'/catalogue.fr.'.$catalogueHash.'.php'));
$translator->warmup($this->tmpDir);
$this->assertTrue(file_exists($this->tmpDir.'/catalogue.fr.php'));
$this->assertTrue(file_exists($this->tmpDir.'/catalogue.fr.'.$catalogueHash.'.php'));
}
}

View File

@ -11,9 +11,6 @@
namespace Symfony\Bundle\SecurityBundle\Tests\Functional;
/**
* @group functional
*/
class CsrfFormLoginTest extends WebTestCase
{
/**

View File

@ -13,9 +13,6 @@ namespace Symfony\Bundle\SecurityBundle\Tests\Functional;
use Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FirewallEntryPointBundle\Security\EntryPointStub;
/**
* @group functional
*/
class FirewallEntryPointTest extends WebTestCase
{
public function testItUsesTheConfiguredEntryPointWhenUsingUnknownCredentials()

View File

@ -11,9 +11,6 @@
namespace Symfony\Bundle\SecurityBundle\Tests\Functional;
/**
* @group functional
*/
class FormLoginTest extends WebTestCase
{
/**

View File

@ -57,7 +57,6 @@ class SecurityRoutingIntegrationTest extends WebTestCase
/**
* @dataProvider getConfigs
* @group ip_whitelist
*/
public function testSecurityConfigurationForSingleIPAddress($config)
{
@ -70,7 +69,6 @@ class SecurityRoutingIntegrationTest extends WebTestCase
/**
* @dataProvider getConfigs
* @group ip_whitelist
*/
public function testSecurityConfigurationForMultipleIPAddresses($config)
{

View File

@ -11,9 +11,6 @@
namespace Symfony\Bundle\SecurityBundle\Tests\Functional;
/**
* @group functional
*/
class SwitchUserTest extends WebTestCase
{
/**

View File

@ -224,7 +224,7 @@ class ExprBuilder
public static function buildExpressions(array $expressions)
{
foreach ($expressions as $k => $expr) {
if ($expr instanceof ExprBuilder) {
if ($expr instanceof self) {
$if = $expr->ifPart;
$then = $expr->thenPart;
$expressions[$k] = function ($v) use ($if, $then) {

View File

@ -82,7 +82,7 @@ abstract class FileLoader extends Loader
try {
$loader = $this->resolve($resource, $type);
if ($loader instanceof FileLoader && null !== $this->currentDir) {
if ($loader instanceof self && null !== $this->currentDir) {
// we fallback to the current locator to keep BC
// as some some loaders do not call the parent __construct()
// @deprecated should be removed in 3.0

View File

@ -39,7 +39,8 @@ class Command
private $applicationDefinitionMerged = false;
private $applicationDefinitionMergedWithArgs = false;
private $code;
private $synopsis;
private $synopsis = array();
private $usages = array();
private $helperSet;
/**
@ -216,7 +217,8 @@ class Command
public function run(InputInterface $input, OutputInterface $output)
{
// force the creation of the synopsis before the merge with the app definition
$this->getSynopsis();
$this->getSynopsis(true);
$this->getSynopsis(false);
// add the application arguments and options
$this->mergeApplicationDefinition();
@ -574,15 +576,45 @@ class Command
/**
* Returns the synopsis for the command.
*
* @param bool $short Whether to show the short version of the synopsis (with options folded) or not
*
* @return string The synopsis
*/
public function getSynopsis()
public function getSynopsis($short = false)
{
if (null === $this->synopsis) {
$this->synopsis = trim(sprintf('%s %s', $this->name, $this->definition->getSynopsis()));
$key = $short ? 'short' : 'long';
if (!isset($this->synopsis[$key])) {
$this->synopsis[$key] = trim(sprintf('%s %s', $this->name, $this->definition->getSynopsis($short)));
}
return $this->synopsis;
return $this->synopsis[$key];
}
/**
* Add a command usage example.
*
* @param string $usage The usage, it'll be prefixed with the command name
*/
public function addUsage($usage)
{
if (0 !== strpos($usage, $this->name)) {
$usage = sprintf('%s %s', $this->name, $usage);
}
$this->usages[] = $usage;
return $this;
}
/**
* Returns alternative usages of the command.
*
* @return array
*/
public function getUsages()
{
return $this->usages;
}
/**

View File

@ -102,7 +102,7 @@ class JsonDescriptor extends Descriptor
'name' => $argument->getName(),
'is_required' => $argument->isRequired(),
'is_array' => $argument->isArray(),
'description' => $argument->getDescription(),
'description' => preg_replace('/\s*\R\s*/', ' ', $argument->getDescription()),
'default' => $argument->getDefault(),
);
}
@ -120,7 +120,7 @@ class JsonDescriptor extends Descriptor
'accept_value' => $option->acceptValue(),
'is_value_required' => $option->isValueRequired(),
'is_multiple' => $option->isArray(),
'description' => $option->getDescription(),
'description' => preg_replace('/\s*\R\s*/', ' ', $option->getDescription()),
'default' => $option->getDefault(),
);
}
@ -157,10 +157,9 @@ class JsonDescriptor extends Descriptor
return array(
'name' => $command->getName(),
'usage' => $command->getSynopsis(),
'usage' => array_merge(array($command->getSynopsis()), $command->getUsages(), $command->getAliases()),
'description' => $command->getDescription(),
'help' => $command->getProcessedHelp(),
'aliases' => $command->getAliases(),
'definition' => $this->getInputDefinitionData($command->getNativeDefinition()),
);
}

View File

@ -36,7 +36,7 @@ class MarkdownDescriptor extends Descriptor
.'* Name: '.($argument->getName() ?: '<none>')."\n"
.'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n"
.'* Is array: '.($argument->isArray() ? 'yes' : 'no')."\n"
.'* Description: '.($argument->getDescription() ?: '<none>')."\n"
.'* Description: '.preg_replace('/\s*\R\s*/', PHP_EOL.' ', $argument->getDescription() ?: '<none>')."\n"
.'* Default: `'.str_replace("\n", '', var_export($argument->getDefault(), true)).'`'
);
}
@ -53,7 +53,7 @@ class MarkdownDescriptor extends Descriptor
.'* Accept value: '.($option->acceptValue() ? 'yes' : 'no')."\n"
.'* Is value required: '.($option->isValueRequired() ? 'yes' : 'no')."\n"
.'* Is multiple: '.($option->isArray() ? 'yes' : 'no')."\n"
.'* Description: '.($option->getDescription() ?: '<none>')."\n"
.'* Description: '.preg_replace('/\s*\R\s*/', PHP_EOL.' ', $option->getDescription() ?: '<none>')."\n"
.'* Default: `'.str_replace("\n", '', var_export($option->getDefault(), true)).'`'
);
}
@ -96,12 +96,14 @@ class MarkdownDescriptor extends Descriptor
$command->getName()."\n"
.str_repeat('-', strlen($command->getName()))."\n\n"
.'* Description: '.($command->getDescription() ?: '<none>')."\n"
.'* Usage: `'.$command->getSynopsis().'`'."\n"
.'* Aliases: '.(count($command->getAliases()) ? '`'.implode('`, `', $command->getAliases()).'`' : '<none>')
.'* Usage:'."\n\n"
.array_reduce(array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()), function ($carry, $usage) {
return $carry .= ' * `'.$usage.'`'."\n";
})
);
if ($help = $command->getProcessedHelp()) {
$this->write("\n\n");
$this->write("\n");
$this->write($help);
}

View File

@ -32,16 +32,19 @@ class TextDescriptor extends Descriptor
protected function describeInputArgument(InputArgument $argument, array $options = array())
{
if (null !== $argument->getDefault() && (!is_array($argument->getDefault()) || count($argument->getDefault()))) {
$default = sprintf('<comment> (default: %s)</comment>', $this->formatDefaultValue($argument->getDefault()));
$default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($argument->getDefault()));
} else {
$default = '';
}
$nameWidth = isset($options['name_width']) ? $options['name_width'] : strlen($argument->getName());
$totalWidth = isset($options['total_width']) ? $options['total_width'] : strlen($argument->getName());
$spacingWidth = $totalWidth - strlen($argument->getName()) + 2;
$this->writeText(sprintf(" <info>%-${nameWidth}s</info> %s%s",
$this->writeText(sprintf(" <info>%s</info>%s%s%s",
$argument->getName(),
str_replace("\n", "\n".str_repeat(' ', $nameWidth + 2), $argument->getDescription()),
str_repeat(' ', $spacingWidth),
// + 17 = 2 spaces + <info> + </info> + 2 spaces
preg_replace('/\s*\R\s*/', PHP_EOL.str_repeat(' ', $totalWidth + 17), $argument->getDescription()),
$default
), $options);
}
@ -52,18 +55,33 @@ class TextDescriptor extends Descriptor
protected function describeInputOption(InputOption $option, array $options = array())
{
if ($option->acceptValue() && null !== $option->getDefault() && (!is_array($option->getDefault()) || count($option->getDefault()))) {
$default = sprintf('<comment> (default: %s)</comment>', $this->formatDefaultValue($option->getDefault()));
$default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($option->getDefault()));
} else {
$default = '';
}
$nameWidth = isset($options['name_width']) ? $options['name_width'] : strlen($option->getName());
$nameWithShortcutWidth = $nameWidth - strlen($option->getName()) - 2;
$value = '';
if ($option->acceptValue()) {
$value = '='.strtoupper($option->getName());
$this->writeText(sprintf(" <info>%s</info> %-${nameWithShortcutWidth}s%s%s%s",
'--'.$option->getName(),
$option->getShortcut() ? sprintf('(-%s) ', $option->getShortcut()) : '',
str_replace("\n", "\n".str_repeat(' ', $nameWidth + 2), $option->getDescription()),
if ($option->isValueOptional()) {
$value = '['.$value.']';
}
}
$totalWidth = isset($options['total_width']) ? $options['total_width'] : $this->calculateTotalWidthForOptions(array($option));
$synopsis = sprintf('%s%s',
$option->getShortcut() ? sprintf('-%s, ', $option->getShortcut()) : ' ',
sprintf('--%s%s', $option->getName(), $value)
);
$spacingWidth = $totalWidth - strlen($synopsis) + 2;
$this->writeText(sprintf(" <info>%s</info>%s%s%s%s",
$synopsis,
str_repeat(' ', $spacingWidth),
// + 17 = 2 spaces + <info> + </info> + 2 spaces
preg_replace('/\s*\R\s*/', "\n".str_repeat(' ', $totalWidth + 17), $option->getDescription()),
$default,
$option->isArray() ? '<comment> (multiple values allowed)</comment>' : ''
), $options);
@ -74,24 +92,16 @@ class TextDescriptor extends Descriptor
*/
protected function describeInputDefinition(InputDefinition $definition, array $options = array())
{
$nameWidth = 0;
foreach ($definition->getOptions() as $option) {
$nameLength = strlen($option->getName()) + 2;
if ($option->getShortcut()) {
$nameLength += strlen($option->getShortcut()) + 3;
}
$nameWidth = max($nameWidth, $nameLength);
}
$totalWidth = $this->calculateTotalWidthForOptions($definition->getOptions());
foreach ($definition->getArguments() as $argument) {
$nameWidth = max($nameWidth, strlen($argument->getName()));
$totalWidth = max($totalWidth, strlen($argument->getName()));
}
++$nameWidth;
if ($definition->getArguments()) {
$this->writeText('<comment>Arguments:</comment>', $options);
$this->writeText("\n");
foreach ($definition->getArguments() as $argument) {
$this->describeInputArgument($argument, array_merge($options, array('name_width' => $nameWidth)));
$this->describeInputArgument($argument, array_merge($options, array('total_width' => $totalWidth)));
$this->writeText("\n");
}
}
@ -101,11 +111,20 @@ class TextDescriptor extends Descriptor
}
if ($definition->getOptions()) {
$laterOptions = array();
$this->writeText('<comment>Options:</comment>', $options);
$this->writeText("\n");
foreach ($definition->getOptions() as $option) {
$this->describeInputOption($option, array_merge($options, array('name_width' => $nameWidth)));
if (strlen($option->getShortcut()) > 1) {
$laterOptions[] = $option;
continue;
}
$this->writeText("\n");
$this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth)));
}
foreach ($laterOptions as $option) {
$this->writeText("\n");
$this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth)));
}
}
}
@ -115,27 +134,26 @@ class TextDescriptor extends Descriptor
*/
protected function describeCommand(Command $command, array $options = array())
{
$command->getSynopsis();
$command->getSynopsis(true);
$command->getSynopsis(false);
$command->mergeApplicationDefinition(false);
$this->writeText('<comment>Usage:</comment>', $options);
$this->writeText("\n");
$this->writeText(' '.$command->getSynopsis(), $options);
$this->writeText("\n");
if (count($command->getAliases()) > 0) {
foreach (array_merge(array($command->getSynopsis(true)), $command->getAliases(), $command->getUsages()) as $usage) {
$this->writeText("\n");
$this->writeText('<comment>Aliases:</comment> <info>'.implode(', ', $command->getAliases()).'</info>', $options);
$this->writeText(' '.$usage, $options);
}
$this->writeText("\n");
if ($definition = $command->getNativeDefinition()) {
$definition = $command->getNativeDefinition();
if ($definition->getOptions() || $definition->getArguments()) {
$this->writeText("\n");
$this->describeInputDefinition($definition, $options);
$this->writeText("\n");
}
$this->writeText("\n");
if ($help = $command->getProcessedHelp()) {
$this->writeText("\n");
$this->writeText('<comment>Help:</comment>', $options);
$this->writeText("\n");
$this->writeText(' '.str_replace("\n", "\n ", $help), $options);
@ -164,27 +182,12 @@ class TextDescriptor extends Descriptor
}
$this->writeText("<comment>Usage:</comment>\n", $options);
$this->writeText(" command [options] [arguments]\n\n", $options);
$this->writeText('<comment>Options:</comment>', $options);
$this->writeText(" command [options] [arguments]\n\n", $options);
$inputOptions = $application->getDefinition()->getOptions();
$this->describeInputDefinition(new InputDefinition($application->getDefinition()->getOptions()), $options);
$width = 0;
foreach ($inputOptions as $option) {
$nameLength = strlen($option->getName()) + 2;
if ($option->getShortcut()) {
$nameLength += strlen($option->getShortcut()) + 3;
}
$width = max($width, $nameLength);
}
++$width;
foreach ($inputOptions as $option) {
$this->writeText("\n", $options);
$this->describeInputOption($option, array_merge($options, array('name_width' => $width)));
}
$this->writeText("\n\n", $options);
$this->writeText("\n");
$this->writeText("\n");
$width = $this->getColumnWidth($description->getCommands());
@ -198,12 +201,13 @@ class TextDescriptor extends Descriptor
foreach ($description->getNamespaces() as $namespace) {
if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
$this->writeText("\n");
$this->writeText('<comment>'.$namespace['id'].'</comment>', $options);
$this->writeText(' <comment>'.$namespace['id'].'</comment>', $options);
}
foreach ($namespace['commands'] as $name) {
$this->writeText("\n");
$this->writeText(sprintf(" <info>%-${width}s</info> %s", $name, $description->getCommand($name)->getDescription()), $options);
$spacingWidth = $width - strlen($name);
$this->writeText(sprintf(" <info>%s</info>%s%s", $name, str_repeat(' ', $spacingWidth), $description->getCommand($name)->getDescription()), $options);
}
}
@ -248,4 +252,27 @@ class TextDescriptor extends Descriptor
return $width + 2;
}
/**
* @param InputOption[] $options
*
* @return int
*/
private function calculateTotalWidthForOptions($options)
{
$totalWidth = 0;
foreach ($options as $option) {
$nameLength = 4 + strlen($option->getName()) + 2; // - + shortcut + , + whitespace + name + --
if ($option->acceptValue()) {
$valueLength = 1 + strlen($option->getName()); // = + value
$valueLength += $option->isValueOptional() ? 2 : 0; // [ + ]
$nameLength += $valueLength;
}
$totalWidth = max($totalWidth, $nameLength);
}
return $totalWidth;
}
}

View File

@ -65,8 +65,11 @@ class XmlDescriptor extends Descriptor
$commandXML->setAttribute('id', $command->getName());
$commandXML->setAttribute('name', $command->getName());
$commandXML->appendChild($usageXML = $dom->createElement('usage'));
$usageXML->appendChild($dom->createTextNode(sprintf($command->getSynopsis(), '')));
$commandXML->appendChild($usagesXML = $dom->createElement('usages'));
foreach (array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()) as $usage) {
$usagesXML->appendChild($dom->createElement('usage', $usage));
}
$commandXML->appendChild($descriptionXML = $dom->createElement('description'));
$descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getDescription())));
@ -74,12 +77,6 @@ class XmlDescriptor extends Descriptor
$commandXML->appendChild($helpXML = $dom->createElement('help'));
$helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getProcessedHelp())));
$commandXML->appendChild($aliasesXML = $dom->createElement('aliases'));
foreach ($command->getAliases() as $alias) {
$aliasesXML->appendChild($aliasXML = $dom->createElement('alias'));
$aliasXML->appendChild($dom->createTextNode($alias));
}
$definitionXML = $this->getInputDefinitionDocument($command->getNativeDefinition());
$this->appendDocument($commandXML, $definitionXML->getElementsByTagName('definition')->item(0));

View File

@ -387,22 +387,50 @@ class InputDefinition
/**
* Gets the synopsis.
*
* @param bool $short Whether to return the short version (with options foloded) or not
*
* @return string The synopsis
*/
public function getSynopsis()
public function getSynopsis($short = false)
{
$elements = array();
foreach ($this->getOptions() as $option) {
$shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : '';
$elements[] = sprintf('['.($option->isValueRequired() ? '%s--%s="..."' : ($option->isValueOptional() ? '%s--%s[="..."]' : '%s--%s')).']', $shortcut, $option->getName());
if ($short && $this->getOptions()) {
$elements[] = '[options]';
} elseif (!$short) {
foreach ($this->getOptions() as $option) {
$value = '';
if ($option->acceptValue()) {
$value = sprintf(
' %s%s%s',
$option->isValueOptional() ? '[' : '',
strtoupper($option->getName()),
$option->isValueOptional() ? ']' : ''
);
}
$shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : '';
$elements[] = sprintf('[%s--%s%s]', $shortcut, $option->getName(), $value);
}
}
if (count($elements) && $this->getArguments()) {
$elements[] = '[--]';
}
foreach ($this->getArguments() as $argument) {
$elements[] = sprintf($argument->isRequired() ? '%s' : '[%s]', $argument->getName().($argument->isArray() ? '1' : ''));
$element = '<'.$argument->getName().'>';
if (!$argument->isRequired()) {
$element = '['.$element.']';
} elseif ($argument->isArray()) {
$element = $element.' ('.$element.')';
}
if ($argument->isArray()) {
$elements[] = sprintf('... [%sN]', $argument->getName());
$element .= '...';
}
$elements[] = $element;
}
return implode(' ', $elements);

View File

@ -154,8 +154,8 @@ class CommandTest extends \PHPUnit_Framework_TestCase
{
$command = new \TestCommand();
$command->addOption('foo');
$command->addArgument('foo');
$this->assertEquals('namespace:name [--foo] [foo]', $command->getSynopsis(), '->getSynopsis() returns the synopsis');
$command->addArgument('bar');
$this->assertEquals('namespace:name [--foo] [--] [<bar>]', $command->getSynopsis(), '->getSynopsis() returns the synopsis');
}
public function testGetHelper()

View File

@ -23,8 +23,10 @@ class HelpCommandTest extends \PHPUnit_Framework_TestCase
$command = new HelpCommand();
$command->setApplication(new Application());
$commandTester = new CommandTester($command);
$commandTester->execute(array('command_name' => 'li'));
$this->assertRegExp('/list \[--xml\] \[--raw\] \[--format="\.\.\."\] \[namespace\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias');
$commandTester->execute(array('command_name' => 'li'), array('decorated' => false));
$this->assertContains('list [options] [--] [<namespace>]', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias');
$this->assertContains('format=FORMAT', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias');
$this->assertContains('raw', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias');
}
public function testExecuteForCommand()
@ -32,8 +34,10 @@ class HelpCommandTest extends \PHPUnit_Framework_TestCase
$command = new HelpCommand();
$commandTester = new CommandTester($command);
$command->setCommand(new ListCommand());
$commandTester->execute(array());
$this->assertRegExp('/list \[--xml\] \[--raw\] \[--format="\.\.\."\] \[namespace\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
$commandTester->execute(array(), array('decorated' => false));
$this->assertContains('list [options] [--] [<namespace>]', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
$this->assertContains('format=FORMAT', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
$this->assertContains('raw', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
}
public function testExecuteForCommandWithXmlOption()
@ -42,7 +46,7 @@ class HelpCommandTest extends \PHPUnit_Framework_TestCase
$commandTester = new CommandTester($command);
$command->setCommand(new ListCommand());
$commandTester->execute(array('--format' => 'xml'));
$this->assertRegExp('/<command/', $commandTester->getDisplay(), '->execute() returns an XML help text if --xml is passed');
$this->assertContains('<command', $commandTester->getDisplay(), '->execute() returns an XML help text if --xml is passed');
}
public function testExecuteForApplicationCommand()
@ -50,7 +54,9 @@ class HelpCommandTest extends \PHPUnit_Framework_TestCase
$application = new Application();
$commandTester = new CommandTester($application->get('help'));
$commandTester->execute(array('command_name' => 'list'));
$this->assertRegExp('/list \[--xml\] \[--raw\] \[--format="\.\.\."\] \[namespace\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
$this->assertContains('list [options] [--] [<namespace>]', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
$this->assertContains('format=FORMAT', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
$this->assertContains('raw', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
}
public function testExecuteForApplicationCommandWithXmlOption()
@ -58,7 +64,7 @@ class HelpCommandTest extends \PHPUnit_Framework_TestCase
$application = new Application();
$commandTester = new CommandTester($application->get('help'));
$commandTester->execute(array('command_name' => 'list', '--format' => 'xml'));
$this->assertRegExp('/list \[--xml\] \[--raw\] \[--format="\.\.\."\] \[namespace\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
$this->assertRegExp('/<command/', $commandTester->getDisplay(), '->execute() returns an XML help text if --format=xml is passed');
$this->assertContains('list [--xml] [--raw] [--format FORMAT] [--] [&lt;namespace&gt;]', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
$this->assertContains('<command', $commandTester->getDisplay(), '->execute() returns an XML help text if --format=xml is passed');
}
}

View File

@ -22,7 +22,7 @@ class ListCommandTest extends \PHPUnit_Framework_TestCase
$commandTester = new CommandTester($command = $application->get('list'));
$commandTester->execute(array('command' => $command->getName()), array('decorated' => false));
$this->assertRegExp('/help Displays help for a command/', $commandTester->getDisplay(), '->execute() returns a list of available commands');
$this->assertRegExp('/help\s{2,}Displays help for a command/', $commandTester->getDisplay(), '->execute() returns a list of available commands');
}
public function testExecuteListsCommandsWithXmlOption()

View File

@ -96,7 +96,7 @@ abstract class AbstractDescriptorTest extends \PHPUnit_Framework_TestCase
return $data;
}
private function assertDescription($expectedDescription, $describedObject)
protected function assertDescription($expectedDescription, $describedObject)
{
$output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
$this->getDescriptor()->describe($output, $describedObject, array('raw_output' => true));

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Console\Tests\Descriptor;
use Symfony\Component\Console\Descriptor\JsonDescriptor;
use Symfony\Component\Console\Output\BufferedOutput;
class JsonDescriptorTest extends AbstractDescriptorTest
{
@ -24,4 +25,11 @@ class JsonDescriptorTest extends AbstractDescriptorTest
{
return 'json';
}
protected function assertDescription($expectedDescription, $describedObject)
{
$output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
$this->getDescriptor()->describe($output, $describedObject, array('raw_output' => true));
$this->assertEquals(json_decode(trim($expectedDescription), true), json_decode(trim(str_replace(PHP_EOL, "\n", $output->fetch())), true));
}
}

View File

@ -30,6 +30,7 @@ class ObjectsProvider
'input_argument_1' => new InputArgument('argument_name', InputArgument::REQUIRED),
'input_argument_2' => new InputArgument('argument_name', InputArgument::IS_ARRAY, 'argument description'),
'input_argument_3' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', 'default_value'),
'input_argument_4' => new InputArgument('argument_name', InputArgument::REQUIRED, "multiline\nargument description"),
);
}
@ -40,6 +41,7 @@ class ObjectsProvider
'input_option_2' => new InputOption('option_name', 'o', InputOption::VALUE_OPTIONAL, 'option description', 'default_value'),
'input_option_3' => new InputOption('option_name', 'o', InputOption::VALUE_REQUIRED, 'option description'),
'input_option_4' => new InputOption('option_name', 'o', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'option description', array()),
'input_option_5' => new InputOption('option_name', 'o', InputOption::VALUE_REQUIRED, "multiline\noption description"),
);
}

View File

@ -23,6 +23,8 @@ class DescriptorCommand2 extends Command
->setName('descriptor:command2')
->setDescription('command 2 description')
->setHelp('command 2 help')
->addUsage('-o|--option_name <argument_name>')
->addUsage('<argument_name>')
->addArgument('argument_name', InputArgument::REQUIRED)
->addOption('option_name', 'o', InputOption::VALUE_NONE)
;

View File

@ -1 +1 @@
{"commands":[{"name":"help","usage":"help [--xml] [--format=\"...\"] [--raw] [command_name]","description":"Displays help for a command","help":"The <info>help<\/info> command displays help for a given command:\n\n <info>php app\/console help list<\/info>\n\nYou can also output the help in other formats by using the <comment>--format<\/comment> option:\n\n <info>php app\/console help --format=xml list<\/info>\n\nTo display the list of available commands, please use the <info>list<\/info> command.","aliases":[],"definition":{"arguments":{"command_name":{"name":"command_name","is_required":false,"is_array":false,"description":"The command name","default":"help"}},"options":{"xml":{"name":"--xml","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"To output help as XML","default":false},"format":{"name":"--format","shortcut":"","accept_value":true,"is_value_required":true,"is_multiple":false,"description":"To output help in other formats","default":"txt"},"raw":{"name":"--raw","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"To output raw command help","default":false},"help":{"name":"--help","shortcut":"-h","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Display this help message","default":false},"quiet":{"name":"--quiet","shortcut":"-q","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Do not output any message","default":false},"verbose":{"name":"--verbose","shortcut":"-v|-vv|-vvv","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug","default":false},"version":{"name":"--version","shortcut":"-V","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Display this application version","default":false},"ansi":{"name":"--ansi","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Force ANSI output","default":false},"no-ansi":{"name":"--no-ansi","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Disable ANSI output","default":false},"no-interaction":{"name":"--no-interaction","shortcut":"-n","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Do not ask any interactive question","default":false}}}},{"name":"list","usage":"list [--xml] [--raw] [--format=\"...\"] [namespace]","description":"Lists commands","help":"The <info>list<\/info> command lists all commands:\n\n <info>php app\/console list<\/info>\n\nYou can also display the commands for a specific namespace:\n\n <info>php app\/console list test<\/info>\n\nYou can also output the information in other formats by using the <comment>--format<\/comment> option:\n\n <info>php app\/console list --format=xml<\/info>\n\nIt's also possible to get raw list of commands (useful for embedding command runner):\n\n <info>php app\/console list --raw<\/info>","aliases":[],"definition":{"arguments":{"namespace":{"name":"namespace","is_required":false,"is_array":false,"description":"The namespace name","default":null}},"options":{"xml":{"name":"--xml","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"To output list as XML","default":false},"raw":{"name":"--raw","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"To output raw command list","default":false},"format":{"name":"--format","shortcut":"","accept_value":true,"is_value_required":true,"is_multiple":false,"description":"To output list in other formats","default":"txt"}}}}],"namespaces":[{"id":"_global","commands":["help","list"]}]}
{"commands":[{"name":"help","usage":["help [--xml] [--format FORMAT] [--raw] [--] [<command_name>]"],"description":"Displays help for a command","help":"The <info>help<\/info> command displays help for a given command:\n\n <info>php app\/console help list<\/info>\n\nYou can also output the help in other formats by using the <comment>--format<\/comment> option:\n\n <info>php app\/console help --format=xml list<\/info>\n\nTo display the list of available commands, please use the <info>list<\/info> command.","definition":{"arguments":{"command_name":{"name":"command_name","is_required":false,"is_array":false,"description":"The command name","default":"help"}},"options":{"xml":{"name":"--xml","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"To output help as XML","default":false},"format":{"name":"--format","shortcut":"","accept_value":true,"is_value_required":true,"is_multiple":false,"description":"To output help in other formats","default":"txt"},"raw":{"name":"--raw","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"To output raw command help","default":false},"help":{"name":"--help","shortcut":"-h","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Display this help message","default":false},"quiet":{"name":"--quiet","shortcut":"-q","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Do not output any message","default":false},"verbose":{"name":"--verbose","shortcut":"-v|-vv|-vvv","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug","default":false},"version":{"name":"--version","shortcut":"-V","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Display this application version","default":false},"ansi":{"name":"--ansi","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Force ANSI output","default":false},"no-ansi":{"name":"--no-ansi","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Disable ANSI output","default":false},"no-interaction":{"name":"--no-interaction","shortcut":"-n","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Do not ask any interactive question","default":false}}}},{"name":"list","usage":["list [--xml] [--raw] [--format FORMAT] [--] [<namespace>]"],"description":"Lists commands","help":"The <info>list<\/info> command lists all commands:\n\n <info>php app\/console list<\/info>\n\nYou can also display the commands for a specific namespace:\n\n <info>php app\/console list test<\/info>\n\nYou can also output the information in other formats by using the <comment>--format<\/comment> option:\n\n <info>php app\/console list --format=xml<\/info>\n\nIt's also possible to get raw list of commands (useful for embedding command runner):\n\n <info>php app\/console list --raw<\/info>","definition":{"arguments":{"namespace":{"name":"namespace","is_required":false,"is_array":false,"description":"The namespace name","default":null}},"options":{"xml":{"name":"--xml","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"To output list as XML","default":false},"raw":{"name":"--raw","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"To output raw command list","default":false},"format":{"name":"--format","shortcut":"","accept_value":true,"is_value_required":true,"is_multiple":false,"description":"To output list in other formats","default":"txt"}}}}],"namespaces":[{"id":"_global","commands":["help","list"]}]}

View File

@ -8,8 +8,9 @@ help
----
* Description: Displays help for a command
* Usage: `help [--xml] [--format="..."] [--raw] [command_name]`
* Aliases: <none>
* Usage:
* `help [--xml] [--format FORMAT] [--raw] [--] [<command_name>]`
The <info>help</info> command displays help for a given command:
@ -137,8 +138,9 @@ list
----
* Description: Lists commands
* Usage: `list [--xml] [--raw] [--format="..."] [namespace]`
* Aliases: <none>
* Usage:
* `list [--xml] [--raw] [--format FORMAT] [--] [<namespace>]`
The <info>list</info> command lists all commands:

View File

@ -1,17 +1,17 @@
<info>Console Tool</info>
<comment>Usage:</comment>
command [options] [arguments]
command [options] [arguments]
<comment>Options:</comment>
<info>--help</info> (-h) Display this help message
<info>--quiet</info> (-q) Do not output any message
<info>--verbose</info> (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
<info>--version</info> (-V) Display this application version
<info>--ansi</info> Force ANSI output
<info>--no-ansi</info> Disable ANSI output
<info>--no-interaction</info> (-n) Do not ask any interactive question
<info>-h, --help</info> Display this help message
<info>-q, --quiet</info> Do not output any message
<info>-V, --version</info> Display this application version
<info> --ansi</info> Force ANSI output
<info> --no-ansi</info> Disable ANSI output
<info>-n, --no-interaction</info> Do not ask any interactive question
<info>-v|vv|vvv, --verbose</info> Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
<comment>Available commands:</comment>
<info>help </info> Displays help for a command
<info>list </info> Lists commands
<info>help</info> Displays help for a command
<info>list</info> Lists commands

View File

@ -2,7 +2,9 @@
<symfony>
<commands>
<command id="help" name="help">
<usage>help [--xml] [--format="..."] [--raw] [command_name]</usage>
<usages>
<usage>help [--xml] [--format FORMAT] [--raw] [--] [&lt;command_name&gt;]</usage>
</usages>
<description>Displays help for a command</description>
<help>The &lt;info&gt;help&lt;/info&gt; command displays help for a given command:
@ -13,7 +15,6 @@
&lt;info&gt;php app/console help --format=xml list&lt;/info&gt;
To display the list of available commands, please use the &lt;info&gt;list&lt;/info&gt; command.</help>
<aliases/>
<arguments>
<argument name="command_name" is_required="0" is_array="0">
<description>The command name</description>
@ -59,7 +60,9 @@
</options>
</command>
<command id="list" name="list">
<usage>list [--xml] [--raw] [--format="..."] [namespace]</usage>
<usages>
<usage>list [--xml] [--raw] [--format FORMAT] [--] [&lt;namespace&gt;]</usage>
</usages>
<description>Lists commands</description>
<help>The &lt;info&gt;list&lt;/info&gt; command lists all commands:
@ -76,7 +79,6 @@
It's also possible to get raw list of commands (useful for embedding command runner):
&lt;info&gt;php app/console list --raw&lt;/info&gt;</help>
<aliases/>
<arguments>
<argument name="namespace" is_required="0" is_array="0">
<description>The namespace name</description>

File diff suppressed because one or more lines are too long

View File

@ -15,8 +15,9 @@ help
----
* Description: Displays help for a command
* Usage: `help [--xml] [--format="..."] [--raw] [command_name]`
* Aliases: <none>
* Usage:
* `help [--xml] [--format FORMAT] [--raw] [--] [<command_name>]`
The <info>help</info> command displays help for a given command:
@ -144,8 +145,9 @@ list
----
* Description: Lists commands
* Usage: `list [--xml] [--raw] [--format="..."] [namespace]`
* Aliases: <none>
* Usage:
* `list [--xml] [--raw] [--format FORMAT] [--] [<namespace>]`
The <info>list</info> command lists all commands:
@ -209,8 +211,11 @@ descriptor:command1
-------------------
* Description: command 1 description
* Usage: `descriptor:command1`
* Aliases: `alias1`, `alias2`
* Usage:
* `descriptor:command1`
* `alias1`
* `alias2`
command 1 help
@ -290,8 +295,11 @@ descriptor:command2
-------------------
* Description: command 2 description
* Usage: `descriptor:command2 [-o|--option_name] argument_name`
* Aliases: <none>
* Usage:
* `descriptor:command2 [-o|--option_name] [--] <argument_name>`
* `descriptor:command2 -o|--option_name <argument_name>`
* `descriptor:command2 <argument_name>`
command 2 help

View File

@ -1,22 +1,22 @@
<info>My Symfony application</info> version <comment>v1.0</comment>
<comment>Usage:</comment>
command [options] [arguments]
command [options] [arguments]
<comment>Options:</comment>
<info>--help</info> (-h) Display this help message
<info>--quiet</info> (-q) Do not output any message
<info>--verbose</info> (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
<info>--version</info> (-V) Display this application version
<info>--ansi</info> Force ANSI output
<info>--no-ansi</info> Disable ANSI output
<info>--no-interaction</info> (-n) Do not ask any interactive question
<info>-h, --help</info> Display this help message
<info>-q, --quiet</info> Do not output any message
<info>-V, --version</info> Display this application version
<info> --ansi</info> Force ANSI output
<info> --no-ansi</info> Disable ANSI output
<info>-n, --no-interaction</info> Do not ask any interactive question
<info>-v|vv|vvv, --verbose</info> Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
<comment>Available commands:</comment>
<info>alias1 </info> command 1 description
<info>alias2 </info> command 1 description
<info>help </info> Displays help for a command
<info>list </info> Lists commands
<comment>descriptor</comment>
<info>descriptor:command1 </info> command 1 description
<info>descriptor:command2 </info> command 2 description
<info>alias1</info> command 1 description
<info>alias2</info> command 1 description
<info>help</info> Displays help for a command
<info>list</info> Lists commands
<comment>descriptor</comment>
<info>descriptor:command1</info> command 1 description
<info>descriptor:command2</info> command 2 description

View File

@ -2,7 +2,9 @@
<symfony name="My Symfony application" version="v1.0">
<commands>
<command id="help" name="help">
<usage>help [--xml] [--format="..."] [--raw] [command_name]</usage>
<usages>
<usage>help [--xml] [--format FORMAT] [--raw] [--] [&lt;command_name&gt;]</usage>
</usages>
<description>Displays help for a command</description>
<help>The &lt;info&gt;help&lt;/info&gt; command displays help for a given command:
@ -13,7 +15,6 @@
&lt;info&gt;php app/console help --format=xml list&lt;/info&gt;
To display the list of available commands, please use the &lt;info&gt;list&lt;/info&gt; command.</help>
<aliases/>
<arguments>
<argument name="command_name" is_required="0" is_array="0">
<description>The command name</description>
@ -59,7 +60,9 @@
</options>
</command>
<command id="list" name="list">
<usage>list [--xml] [--raw] [--format="..."] [namespace]</usage>
<usages>
<usage>list [--xml] [--raw] [--format FORMAT] [--] [&lt;namespace&gt;]</usage>
</usages>
<description>Lists commands</description>
<help>The &lt;info&gt;list&lt;/info&gt; command lists all commands:
@ -76,7 +79,6 @@
It's also possible to get raw list of commands (useful for embedding command runner):
&lt;info&gt;php app/console list --raw&lt;/info&gt;</help>
<aliases/>
<arguments>
<argument name="namespace" is_required="0" is_array="0">
<description>The namespace name</description>
@ -99,13 +101,13 @@
</options>
</command>
<command id="descriptor:command1" name="descriptor:command1">
<usage>descriptor:command1</usage>
<usages>
<usage>descriptor:command1</usage>
<usage>alias1</usage>
<usage>alias2</usage>
</usages>
<description>command 1 description</description>
<help>command 1 help</help>
<aliases>
<alias>alias1</alias>
<alias>alias2</alias>
</aliases>
<arguments/>
<options>
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
@ -132,10 +134,13 @@
</options>
</command>
<command id="descriptor:command2" name="descriptor:command2">
<usage>descriptor:command2 [-o|--option_name] argument_name</usage>
<usages>
<usage>descriptor:command2 [-o|--option_name] [--] &lt;argument_name&gt;</usage>
<usage>descriptor:command2 -o|--option_name &lt;argument_name&gt;</usage>
<usage>descriptor:command2 &lt;argument_name&gt;</usage>
</usages>
<description>command 2 description</description>
<help>command 2 help</help>
<aliases/>
<arguments>
<argument name="argument_name" is_required="1" is_array="0">
<description></description>

View File

@ -1,20 +1,20 @@
<info>Console Tool</info>
<comment>Usage:</comment>
command [options] [arguments]
command [options] [arguments]
<comment>Options:</comment>
<info>--help</info> (-h) Display this help message
<info>--quiet</info> (-q) Do not output any message
<info>--verbose</info> (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
<info>--version</info> (-V) Display this application version
<info>--ansi</info> Force ANSI output
<info>--no-ansi</info> Disable ANSI output
<info>--no-interaction</info> (-n) Do not ask any interactive question
<info>-h, --help</info> Display this help message
<info>-q, --quiet</info> Do not output any message
<info>-V, --version</info> Display this application version
<info> --ansi</info> Force ANSI output
<info> --no-ansi</info> Disable ANSI output
<info>-n, --no-interaction</info> Do not ask any interactive question
<info>-v|vv|vvv, --verbose</info> Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
<comment>Available commands:</comment>
<info>afoobar </info> The foo:bar command
<info>help </info> Displays help for a command
<info>list </info> Lists commands
<comment>foo</comment>
<info>foo:bar </info> The foo:bar command
<info>afoobar</info> The foo:bar command
<info>help</info> Displays help for a command
<info>list</info> Lists commands
<comment>foo</comment>
<info>foo:bar</info> The foo:bar command

View File

@ -1,16 +1,16 @@
<info>Console Tool</info>
<comment>Usage:</comment>
command [options] [arguments]
command [options] [arguments]
<comment>Options:</comment>
<info>--help</info> (-h) Display this help message
<info>--quiet</info> (-q) Do not output any message
<info>--verbose</info> (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
<info>--version</info> (-V) Display this application version
<info>--ansi</info> Force ANSI output
<info>--no-ansi</info> Disable ANSI output
<info>--no-interaction</info> (-n) Do not ask any interactive question
<info>-h, --help</info> Display this help message
<info>-q, --quiet</info> Do not output any message
<info>-V, --version</info> Display this application version
<info> --ansi</info> Force ANSI output
<info> --no-ansi</info> Disable ANSI output
<info>-n, --no-interaction</info> Do not ask any interactive question
<info>-v|vv|vvv, --verbose</info> Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
<comment>Available commands for the "foo" namespace:</comment>
<info>foo:bar </info> The foo:bar command
<info>foo:bar</info> The foo:bar command

View File

@ -2,7 +2,9 @@
<symfony>
<commands>
<command id="help" name="help">
<usage>help [--xml] [--format="..."] [--raw] [command_name]</usage>
<usages>
<usage>help [--xml] [--format FORMAT] [--raw] [--] [&lt;command_name&gt;]</usage>
</usages>
<description>Displays help for a command</description>
<help>The &lt;info&gt;help&lt;/info&gt; command displays help for a given command:
@ -13,7 +15,6 @@
&lt;info&gt;php app/console help --format=xml list&lt;/info&gt;
To display the list of available commands, please use the &lt;info&gt;list&lt;/info&gt; command.</help>
<aliases />
<arguments>
<argument name="command_name" is_required="0" is_array="0">
<description>The command name</description>
@ -59,7 +60,9 @@
</options>
</command>
<command id="list" name="list">
<usage>list [--xml] [--raw] [--format="..."] [namespace]</usage>
<usages>
<usage>list [--xml] [--raw] [--format FORMAT] [--] [&lt;namespace&gt;]</usage>
</usages>
<description>Lists commands</description>
<help>The &lt;info&gt;list&lt;/info&gt; command lists all commands:
@ -76,7 +79,6 @@
It's also possible to get raw list of commands (useful for embedding command runner):
&lt;info&gt;php app/console list --raw&lt;/info&gt;</help>
<aliases/>
<arguments>
<argument name="namespace" is_required="0" is_array="0">
<description>The namespace name</description>
@ -99,12 +101,12 @@
</options>
</command>
<command id="foo:bar" name="foo:bar">
<usage>foo:bar</usage>
<usages>
<usage>foo:bar</usage>
<usage>afoobar</usage>
</usages>
<description>The foo:bar command</description>
<help/>
<aliases>
<alias>afoobar</alias>
</aliases>
<arguments/>
<options>
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">

View File

@ -2,12 +2,12 @@
<symfony>
<commands namespace="foo">
<command id="foo:bar" name="foo:bar">
<usage>foo:bar</usage>
<usages>
<usage>foo:bar</usage>
<usage>afoobar</usage>
</usages>
<description>The foo:bar command</description>
<help/>
<aliases>
<alias>afoobar</alias>
</aliases>
<arguments/>
<options>
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">

View File

@ -6,6 +6,6 @@
list [--xml] [--raw] [--format="..."] [namespace]
list [--xml] [--raw] [--format FORMAT] [--] [<namespace>]

View File

@ -1,17 +1,17 @@
Console Tool
Usage:
command [options] [arguments]
command [options] [arguments]
Options:
--help (-h) Display this help message
--quiet (-q) Do not output any message
--verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
--version (-V) Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
--no-interaction (-n) Do not ask any interactive question
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
help Displays help for a command
list Lists commands
help Displays help for a command
list Lists commands

View File

@ -1,21 +1,21 @@
Usage:
help [--xml] [--format="..."] [--raw] [command_name]
help [options] [--] [<command_name>]
Arguments:
command The command to execute
command_name The command name (default: "help")
command The command to execute
command_name The command name [default: "help"]
Options:
--xml To output help as XML
--format To output help in other formats (default: "txt")
--raw To output raw command help
--help (-h) Display this help message
--quiet (-q) Do not output any message
--verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
--version (-V) Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
--no-interaction (-n) Do not ask any interactive question
--xml To output help as XML
--format=FORMAT To output help in other formats [default: "txt"]
--raw To output raw command help
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Help:
The help command displays help for a given command:

View File

@ -1,13 +1,13 @@
Usage:
list [--xml] [--raw] [--format="..."] [namespace]
list [options] [--] [<namespace>]
Arguments:
namespace The namespace name
namespace The namespace name
Options:
--xml To output list as XML
--raw To output raw command list
--format To output list in other formats (default: "txt")
--xml To output list as XML
--raw To output raw command list
--format=FORMAT To output list in other formats [default: "txt"]
Help:
The list command lists all commands:

View File

@ -1 +1 @@
{"name":"descriptor:command1","usage":"descriptor:command1","description":"command 1 description","help":"command 1 help","aliases":["alias1","alias2"],"definition":{"arguments":[],"options":[]}}
{"name":"descriptor:command1","usage":["descriptor:command1", "alias1", "alias2"],"description":"command 1 description","help":"command 1 help","definition":{"arguments":[],"options":[]}}

View File

@ -2,7 +2,10 @@ descriptor:command1
-------------------
* Description: command 1 description
* Usage: `descriptor:command1`
* Aliases: `alias1`, `alias2`
* Usage:
* `descriptor:command1`
* `alias1`
* `alias2`
command 1 help

View File

@ -1,7 +1,7 @@
<comment>Usage:</comment>
descriptor:command1
<comment>Aliases:</comment> <info>alias1, alias2</info>
descriptor:command1
alias1
alias2
<comment>Help:</comment>
command 1 help

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<command id="descriptor:command1" name="descriptor:command1">
<usage>descriptor:command1</usage>
<usages>
<usage>descriptor:command1</usage>
<usage>alias1</usage>
<usage>alias2</usage>
</usages>
<description>command 1 description</description>
<help>command 1 help</help>
<aliases>
<alias>alias1</alias>
<alias>alias2</alias>
</aliases>
<arguments/>
<options/>
</command>

View File

@ -1 +1 @@
{"name":"descriptor:command2","usage":"descriptor:command2 [-o|--option_name] argument_name","description":"command 2 description","help":"command 2 help","aliases":[],"definition":{"arguments":{"argument_name":{"name":"argument_name","is_required":true,"is_array":false,"description":"","default":null}},"options":{"option_name":{"name":"--option_name","shortcut":"-o","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"","default":false}}}}
{"name":"descriptor:command2","usage":["descriptor:command2 [-o|--option_name] [--] <argument_name>", "descriptor:command2 -o|--option_name <argument_name>", "descriptor:command2 <argument_name>"],"description":"command 2 description","help":"command 2 help","definition":{"arguments":{"argument_name":{"name":"argument_name","is_required":true,"is_array":false,"description":"","default":null}},"options":{"option_name":{"name":"--option_name","shortcut":"-o","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"","default":false}}}}

View File

@ -2,8 +2,11 @@ descriptor:command2
-------------------
* Description: command 2 description
* Usage: `descriptor:command2 [-o|--option_name] argument_name`
* Aliases: <none>
* Usage:
* `descriptor:command2 [-o|--option_name] [--] <argument_name>`
* `descriptor:command2 -o|--option_name <argument_name>`
* `descriptor:command2 <argument_name>`
command 2 help

View File

@ -1,11 +1,13 @@
<comment>Usage:</comment>
descriptor:command2 [-o|--option_name] argument_name
descriptor:command2 [options] [--] <argument_name>
descriptor:command2 -o|--option_name <argument_name>
descriptor:command2 <argument_name>
<comment>Arguments:</comment>
<info>argument_name </info>
<info>argument_name</info>
<comment>Options:</comment>
<info>--option_name</info> (-o)
<info>-o, --option_name</info>
<comment>Help:</comment>
command 2 help

View File

@ -1,9 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<command id="descriptor:command2" name="descriptor:command2">
<usage>descriptor:command2 [-o|--option_name] argument_name</usage>
<usages>
<usage>descriptor:command2 [-o|--option_name] [--] &lt;argument_name&gt;</usage>
<usage>descriptor:command2 -o|--option_name &lt;argument_name&gt;</usage>
<usage>descriptor:command2 &lt;argument_name&gt;</usage>
</usages>
<description>command 2 description</description>
<help>command 2 help</help>
<aliases/>
<arguments>
<argument name="argument_name" is_required="1" is_array="0">
<description></description>

View File

@ -1,18 +1,18 @@
<comment>Usage:</comment>
namespace:name
namespace:name
name
<comment>Aliases:</comment> <info>name</info>
<comment>Arguments:</comment>
<info>command </info> The command to execute
<info>command</info> The command to execute
<comment>Options:</comment>
<info>--help</info> (-h) Display this help message
<info>--quiet</info> (-q) Do not output any message
<info>--verbose</info> (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
<info>--version</info> (-V) Display this application version
<info>--ansi</info> Force ANSI output
<info>--no-ansi</info> Disable ANSI output
<info>--no-interaction</info> (-n) Do not ask any interactive question
<info>-h, --help</info> Display this help message
<info>-q, --quiet</info> Do not output any message
<info>-V, --version</info> Display this application version
<info> --ansi</info> Force ANSI output
<info> --no-ansi</info> Disable ANSI output
<info>-n, --no-interaction</info> Do not ask any interactive question
<info>-v|vv|vvv, --verbose</info> Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
<comment>Help:</comment>
help

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<command id="namespace:name" name="namespace:name">
<usage>namespace:name</usage>
<usages>
<usage>namespace:name</usage>
<usage>name</usage>
</usages>
<description>description</description>
<help>help</help>
<aliases>
<alias>name</alias>
</aliases>
<arguments>
<argument name="command" is_required="1" is_array="0">
<description>The command to execute</description>

View File

@ -1,11 +1,11 @@
<comment>Arguments:</comment>
<info>foo </info> The foo argument
<info>baz </info> The baz argument<comment> (default: true)</comment>
<info>bar </info> The bar argument<comment> (default: ["http://foo.com/"])</comment>
<info>foo</info> The foo argument
<info>baz</info> The baz argument<comment> [default: true]</comment>
<info>bar</info> The bar argument<comment> [default: ["http://foo.com/"]]</comment>
<comment>Options:</comment>
<info>--foo</info> (-f) The foo option
<info>--baz</info> The baz option<comment> (default: false)</comment>
<info>--bar</info> (-b) The bar option<comment> (default: "bar")</comment>
<info>--qux</info> The qux option<comment> (default: ["http://foo.com/","bar"])</comment><comment> (multiple values allowed)</comment>
<info>--qux2</info> The qux2 option<comment> (default: {"foo":"bar"})</comment><comment> (multiple values allowed)</comment>
<info>-f, --foo=FOO</info> The foo option
<info> --baz[=BAZ]</info> The baz option<comment> [default: false]</comment>
<info>-b, --bar[=BAR]</info> The bar option<comment> [default: "bar"]</comment>
<info> --qux[=QUX]</info> The qux option<comment> [default: ["http://foo.com/","bar"]]</comment><comment> (multiple values allowed)</comment>
<info> --qux2[=QUX2]</info> The qux2 option<comment> [default: {"foo":"bar"}]</comment><comment> (multiple values allowed)</comment>

View File

@ -1 +1 @@
<info>argument_name</info>
<info>argument_name</info>

View File

@ -1 +1 @@
<info>argument_name</info> argument description
<info>argument_name</info> argument description

View File

@ -1 +1 @@
<info>argument_name</info> argument description<comment> (default: "default_value")</comment>
<info>argument_name</info> argument description<comment> [default: "default_value"]</comment>

View File

@ -0,0 +1 @@
{"name":"argument_name","is_required":true,"is_array":false,"description":"multiline argument description","default":null}

View File

@ -0,0 +1,8 @@
**argument_name:**
* Name: argument_name
* Is required: yes
* Is array: no
* Description: multiline
argument description
* Default: `NULL`

View File

@ -0,0 +1,2 @@
<info>argument_name</info> multiline
argument description

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<argument name="argument_name" is_required="1" is_array="0">
<description>multiline
argument description</description>
<defaults/>
</argument>

View File

@ -1,2 +1,2 @@
<comment>Arguments:</comment>
<info>argument_name </info>
<info>argument_name</info>

View File

@ -1,2 +1,2 @@
<comment>Options:</comment>
<info>--option_name</info> (-o)
<info>-o, --option_name</info>

View File

@ -1,5 +1,5 @@
<comment>Arguments:</comment>
<info>argument_name </info>
<info>argument_name</info>
<comment>Options:</comment>
<info>--option_name</info> (-o)
<info>-o, --option_name</info>

View File

@ -1 +1 @@
<info>--option_name</info> (-o)
<info>-o, --option_name</info>

View File

@ -1 +1 @@
<info>--option_name</info> (-o) option description<comment> (default: "default_value")</comment>
<info>-o, --option_name[=OPTION_NAME]</info> option description<comment> [default: "default_value"]</comment>

View File

@ -1 +1 @@
<info>--option_name</info> (-o) option description
<info>-o, --option_name=OPTION_NAME</info> option description

View File

@ -1 +1 @@
<info>--option_name</info> (-o) option description<comment> (multiple values allowed)</comment>
<info>-o, --option_name[=OPTION_NAME]</info> option description<comment> (multiple values allowed)</comment>

View File

@ -0,0 +1 @@
{"name":"--option_name","shortcut":"-o","accept_value":true,"is_value_required":true,"is_multiple":false,"description":"multiline option description","default":null}

View File

@ -0,0 +1,10 @@
**option_name:**
* Name: `--option_name`
* Shortcut: `-o`
* Accept value: yes
* Is value required: yes
* Is multiple: no
* Description: multiline
option description
* Default: `NULL`

View File

@ -0,0 +1,2 @@
<info>-o, --option_name=OPTION_NAME</info> multiline
option description

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<option name="--option_name" shortcut="-o" accept_value="1" is_value_required="1" is_multiple="0">
<description>multiline
option description</description>
<defaults/>
</option>

View File

@ -352,25 +352,35 @@ class InputDefinitionTest extends \PHPUnit_Framework_TestCase
$this->assertSame($defaults, $definition->getOptionDefaults(), '->getOptionDefaults() returns the default values for all options');
}
public function testGetSynopsis()
/**
* @dataProvider getGetSynopsisData
*/
public function testGetSynopsis(InputDefinition $definition, $expectedSynopsis, $message = null)
{
$definition = new InputDefinition(array(new InputOption('foo')));
$this->assertEquals('[--foo]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options');
$definition = new InputDefinition(array(new InputOption('foo', 'f')));
$this->assertEquals('[-f|--foo]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options');
$definition = new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)));
$this->assertEquals('[-f|--foo="..."]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options');
$definition = new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)));
$this->assertEquals('[-f|--foo[="..."]]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options');
$this->assertEquals($expectedSynopsis, $definition->getSynopsis(), $message ? '->getSynopsis() '.$message : '');
}
$definition = new InputDefinition(array(new InputArgument('foo')));
$this->assertEquals('[foo]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options');
$definition = new InputDefinition(array(new InputArgument('foo', InputArgument::REQUIRED)));
$this->assertEquals('foo', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options');
$definition = new InputDefinition(array(new InputArgument('foo', InputArgument::IS_ARRAY)));
$this->assertEquals('[foo1] ... [fooN]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options');
$definition = new InputDefinition(array(new InputArgument('foo', InputArgument::REQUIRED | InputArgument::IS_ARRAY)));
$this->assertEquals('foo1 ... [fooN]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options');
public function getGetSynopsisData()
{
return array(
array(new InputDefinition(array(new InputOption('foo'))), '[--foo]', 'puts optional options in square brackets'),
array(new InputDefinition(array(new InputOption('foo', 'f'))), '[-f|--foo]', 'separates shortcut with a pipe'),
array(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED))), '[-f|--foo FOO]', 'uses shortcut as value placeholder'),
array(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL))), '[-f|--foo [FOO]]', 'puts optional values in square brackets'),
array(new InputDefinition(array(new InputArgument('foo', InputArgument::REQUIRED))), '<foo>', 'puts arguments in angle brackets'),
array(new InputDefinition(array(new InputArgument('foo'))), '[<foo>]', 'puts optional arguments in square brackets'),
array(new InputDefinition(array(new InputArgument('foo', InputArgument::IS_ARRAY))), '[<foo>]...', 'uses an ellipsis for array arguments'),
array(new InputDefinition(array(new InputArgument('foo', InputArgument::REQUIRED | InputArgument::IS_ARRAY))), '<foo> (<foo>)...', 'uses parenthesis and ellipsis for required array arguments'),
array(new InputDefinition(array(new InputOption('foo'), new InputArgument('foo', InputArgument::REQUIRED))), '[--foo] [--] <foo>', 'puts [--] between options and arguments'),
);
}
public function testGetShortSynopsis()
{
$definition = new InputDefinition(array(new InputOption('foo'), new InputOption('bar'), new InputArgument('cat')));
$this->assertEquals('[options] [--] [<cat>]', $definition->getSynopsis(true), '->getSynopsis(true) groups options in [options]');
}
protected function initializeArguments()

View File

@ -768,7 +768,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
*/
public function register($id, $class = null)
{
return $this->setDefinition(strtolower($id), new Definition($class));
return $this->setDefinition($id, new Definition($class));
}
/**

View File

@ -986,6 +986,13 @@ HTML;
);
}
public function testCountOfNestedElements()
{
$crawler = new Crawler('<html><body><ul><li>List item 1<ul><li>Sublist item 1</li><li>Sublist item 2</ul></li></ul></body></html>');
$this->assertCount(1, $crawler->filter('li:contains("List item 1")'));
}
public function createTestCrawler($uri = null)
{
$dom = new \DOMDocument();

View File

@ -132,8 +132,6 @@ class FinderTest extends Iterator\RealIteratorTestCase
/**
* @dataProvider getRegexNameTestData
*
* @group regexName
*/
public function testRegexName($adapter, $regex)
{
@ -506,7 +504,6 @@ class FinderTest extends Iterator\RealIteratorTestCase
/**
* @dataProvider getContainsTestData
* @group grep
*/
public function testContains($adapter, $matchPatterns, $noMatchPatterns, $expected)
{

View File

@ -9,16 +9,17 @@
* file that was distributed with this source code.
*/
namespace Symfony\Component\Form\ChoiceList\View;
use Symfony\Component\Form\Extension\Core\View\ChoiceView as LegacyChoiceView;
namespace Symfony\Component\Form\Extension\Core\View;
/**
* Represents a choice in templates.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @deprecated since version 2.7, to be removed in 3.0.
* Use {@link \Symfony\Component\Form\ChoiceList\View\ChoiceView} instead.
*/
class ChoiceView extends LegacyChoiceView
class ChoiceView
{
/**
* The label displayed to humans.
@ -41,6 +42,32 @@ class ChoiceView extends LegacyChoiceView
*/
public $data;
/**
* Creates a new ChoiceView.
*
* @param mixed $data The original choice.
* @param string $value The view representation of the choice.
* @param string $label The label displayed to humans.
*/
public function __construct($data, $value, $label)
{
$this->data = $data;
$this->value = $value;
$this->label = $label;
}
}
namespace Symfony\Component\Form\ChoiceList\View;
use Symfony\Component\Form\Extension\Core\View\ChoiceView as LegacyChoiceView;
/**
* Represents a choice in templates.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class ChoiceView extends LegacyChoiceView
{
/**
* Additional attributes for the HTML tag.
*
@ -58,9 +85,8 @@ class ChoiceView extends LegacyChoiceView
*/
public function __construct($label, $value, $data, array $attr = array())
{
$this->label = $label;
$this->value = $value;
$this->data = $data;
parent::__construct($data, $value, $label);
$this->attr = $attr;
}
}

View File

@ -34,7 +34,7 @@ use Symfony\Component\Form\Extension\Core\View\ChoiceView;
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @deprecated Deprecated since Symfony 2.7, to be removed in Symfony 3.0.
* @deprecated since version 2.7, to be removed in 3.0.
* Use {@link \Symfony\Component\Form\ChoiceList\ArrayChoiceList} instead.
*/
class ChoiceList implements ChoiceListInterface

View File

@ -28,7 +28,7 @@ use Symfony\Component\Form\ChoiceList\ChoiceListInterface as BaseChoiceListInter
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @deprecated Deprecated since Symfony 2.7, to be removed in Symfony 3.0.
* @deprecated since version 2.7, to be removed in 3.0.
* Use {@link BaseChoiceListInterface} instead.
*/
interface ChoiceListInterface extends BaseChoiceListInterface

View File

@ -22,9 +22,8 @@ use Symfony\Component\Form\Exception\InvalidArgumentException;
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @deprecated Deprecated since Symfony 2.7, to be removed in Symfony 3.0.
* Use {@link \Symfony\Component\Form\ChoiceList\LazyChoiceList}
* instead.
* @deprecated since version 2.7, to be removed in 3.0.
* Use {@link \Symfony\Component\Form\ChoiceList\LazyChoiceList} instead.
*/
abstract class LazyChoiceList implements ChoiceListInterface
{

View File

@ -33,9 +33,8 @@ use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @deprecated Deprecated since Symfony 2.7, to be removed in Symfony 3.0.
* Use {@link \Symfony\Component\Form\ChoiceList\ArrayChoiceList}
* instead.
* @deprecated since Symfony 2.7, to be removed in version 3.0.
* Use {@link \Symfony\Component\Form\ChoiceList\ArrayChoiceList} instead.
*/
class ObjectChoiceList extends ChoiceList
{

View File

@ -29,9 +29,8 @@ namespace Symfony\Component\Form\Extension\Core\ChoiceList;
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @deprecated Deprecated since Symfony 2.7, to be removed in Symfony 3.0.
* Use {@link \Symfony\Component\Form\ChoiceList\ArrayChoiceList}
* instead.
* @deprecated since version 2.7, to be removed in 3.0.
* Use {@link \Symfony\Component\Form\ChoiceList\ArrayChoiceList} instead.
*/
class SimpleChoiceList extends ChoiceList
{

View File

@ -18,9 +18,8 @@ use Symfony\Component\Form\Exception\TransformationFailedException;
/**
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @deprecated Deprecated since Symfony 2.7, to be removed in Symfony 3.0.
* Use {@link \Symfony\Component\Form\ChoiceList\LazyChoiceList}
* instead.
* @deprecated since version 2.7, to be removed in 3.0.
* Use {@link \Symfony\Component\Form\ChoiceList\LazyChoiceList} instead.
*/
class ChoiceToBooleanArrayTransformer implements DataTransformerInterface
{

View File

@ -18,9 +18,8 @@ use Symfony\Component\Form\Exception\TransformationFailedException;
/**
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @deprecated Deprecated since Symfony 2.7, to be removed in Symfony 3.0.
* Use {@link \Symfony\Component\Form\ChoiceList\LazyChoiceList}
* instead.
* @deprecated since version 2.7, to be removed in 3.0.
* Use {@link \Symfony\Component\Form\ChoiceList\LazyChoiceList} instead.
*/
class ChoicesToBooleanArrayTransformer implements DataTransformerInterface
{

View File

@ -23,9 +23,8 @@ use Symfony\Component\Form\FormEvents;
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @deprecated Deprecated since Symfony 2.7, to be removed in Symfony 3.0.
* Use {@link \Symfony\Component\Form\Extension\Core\DataMapper\CheckboxListMapper}
* instead.
* @deprecated since version 2.7, to be removed in 3.0.
* Use {@link \Symfony\Component\Form\Extension\Core\DataMapper\CheckboxListMapper} instead.
*/
class FixCheckboxInputListener implements EventSubscriberInterface
{

View File

@ -22,9 +22,8 @@ use Symfony\Component\Form\FormEvents;
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @deprecated Deprecated since Symfony 2.7, to be removed in Symfony 3.0.
* Use {@link \Symfony\Component\Form\Extension\Core\DataMapper\RadioListMapper}
* instead.
* @deprecated since version 2.7, to be removed in 3.0.
* Use {@link \Symfony\Component\Form\Extension\Core\DataMapper\RadioListMapper} instead.
*/
class FixRadioInputListener implements EventSubscriberInterface
{

View File

@ -11,50 +11,14 @@
namespace Symfony\Component\Form\Extension\Core\View;
trigger_error('The '.__NAMESPACE__.'\ChoiceView class is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\ChoiceList\View\ChoiceView instead.', E_USER_DEPRECATED);
/**
* Represents a choice in templates.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @deprecated Deprecated since Symfony 2.7, to be removed in Symfony 3.0.
* @deprecated since version 2.7, to be removed in 3.0.
* Use {@link \Symfony\Component\Form\ChoiceList\View\ChoiceView} instead.
*/
class ChoiceView
{
/**
* The original choice value.
*
* @var mixed
*/
public $data;
/**
* The view representation of the choice.
*
* @var string
*/
public $value;
/**
* The label displayed to humans.
*
* @var string
*/
public $label;
/**
* Creates a new ChoiceView.
*
* @param mixed $data The original choice.
* @param string $value The view representation of the choice.
* @param string $label The label displayed to humans.
*/
public function __construct($data, $value, $label)
{
$this->data = $data;
$this->value = $value;
$this->label = $label;
trigger_error('The '.__CLASS__.' class is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\ChoiceList\View\ChoiceView instead.', E_USER_DEPRECATED);
}
}
class_exists('Symfony\Component\Form\ChoiceList\View\ChoiceView');

View File

@ -71,7 +71,7 @@ interface FormTypeInterface
/**
* Configures the options for this type.
*
* @param OptionsResolver $resolver The resolver for the options.
* @param OptionsResolver $resolver The resolver for the options
*/
public function configureOptions(OptionsResolver $resolver);

View File

@ -139,7 +139,7 @@ class File extends \SplFileInfo
$target = rtrim($directory, '/\\').DIRECTORY_SEPARATOR.(null === $name ? $this->getBasename() : $this->getName($name));
return new File($target, false);
return new self($target, false);
}
/**

View File

@ -79,7 +79,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
$line = $trace[$i]['line'];
while (++$i < 7) {
if (isset($trace[$i]['function']) && empty($trace[$i]['class']) && 'call_user_func' !== $trace[$i]['function']) {
if (isset($trace[$i]['function'], $trace[$i]['file']) && empty($trace[$i]['class']) && 0 !== strpos($trace[$i]['function'], 'call_user_func')) {
$file = $trace[$i]['file'];
$line = $trace[$i]['line'];

View File

@ -117,7 +117,7 @@ final class Intl
{
if (null === self::$currencyBundle) {
self::$currencyBundle = new CurrencyBundle(
self::getDataDirectory().'/'.Intl::CURRENCY_DIR,
self::getDataDirectory().'/'.self::CURRENCY_DIR,
self::getEntryReader(),
self::getLocaleBundle()
);
@ -135,11 +135,11 @@ final class Intl
{
if (null === self::$languageBundle) {
self::$languageBundle = new LanguageBundle(
self::getDataDirectory().'/'.Intl::LANGUAGE_DIR,
self::getDataDirectory().'/'.self::LANGUAGE_DIR,
self::getEntryReader(),
self::getLocaleBundle(),
new ScriptDataProvider(
self::getDataDirectory().'/'.Intl::SCRIPT_DIR,
self::getDataDirectory().'/'.self::SCRIPT_DIR,
self::getEntryReader()
)
);
@ -157,7 +157,7 @@ final class Intl
{
if (null === self::$localeBundle) {
self::$localeBundle = new LocaleBundle(
self::getDataDirectory().'/'.Intl::LOCALE_DIR,
self::getDataDirectory().'/'.self::LOCALE_DIR,
self::getEntryReader()
);
}
@ -174,7 +174,7 @@ final class Intl
{
if (null === self::$regionBundle) {
self::$regionBundle = new RegionBundle(
self::getDataDirectory().'/'.Intl::REGION_DIR,
self::getDataDirectory().'/'.self::REGION_DIR,
self::getEntryReader(),
self::getLocaleBundle()
);

View File

@ -798,9 +798,6 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($process->isSuccessful());
}
/**
* @group idle-timeout
*/
public function testIdleTimeout()
{
$process = $this->getProcess('php -r "sleep(3);"');
@ -818,21 +815,18 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
}
}
/**
* @group idle-timeout
*/
public function testIdleTimeoutNotExceededWhenOutputIsSent()
{
$process = $this->getProcess('php -r "echo \'foo\'; sleep(1); echo \'foo\'; sleep(1); echo \'foo\'; sleep(1); "');
$process = $this->getProcess(sprintf('php -r %s', escapeshellarg('$n = 30; while ($n--) {echo "foo\n"; usleep(100000); }')));
$process->setTimeout(2);
$process->setIdleTimeout(1.5);
$process->setIdleTimeout(1);
try {
$process->run();
$this->fail('A timeout exception was expected.');
} catch (ProcessTimedOutException $ex) {
$this->assertTrue($ex->isGeneralTimeout());
$this->assertFalse($ex->isIdleTimeout());
$this->assertTrue($ex->isGeneralTimeout(), 'A general timeout is expected.');
$this->assertFalse($ex->isIdleTimeout(), 'No idle timeout is expected.');
$this->assertEquals(2, $ex->getExceededTimeout());
}
}

View File

@ -76,7 +76,7 @@ class PropertyPath implements \IteratorAggregate, PropertyPathInterface
public function __construct($propertyPath)
{
// Can be used as copy constructor
if ($propertyPath instanceof PropertyPath) {
if ($propertyPath instanceof self) {
/* @var PropertyPath $propertyPath */
$this->elements = $propertyPath->elements;
$this->singulars = $propertyPath->singulars;

View File

@ -50,7 +50,7 @@ class DumperCollection implements \IteratorAggregate
*/
public function add($child)
{
if ($child instanceof DumperCollection) {
if ($child instanceof self) {
$child->setParent($this);
}
$this->children[] = $child;
@ -64,7 +64,7 @@ class DumperCollection implements \IteratorAggregate
public function setAll(array $children)
{
foreach ($children as $child) {
if ($child instanceof DumperCollection) {
if ($child instanceof self) {
$child->setParent($this);
}
}

View File

@ -66,7 +66,7 @@ class DumperPrefixCollection extends DumperCollection
// Prefix starts with route's prefix
if ('' === $collection->prefix || 0 === strpos($prefix, $collection->prefix)) {
$child = new DumperPrefixCollection();
$child = new self();
$child->setPrefix(substr($prefix, 0, strlen($collection->prefix) + 1));
$collection->add($child);

View File

@ -52,7 +52,7 @@ final class RoleSecurityIdentity implements SecurityIdentityInterface
*/
public function equals(SecurityIdentityInterface $sid)
{
if (!$sid instanceof RoleSecurityIdentity) {
if (!$sid instanceof self) {
return false;
}

View File

@ -102,7 +102,7 @@ final class UserSecurityIdentity implements SecurityIdentityInterface
*/
public function equals(SecurityIdentityInterface $sid)
{
if (!$sid instanceof UserSecurityIdentity) {
if (!$sid instanceof self) {
return false;
}

View File

@ -76,6 +76,7 @@ class StopwatchEventTest extends \PHPUnit_Framework_TestCase
$event->start();
usleep(100000);
$event->stop();
usleep(50000);
$event->start();
usleep(100000);
$event->stop();
@ -93,6 +94,7 @@ class StopwatchEventTest extends \PHPUnit_Framework_TestCase
$event->start();
usleep(100000);
$event->stop();
usleep(50000);
$event->start();
usleep(100000);
$this->assertEquals(100, $event->getDuration(), null, self::DELTA);

View File

@ -11,6 +11,7 @@
namespace Symfony\Component\Translation\Tests;
use Symfony\Component\Translation\Loader\ArrayLoader;
use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation\MessageCatalogue;
use Symfony\Component\Translation\MessageSelector;
@ -164,6 +165,37 @@ class TranslatorCacheTest extends \PHPUnit_Framework_TestCase
}
}
public function testDifferentCacheFilesAreUsedForDifferentSetsOfFallbackLocales()
{
/*
* Because the cache file contains a catalogue including all of its fallback
* catalogues (either "inlined" in Symfony 2.7 production or "standalone"),
* we must take the active set of fallback locales into consideration when
* loading a catalogue from the cache.
*/
$translator = new Translator('a', null, $this->tmpDir);
$translator->setFallbackLocales(array('b'));
$translator->addLoader('array', new ArrayLoader());
$translator->addResource('array', array('foo' => 'foo (a)'), 'a');
$translator->addResource('array', array('bar' => 'bar (b)'), 'b');
$this->assertEquals('bar (b)', $translator->trans('bar'));
// Remove fallback locale
$translator->setFallbackLocales(array());
$this->assertEquals('bar', $translator->trans('bar'));
// Use a fresh translator with no fallback locales, result should be the same
$translator = new Translator('a', null, $this->tmpDir);
$translator->addLoader('array', new ArrayLoader());
$translator->addResource('array', array('foo' => 'foo (a)'), 'a');
$translator->addResource('array', array('bar' => 'bar (b)'), 'b');
$this->assertEquals('bar', $translator->trans('bar'));
}
protected function getCatalogue($locale, $messages)
{
$catalogue = new MessageCatalogue($locale);

View File

@ -354,9 +354,8 @@ class Translator implements TranslatorInterface, TranslatorBagInterface
}
$this->assertValidLocale($locale);
$cacheFile = $this->cacheDir.'/catalogue.'.$locale.'.php';
$self = $this; // required for PHP 5.3 where "$this" cannot be use()d in anonymous functions. Change in Symfony 3.0.
$cache = $this->getConfigCacheFactory()->cache($cacheFile,
$cache = $this->getConfigCacheFactory()->cache($this->getCatalogueCachePath($locale),
function (ConfigCacheInterface $cache) use ($self, $locale) {
$self->dumpCatalogue($locale, $cache);
}
@ -368,40 +367,12 @@ class Translator implements TranslatorInterface, TranslatorBagInterface
}
/* Read catalogue from cache. */
$catalogue = include $cache->getPath();
/*
* Gracefully handle the case when the cached catalogue is in an "old" format, without a resourcesHash
*/
$resourcesHash = null;
if (is_array($catalogue)) {
list($catalogue, $resourcesHash) = $catalogue;
}
if ($this->debug && $resourcesHash !== $this->getResourcesHash($locale)) {
/*
* This approach of resource checking has the disadvantage that a second
* type of freshness check happens based on content *inside* the cache, while
* the idea of ConfigCache is to make this check transparent to the client (and keeps
* the resources in a .meta file).
*
* Thus, we might run into the unfortunate situation that we just thought (a few lines above)
* that the cache is fresh -- and now that we look into it, we figure it's not.
*
* For now, just unlink the cache and try again. See
* https://github.com/symfony/symfony/pull/11862#issuecomment-54634631 and/or
* https://github.com/symfony/symfony/issues/7176 for possible better approaches.
*/
unlink($cacheFile);
$this->initializeCacheCatalogue($locale);
} else {
/* Initialize with catalogue from cache. */
$this->catalogues[$locale] = $catalogue;
}
$this->catalogues[$locale] = include $cache->getPath();
}
/**
* This method is public because it needs to be callable from a closure in PHP 5.3. It should be made protected (or even private, if possible) in 3.0.
*
* @internal
*/
public function dumpCatalogue($locale, ConfigCacheInterface $cache)
@ -414,15 +385,13 @@ class Translator implements TranslatorInterface, TranslatorBagInterface
use Symfony\Component\Translation\MessageCatalogue;
\$resourcesHash = '%s';
\$catalogue = new MessageCatalogue('%s', %s);
%s
return array(\$catalogue, \$resourcesHash);
return \$catalogue;
EOF
,
$this->getResourcesHash($locale),
$locale,
var_export($this->catalogues[$locale]->all(), true),
$fallbackContent
@ -476,13 +445,14 @@ EOF
return $fallbackContent;
}
private function getResourcesHash($locale)
private function getCatalogueCachePath($locale)
{
if (!isset($this->resources[$locale])) {
return '';
}
$catalogueHash = sha1(serialize(array(
'resources' => isset($this->resources[$locale]) ? $this->resources[$locale] : array(),
'fallback_locales' => $this->fallbackLocales,
)));
return sha1(serialize($this->resources[$locale]));
return $this->cacheDir.'/catalogue.'.$locale.'.'.$catalogueHash.'.php';
}
private function doLoadCatalogue($locale)

Some files were not shown because too many files have changed in this diff Show More