Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 62f3d2a

Browse files
committed
merged branch Tobion/debug-command (PR #7301)
This PR was merged into the 2.2 branch. Commits ------- 15bf033 [FrameworkBundle] fix router debug command d16d193 [FramworkBundle] removed unused property of trans update command 5361f83 [FramworkBundle] fix phpdoc of commands Discussion ---------- [FrameworkBundle] router debug command fix | Q | A | ------------- | --- | Bug fix? | [yes] | New feature? | [no] | BC breaks? | [no] | Deprecations? | [no] | Tests pass? | [yes] | License | MIT See commits.
2 parents 9544405 + 15bf033 commit 62f3d2a

12 files changed

+95
-82
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Symfony\Component\Console\Input\InputOption;
1616
use Symfony\Component\Console\Input\InputInterface;
1717
use Symfony\Component\Console\Output\OutputInterface;
18-
use Symfony\Component\Console\Output\Output;
1918
use Symfony\Component\Finder\Finder;
2019

2120
/**
@@ -26,7 +25,7 @@
2625
class AssetsInstallCommand extends ContainerAwareCommand
2726
{
2827
/**
29-
* @see Command
28+
* {@inheritdoc}
3029
*/
3130
protected function configure()
3231
{
@@ -62,9 +61,9 @@ protected function configure()
6261
}
6362

6463
/**
65-
* @see Command
64+
* {@inheritdoc}
6665
*
67-
* @throws \InvalidArgumentException When the target directory does not exist
66+
* @throws \InvalidArgumentException When the target directory does not exist or symlink cannot be used
6867
*/
6968
protected function execute(InputInterface $input, OutputInterface $output)
7069
{

src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class CacheClearCommand extends ContainerAwareCommand
2828
protected $name;
2929

3030
/**
31-
* @see Command
31+
* {@inheritdoc}
3232
*/
3333
protected function configure()
3434
{

src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
class CacheWarmupCommand extends ContainerAwareCommand
2424
{
2525
/**
26-
* @see Command
26+
* {@inheritdoc}
2727
*/
2828
protected function configure()
2929
{

src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
class ConfigDumpReferenceCommand extends ContainerDebugCommand
2626
{
2727
/**
28-
* @see Command
28+
* {@inheritdoc}
2929
*/
3030
protected function configure()
3131
{
@@ -53,7 +53,9 @@ protected function configure()
5353
}
5454

5555
/**
56-
* @see Command
56+
* {@inheritdoc}
57+
*
58+
* @throws \LogicException
5759
*/
5860
protected function execute(InputInterface $input, OutputInterface $output)
5961
{

src/Symfony/Bundle/FrameworkBundle/Command/ContainerAwareCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
abstract class ContainerAwareCommand extends Command implements ContainerAwareInterface
2424
{
2525
/**
26-
* @var ContainerInterface
26+
* @var ContainerInterface|null
2727
*/
2828
private $container;
2929

@@ -40,7 +40,7 @@ protected function getContainer()
4040
}
4141

4242
/**
43-
* @see ContainerAwareInterface::setContainer()
43+
* {@inheritdoc}
4444
*/
4545
public function setContainer(ContainerInterface $container = null)
4646
{

src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
class ContainerDebugCommand extends ContainerAwareCommand
3030
{
3131
/**
32-
* @var ContainerBuilder
32+
* @var ContainerBuilder|null
3333
*/
3434
protected $containerBuilder;
3535

3636
/**
37-
* @see Command
37+
* {@inheritdoc}
3838
*/
3939
protected function configure()
4040
{
@@ -74,7 +74,9 @@ protected function configure()
7474
}
7575

7676
/**
77-
* @see Command
77+
* {@inheritdoc}
78+
*
79+
* @throws \LogicException
7880
*/
7981
protected function execute(InputInterface $input, OutputInterface $output)
8082
{
@@ -307,7 +309,7 @@ protected function getContainerBuilder()
307309
*
308310
* @param string $serviceId The service id to resolve
309311
*
310-
* @return \Symfony\Component\DependencyInjection\Definition|\Symfony\Component\DependencyInjection\Alias
312+
* @return Definition|Alias
311313
*/
312314
protected function resolveServiceDefinition($serviceId)
313315
{
@@ -328,7 +330,7 @@ protected function resolveServiceDefinition($serviceId)
328330
* Renders list of tagged services grouped by tag
329331
*
330332
* @param OutputInterface $output
331-
* @param bool $showPrivate
333+
* @param Boolean $showPrivate
332334
*/
333335
protected function outputTags(OutputInterface $output, $showPrivate = false)
334336
{

src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
class RouterApacheDumperCommand extends ContainerAwareCommand
2727
{
2828
/**
29-
* {@inheritDoc}
29+
* {@inheritdoc}
3030
*/
3131
public function isEnabled()
3232
{
@@ -42,7 +42,7 @@ public function isEnabled()
4242
}
4343

4444
/**
45-
* @see Command
45+
* {@inheritdoc}
4646
*/
4747
protected function configure()
4848
{
@@ -65,7 +65,7 @@ protected function configure()
6565
}
6666

6767
/**
68-
* @see Command
68+
* {@inheritdoc}
6969
*/
7070
protected function execute(InputInterface $input, OutputInterface $output)
7171
{

src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php

Lines changed: 65 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
* A console command for retrieving information about routes
2121
*
2222
* @author Fabien Potencier <[email protected]>
23+
* @author Tobias Schultze <http://tobion.de>
2324
*/
2425
class RouterDebugCommand extends ContainerAwareCommand
2526
{
2627
/**
27-
* {@inheritDoc}
28+
* {@inheritdoc}
2829
*/
2930
public function isEnabled()
3031
{
@@ -40,7 +41,7 @@ public function isEnabled()
4041
}
4142

4243
/**
43-
* @see Command
44+
* {@inheritdoc}
4445
*/
4546
protected function configure()
4647
{
@@ -60,7 +61,9 @@ protected function configure()
6061
}
6162

6263
/**
63-
* @see Command
64+
* {@inheritdoc}
65+
*
66+
* @throws \InvalidArgumentException When route does not exist
6467
*/
6568
protected function execute(InputInterface $input, OutputInterface $output)
6669
{
@@ -83,34 +86,28 @@ protected function outputRoutes(OutputInterface $output, $routes = null)
8386

8487
$maxName = strlen('name');
8588
$maxMethod = strlen('method');
89+
$maxScheme = strlen('scheme');
8690
$maxHost = strlen('host');
8791

8892
foreach ($routes as $name => $route) {
89-
$requirements = $route->getRequirements();
90-
$method = isset($requirements['_method'])
91-
? strtoupper(is_array($requirements['_method'])
92-
? implode(', ', $requirements['_method']) : $requirements['_method']
93-
)
94-
: 'ANY';
93+
$method = $route->getMethods() ? implode('|', $route->getMethods()) : 'ANY';
94+
$scheme = $route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY';
9595
$host = '' !== $route->getHost() ? $route->getHost() : 'ANY';
9696
$maxName = max($maxName, strlen($name));
9797
$maxMethod = max($maxMethod, strlen($method));
98+
$maxScheme = max($maxScheme, strlen($scheme));
9899
$maxHost = max($maxHost, strlen($host));
99100
}
100-
$format = '%-'.$maxName.'s %-'.$maxMethod.'s %-'.$maxHost.'s %s';
101101

102-
// displays the generated routes
103-
$format1 = '%-'.($maxName + 19).'s %-'.($maxMethod + 19).'s %-'.($maxHost + 19).'s %s';
104-
$output->writeln(sprintf($format1, '<comment>Name</comment>', '<comment>Method</comment>', '<comment>Host</comment>', '<comment>Pattern</comment>'));
102+
$format = '%-'.$maxName.'s %-'.$maxMethod.'s %-'.$maxScheme.'s %-'.$maxHost.'s %s';
103+
$formatHeader = '%-'.($maxName + 19).'s %-'.($maxMethod + 19).'s %-'.($maxScheme + 19).'s %-'.($maxHost + 19).'s %s';
104+
$output->writeln(sprintf($formatHeader, '<comment>Name</comment>', '<comment>Method</comment>', '<comment>Scheme</comment>', '<comment>Host</comment>', '<comment>Path</comment>'));
105+
105106
foreach ($routes as $name => $route) {
106-
$requirements = $route->getRequirements();
107-
$method = isset($requirements['_method'])
108-
? strtoupper(is_array($requirements['_method'])
109-
? implode(', ', $requirements['_method']) : $requirements['_method']
110-
)
111-
: 'ANY';
107+
$method = $route->getMethods() ? implode('|', $route->getMethods()) : 'ANY';
108+
$scheme = $route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY';
112109
$host = '' !== $route->getHost() ? $route->getHost() : 'ANY';
113-
$output->writeln(sprintf($format, $name, $method, $host, $route->getPath()));
110+
$output->writeln(sprintf($format, $name, $method, $scheme, $host, $route->getPath()), OutputInterface::OUTPUT_RAW);
114111
}
115112
}
116113

@@ -124,41 +121,49 @@ protected function outputRoute(OutputInterface $output, $name)
124121
throw new \InvalidArgumentException(sprintf('The route "%s" does not exist.', $name));
125122
}
126123

124+
$output->writeln($this->getHelper('formatter')->formatSection('router', sprintf('Route "%s"', $name)));
125+
126+
$method = $route->getMethods() ? implode('|', $route->getMethods()) : 'ANY';
127+
$scheme = $route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY';
127128
$host = '' !== $route->getHost() ? $route->getHost() : 'ANY';
128129

129-
$output->writeln($this->getHelper('formatter')->formatSection('router', sprintf('Route "%s"', $name)));
130+
$output->write('<comment>Name</comment> ');
131+
$output->writeln($name, OutputInterface::OUTPUT_RAW);
130132

131-
$output->writeln(sprintf('<comment>Name</comment> %s', $name));
132-
$output->writeln(sprintf('<comment>Pattern</comment> %s', $route->getPath()));
133-
$output->writeln(sprintf('<comment>Host</comment> %s', $host));
134-
$output->writeln(sprintf('<comment>Class</comment> %s', get_class($route)));
133+
$output->write('<comment>Path</comment> ');
134+
$output->writeln($route->getPath(), OutputInterface::OUTPUT_RAW);
135135

136-
$defaults = '';
137-
$d = $route->getDefaults();
138-
ksort($d);
139-
foreach ($d as $name => $value) {
140-
$defaults .= ($defaults ? "\n".str_repeat(' ', 13) : '').$name.': '.$this->formatValue($value);
141-
}
142-
$output->writeln(sprintf('<comment>Defaults</comment> %s', $defaults));
136+
$output->write('<comment>Host</comment> ');
137+
$output->writeln($host, OutputInterface::OUTPUT_RAW);
143138

144-
$requirements = '';
145-
$r = $route->getRequirements();
146-
ksort($r);
147-
foreach ($r as $name => $value) {
148-
$requirements .= ($requirements ? "\n".str_repeat(' ', 13) : '').$name.': '.$this->formatValue($value);
149-
}
150-
$requirements = '' !== $requirements ? $requirements : 'NONE';
151-
$output->writeln(sprintf('<comment>Requirements</comment> %s', $requirements));
152-
153-
$options = '';
154-
$o = $route->getOptions();
155-
ksort($o);
156-
foreach ($o as $name => $value) {
157-
$options .= ($options ? "\n".str_repeat(' ', 13) : '').$name.': '.$this->formatValue($value);
139+
$output->write('<comment>Scheme</comment> ');
140+
$output->writeln($scheme, OutputInterface::OUTPUT_RAW);
141+
142+
$output->write('<comment>Method</comment> ');
143+
$output->writeln($method, OutputInterface::OUTPUT_RAW);
144+
145+
$output->write('<comment>Class</comment> ');
146+
$output->writeln(get_class($route), OutputInterface::OUTPUT_RAW);
147+
148+
$output->write('<comment>Defaults</comment> ');
149+
$output->writeln($this->formatConfigs($route->getDefaults()), OutputInterface::OUTPUT_RAW);
150+
151+
$output->write('<comment>Requirements</comment> ');
152+
// we do not want to show the schemes and methods again that are also in the requirements for BC
153+
$requirements = $route->getRequirements();
154+
unset($requirements['_scheme'], $requirements['_method']);
155+
$output->writeln($this->formatConfigs($requirements) ?: 'NO CUSTOM', OutputInterface::OUTPUT_RAW);
156+
157+
$output->write('<comment>Options</comment> ');
158+
$output->writeln($this->formatConfigs($route->getOptions()), OutputInterface::OUTPUT_RAW);
159+
160+
$output->write('<comment>Path-Regex</comment> ');
161+
$output->writeln($route->compile()->getRegex(), OutputInterface::OUTPUT_RAW);
162+
163+
if (null !== $route->compile()->getHostRegex()) {
164+
$output->write('<comment>Host-Regex</comment> ');
165+
$output->writeln($route->compile()->getHostRegex(), OutputInterface::OUTPUT_RAW);
158166
}
159-
$output->writeln(sprintf('<comment>Options</comment> %s', $options));
160-
$output->write('<comment>Regex</comment> ');
161-
$output->writeln(preg_replace('/^ /', '', preg_replace('/^/m', ' ', $route->compile()->getRegex())), OutputInterface::OUTPUT_RAW);
162167
}
163168

164169
protected function formatValue($value)
@@ -173,4 +178,15 @@ protected function formatValue($value)
173178

174179
return preg_replace("/\n\s*/s", '', var_export($value, true));
175180
}
181+
182+
private function formatConfigs(array $array)
183+
{
184+
$string = '';
185+
ksort($array);
186+
foreach ($array as $name => $value) {
187+
$string .= ($string ? "\n" . str_repeat(' ', 13) : '') . $name . ': ' . $this->formatValue($value);
188+
}
189+
190+
return $string;
191+
}
176192
}

src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
class RouterMatchCommand extends ContainerAwareCommand
2626
{
2727
/**
28-
* {@inheritDoc}
28+
* {@inheritdoc}
2929
*/
3030
public function isEnabled()
3131
{
@@ -41,7 +41,7 @@ public function isEnabled()
4141
}
4242

4343
/**
44-
* @see Command
44+
* {@inheritdoc}
4545
*/
4646
protected function configure()
4747
{
@@ -61,7 +61,7 @@ protected function configure()
6161
}
6262

6363
/**
64-
* @see Command
64+
* {@inheritdoc}
6565
*/
6666
protected function execute(InputInterface $input, OutputInterface $output)
6767
{

src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
class ServerRunCommand extends ContainerAwareCommand
2626
{
2727
/**
28-
* {@inheritDoc}
28+
* {@inheritdoc}
2929
*/
3030
public function isEnabled()
3131
{
@@ -37,7 +37,7 @@ public function isEnabled()
3737
}
3838

3939
/**
40-
* @see Command
40+
* {@inheritdoc}
4141
*/
4242
protected function configure()
4343
{
@@ -74,7 +74,7 @@ protected function configure()
7474
}
7575

7676
/**
77-
* @see Command
77+
* {@inheritdoc}
7878
*/
7979
protected function execute(InputInterface $input, OutputInterface $output)
8080
{

0 commit comments

Comments
 (0)