Skip to content

Commit a298302

Browse files
[HttpKernel] fix deprecation notice for Kernel::init()
1 parent f8618ba commit a298302

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

Kernel.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,20 @@ public function __construct($environment, $debug)
8585
$this->startTime = microtime(true);
8686
}
8787

88-
$this->init();
88+
$defClass = new \ReflectionMethod($this, 'init');
89+
$defClass = $defClass->getDeclaringClass()->name;
90+
91+
if (__CLASS__ !== $defClass) {
92+
trigger_error(sprintf('Calling %s::init() was deprecated in Symfony 2.3 and will be removed in 3.0. Move your logic to the constructor instead.', $defClass), E_USER_DEPRECATED);
93+
$this->init();
94+
}
8995
}
9096

9197
/**
9298
* @deprecated Deprecated since version 2.3, to be removed in 3.0. Move your logic in the constructor instead.
9399
*/
94100
public function init()
95101
{
96-
trigger_error('The Kernel::init() method was deprecated in version 2.3 and will be removed in 3.0. Move your logic to the constructor instead.', E_USER_DEPRECATED);
97102
}
98103

99104
public function __clone()

Tests/DataCollector/ConfigDataCollectorTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ public function registerBundles()
6969
{
7070
}
7171

72-
public function init()
73-
{
74-
}
75-
7672
public function getBundles()
7773
{
7874
return array();

0 commit comments

Comments
 (0)