From cb70632077e2a301d8b496928c77b80e599b7673 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 13 Dec 2014 11:00:55 +0100 Subject: [PATCH] [HttpKernel] fix deprecation notice for Kernel::init() --- .../FrameworkBundle/Tests/Functional/app/AppKernel.php | 4 ---- .../SecurityBundle/Tests/Functional/app/AppKernel.php | 4 ---- src/Symfony/Component/HttpKernel/Kernel.php | 9 +++++++-- .../Tests/DataCollector/ConfigDataCollectorTest.php | 4 ---- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php index 30bfc56a116d..b07d44fe22be 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php @@ -74,10 +74,6 @@ public function registerBundles() return include $filename; } - public function init() - { - } - public function getRootDir() { return __DIR__; diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php index dfce6e4a6c66..977be9162c63 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php @@ -74,10 +74,6 @@ public function registerBundles() return include $filename; } - public function init() - { - } - public function getRootDir() { return __DIR__; diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 8af95f9298d0..40771d8aad4a 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -85,7 +85,13 @@ public function __construct($environment, $debug) $this->startTime = microtime(true); } - $this->init(); + $defClass = new \ReflectionMethod($this, 'init'); + $defClass = $defClass->getDeclaringClass()->name; + + if (__CLASS__ !== $defClass) { + 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); + $this->init(); + } } /** @@ -93,7 +99,6 @@ public function __construct($environment, $debug) */ public function init() { - 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); } public function __clone() diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php index 401f1438ea67..0d672a1f0cd5 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php @@ -69,10 +69,6 @@ public function registerBundles() { } - public function init() - { - } - public function getBundles() { return array();