[HttpKernel] remove all deprecated code from http kernel
This commit is contained in:
parent
ceb40c14be
commit
48351d53e0
@ -157,11 +157,6 @@ class TranslationUpdateCommandTest extends TestCase
|
||||
->willReturnMap($returnValues);
|
||||
}
|
||||
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getRootDir')
|
||||
->willReturn($this->translationDir);
|
||||
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getBundles')
|
||||
|
@ -13,7 +13,6 @@
|
||||
<argument>%kernel.bundles_metadata%</argument>
|
||||
<argument>%twig.default_path%</argument>
|
||||
<argument type="service" id="debug.file_link_formatter" on-invalid="null" />
|
||||
<argument>%kernel.root_dir%</argument>
|
||||
<tag name="console.command" command="debug:twig" />
|
||||
</service>
|
||||
|
||||
|
@ -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
|
||||
|
@ -211,20 +211,6 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
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.
|
||||
*
|
||||
|
@ -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 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
{
|
||||
$this->environment = $environment;
|
||||
$this->debug = $debug;
|
||||
$this->rootDir = $this->getRootDir(false);
|
||||
$this->name = $this->getName(false);
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
@ -278,27 +268,6 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
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 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
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 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
{
|
||||
$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 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
];
|
||||
}
|
||||
|
||||
$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 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -96,15 +96,6 @@ interface KernelInterface extends HttpKernelInterface
|
||||
*/
|
||||
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 @@ interface KernelInterface extends HttpKernelInterface
|
||||
*/
|
||||
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).
|
||||
*
|
||||
|
@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* 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)
|
||||
{
|
||||
}
|
||||
}
|
@ -23,7 +23,6 @@ use Symfony\Component\HttpKernel\DependencyInjection\ResettableServicePass;
|
||||
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 @@ class KernelTest extends TestCase
|
||||
$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 @@ EOF;
|
||||
$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 @@ EOF;
|
||||
|
||||
$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 @@ EOF;
|
||||
->method('registerBundles')
|
||||
->willReturn($bundles)
|
||||
;
|
||||
$p = new \ReflectionProperty($kernel, 'rootDir');
|
||||
$p->setAccessible(true);
|
||||
$p->setValue($kernel, __DIR__.'/Fixtures');
|
||||
|
||||
return $kernel;
|
||||
}
|
||||
@ -693,9 +659,6 @@ EOF;
|
||||
->setConstructorArgs(['test', $debug])
|
||||
->setMethods($methods)
|
||||
->getMock();
|
||||
$p = new \ReflectionProperty($kernel, 'rootDir');
|
||||
$p->setAccessible(true);
|
||||
$p->setValue($kernel, __DIR__.'/Fixtures');
|
||||
|
||||
return $kernel;
|
||||
}
|
||||
|
Reference in New Issue
Block a user