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 98ff750

Browse filesBrowse files
committed
[HttpKernel] deprecated the Kernel name
1 parent 7cb823a commit 98ff750
Copy full SHA for 98ff750

File tree

Expand file treeCollapse file tree

17 files changed

+61
-40
lines changed
Filter options
Expand file treeCollapse file tree

17 files changed

+61
-40
lines changed

‎src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ protected function loadCacheDriver($cacheName, $objectManagerName, array $cacheD
367367
} else {
368368
$seed = '_'.$container->getParameter('kernel.root_dir');
369369
}
370-
$seed .= '.'.$container->getParameter('kernel.name').'.'.$container->getParameter('kernel.environment').'.'.$container->getParameter('kernel.debug');
370+
$seed .= '.'.$container->getParameter('kernel.container_class').'.'.$container->getParameter('kernel.environment').'.'.$container->getParameter('kernel.debug');
371371
$namespace = 'sf_'.$this->getMappingResourceExtension().'_'.$objectManagerName.'_'.ContainerBuilder::hash($seed);
372372

373373
$cacheDriver['namespace'] = $namespace;

‎src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ protected function createContainer(array $data = array())
271271
'kernel.cache_dir' => __DIR__,
272272
'kernel.debug' => false,
273273
'kernel.environment' => 'test',
274-
'kernel.name' => 'kernel',
274+
'kernel.container_class' => 'kernel',
275275
'kernel.root_dir' => __DIR__,
276276
), $data)));
277277
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
7171
array('<info>Kernel</>'),
7272
new TableSeparator(),
7373
array('Type', \get_class($kernel)),
74-
array('Name', $kernel->getName()),
7574
array('Environment', $kernel->getEnvironment()),
7675
array('Debug', $kernel->isDebug() ? 'true' : 'false'),
7776
array('Charset', $kernel->getCharset()),

‎src/Symfony/Bundle/FrameworkBundle/Console/Application.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Console/Application.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public function all($namespace = null)
148148
*/
149149
public function getLongVersion()
150150
{
151-
return parent::getLongVersion().sprintf(' (kernel: <comment>%s</>, env: <comment>%s</>, debug: <comment>%s</>)', $this->kernel->getName(), $this->kernel->getEnvironment(), $this->kernel->isDebug() ? 'true' : 'false');
151+
return parent::getLongVersion().sprintf(' (env: <comment>%s</>, debug: <comment>%s</>)', $this->kernel->getEnvironment(), $this->kernel->isDebug() ? 'true' : 'false');
152152
}
153153

