diff --git a/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php
index 8556561..e45ee03 100644
--- a/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php
@@ -33,16 +33,15 @@ protected function alterRoutes(RouteCollection $collection) {
       '_content',
       '_form',
     );
-
-    foreach ($collection->all() as $route) {
+    $is_valid = TRUE;
+    foreach ($collection->all() as $name => $route) {
       if ($not_allowed_variables = array_intersect($route->compile()->getVariables(), $special_variables)) {
-        $placeholders = array('@variables' => implode(', ', $not_allowed_variables));
-        drupal_set_message(String::format('The following variables are reserved names by drupal: @variables', $placeholders));
-        watchdog('error', 'The following variables are reserved names by drupal: @variables', $placeholders);
-        return FALSE;
+        $reserved = implode(', ', $not_allowed_variables);
+        trigger_error(sprintf('Route %s uses reserved variable names: %s', $name, $reserved), E_USER_WARNING);
+        $is_valid = FALSE;
       }
     }
-    return TRUE;
+    return $is_valid;
   }
 
   /**
diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/SpecialAttributesRouteSubscriberTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/SpecialAttributesRouteSubscriberTest.php
index cdab44f..d519e7e 100644
--- a/core/tests/Drupal/Tests/Core/EventSubscriber/SpecialAttributesRouteSubscriberTest.php
+++ b/core/tests/Drupal/Tests/Core/EventSubscriber/SpecialAttributesRouteSubscriberTest.php
@@ -5,7 +5,7 @@
  * Contains \Drupal\Tests\Core\EventSubscriber\SpecialAttributesRouteSubscriberTest.
  */
 
-namespace Drupal\Tests\Core\EventSubscriber {
+namespace Drupal\Tests\Core\EventSubscriber;
 
 use Drupal\Core\EventSubscriber\SpecialAttributesRouteSubscriber;
 use Drupal\Core\Routing\RouteBuildEvent;
@@ -95,6 +95,8 @@ public function testOnRouteBuildingValidVariables(Route $route) {
    *   The route to check.
    *
    * @dataProvider providerTestOnRouteBuildingInvalidVariables
+   * @expectedException \PHPUnit_Framework_Error_Warning
+   * @expectedExceptionMessage uses reserved variable names
    */
   public function testOnRouteBuildingInvalidVariables(Route $route) {
     $route_collection = new RouteCollection();
@@ -104,16 +106,3 @@ public function testOnRouteBuildingInvalidVariables(Route $route) {
   }
 
 }
-
-}
-
-namespace {
-  if (!function_exists('watchdog')) {
-    function watchdog($type, $message, array $args = array()) {
-    }
-  }
-  if (!function_exists('drupal_set_message')) {
-    function drupal_set_message($type = NULL, $message = '') {
-    }
-  }
-}
