Skip to content

Commit 8e522a8

Browse files
committed
[FrameworkBundle] Avoid calling getProjectDir() on KernelInterface
1 parent eaa8529 commit 8e522a8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Command/AboutCommand.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
5858
{
5959
$io = new SymfonyStyle($input, $output);
6060

61-
/** @var $kernel KernelInterface */
61+
/** @var KernelInterface $kernel */
6262
$kernel = $this->getApplication()->getKernel();
63+
$projectDir = $kernel->getContainer()->getParameter('kernel.project_dir');
6364

6465
$rows = array(
6566
array('<info>Symfony</>'),
@@ -74,8 +75,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
7475
array('Environment', $kernel->getEnvironment()),
7576
array('Debug', $kernel->isDebug() ? 'true' : 'false'),
7677
array('Charset', $kernel->getCharset()),
77-
array('Cache directory', self::formatPath($kernel->getCacheDir(), $kernel->getProjectDir()).' (<comment>'.self::formatFileSize($kernel->getCacheDir()).'</>)'),
78-
array('Log directory', self::formatPath($kernel->getLogDir(), $kernel->getProjectDir()).' (<comment>'.self::formatFileSize($kernel->getLogDir()).'</>)'),
78+
array('Cache directory', self::formatPath($kernel->getCacheDir(), $projectDir).' (<comment>'.self::formatFileSize($kernel->getCacheDir()).'</>)'),
79+
array('Log directory', self::formatPath($kernel->getLogDir(), $projectDir).' (<comment>'.self::formatFileSize($kernel->getLogDir()).'</>)'),
7980
new TableSeparator(),
8081
array('<info>PHP</>'),
8182
new TableSeparator(),
@@ -101,9 +102,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
101102
$io->table(array(), $rows);
102103
}
103104

104-
private static function formatPath(string $path, string $baseDir = null): string
105+
private static function formatPath(string $path, string $baseDir): string
105106
{
106-
return null !== $baseDir ? preg_replace('~^'.preg_quote($baseDir, '~').'~', '.', $path) : $path;
107+
return preg_replace('~^'.preg_quote($baseDir, '~').'~', '.', $path);
107108
}
108109

109110
private static function formatFileSize(string $path): string

0 commit comments

Comments
 (0)