154154
public function add(Command $command)

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolClearerPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolClearerPassTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function testPoolRefsAreWeak()
3030
{
3131
$container = new ContainerBuilder();
3232
$container->setParameter('kernel.debug', false);
33-
$container->setParameter('kernel.name', 'app');
33+
$container->setParameter('kernel.container_class', 'app');
3434
$container->setParameter('kernel.environment', 'prod');
3535
$container->setParameter('kernel.root_dir', 'foo');
3636

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPassTest.php
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function testNamespaceArgumentIsReplaced()
3535
{
3636
$container = new ContainerBuilder();
3737
$container->setParameter('kernel.debug', false);
38-
$container->setParameter('kernel.name', 'app');
38+
$container->setParameter('kernel.container_class', 'app');
3939
$container->setParameter('kernel.environment', 'prod');
4040
$container->setParameter('kernel.root_dir', 'foo');
4141
$adapter = new Definition();
@@ -57,7 +57,7 @@ public function testNamespaceArgumentIsNotReplacedIfArrayAdapterIsUsed()
5757
{
5858
$container = new ContainerBuilder();
5959
$container->setParameter('kernel.environment', 'prod');
60-
$container->setParameter('kernel.name', 'app');
60+
$container->setParameter('kernel.container_class', 'app');
6161
$container->setParameter('kernel.root_dir', 'foo');
6262

6363
$container->register('cache.adapter.array', ArrayAdapter::class)->addArgument(0);
@@ -75,7 +75,7 @@ public function testArgsAreReplaced()
7575
{
7676
$container = new ContainerBuilder();
7777
$container->setParameter('kernel.debug', false);
78-
$container->setParameter('kernel.name', 'app');
78+
$container->setParameter('kernel.container_class', 'app');
7979
$container->setParameter('kernel.environment', 'prod');
8080
$container->setParameter('cache.prefix.seed', 'foo');
8181
$cachePool = new Definition();
@@ -100,7 +100,7 @@ public function testWithNameAttribute()
100100
{
101101
$container = new ContainerBuilder();
102102
$container->setParameter('kernel.debug', false);
103-
$container->setParameter('kernel.name', 'app');
103+
$container->setParameter('kernel.container_class', 'app');
104104
$container->setParameter('kernel.environment', 'prod');
105105
$container->setParameter('cache.prefix.seed', 'foo');
106106
$cachePool = new Definition();
@@ -126,7 +126,7 @@ public function testThrowsExceptionWhenCachePoolTagHasUnknownAttributes()
126126
{
127127
$container = new ContainerBuilder();
128128
$container->setParameter('kernel.debug', false);
129-
$container->setParameter('kernel.name', 'app');
129+
$container->setParameter('kernel.container_class', 'app');
130130
$container->setParameter('kernel.environment', 'prod');
131131
$container->setParameter('kernel.root_dir', 'foo');
132132
$adapter = new Definition();

‎src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,9 @@ public function __construct($varDir, $testCase, $rootConfig, $environment, $debu
4646
/**
4747
* {@inheritdoc}
4848
*/
49-
public function getName()
49+
public function getContainerClass()
5050
{
51-
if (null === $this->name) {
52-
$this->name = parent::getName().substr(md5($this->rootConfig), -16);
53-
}
54-
55-
return $this->name;
51+
return parent::getContainerClass().substr(md5($this->rootConfig), -16);
5652
}
5753

5854
public function registerBundles()

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig
-7Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,6 @@
5050
</span>
5151
</div>
5252

53-
{% if 'n/a' is not same as(collector.appname) %}
54-
<div class="sf-toolbar-info-piece">
55-
<b>Kernel name</b>
56-
<span>{{ collector.appname }}</span>
57-
</div>
58-
{% endif %}
59-
6053
{% if 'n/a' is not same as(collector.env) %}
6154
<div class="sf-toolbar-info-piece">
6255
<b>Environment</b>

‎src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function process(ContainerBuilder $container)
5252
} else {
5353
$seed = '_'.$container->getParameter('kernel.root_dir');
5454
}
55-
$seed .= '.'.$container->getParameter('kernel.name').'.'.$container->getParameter('kernel.environment');
55+
$seed .= '.'.$container->getParameter('kernel.container_class').'.'.$container->getParameter('kernel.environment');
5656

5757
$pools = array();
5858
$clearers = array();

‎src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolClearerPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolClearerPassTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function testPoolRefsAreWeak()
2727
{
2828
$container = new ContainerBuilder();
2929
$container->setParameter('kernel.debug', false);
30-
$container->setParameter('kernel.name', 'app');
30+
$container->setParameter('kernel.container_class', 'app');
3131
$container->setParameter('kernel.environment', 'prod');
3232
$container->setParameter('kernel.root_dir', 'foo');
3333

‎src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPassTest.php
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testNamespaceArgumentIsReplaced()
3232
{
3333
$container = new ContainerBuilder();
3434
$container->setParameter('kernel.debug', false);
35-
$container->setParameter('kernel.name', 'app');
35+
$container->setParameter('kernel.container_class', 'app');
3636
$container->setParameter('kernel.environment', 'prod');
3737
$container->setParameter('kernel.root_dir', 'foo');
3838
$adapter = new Definition();
@@ -54,7 +54,7 @@ public function testNamespaceArgumentIsNotReplacedIfArrayAdapterIsUsed()
5454
{
5555
$container = new ContainerBuilder();
5656
$container->setParameter('kernel.environment', 'prod');
57-
$container->setParameter('kernel.name', 'app');
57+
$container->setParameter('kernel.container_class', 'app');
5858
$container->setParameter('kernel.root_dir', 'foo');
5959

6060
$container->register('cache.adapter.array', ArrayAdapter::class)->addArgument(0);
@@ -72,7 +72,7 @@ public function testArgsAreReplaced()
7272
{
7373
$container = new ContainerBuilder();
7474
$container->setParameter('kernel.debug', false);
75-
$container->setParameter('kernel.name', 'app');
75+
$container->setParameter('kernel.container_class', 'app');
7676
$container->setParameter('kernel.environment', 'prod');
7777
$container->setParameter('cache.prefix.seed', 'foo');
7878
$cachePool = new Definition();
@@ -97,7 +97,7 @@ public function testWithNameAttribute()
9797
{
9898
$container = new ContainerBuilder();
9999
$container->setParameter('kernel.debug', false);
100-
$container->setParameter('kernel.name', 'app');
100+
$container->setParameter('kernel.container_class', 'app');
101101
$container->setParameter('kernel.environment', 'prod');
102102
$container->setParameter('cache.prefix.seed', 'foo');
103103
$cachePool = new Definition();
@@ -123,7 +123,7 @@ public function testThrowsExceptionWhenCachePoolTagHasUnknownAttributes()
123123
{
124124
$container = new ContainerBuilder();
125125
$container->setParameter('kernel.debug', false);
126-
$container->setParameter('kernel.name', 'app');
126+
$container->setParameter('kernel.container_class', 'app');
127127
$container->setParameter('kernel.environment', 'prod');
128128
$container->setParameter('kernel.root_dir', 'foo');
129129
$adapter = new Definition();

‎src/Symfony/Component/HttpKernel/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
4.2.0
5+
-----
6+
7+
* deprecated `KernelInterface::getName()` and the `kernel.name` parameter
8+
49
4.1.0
510
-----
611

‎src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function collect(Request $request, Response $response, \Exception $except
6060
'token' => $response->headers->get('X-Debug-Token'),
6161
'symfony_version' => Kernel::VERSION,
6262
'symfony_state' => 'unknown',
63-
'name' => isset($this->kernel) ? $this->kernel->getName() : 'n/a',
63+
'name' => 'n/a',
6464
'env' => isset($this->kernel) ? $this->kernel->getEnvironment() : 'n/a',
6565
'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a',
6666
'php_version' => PHP_VERSION,
@@ -227,6 +227,8 @@ public function getPhpTimezone()
227227
* Gets the application name.
228228
*
229229
* @return string The application name
230+
*
231+
* @deprecated since Symfony 4.2
230232
*/
231233
public function getAppName()
232234
{

‎src/Symfony/Component/HttpKernel/Kernel.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Kernel.php
+13-3Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
5555
protected $environment;
5656
protected $debug;
5757
protected $booted = false;
58+
/**
59+
* @deprecated since Symfony 4.2
60+
*/
5861
protected $name;
5962
protected $startTime;
6063

@@ -78,7 +81,7 @@ public function __construct(string $environment, bool $debug)
7881
$this->environment = $environment;
7982
$this->debug = $debug;
8083
$this->rootDir = $this->getRootDir();
81-
$this->name = $this->getName();
84+
$this->name = $this->getName(false);
8285
}
8386

8487
public function __clone()
@@ -268,8 +271,12 @@ public function locateResource($name, $dir = null, $first = true)
268271
/**
269272
* {@inheritdoc}
270273
*/
271-
public function getName()
274+
public function getName(/* $triggerDeprecation = true */)
272275
{
276+
if (0 === \func_num_args() || func_get_arg(0)) {
277+
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
278+
}
279+
273280
if (null === $this->name) {
274281
$this->name = preg_replace('/[^a-zA-Z0-9_]+/', '', basename($this->rootDir));
275282
if (ctype_digit($this->name[0])) {
@@ -421,7 +428,7 @@ protected function build(ContainerBuilder $container)
421428
*/
422429
protected function getContainerClass()
423430
{
424-
return $this->name.ucfirst($this->environment).($this->debug ? 'Debug' : '').'ProjectContainer';
431+
return str_replace('\\', '_', \get_class($this)).ucfirst($this->environment).($this->debug ? 'Debug' : '').'Container';
425432
}
426433

427434
/**
@@ -576,6 +583,9 @@ protected function getKernelParameters()
576583
'kernel.project_dir' => realpath($this->getProjectDir()) ?: $this->getProjectDir(),
577584
'kernel.environment' => $this->environment,
578585
'kernel.debug' => $this->debug,
586+
/*
587+
* @deprecated since Symfony 4.2
588+
*/
579589
'kernel.name' => $this->name,
580590
'kernel.cache_dir' => realpath($cacheDir = $this->warmupDir ?: $this->getCacheDir()) ?: $cacheDir,
581591
'kernel.logs_dir' => realpath($this->getLogDir()) ?: $this->getLogDir(),

‎src/Symfony/Component/HttpKernel/KernelInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/KernelInterface.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ public function locateResource($name, $dir = null, $first = true);
100100
* Gets the name of the kernel.
101101
*
102102
* @return string The kernel name
103+
*
104+
* @deprecated since Symfony 4.2
103105
*/
104106
public function getName();
105107

‎src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function testCollect()
3030
$this->assertSame('test', $c->getEnv());
3131
$this->assertTrue($c->isDebug());
3232
$this->assertSame('config', $c->getName());
33-
$this->assertSame('testkernel', $c->getAppName());
33+
$this->assertSame('n/a', $c->getAppName());
3434
$this->assertRegExp('~^'.preg_quote($c->getPhpVersion(), '~').'~', PHP_VERSION);
3535
$this->assertRegExp('~'.preg_quote((string) $c->getPhpVersionExtra(), '~').'$~', PHP_VERSION);
3636
$this->assertSame(PHP_INT_SIZE * 8, $c->getPhpArchitecture());

‎src/Symfony/Component/HttpKernel/Tests/KernelTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/KernelTest.php
+19-5Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function testInitializeContainerClearsOldContainers()
7575
$kernel->boot();
7676

7777
$containerDir = __DIR__.'/Fixtures/cache/custom/'.substr(\get_class($kernel->getContainer()), 0, 16);
78-
$this->assertTrue(unlink(__DIR__.'/Fixtures/cache/custom/FixturesCustomDebugProjectContainer.php.meta'));
78+
$this->assertTrue(unlink(__DIR__.'/Fixtures/cache/custom/FixturesSymfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta'));
7979
$this->assertFileExists($containerDir);
8080
$this->assertFileNotExists($containerDir.'.legacy');
8181

@@ -302,13 +302,19 @@ public function testGetRootDir()
302302
$this->assertEquals(__DIR__.\DIRECTORY_SEPARATOR.'Fixtures', realpath($kernel->getRootDir()));
303303
}
304304

305+
/**
306+
* @group legacy
307+
*/
305308
public function testGetName()
306309
{
307310
$kernel = new KernelForTest('test', true);
308311

309312
$this->assertEquals('Fixtures', $kernel->getName());
310313
}
311314

315+
/**
316+
* @group legacy
317+
*/
312318
public function testOverrideGetName()
313319
{
314320
$kernel = new KernelForOverrideName('test', true);
@@ -506,6 +512,9 @@ public function testKernelWithoutBundles()
506512
$this->assertTrue($kernel->getContainer()->getParameter('test_executed'));
507513
}
508514

515+
/**
516+
* @group legacy
517+
*/
509518
public function testKernelRootDirNameStartingWithANumber()
510519
{
511520
$dir = __DIR__.'/Fixtures/123';
@@ -532,14 +541,14 @@ public function testKernelReset()
532541

533542
$containerClass = \get_class($kernel->getContainer());
534543
$containerFile = (new \ReflectionClass($kernel->getContainer()))->getFileName();
535-
unlink(__DIR__.'/Fixtures/cache/custom/FixturesCustomDebugProjectContainer.php.meta');
544+
unlink(__DIR__.'/Fixtures/cache/custom/FixturesSymfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta');
536545

537546
$kernel = new CustomProjectDirKernel();
538547
$kernel->boot();
539548

540549
$this->assertInstanceOf($containerClass, $kernel->getContainer());
541550
$this->assertFileExists($containerFile);
542-
unlink(__DIR__.'/Fixtures/cache/custom/FixturesCustomDebugProjectContainer.php.meta');
551+
unlink(__DIR__.'/Fixtures/cache/custom/FixturesSymfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta');
543552

544553
$kernel = new CustomProjectDirKernel(function ($container) { $container->register('foo', 'stdClass')->setPublic(true); });
545554
$kernel->boot();
@@ -707,9 +716,9 @@ class CustomProjectDirKernel extends Kernel
707716
private $buildContainer;
708717
private $httpKernel;
709718

710-
public function __construct(\Closure $buildContainer = null, HttpKernelInterface $httpKernel = null, $name = 'custom')
719+
public function __construct(\Closure $buildContainer = null, HttpKernelInterface $httpKernel = null, $env = 'custom')
711720
{
712-
parent::__construct($name, true);
721+
parent::__construct($env, true);
713722

714723
$this->baseDir = 'foo';
715724
$this->buildContainer = $buildContainer;
@@ -725,6 +734,11 @@ public function registerContainerConfiguration(LoaderInterface $loader)
725734
{
726735
}
727736

737+
protected function getContainerClass()
738+
{
739+
return $this->name.parent::getContainerClass();
740+
}
741+
728742
public function getProjectDir()
729743
{
730744
return $this->baseDir;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.