Change record status: 
Project: 
Introduced in branch: 
8.x
Introduced in version: 
8.x-alpha4
Description: 

In order to prevent both strange errors (#1766052: Importing of "global names" yields PHP warnings/fatal errors in (un)certain situations) and the silent eating of error messages (#1750980: use Exception; missing in core/lib/Drupal/Core/Utility/UpdateException.php), native PHP or global classes must be prefixed with a "\".

The rule is:

Classes and interfaces with a backslash \ inside their fully-qualified name (for example: Drupal\simpletest\WebTestBase) must not use their fully qualified name inside the code. If the namespace differs from the namespace of the current file, put a use statement on the top of the file. For example:

<?php
namespace Drupal\mymodule\Tests\Foo;

use
Drupal\simpletest\WebTestBase;

/**
 * Test that the foo bars.
 */
class BarTest extends WebTestBase {
?>

Classes and interfaces without a backslash \ inside their fully-qualified name (for example, the built-in PHP Exception class) must be fully qualified when used in a namespaced file: for example new \Exception();.

This also applies to the global "\Drupal" class.

Impacts: 
Module developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done