From 5361f83be8ffec4007c70c0bdd1ee66a57813bc8 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Thu, 7 Mar 2013 14:36:36 +0100 Subject: [PATCH 1/3] [FramworkBundle] fix phpdoc of commands --- .../FrameworkBundle/Command/AssetsInstallCommand.php | 7 +++---- .../FrameworkBundle/Command/CacheClearCommand.php | 2 +- .../FrameworkBundle/Command/CacheWarmupCommand.php | 2 +- .../Command/ConfigDumpReferenceCommand.php | 6 ++++-- .../Command/ContainerAwareCommand.php | 4 ++-- .../Command/ContainerDebugCommand.php | 12 +++++++----- .../Command/RouterApacheDumperCommand.php | 6 +++--- .../FrameworkBundle/Command/RouterDebugCommand.php | 8 +++++--- .../FrameworkBundle/Command/RouterMatchCommand.php | 6 +++--- .../FrameworkBundle/Command/ServerRunCommand.php | 6 +++--- .../Command/TranslationUpdateCommand.php | 4 ++-- .../DependencyInjection/ContainerAwareInterface.php | 2 +- 12 files changed, 35 insertions(+), 30 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php index 0159fbcaf31ff..831c682e4be7d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php @@ -15,7 +15,6 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Output\Output; use Symfony\Component\Finder\Finder; /** @@ -26,7 +25,7 @@ class AssetsInstallCommand extends ContainerAwareCommand { /** - * @see Command + * {@inheritdoc} */ protected function configure() { @@ -62,9 +61,9 @@ protected function configure() } /** - * @see Command + * {@inheritdoc} * - * @throws \InvalidArgumentException When the target directory does not exist + * @throws \InvalidArgumentException When the target directory does not exist or symlink cannot be used */ protected function execute(InputInterface $input, OutputInterface $output) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php index 99a0f2e88cfa4..4364f550d2222 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php @@ -28,7 +28,7 @@ class CacheClearCommand extends ContainerAwareCommand protected $name; /** - * @see Command + * {@inheritdoc} */ protected function configure() { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php index baca8959475b6..71f071105b62c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php @@ -23,7 +23,7 @@ class CacheWarmupCommand extends ContainerAwareCommand { /** - * @see Command + * {@inheritdoc} */ protected function configure() { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php index c5f6ffcc757a0..5343a18a14adc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php @@ -25,7 +25,7 @@ class ConfigDumpReferenceCommand extends ContainerDebugCommand { /** - * @see Command + * {@inheritdoc} */ protected function configure() { @@ -53,7 +53,9 @@ protected function configure() } /** - * @see Command + * {@inheritdoc} + * + * @throws \LogicException */ protected function execute(InputInterface $input, OutputInterface $output) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerAwareCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerAwareCommand.php index 0540870657417..035f5536ee8dc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerAwareCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerAwareCommand.php @@ -23,7 +23,7 @@ abstract class ContainerAwareCommand extends Command implements ContainerAwareInterface { /** - * @var ContainerInterface + * @var ContainerInterface|null */ private $container; @@ -40,7 +40,7 @@ protected function getContainer() } /** - * @see ContainerAwareInterface::setContainer() + * {@inheritdoc} */ public function setContainer(ContainerInterface $container = null) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php index fae3498bbc807..289f06f5a276d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php @@ -29,12 +29,12 @@ class ContainerDebugCommand extends ContainerAwareCommand { /** - * @var ContainerBuilder + * @var ContainerBuilder|null */ protected $containerBuilder; /** - * @see Command + * {@inheritdoc} */ protected function configure() { @@ -74,7 +74,9 @@ protected function configure() } /** - * @see Command + * {@inheritdoc} + * + * @throws \LogicException */ protected function execute(InputInterface $input, OutputInterface $output) { @@ -307,7 +309,7 @@ protected function getContainerBuilder() * * @param string $serviceId The service id to resolve * - * @return \Symfony\Component\DependencyInjection\Definition|\Symfony\Component\DependencyInjection\Alias + * @return Definition|Alias */ protected function resolveServiceDefinition($serviceId) { @@ -328,7 +330,7 @@ protected function resolveServiceDefinition($serviceId) * Renders list of tagged services grouped by tag * * @param OutputInterface $output - * @param bool $showPrivate + * @param Boolean $showPrivate */ protected function outputTags(OutputInterface $output, $showPrivate = false) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php index 12fe9b028e079..c8a17e8904b05 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php @@ -26,7 +26,7 @@ class RouterApacheDumperCommand extends ContainerAwareCommand { /** - * {@inheritDoc} + * {@inheritdoc} */ public function isEnabled() { @@ -42,7 +42,7 @@ public function isEnabled() } /** - * @see Command + * {@inheritdoc} */ protected function configure() { @@ -65,7 +65,7 @@ protected function configure() } /** - * @see Command + * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php index 61e6818652c53..079e494eaac76 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php @@ -24,7 +24,7 @@ class RouterDebugCommand extends ContainerAwareCommand { /** - * {@inheritDoc} + * {@inheritdoc} */ public function isEnabled() { @@ -40,7 +40,7 @@ public function isEnabled() } /** - * @see Command + * {@inheritdoc} */ protected function configure() { @@ -60,7 +60,9 @@ protected function configure() } /** - * @see Command + * {@inheritdoc} + * + * @throws \InvalidArgumentException When route does not exist */ protected function execute(InputInterface $input, OutputInterface $output) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php index b0f3858df0ff6..1ccfa082407d3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php @@ -25,7 +25,7 @@ class RouterMatchCommand extends ContainerAwareCommand { /** - * {@inheritDoc} + * {@inheritdoc} */ public function isEnabled() { @@ -41,7 +41,7 @@ public function isEnabled() } /** - * @see Command + * {@inheritdoc} */ protected function configure() { @@ -61,7 +61,7 @@ protected function configure() } /** - * @see Command + * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php index 446db900e339e..f62a15de28665 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php @@ -25,7 +25,7 @@ class ServerRunCommand extends ContainerAwareCommand { /** - * {@inheritDoc} + * {@inheritdoc} */ public function isEnabled() { @@ -37,7 +37,7 @@ public function isEnabled() } /** - * @see Command + * {@inheritdoc} */ protected function configure() { @@ -74,7 +74,7 @@ protected function configure() } /** - * @see Command + * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php index e5e1e8a264265..3b0077cc7bea0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php @@ -33,7 +33,7 @@ class TranslationUpdateCommand extends ContainerAwareCommand protected $catalogue; /** - * {@inheritDoc} + * {@inheritdoc} */ protected function configure() { @@ -74,7 +74,7 @@ protected function configure() } /** - * {@inheritDoc} + * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { diff --git a/src/Symfony/Component/DependencyInjection/ContainerAwareInterface.php b/src/Symfony/Component/DependencyInjection/ContainerAwareInterface.php index eb96632c66555..e85bb53dcb9a7 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerAwareInterface.php +++ b/src/Symfony/Component/DependencyInjection/ContainerAwareInterface.php @@ -23,7 +23,7 @@ interface ContainerAwareInterface /** * Sets the Container. * - * @param ContainerInterface $container A ContainerInterface instance + * @param ContainerInterface|null $container A ContainerInterface instance or null * * @api */ From d16d193d1e35c4e870bdd0ee8e525cc5b23ece3e Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Thu, 7 Mar 2013 14:40:19 +0100 Subject: [PATCH 2/3] [FramworkBundle] removed unused property of trans update command --- .../FrameworkBundle/Command/TranslationUpdateCommand.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php index 3b0077cc7bea0..6d9db047f263d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php @@ -26,12 +26,6 @@ */ class TranslationUpdateCommand extends ContainerAwareCommand { - /** - * Compiled catalogue of messages. - * @var MessageCatalogue - */ - protected $catalogue; - /** * {@inheritdoc} */ From 15bf0337edd5e588db861ec5bd13f2fdbf7934ef Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Fri, 8 Mar 2013 13:06:24 +0100 Subject: [PATCH 3/3] [FrameworkBundle] fix router debug command - use dedicated Route:getMethods, getSchemes - pattern -> path - show missing scheme requirement - show missing host regex - refactoring --- .../Command/RouterDebugCommand.php | 106 ++++++++++-------- 1 file changed, 60 insertions(+), 46 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php index 079e494eaac76..9859743ff7e2a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php @@ -20,6 +20,7 @@ * A console command for retrieving information about routes * * @author Fabien Potencier + * @author Tobias Schultze */ class RouterDebugCommand extends ContainerAwareCommand { @@ -85,34 +86,28 @@ protected function outputRoutes(OutputInterface $output, $routes = null) $maxName = strlen('name'); $maxMethod = strlen('method'); + $maxScheme = strlen('scheme'); $maxHost = strlen('host'); foreach ($routes as $name => $route) { - $requirements = $route->getRequirements(); - $method = isset($requirements['_method']) - ? strtoupper(is_array($requirements['_method']) - ? implode(', ', $requirements['_method']) : $requirements['_method'] - ) - : 'ANY'; + $method = $route->getMethods() ? implode('|', $route->getMethods()) : 'ANY'; + $scheme = $route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY'; $host = '' !== $route->getHost() ? $route->getHost() : 'ANY'; $maxName = max($maxName, strlen($name)); $maxMethod = max($maxMethod, strlen($method)); + $maxScheme = max($maxScheme, strlen($scheme)); $maxHost = max($maxHost, strlen($host)); } - $format = '%-'.$maxName.'s %-'.$maxMethod.'s %-'.$maxHost.'s %s'; - // displays the generated routes - $format1 = '%-'.($maxName + 19).'s %-'.($maxMethod + 19).'s %-'.($maxHost + 19).'s %s'; - $output->writeln(sprintf($format1, 'Name', 'Method', 'Host', 'Pattern')); + $format = '%-'.$maxName.'s %-'.$maxMethod.'s %-'.$maxScheme.'s %-'.$maxHost.'s %s'; + $formatHeader = '%-'.($maxName + 19).'s %-'.($maxMethod + 19).'s %-'.($maxScheme + 19).'s %-'.($maxHost + 19).'s %s'; + $output->writeln(sprintf($formatHeader, 'Name', 'Method', 'Scheme', 'Host', 'Path')); + foreach ($routes as $name => $route) { - $requirements = $route->getRequirements(); - $method = isset($requirements['_method']) - ? strtoupper(is_array($requirements['_method']) - ? implode(', ', $requirements['_method']) : $requirements['_method'] - ) - : 'ANY'; + $method = $route->getMethods() ? implode('|', $route->getMethods()) : 'ANY'; + $scheme = $route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY'; $host = '' !== $route->getHost() ? $route->getHost() : 'ANY'; - $output->writeln(sprintf($format, $name, $method, $host, $route->getPath())); + $output->writeln(sprintf($format, $name, $method, $scheme, $host, $route->getPath()), OutputInterface::OUTPUT_RAW); } } @@ -126,41 +121,49 @@ protected function outputRoute(OutputInterface $output, $name) throw new \InvalidArgumentException(sprintf('The route "%s" does not exist.', $name)); } + $output->writeln($this->getHelper('formatter')->formatSection('router', sprintf('Route "%s"', $name))); + + $method = $route->getMethods() ? implode('|', $route->getMethods()) : 'ANY'; + $scheme = $route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY'; $host = '' !== $route->getHost() ? $route->getHost() : 'ANY'; - $output->writeln($this->getHelper('formatter')->formatSection('router', sprintf('Route "%s"', $name))); + $output->write('Name '); + $output->writeln($name, OutputInterface::OUTPUT_RAW); - $output->writeln(sprintf('Name %s', $name)); - $output->writeln(sprintf('Pattern %s', $route->getPath())); - $output->writeln(sprintf('Host %s', $host)); - $output->writeln(sprintf('Class %s', get_class($route))); + $output->write('Path '); + $output->writeln($route->getPath(), OutputInterface::OUTPUT_RAW); - $defaults = ''; - $d = $route->getDefaults(); - ksort($d); - foreach ($d as $name => $value) { - $defaults .= ($defaults ? "\n".str_repeat(' ', 13) : '').$name.': '.$this->formatValue($value); - } - $output->writeln(sprintf('Defaults %s', $defaults)); + $output->write('Host '); + $output->writeln($host, OutputInterface::OUTPUT_RAW); - $requirements = ''; - $r = $route->getRequirements(); - ksort($r); - foreach ($r as $name => $value) { - $requirements .= ($requirements ? "\n".str_repeat(' ', 13) : '').$name.': '.$this->formatValue($value); - } - $requirements = '' !== $requirements ? $requirements : 'NONE'; - $output->writeln(sprintf('Requirements %s', $requirements)); - - $options = ''; - $o = $route->getOptions(); - ksort($o); - foreach ($o as $name => $value) { - $options .= ($options ? "\n".str_repeat(' ', 13) : '').$name.': '.$this->formatValue($value); + $output->write('Scheme '); + $output->writeln($scheme, OutputInterface::OUTPUT_RAW); + + $output->write('Method '); + $output->writeln($method, OutputInterface::OUTPUT_RAW); + + $output->write('Class '); + $output->writeln(get_class($route), OutputInterface::OUTPUT_RAW); + + $output->write('Defaults '); + $output->writeln($this->formatConfigs($route->getDefaults()), OutputInterface::OUTPUT_RAW); + + $output->write('Requirements '); + // we do not want to show the schemes and methods again that are also in the requirements for BC + $requirements = $route->getRequirements(); + unset($requirements['_scheme'], $requirements['_method']); + $output->writeln($this->formatConfigs($requirements) ?: 'NO CUSTOM', OutputInterface::OUTPUT_RAW); + + $output->write('Options '); + $output->writeln($this->formatConfigs($route->getOptions()), OutputInterface::OUTPUT_RAW); + + $output->write('Path-Regex '); + $output->writeln($route->compile()->getRegex(), OutputInterface::OUTPUT_RAW); + + if (null !== $route->compile()->getHostRegex()) { + $output->write('Host-Regex '); + $output->writeln($route->compile()->getHostRegex(), OutputInterface::OUTPUT_RAW); } - $output->writeln(sprintf('Options %s', $options)); - $output->write('Regex '); - $output->writeln(preg_replace('/^ /', '', preg_replace('/^/m', ' ', $route->compile()->getRegex())), OutputInterface::OUTPUT_RAW); } protected function formatValue($value) @@ -175,4 +178,15 @@ protected function formatValue($value) return preg_replace("/\n\s*/s", '', var_export($value, true)); } + + private function formatConfigs(array $array) + { + $string = ''; + ksort($array); + foreach ($array as $name => $value) { + $string .= ($string ? "\n" . str_repeat(' ', 13) : '') . $name . ': ' . $this->formatValue($value); + } + + return $string; + } }