From 70f2b3eb8c538dea6130959353e94a4017dde1cc Mon Sep 17 00:00:00 2001 From: spdionis Date: Tue, 18 Nov 2014 02:17:03 +0200 Subject: [PATCH 1/6] global commands are always first in command list --- .../Descriptor/ApplicationDescription.php | 8 +++-- .../Console/Tests/Command/ListCommandTest.php | 32 +++++++++++++++++++ .../Console/Tests/Fixtures/Foo6Command.php | 13 ++++++++ 3 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php diff --git a/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php b/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php index 81aa1b0e27..511921cb24 100644 --- a/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php +++ b/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php @@ -134,15 +134,17 @@ class ApplicationDescription private function sortCommands(array $commands) { $namespacedCommands = array(); + $globalCommands = array(); foreach ($commands as $name => $command) { $key = $this->application->extractNamespace($name, 1); if (!$key) { - $key = '_global'; + $globalCommands['_global'][$name] = $command; + } else { + $namespacedCommands[$key][$name] = $command; } - - $namespacedCommands[$key][$name] = $command; } ksort($namespacedCommands); + $namespacedCommands = array_merge($globalCommands, $namespacedCommands); foreach ($namespacedCommands as &$commandsSet) { ksort($commandsSet); diff --git a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php index fbb9feeb68..cfc1b99dd3 100644 --- a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php @@ -61,4 +61,36 @@ EOF; $this->assertEquals($output, $commandTester->getDisplay(true)); } + + public function testExecuteListsCommandsNameAndNamespaceRaw() + { + require_once realpath(__DIR__.'/../Fixtures/Foo6Command.php'); + $application = new Application(); + $application->add(new \Foo6Command()); + $commandTester = new CommandTester($command = $application->get('list')); + $commandTester->execute(array('command' => $command->getName())); + $output = <<foo + foo:bar +EOF; + + $this->assertEquals($output, trim($commandTester->getDisplay(true))); + } } diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php b/src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php new file mode 100644 index 0000000000..20ec2679b7 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php @@ -0,0 +1,13 @@ +setName('foo:bar'); + } + +} From 2984f8ed605c4bbdce9411e3ad6d86400df236c2 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 5 Oct 2015 15:59:28 +0200 Subject: [PATCH 2/6] fixed previous commit --- .../Console/Tests/Command/ListCommandTest.php | 44 +++++++++++++------ .../Console/Tests/Fixtures/Foo6Command.php | 3 +- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php index cfc1b99dd3..d5b5bfbdbb 100644 --- a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php @@ -62,33 +62,49 @@ EOF; $this->assertEquals($output, $commandTester->getDisplay(true)); } - public function testExecuteListsCommandsNameAndNamespaceRaw() + public function testExecuteListsCommandsOrder() { require_once realpath(__DIR__.'/../Fixtures/Foo6Command.php'); $application = new Application(); $application->add(new \Foo6Command()); $commandTester = new CommandTester($command = $application->get('list')); - $commandTester->execute(array('command' => $command->getName())); + $commandTester->execute(array('command' => $command->getName()), array('decorated' => false)); $output = <<foo - foo:bar + help Displays help for a command + list Lists commands +0foo + 0foo:bar 0foo:bar command +EOF; + + $this->assertEquals($output, trim($commandTester->getDisplay(true))); + } + + public function testExecuteListsCommandsOrderRaw() + { + require_once realpath(__DIR__.'/../Fixtures/Foo6Command.php'); + $application = new Application(); + $application->add(new \Foo6Command()); + $commandTester = new CommandTester($command = $application->get('list')); + $commandTester->execute(array('command' => $command->getName(), '--raw' => true)); + $output = <<assertEquals($output, trim($commandTester->getDisplay(true))); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php b/src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php index 20ec2679b7..6ae987e484 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php @@ -7,7 +7,6 @@ class Foo6Command extends Command { protected function configure() { - $this->setName('foo:bar'); + $this->setName('0foo:bar')->setDescription('0foo:bar command'); } - } From a25beb623d02dafea8203e773a35fbcd901343eb Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 5 Oct 2015 19:32:31 +0200 Subject: [PATCH 3/6] Fix docblocks about callables --- .../Component/Finder/Iterator/CustomFilterIterator.php | 4 ++-- .../Component/HttpKernel/Controller/ControllerResolver.php | 2 +- .../Component/HttpKernel/Event/FilterControllerEvent.php | 2 -- src/Symfony/Component/Process/Process.php | 2 +- src/Symfony/Component/Templating/PhpEngine.php | 6 +++--- src/Symfony/Component/Translation/PluralizationRules.php | 4 ++-- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php b/src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php index 24b15d97ad..b43b88d98d 100644 --- a/src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php @@ -26,8 +26,8 @@ class CustomFilterIterator extends FilterIterator /** * Constructor. * - * @param \Iterator $iterator The Iterator to filter - * @param array $filters An array of PHP callbacks + * @param \Iterator $iterator The Iterator to filter + * @param callable[] $filters An array of PHP callbacks * * @throws \InvalidArgumentException */ diff --git a/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php b/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php index d3bc6ad2e8..fbdc993036 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php @@ -145,7 +145,7 @@ class ControllerResolver implements ControllerResolverInterface * * @param string $controller A Controller string * - * @return mixed A PHP callable + * @return callable A PHP callable * * @throws \InvalidArgumentException */ diff --git a/src/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php b/src/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php index b61999cd6d..77a5c1a2ad 100644 --- a/src/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php +++ b/src/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php @@ -29,8 +29,6 @@ class FilterControllerEvent extends KernelEvent { /** * The current controller. - * - * @var callable */ private $controller; diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index ec5d211e40..64f6d15cb9 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -1015,7 +1015,7 @@ class Process * * @param callback|null $callback The user defined PHP callback * - * @return callback A PHP callable + * @return \Closure A PHP closure */ protected function buildCallback($callback) { diff --git a/src/Symfony/Component/Templating/PhpEngine.php b/src/Symfony/Component/Templating/PhpEngine.php index 93da75bf35..bf3261b18e 100644 --- a/src/Symfony/Component/Templating/PhpEngine.php +++ b/src/Symfony/Component/Templating/PhpEngine.php @@ -354,8 +354,8 @@ class PhpEngine implements EngineInterface, \ArrayAccess /** * Adds an escaper for the given context. * - * @param string $context The escaper context (html, js, ...) - * @param mixed $escaper A PHP callable + * @param string $context The escaper context (html, js, ...) + * @param callable $escaper A PHP callable */ public function setEscaper($context, $escaper) { @@ -368,7 +368,7 @@ class PhpEngine implements EngineInterface, \ArrayAccess * * @param string $context The context name * - * @return mixed $escaper A PHP callable + * @return callable $escaper A PHP callable * * @throws \InvalidArgumentException */ diff --git a/src/Symfony/Component/Translation/PluralizationRules.php b/src/Symfony/Component/Translation/PluralizationRules.php index 4264e5c802..6d91da7fc6 100644 --- a/src/Symfony/Component/Translation/PluralizationRules.php +++ b/src/Symfony/Component/Translation/PluralizationRules.php @@ -190,8 +190,8 @@ class PluralizationRules /** * Overrides the default plural rule for a given locale. * - * @param string $rule A PHP callable - * @param string $locale The locale + * @param callable $rule A PHP callable + * @param string $locale The locale * * @throws \LogicException */ From 1ecbc672387c5a8101c86919eda9711eb2b6516c Mon Sep 17 00:00:00 2001 From: ogizanagi Date: Mon, 5 Oct 2015 19:46:50 +0200 Subject: [PATCH 4/6] [SecurityBundle] Remove duplicated require-dev --- src/Symfony/Bundle/SecurityBundle/composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Symfony/Bundle/SecurityBundle/composer.json b/src/Symfony/Bundle/SecurityBundle/composer.json index d135a9f96e..1ceb4ed0eb 100644 --- a/src/Symfony/Bundle/SecurityBundle/composer.json +++ b/src/Symfony/Bundle/SecurityBundle/composer.json @@ -32,7 +32,6 @@ "symfony/http-foundation": "~2.3", "symfony/twig-bundle": "~2.2", "symfony/twig-bridge": "~2.2,>=2.2.6", - "symfony/form": "~2.3", "symfony/process": "~2.0,>=2.0.5", "symfony/validator": "~2.2", "symfony/yaml": "~2.0,>=2.0.5", From 7bc836cc723aec221c733dd119e328c7b58d60bf Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 5 Oct 2015 23:04:03 +0200 Subject: [PATCH 5/6] compatibility with Security component split The FrameworkBundle in version 2.3 can be used with recent versions of the Security component. However, after the Security component has been split with Symfony 2.4, translations resources have been moved to the `symfony/security-core` package. Thus, the changed location must be taken into account. --- .../DependencyInjection/FrameworkExtension.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index c6801f56e2..1129dfe1f4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -553,7 +553,16 @@ class FrameworkExtension extends Extension if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) { $r = new \ReflectionClass('Symfony\Component\Security\Core\Exception\AuthenticationException'); - $dirs[] = dirname($r->getFilename()).'/../../Resources/translations'; + $legacyTranslationsDir = dirname($r->getFilename()).'/../../Resources/translations'; + + if (file_exists($legacyTranslationsDir)) { + // in Symfony 2.3, translations are located in the symfony/security package + $dirs[] = $legacyTranslationsDir; + } else { + // with Symfony 2.4, the Security component was split into several subpackages + // and the translations have been moved to the symfony/security-core package + $dirs[] = dirname($r->getFilename()).'/../Resources/translations'; + } } $overridePath = $container->getParameter('kernel.root_dir').'/Resources/%s/translations'; foreach ($container->getParameter('kernel.bundles') as $bundle => $class) { From 742547c099910f162f11fbc54c0f3db5f89b6ecd Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 6 Oct 2015 08:51:57 +0200 Subject: [PATCH 6/6] [Security\Core] Fix test failure after sebastianbergmann/phpunit#1821 --- .../Tests/Core/Authorization/AccessDecisionManagerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/Tests/Core/Authorization/AccessDecisionManagerTest.php b/src/Symfony/Component/Security/Tests/Core/Authorization/AccessDecisionManagerTest.php index b416e9577c..5341baf95d 100644 --- a/src/Symfony/Component/Security/Tests/Core/Authorization/AccessDecisionManagerTest.php +++ b/src/Symfony/Component/Security/Tests/Core/Authorization/AccessDecisionManagerTest.php @@ -96,7 +96,7 @@ class AccessDecisionManagerTest extends \PHPUnit_Framework_TestCase protected function getVoterFor2Roles($token, $vote1, $vote2) { $voter = $this->getMock('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface'); - $voter->expects($this->exactly(2)) + $voter->expects($this->any()) ->method('vote') ->will($this->returnValueMap(array( array($token, null, array('ROLE_FOO'), $vote1),