Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[HttpKernel] remove all deprecated code from http kernel
  • Loading branch information
Simperfit authored and nicolas-grekas committed Jun 8, 2019
1 parent ceb40c1 commit 424d6d8
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 201 deletions.
Expand Up @@ -159,7 +159,7 @@ function ($path, $catalogue) use ($loadedMessages) {

$kernel
->expects($this->any())
->method('getRootDir')
->method('getProjectDir')
->willReturn($this->translationDir);

$kernel
Expand All @@ -168,7 +168,7 @@ function ($path, $catalogue) use ($loadedMessages) {
->willReturn([]);

$container = new Container();
$container->setParameter('kernel.root_dir', $this->translationDir);
$container->setParameter('kernel.project_dir', $this->translationDir);
$kernel
->expects($this->any())
->method('getContainer')
Expand Down
Expand Up @@ -1351,7 +1351,6 @@ protected function createContainer(array $data = [])
'kernel.debug' => false,
'kernel.environment' => 'test',
'kernel.name' => 'kernel',
'kernel.root_dir' => __DIR__,
'kernel.container_class' => 'testContainer',
'container.build_hash' => 'Abc1234',
'container.build_id' => hash('crc32', 'Abc123423456789'),
Expand Down
Expand Up @@ -125,7 +125,6 @@ private function createContainer($sessionStorageOptions)
$container->setParameter('kernel.container_class', 'cc');
$container->setParameter('kernel.debug', true);
$container->setParameter('kernel.project_dir', __DIR__);
$container->setParameter('kernel.root_dir', __DIR__);
$container->setParameter('kernel.secret', __DIR__);
if (null !== $sessionStorageOptions) {
$container->setParameter('session.storage.options', $sessionStorageOptions);
Expand Down
Expand Up @@ -354,7 +354,6 @@ public function testRememberMeCookieInheritFrameworkSessionCookie($config, $same
$container->registerExtension(new FrameworkExtension());
$container->setParameter('kernel.bundles_metadata', []);
$container->setParameter('kernel.project_dir', __DIR__);
$container->setParameter('kernel.root_dir', __DIR__);
$container->setParameter('kernel.cache_dir', __DIR__);

$container->loadFromExtension('security', [
Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Bundle/TwigBundle/Resources/config/console.xml
Expand Up @@ -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>

Expand Down
Expand Up @@ -264,7 +264,6 @@ private function createContainer(string $rootDir = __DIR__.'/Fixtures')
{
$container = new ContainerBuilder(new ParameterBag([
'kernel.cache_dir' => __DIR__,
'kernel.root_dir' => $rootDir,
'kernel.project_dir' => __DIR__,
'kernel.charset' => 'UTF-8',
'kernel.debug' => false,
Expand Down
3 changes: 2 additions & 1 deletion src/Symfony/Component/HttpKernel/CHANGELOG.md
Expand Up @@ -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
Expand All @@ -18,7 +19,7 @@ CHANGELOG
* removed `PostResponseEvent`, use `TerminateEvent` instead
* removed `SaveSessionListener` in favor of `AbstractSessionListener`
* removed `Client`, use `HttpKernelBrowser` instead
* added method `getProjectDir()` to `KernelInterface`
* added method `getProjectDir()` to `KernelInterfac

4.3.0
-----
Expand Down
Expand Up @@ -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.
*
Expand Down
101 changes: 7 additions & 94 deletions src/Symfony/Component/HttpKernel/Kernel.php
Expand Up @@ -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;
Expand All @@ -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()
Expand Down Expand Up @@ -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}
*/
Expand All @@ -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).
*
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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
*/
/*
* @deprecated since Symfony 4.2, use kernel.project_dir instead
*/
'kernel.root_dir' => realpath($this->rootDir) ?: $this->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,
Expand Down Expand Up @@ -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);
}
}
18 changes: 0 additions & 18 deletions src/Symfony/Component/HttpKernel/KernelInterface.php
Expand Up @@ -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.
*
Expand All @@ -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).
*
Expand Down

This file was deleted.

0 comments on commit 424d6d8

Please sign in to comment.