8000 [FrameworkBundle] Avoid calling getProjectDir() on KernelInterface by ro0NL · Pull Request #28897 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle] Avoid calling getProjectDir() on KernelInterface #28897

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[FrameworkBundle] Avoid calling getProjectDir() on KernelInterface
  • Loading branch information
ro0NL committed Oct 16, 2018
commit 894c15529998283a3bc4a52adc1ca43b6298d61d
11 changes: 6 additions & 5 deletions src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);

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

$rows = array(
array('<info>Symfony</>'),
Expand All @@ -74,8 +75,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
array('Environment', $kernel->getEnvironment()),
array('Debug', $kernel->isDebug() ? 'true' : 'false'),
array('Charset', $kernel->getCharset()),
array('Cache directory', self::formatPath($kernel->getCacheDir(), $kernel->getProjectDir()).' (<comment>'.self::formatFileSize($kernel->getCacheDir()).'</>)'),
array('Log directory', self::formatPath($kernel->getLogDir(), $kernel->getProjectDir()).' (<comment>'.self::formatFileSize($kernel->getLogDir()).'</>)'),
array('Cache directory', self::formatPath($kernel->getCacheDir(), $projectDir).' (<comment>'.self::formatFileSize($kernel->getCacheDir()).'</>)'),
array('Log directory', self::formatPath($kernel->getLogDir(), $projectDir).' (<comment>'.self::formatFileSize($kernel->getLogDir()).'</>)'),
new TableSeparator(),
array('<info>PHP</>'),
new TableSeparator(),
Expand All @@ -101,9 +102,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io->table(array(), $rows);
}

private static function formatPath(string $path, string $baseDir = null): string
private static function formatPath(string $path, string $baseDir): string
{
return null !== $baseDir ? preg_replace('~^'.preg_quote($baseDir, '~').'~', '.', $path) : $path;
return preg_replace('~^'.preg_quote($baseDir, '~').'~', '.', $path);
}

private static function formatFileSize(string $path): string
Expand Down
0