Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7048679

Browse filesBrowse files
minor #28897 [FrameworkBundle] Avoid calling getProjectDir() on KernelInterface (ro0NL)
This PR was merged into the 4.2-dev branch. Discussion ---------- [FrameworkBundle] Avoid calling getProjectDir() on KernelInterface | Q | A | ------------- | --- | Branch? | master (might be applied on 3.4 as well) | Bug fix? | no | New feature? | yes | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #... <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> Removes the last call to getProjectDir() in core (tests/kernel itself excluded). Yay :) Commits ------- 894c155 [FrameworkBundle] Avoid calling getProjectDir() on KernelInterface
2 parents 557f85d + 894c155 commit 7048679
Copy full SHA for 7048679

File tree

1 file changed

+6
-5
lines changed
Filter options

1 file changed

+6
-5
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php
+6-5Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.