From 2a9749d0f4801d4fac94f781bde5912a060531b0 Mon Sep 17 00:00:00 2001 From: Hugo Hamon Date: Mon, 29 Dec 2014 20:15:36 +0100 Subject: [PATCH] Fixes deprecation notices. --- src/Symfony/Component/EventDispatcher/Event.php | 16 ++++++---------- .../EventListener/ProfilerListener.php | 11 ++++++++--- .../Component/HttpKernel/Log/NullLogger.php | 10 ++-------- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/Symfony/Component/EventDispatcher/Event.php b/src/Symfony/Component/EventDispatcher/Event.php index 0d26ec551d..e873b24702 100644 --- a/src/Symfony/Component/EventDispatcher/Event.php +++ b/src/Symfony/Component/EventDispatcher/Event.php @@ -77,14 +77,12 @@ class Event * * @param EventDispatcherInterface $dispatcher * - * @deprecated Deprecated in 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call. + * @deprecated since version 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call. * * @api */ public function setDispatcher(EventDispatcherInterface $dispatcher) { - trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0. The event dispatcher instance can be received in the listener call instead.', E_USER_DEPRECATED); - $this->dispatcher = $dispatcher; } @@ -93,13 +91,13 @@ class Event * * @return EventDispatcherInterface * - * @deprecated Deprecated in 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call. + * @deprecated since version 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call. * * @api */ public function getDispatcher() { - trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0. The event dispatcher instance can be received in the listener call instead.', E_USER_DEPRECATED); + trigger_error('The '.__METHOD__.' and '.__CLASS__.'::setDispatcher methods are deprecated since version 2.4 and will be removed in 3.0. The event dispatcher instance can be received in the listener call instead.', E_USER_DEPRECATED); return $this->dispatcher; } @@ -109,13 +107,13 @@ class Event * * @return string * - * @deprecated Deprecated in 2.4, to be removed in 3.0. The event name is passed to the listener call. + * @deprecated since version 2.4, to be removed in 3.0. The event name is passed to the listener call. * * @api */ public function getName() { - trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0. The event name can be received in the listener call instead.', E_USER_DEPRECATED); + trigger_error('The '.__METHOD__.' and '.__CLASS__.'::setName methods are deprecated since version 2.4 and will be removed in 3.0. The event name can be received in the listener call instead.', E_USER_DEPRECATED); return $this->name; } @@ -125,14 +123,12 @@ class Event * * @param string $name The event name. * - * @deprecated Deprecated in 2.4, to be removed in 3.0. The event name is passed to the listener call. + * @deprecated since version 2.4, to be removed in 3.0. The event name is passed to the listener call. * * @api */ public function setName($name) { - trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0. The event name can be received in the listener call instead.', E_USER_DEPRECATED); - $this->name = $name; } } diff --git a/src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php b/src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php index 60d15f4e54..c5a024d147 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php @@ -22,7 +22,7 @@ use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** - * ProfilerListener collects data for the current request by listening to the onKernelResponse event. + * ProfilerListener collects data for the current request by listening to the kernel events. * * @author Fabien Potencier */ @@ -49,6 +49,13 @@ class ProfilerListener implements EventSubscriberInterface */ public function __construct(Profiler $profiler, RequestMatcherInterface $matcher = null, $onlyException = false, $onlyMasterRequests = false, RequestStack $requestStack = null) { + if (null === $requestStack) { + // Prevent the deprecation notice to be triggered all the time. + // The onKernelRequest() method fires some logic only when the + // RequestStack instance is not provided as a dependency. + trigger_error('The '.__CLASS__.'::onKernelRequest method is deprecated since version 2.4 and will be removed in 3.0.', E_USER_DEPRECATED); + } + $this->profiler = $profiler; $this->matcher = $matcher; $this->onlyException = (bool) $onlyException; @@ -77,8 +84,6 @@ class ProfilerListener implements EventSubscriberInterface */ public function onKernelRequest(GetResponseEvent $event) { - trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0.', E_USER_DEPRECATED); - if (null === $this->requestStack) { $this->requests[] = $event->getRequest(); } diff --git a/src/Symfony/Component/HttpKernel/Log/NullLogger.php b/src/Symfony/Component/HttpKernel/Log/NullLogger.php index 16a7807643..0b2bb4253c 100644 --- a/src/Symfony/Component/HttpKernel/Log/NullLogger.php +++ b/src/Symfony/Component/HttpKernel/Log/NullLogger.php @@ -11,6 +11,8 @@ namespace Symfony\Component\HttpKernel\Log; +trigger_error('The '.__NAMESPACE__.'\NullLogger class is deprecated since version 2.2 and will be removed in 3.0. Use the Psr\Log\NullLogger class instead from the psr/log Composer package.'); + use Psr\Log\NullLogger as PsrNullLogger; /** @@ -24,8 +26,6 @@ class NullLogger extends PsrNullLogger implements LoggerInterface { /** * @api - * - * @deprecated since version 2.2, to be removed in 3.0. Use emergency() which is PSR-3 compatible. */ public function emerg($message, array $context = array()) { @@ -34,8 +34,6 @@ class NullLogger extends PsrNullLogger implements LoggerInterface /** * @api - * - * @deprecated since version 2.2, to be removed in 3.0. Use critical() which is PSR-3 compatible. */ public function crit($message, array $context = array()) { @@ -44,8 +42,6 @@ class NullLogger extends PsrNullLogger implements LoggerInterface /** * @api - * - * @deprecated since version 2.2, to be removed in 3.0. Use error() which is PSR-3 compatible. */ public function err($message, array $context = array()) { @@ -54,8 +50,6 @@ class NullLogger extends PsrNullLogger implements LoggerInterface /** * @api - * - * @deprecated since version 2.2, to be removed in 3.0. Use warning() which is PSR-3 compatible. */ public function warn($message, array $context = array()) {