diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php
index 40f1f41618fa5..ccbe99359ff4d 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php
@@ -157,11 +157,6 @@ function ($path, $catalogue) use ($loadedMessages) {
->willReturnMap($returnValues);
}
- $kernel
- ->expects($this->any())
- ->method('getRootDir')
- ->willReturn($this->translationDir);
-
$kernel
->expects($this->any())
->method('getBundles')
diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/console.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/console.xml
index 28306e19c5f89..68afbcc30f2c6 100644
--- a/src/Symfony/Bundle/TwigBundle/Resources/config/console.xml
+++ b/src/Symfony/Bundle/TwigBundle/Resources/config/console.xml
@@ -13,7 +13,6 @@
%kernel.bundles_metadata%
%twig.default_path%
- %kernel.root_dir%
diff --git a/src/Symfony/Component/HttpKernel/CHANGELOG.md b/src/Symfony/Component/HttpKernel/CHANGELOG.md
index 923d9114f4171..bdb7cc995e56f 100644
--- a/src/Symfony/Component/HttpKernel/CHANGELOG.md
+++ b/src/Symfony/Component/HttpKernel/CHANGELOG.md
@@ -9,6 +9,7 @@ CHANGELOG
* removed `ConfigDataCollector::getApplicationVersion()`
* removed support for `Symfony\Component\Templating\EngineInterface` in `HIncludeFragmentRenderer`, use a `Twig\Environment` only
* removed `TranslatorListener` in favor of `LocaleAwareListener`
+ * removed `getRootDir()` and `getName()` from `Kernel` and `KernelInterface`
* removed `FilterControllerArgumentsEvent`, use `ControllerArgumentsEvent` instead
* removed `FilterControllerEvent`, use `ControllerEvent` instead
* removed `FilterResponseEvent`, use `ResponseEvent` instead
diff --git a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php
index 2280888951cfc..f50a4a0e6bc12 100644
--- a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php
+++ b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php
@@ -211,20 +211,6 @@ public function getPhpTimezone()
return $this->data['php_timezone'];
}
- /**
- * Gets the application name.
- *
- * @return string The application name
- *
- * @deprecated since Symfony 4.2
- */
- public function getAppName()
- {
- @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
-
- return 'n/a';
- }
-
/**
* Gets the environment.
*
diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php
index 09f5deaebf367..9dc3ea085a302 100644
--- a/src/Symfony/Component/HttpKernel/Kernel.php
+++ b/src/Symfony/Component/HttpKernel/Kernel.php
@@ -55,17 +55,9 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
protected $bundles = [];
protected $container;
- /**
- * @deprecated since Symfony 4.2
- */
- protected $rootDir;
protected $environment;
protected $debug;
protected $booted = false;
- /**
- * @deprecated since Symfony 4.2
- */
- protected $name;
protected $startTime;
private $projectDir;
@@ -87,8 +79,6 @@ public function __construct(string $environment, bool $debug)
{
$this->environment = $environment;
$this->debug = $debug;
- $this->rootDir = $this->getRootDir(false);
- $this->name = $this->getName(false);
}
public function __clone()
@@ -278,27 +268,6 @@ public function locateResource($name, $dir = null, $first = true)
throw new \InvalidArgumentException(sprintf('Unable to find file "%s".', $name));
}
- /**
- * {@inheritdoc}
- *
- * @deprecated since Symfony 4.2
- */
- public function getName(/* $triggerDeprecation = true */)
- {
- if (0 === \func_num_args() || func_get_arg(0)) {
- @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
- }
-
- if (null === $this->name) {
- $this->name = preg_replace('/[^a-zA-Z0-9_]+/', '', basename($this->rootDir));
- if (ctype_digit($this->name[0])) {
- $this->name = '_'.$this->name;
- }
- }
-
- return $this->name;
- }
-
/**
* {@inheritdoc}
*/
@@ -315,25 +284,6 @@ public function isDebug()
return $this->debug;
}
- /**
- * {@inheritdoc}
- *
- * @deprecated since Symfony 4.2, use getProjectDir() instead
- */
- public function getRootDir(/* $triggerDeprecation = true */)
- {
- if (0 === \func_num_args() || func_get_arg(0)) {
- @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use getProjectDir() instead.', __METHOD__), E_USER_DEPRECATED);
- }
-
- if (null === $this->rootDir) {
- $r = new \ReflectionObject($this);
- $this->rootDir = \dirname($r->getFileName());
- }
-
- return $this->rootDir;
- }
-
/**
* Gets the application root dir (path of the project's composer file).
*
@@ -450,8 +400,7 @@ protected function getContainerClass()
{
$class = \get_class($this);
$class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class).str_replace('.', '_', ContainerBuilder::hash($class)) : $class;
- $class = $this->name.str_replace('\\', '_', $class).ucfirst($this->environment).($this->debug ? 'Debug' : '').'Container';
-
+ $class = str_replace('\\', '_', $class).ucfirst($this->environment).($this->debug ? 'Debug' : '').'Container';
if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $class)) {
throw new \InvalidArgumentException(sprintf('The environment "%s" contains invalid characters, it can only contain characters allowed in PHP class names.', $this->environment));
}
@@ -611,18 +560,17 @@ protected function getKernelParameters()
];
}
+ $rootDir = new \ReflectionObject($this);
+ $rootDir = \dirname($rootDir->getFileName());
+
return [
/*
* @deprecated since Symfony 4.2, use kernel.project_dir instead
*/
- 'kernel.root_dir' => realpath($this->rootDir) ?: $this->rootDir,
+ 'kernel.root_dir' => realpath($rootDir) ?: $rootDir,
'kernel.project_dir' => realpath($this->getProjectDir()) ?: $this->getProjectDir(),
'kernel.environment' => $this->environment,
'kernel.debug' => $this->debug,
- /*
- * @deprecated since Symfony 4.2
- */
- 'kernel.name' => $this->name,
'kernel.cache_dir' => realpath($cacheDir = $this->warmupDir ?: $this->getCacheDir()) ?: $cacheDir,
'kernel.logs_dir' => realpath($this->getLogDir()) ?: $this->getLogDir(),
'kernel.bundles' => $bundles,
@@ -837,48 +785,13 @@ public static function stripComments($source)
return $output;
}
- /**
- * @deprecated since Symfony 4.3
- */
- public function serialize()
- {
- @trigger_error(sprintf('The "%s" method is deprecated since Symfony 4.3.', __METHOD__), E_USER_DEPRECATED);
-
- return serialize([$this->environment, $this->debug]);
- }
-
- /**
- * @deprecated since Symfony 4.3
- */
- public function unserialize($data)
- {
- @trigger_error(sprintf('The "%s" method is deprecated since Symfony 4.3.', __METHOD__), E_USER_DEPRECATED);
- list($environment, $debug) = unserialize($data, ['allowed_classes' => false]);
-
- $this->__construct($environment, $debug);
- }
-
public function __sleep()
{
- if (__CLASS__ !== $c = (new \ReflectionMethod($this, 'serialize'))->getDeclaringClass()->name) {
- @trigger_error(sprintf('Implementing the "%s::serialize()" method is deprecated since Symfony 4.3.', $c), E_USER_DEPRECATED);
- $this->serialized = $this->serialize();
-
- return ['serialized'];
- }
-
return ['environment', 'debug'];
}
public function __wakeup()
{
- if (__CLASS__ !== $c = (new \ReflectionMethod($this, 'serialize'))->getDeclaringClass()->name) {
- @trigger_error(sprintf('Implementing the "%s::serialize()" method is deprecated since Symfony 4.3.', $c), E_USER_DEPRECATED);
- $this->unserialize($this->serialized);
- unset($this->serialized);
-
- return;
- }
$this->__construct($this->environment, $this->debug);
}
}
diff --git a/src/Symfony/Component/HttpKernel/KernelInterface.php b/src/Symfony/Component/HttpKernel/KernelInterface.php
index 56b2fac86b777..cf8dcef0850e0 100644
--- a/src/Symfony/Component/HttpKernel/KernelInterface.php
+++ b/src/Symfony/Component/HttpKernel/KernelInterface.php
@@ -96,15 +96,6 @@ public function getBundle($name);
*/
public function locateResource($name, $dir = null, $first = true);
- /**
- * Gets the name of the kernel.
- *
- * @return string The kernel name
- *
- * @deprecated since Symfony 4.2
- */
- public function getName();
-
/**
* Gets the environment.
*
@@ -119,15 +110,6 @@ public function getEnvironment();
*/
public function isDebug();
- /**
- * Gets the application root dir (path of the project's Kernel class).
- *
- * @return string The Kernel root dir
- *
- * @deprecated since Symfony 4.2
- */
- public function getRootDir();
-
/**
* Gets the project dir (path of the project's composer file).
*
diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForOverrideName.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForOverrideName.php
deleted file mode 100644
index f7baaa6325fb2..0000000000000
--- a/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForOverrideName.php
+++ /dev/null
@@ -1,28 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\HttpKernel\Tests\Fixtures;
-
-use Symfony\Component\Config\Loader\LoaderInterface;
-use Symfony\Component\HttpKernel\Kernel;
-
-class KernelForOverrideName extends Kernel
-{
- protected $name = 'overridden';
-
- public function registerBundles()
- {
- }
-
- public function registerContainerConfiguration(LoaderInterface $loader)
- {
- }
-}
diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php
index f97074e1cdd0f..cc969e72b3381 100644
--- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php
@@ -23,7 +23,6 @@
use Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Kernel;
-use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForOverrideName;
use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest;
use Symfony\Component\HttpKernel\Tests\Fixtures\KernelWithoutBundles;
use Symfony\Component\HttpKernel\Tests\Fixtures\ResettableService;
@@ -89,7 +88,7 @@ public function testInitializeContainerClearsOldContainers()
$kernel->boot();
$containerDir = __DIR__.'/Fixtures/var/cache/custom/'.substr(\get_class($kernel->getContainer()), 0, 16);
- $this->assertTrue(unlink(__DIR__.'/Fixtures/var/cache/custom/TestsSymfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta'));
+ $this->assertTrue(unlink(__DIR__.'/Fixtures/var/cache/custom/Symfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta'));
$this->assertFileExists($containerDir);
$this->assertFileNotExists($containerDir.'.legacy');
@@ -309,36 +308,6 @@ public function doStuff()
$this->assertEquals($expected, $output);
}
- /**
- * @group legacy
- */
- public function testGetRootDir()
- {
- $kernel = new KernelForTest('test', true);
-
- $this->assertEquals(__DIR__.\DIRECTORY_SEPARATOR.'Fixtures', realpath($kernel->getRootDir()));
- }
-
- /**
- * @group legacy
- */
- public function testGetName()
- {
- $kernel = new KernelForTest('test', true);
-
- $this->assertEquals('Fixtures', $kernel->getName());
- }
-
- /**
- * @group legacy
- */
- public function testOverrideGetName()
- {
- $kernel = new KernelForOverrideName('test', true);
-
- $this->assertEquals('overridden', $kernel->getName());
- }
-
public function testSerialize()
{
$env = 'test_env';
@@ -546,14 +515,14 @@ public function testKernelReset()
$containerClass = \get_class($kernel->getContainer());
$containerFile = (new \ReflectionClass($kernel->getContainer()))->getFileName();
- unlink(__DIR__.'/Fixtures/var/cache/custom/TestsSymfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta');
+ unlink(__DIR__.'/Fixtures/var/cache/custom/Symfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta');
$kernel = new CustomProjectDirKernel();
$kernel->boot();
$this->assertInstanceOf($containerClass, $kernel->getContainer());
$this->assertFileExists($containerFile);
- unlink(__DIR__.'/Fixtures/var/cache/custom/TestsSymfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta');
+ unlink(__DIR__.'/Fixtures/var/cache/custom/Symfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta');
$kernel = new CustomProjectDirKernel(function ($container) { $container->register('foo', 'stdClass')->setPublic(true); });
$kernel->boot();
@@ -680,9 +649,6 @@ protected function getKernel(array $methods = [], array $bundles = [])
->method('registerBundles')
->willReturn($bundles)
;
- $p = new \ReflectionProperty($kernel, 'rootDir');
- $p->setAccessible(true);
- $p->setValue($kernel, __DIR__.'/Fixtures');
return $kernel;
}
@@ -693,9 +659,6 @@ protected function getKernelForTest(array $methods = [], $debug = false)
->setConstructorArgs(['test', $debug])
->setMethods($methods)
->getMock();
- $p = new \ReflectionProperty($kernel, 'rootDir');
- $p->setAccessible(true);
- $p->setValue($kernel, __DIR__.'/Fixtures');
return $kernel;
}