diff --git a/core/lib/Drupal/Component/Archiver/Zip.php b/core/lib/Drupal/Component/Archiver/Zip.php index 3f0a066..6cc1182 100644 --- a/core/lib/Drupal/Component/Archiver/Zip.php +++ b/core/lib/Drupal/Component/Archiver/Zip.php @@ -7,8 +7,6 @@ namespace Drupal\Component\Archiver; -use ZipArchive; - /** * Defines a archiver implementation for .zip files. * @@ -19,7 +17,7 @@ class Zip implements ArchiverInterface { /** * The underlying ZipArchive instance that does the heavy lifting. * - * @var ZipArchive + * @var \ZipArchive */ protected $zip; @@ -34,7 +32,7 @@ class Zip implements ArchiverInterface { * @throws Drupal\Component\Archiver\ArchiverException */ public function __construct($file_path) { - $this->zip = new ZipArchive(); + $this->zip = new \ZipArchive(); if ($this->zip->open($file_path) !== TRUE) { throw new ArchiverException(t('Cannot open %file_path', array('%file_path' => $file_path))); } @@ -90,7 +88,7 @@ public function listContents() { * ZipArchive object for implementation-specific logic. This is for advanced * use only as it is not shared by other implementations of ArchiveInterface. * - * @return ZipArchive + * @return \ZipArchive * The ZipArchive object used by this object. */ public function getArchive() { diff --git a/core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php b/core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php index 4d564fb..6b7ab5c 100644 --- a/core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php +++ b/core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php @@ -7,8 +7,6 @@ namespace Drupal\Component\PhpStorage; -use DirectoryIterator; - /** * Stores PHP code in files with securely hashed names. * @@ -164,7 +162,7 @@ protected function ensureDirectory() { */ protected function cleanDirectory($directory) { chmod($directory, 0700); - foreach (new DirectoryIterator($directory) as $fileinfo) { + foreach (new \DirectoryIterator($directory) as $fileinfo) { if (!$fileinfo->isDot()) { $this->unlink($fileinfo->getPathName()); } diff --git a/core/lib/Drupal/Component/Plugin/Discovery/AnnotatedClassDiscovery.php b/core/lib/Drupal/Component/Plugin/Discovery/AnnotatedClassDiscovery.php index 6110bd1..d9c1bc3 100644 --- a/core/lib/Drupal/Component/Plugin/Discovery/AnnotatedClassDiscovery.php +++ b/core/lib/Drupal/Component/Plugin/Discovery/AnnotatedClassDiscovery.php @@ -7,7 +7,6 @@ namespace Drupal\Component\Plugin\Discovery; -use DirectoryIterator; use Drupal\Component\Plugin\Discovery\DiscoveryInterface; use Drupal\Component\Reflection\MockFileFinder; use Doctrine\Common\Annotations\AnnotationReader; @@ -79,7 +78,7 @@ public function getDefinitions() { foreach ($dirs as $dir) { $dir .= DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $namespace); if (file_exists($dir)) { - foreach (new DirectoryIterator($dir) as $fileinfo) { + foreach (new \DirectoryIterator($dir) as $fileinfo) { // @todo Once core requires 5.3.6, use $fileinfo->getExtension(). if (pathinfo($fileinfo->getFilename(), PATHINFO_EXTENSION) == 'php') { $class = $namespace . '\\' . $fileinfo->getBasename('.php'); diff --git a/core/lib/Drupal/Component/Plugin/Factory/ReflectionFactory.php b/core/lib/Drupal/Component/Plugin/Factory/ReflectionFactory.php index 01f300e..1edd04f 100644 --- a/core/lib/Drupal/Component/Plugin/Factory/ReflectionFactory.php +++ b/core/lib/Drupal/Component/Plugin/Factory/ReflectionFactory.php @@ -6,8 +6,6 @@ namespace Drupal\Component\Plugin\Factory; -use ReflectionClass; - /** * A plugin factory that maps instance configuration to constructor arguments. * @@ -25,7 +23,7 @@ public function createInstance($plugin_id, array $configuration) { // Lets figure out of there's a constructor for this class and pull // arguments from the $options array if so to populate it. - $reflector = new ReflectionClass($plugin_class); + $reflector = new \ReflectionClass($plugin_class); if ($reflector->hasMethod('__construct')) { $arguments = $this->getInstanceArguments($reflector, $plugin_id, $plugin_definition, $configuration); $instance = $reflector->newInstanceArgs($arguments); @@ -43,7 +41,7 @@ public function createInstance($plugin_id, array $configuration) { * This is provided as a helper method so factories extending this class can * replace this and insert their own reflection logic. * - * @param ReflectionClass $reflector + * @param \ReflectionClass $reflector * The reflector object being used to inspect the plugin class. * @param string $plugin_id * The identifier of the plugin implementation. @@ -55,7 +53,7 @@ public function createInstance($plugin_id, array $configuration) { * @return array * An array of arguments to be passed to the constructor. */ - protected function getInstanceArguments(ReflectionClass $reflector, $plugin_id, array $plugin_definition, array $configuration) { + protected function getInstanceArguments(\ReflectionClass $reflector, $plugin_id, array $plugin_definition, array $configuration) { $arguments = array(); foreach ($reflector->getMethod('__construct')->getParameters() as $param) { diff --git a/core/lib/Drupal/Core/Config/ConfigException.php b/core/lib/Drupal/Core/Config/ConfigException.php index 5e7daed..012fcfa 100644 --- a/core/lib/Drupal/Core/Config/ConfigException.php +++ b/core/lib/Drupal/Core/Config/ConfigException.php @@ -7,9 +7,7 @@ namespace Drupal\Core\Config; -use RuntimeException; - /** * A base exception thrown in any configuration system operations. */ -class ConfigException extends RuntimeException {} +class ConfigException extends \RuntimeException {} diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php index 2d53763..3b194f6 100644 --- a/core/lib/Drupal/Core/Database/Connection.php +++ b/core/lib/Drupal/Core/Database/Connection.php @@ -10,9 +10,6 @@ use Drupal\Core\Database\TransactionNoActiveException; use Drupal\Core\Database\TransactionOutOfOrderException; -use PDO; -use PDOException; - /** * Base Database API class. * @@ -145,13 +142,13 @@ /** * Constructs a Connection object. */ - public function __construct(PDO $connection, array $connection_options) { + public function __construct(\PDO $connection, array $connection_options) { // Initialize and prepare the connection prefix. $this->setPrefix(isset($connection_options['prefix']) ? $connection_options['prefix'] : ''); // Set a Statement class, unless the driver opted out. if (!empty($this->statementClass)) { - $connection->setAttribute(PDO::ATTR_STATEMENT_CLASS, array($this->statementClass, array($this))); + $connection->setAttribute(\PDO::ATTR_STATEMENT_CLASS, array($this->statementClass, array($this))); } $this->connection = $connection; @@ -181,7 +178,7 @@ public function destroy() { // Destroy all references to this connection by setting them to NULL. // The Statement class attribute only accepts a new value that presents a // proper callable, so we reset it to PDOStatement. - $this->connection->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('PDOStatement', array())); + $this->connection->setAttribute(\PDO::ATTR_STATEMENT_CLASS, array('PDOStatement', array())); $this->schema = NULL; } @@ -233,7 +230,7 @@ public function destroy() { protected function defaultOptions() { return array( 'target' => 'default', - 'fetch' => PDO::FETCH_OBJ, + 'fetch' => \PDO::FETCH_OBJ, 'return' => Database::RETURN_STATEMENT, 'throw_exception' => TRUE, ); @@ -518,7 +515,7 @@ protected function filterComment($comment = '') { * this method will return NULL and may throw an exception if * $options['throw_exception'] is TRUE. * - * @throws PDOException + * @throws \PDOException * @throws \Drupal\Core\Database\IntegrityConstraintViolationException */ public function query($query, array $args = array(), $options = array()) { @@ -553,10 +550,10 @@ public function query($query, array $args = array(), $options = array()) { case Database::RETURN_NULL: return; default: - throw new PDOException('Invalid return directive: ' . $options['return']); + throw new \PDOException('Invalid return directive: ' . $options['return']); } } - catch (PDOException $e) { + catch (\PDOException $e) { if ($options['throw_exception']) { // Wrap the exception in another exception, because PHP does not allow // overriding Exception::getMessage(). Its message is the extra database @@ -1101,7 +1098,7 @@ protected function generateTemporaryTableName() { * Returns the version of the database server. */ public function version() { - return $this->connection->getAttribute(PDO::ATTR_SERVER_VERSION); + return $this->connection->getAttribute(\PDO::ATTR_SERVER_VERSION); } /** @@ -1268,7 +1265,7 @@ public function unserialize($serialized) { // Re-set a Statement class if necessary. if (!empty($this->statementClass)) { - $this->connection->setAttribute(PDO::ATTR_STATEMENT_CLASS, array($this->statementClass, array($this))); + $this->connection->setAttribute(\PDO::ATTR_STATEMENT_CLASS, array($this->statementClass, array($this))); } } diff --git a/core/lib/Drupal/Core/Database/ConnectionNotDefinedException.php b/core/lib/Drupal/Core/Database/ConnectionNotDefinedException.php index d145358..a172d7e 100644 --- a/core/lib/Drupal/Core/Database/ConnectionNotDefinedException.php +++ b/core/lib/Drupal/Core/Database/ConnectionNotDefinedException.php @@ -7,9 +7,7 @@ namespace Drupal\Core\Database; -use RuntimeException; - /** * Exception thrown if an undefined database connection is requested. */ -class ConnectionNotDefinedException extends RuntimeException {} +class ConnectionNotDefinedException extends \RuntimeException {} diff --git a/core/lib/Drupal/Core/Database/DatabaseExceptionWrapper.php b/core/lib/Drupal/Core/Database/DatabaseExceptionWrapper.php index b212478..f9527d4 100644 --- a/core/lib/Drupal/Core/Database/DatabaseExceptionWrapper.php +++ b/core/lib/Drupal/Core/Database/DatabaseExceptionWrapper.php @@ -7,13 +7,11 @@ namespace Drupal\Core\Database; -use RuntimeException; - /** * This wrapper class serves only to provide additional debug information. * * This class will always wrap a PDOException. */ -class DatabaseExceptionWrapper extends RuntimeException implements DatabaseException { +class DatabaseExceptionWrapper extends \RuntimeException implements DatabaseException { } diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php b/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php index ab374f8..7be16b3 100644 --- a/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php +++ b/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php @@ -15,8 +15,6 @@ use Drupal\Core\Database\DatabaseException; use Drupal\Core\Database\Connection as DatabaseConnection; -use PDO; - /** * @addtogroup database * @{ @@ -39,7 +37,7 @@ class Connection extends DatabaseConnection { /** * Constructs a Connection object. */ - public function __construct(PDO $connection, array $connection_options = array()) { + public function __construct(\PDO $connection, array $connection_options = array()) { parent::__construct($connection, $connection_options); // This driver defaults to transaction support, except if explicitly passed FALSE. @@ -71,18 +69,18 @@ public static function open(array &$connection_options = array()) { 'pdo' => array(), ); $connection_options['pdo'] += array( - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, // So we don't have to mess around with cursors and unbuffered queries by default. - PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => TRUE, + \PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => TRUE, // Make sure MySQL returns all matched rows on update queries including // rows that actually didn't have to be updated because the values didn't // change. This matches common behaviour among other database systems. - PDO::MYSQL_ATTR_FOUND_ROWS => TRUE, + \PDO::MYSQL_ATTR_FOUND_ROWS => TRUE, // Because MySQL's prepared statements skip the query cache, because it's dumb. - PDO::ATTR_EMULATE_PREPARES => TRUE, + \PDO::ATTR_EMULATE_PREPARES => TRUE, ); - $pdo = new PDO($dsn, $connection_options['username'], $connection_options['password'], $connection_options['pdo']); + $pdo = new \PDO($dsn, $connection_options['username'], $connection_options['password'], $connection_options['pdo']); // Force MySQL to use the UTF-8 character set. Also set the collation, if a // certain one has been set; otherwise, MySQL defaults to 'utf8_general_ci' diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php index 02a14f1..68e9c98 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php @@ -13,10 +13,6 @@ use Drupal\Core\Database\StatementInterface; use Drupal\Core\Database\IntegrityConstraintViolationException; -use Locale; -use PDO; -use PDOException; - /** * @addtogroup database * @{ @@ -37,7 +33,7 @@ class Connection extends DatabaseConnection { /** * Constructs a connection object. */ - public function __construct(PDO $connection, array $connection_options) { + public function __construct(\PDO $connection, array $connection_options) { parent::__construct($connection, $connection_options); // This driver defaults to transaction support, except if explicitly passed FALSE. @@ -89,18 +85,18 @@ public static function open(array &$connection_options = array()) { 'pdo' => array(), ); $connection_options['pdo'] += array( - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, // Prepared statements are most effective for performance when queries // are recycled (used several times). However, if they are not re-used, // prepared statements become ineffecient. Since most of Drupal's // prepared queries are not re-used, it should be faster to emulate // the preparation than to actually ready statements for re-use. If in // doubt, reset to FALSE and measure performance. - PDO::ATTR_EMULATE_PREPARES => TRUE, + \PDO::ATTR_EMULATE_PREPARES => TRUE, // Convert numeric values to strings when fetching. - PDO::ATTR_STRINGIFY_FETCHES => TRUE, + \PDO::ATTR_STRINGIFY_FETCHES => TRUE, ); - $pdo = new PDO($dsn, $connection_options['username'], $connection_options['password'], $connection_options['pdo']); + $pdo = new \PDO($dsn, $connection_options['username'], $connection_options['password'], $connection_options['pdo']); return $pdo; } @@ -142,10 +138,10 @@ public function query($query, array $args = array(), $options = array()) { case Database::RETURN_NULL: return; default: - throw new PDOException('Invalid return directive: ' . $options['return']); + throw new \PDOException('Invalid return directive: ' . $options['return']); } } - catch (PDOException $e) { + catch (\PDOException $e) { if ($options['throw_exception']) { // Match all SQLSTATE 23xxx errors. if (substr($e->getCode(), -6, -3) == '23') { @@ -209,7 +205,7 @@ public function createDatabase($database) { // If the PECL intl extension is installed, use it to determine the proper // locale. Otherwise, fall back to en_US. if (class_exists('Locale')) { - $locale = Locale::getDefault(); + $locale = \Locale::getDefault(); } else { $locale = 'en_US'; diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php index 998cbb7..9c2c448 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php @@ -10,8 +10,6 @@ use Drupal\Core\Database\Database; use Drupal\Core\Database\Query\Insert as QueryInsert; -use PDO; - /** * @ingroup database * @{ @@ -39,7 +37,7 @@ public function execute() { fwrite($blobs[$blob_count], $insert_values[$idx]); rewind($blobs[$blob_count]); - $stmt->bindParam(':db_insert_placeholder_' . $max_placeholder++, $blobs[$blob_count], PDO::PARAM_LOB); + $stmt->bindParam(':db_insert_placeholder_' . $max_placeholder++, $blobs[$blob_count], \PDO::PARAM_LOB); // Pre-increment is faster in PHP than increment. ++$blob_count; diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Update.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Update.php index ec9162d3..5c93433 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Update.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Update.php @@ -10,8 +10,6 @@ use Drupal\Core\Database\Database; use Drupal\Core\Database\Query\Update as QueryUpdate; -use PDO; - class Update extends QueryUpdate { public function execute() { @@ -48,7 +46,7 @@ public function execute() { $blobs[$blob_count] = fopen('php://memory', 'a'); fwrite($blobs[$blob_count], $value); rewind($blobs[$blob_count]); - $stmt->bindParam($placeholder, $blobs[$blob_count], PDO::PARAM_LOB); + $stmt->bindParam($placeholder, $blobs[$blob_count], \PDO::PARAM_LOB); ++$blob_count; } else { diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php index f727ac9..edd54f3 100644 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php +++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php @@ -15,9 +15,6 @@ use Drupal\Core\Database\Driver\sqlite\Statement; use Drupal\Core\Database\Connection as DatabaseConnection; -use PDO; -use SplFileInfo; - /** * Specific SQLite implementation of DatabaseConnection. */ @@ -68,7 +65,7 @@ class Connection extends DatabaseConnection { /** * Constructs a \Drupal\Core\Database\Driver\sqlite\Connection object. */ - public function __construct(PDO $connection, array $connection_options) { + public function __construct(\PDO $connection, array $connection_options) { parent::__construct($connection, $connection_options); // We don't need a specific PDOStatement class here, we simulate it below. @@ -112,11 +109,11 @@ public static function open(array &$connection_options = array()) { 'pdo' => array(), ); $connection_options['pdo'] += array( - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, // Convert numeric values to strings when fetching. - PDO::ATTR_STRINGIFY_FETCHES => TRUE, + \PDO::ATTR_STRINGIFY_FETCHES => TRUE, ); - $pdo = new PDO('sqlite:' . $connection_options['database'], '', '', $connection_options['pdo']); + $pdo = new \PDO('sqlite:' . $connection_options['database'], '', '', $connection_options['pdo']); // Create functions needed by SQLite. $pdo->sqliteCreateFunction('if', array(__CLASS__, 'sqlFunctionIf')); diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php index b21d448..0be036d 100644 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php +++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php @@ -10,9 +10,6 @@ use Drupal\Core\Database\StatementPrefetch; use Drupal\Core\Database\StatementInterface; -use Iterator; -use PDOException; - /** * Specific SQLite implementation of DatabaseConnection. * @@ -22,7 +19,7 @@ * user-space mock of PDOStatement that buffers all the data and doesn't * have those limitations. */ -class Statement extends StatementPrefetch implements Iterator, StatementInterface { +class Statement extends StatementPrefetch implements \Iterator, StatementInterface { /** * SQLite specific implementation of getStatement(). @@ -94,7 +91,7 @@ public function execute($args = array(), $options = array()) { try { $return = parent::execute($args, $options); } - catch (PDOException $e) { + catch (\PDOException $e) { if (!empty($e->errorInfo[1]) && $e->errorInfo[1] === 17) { // The schema has changed. SQLite specifies that we must resend the query. $return = parent::execute($args, $options); diff --git a/core/lib/Drupal/Core/Database/DriverNotSpecifiedException.php b/core/lib/Drupal/Core/Database/DriverNotSpecifiedException.php index 9463931..bd5935a 100644 --- a/core/lib/Drupal/Core/Database/DriverNotSpecifiedException.php +++ b/core/lib/Drupal/Core/Database/DriverNotSpecifiedException.php @@ -7,9 +7,7 @@ namespace Drupal\Core\Database; -use RuntimeException; - /** * Exception thrown if no driver is specified for a database connection. */ -class DriverNotSpecifiedException extends RuntimeException {} +class DriverNotSpecifiedException extends \RuntimeException {} diff --git a/core/lib/Drupal/Core/Database/Install/TaskException.php b/core/lib/Drupal/Core/Database/Install/TaskException.php index d93b736..2cf1c18 100644 --- a/core/lib/Drupal/Core/Database/Install/TaskException.php +++ b/core/lib/Drupal/Core/Database/Install/TaskException.php @@ -7,9 +7,7 @@ namespace Drupal\Core\Database\Install; -use RuntimeException; - /** * Exception thrown if the database installer fails. */ -class TaskException extends RuntimeException { } +class TaskException extends \RuntimeException { } diff --git a/core/lib/Drupal/Core/Database/Install/Tasks.php b/core/lib/Drupal/Core/Database/Install/Tasks.php index d46251b..4ff0b71 100644 --- a/core/lib/Drupal/Core/Database/Install/Tasks.php +++ b/core/lib/Drupal/Core/Database/Install/Tasks.php @@ -9,8 +9,6 @@ use Drupal\Core\Database\Database; -use PDO; - /** * Database installer structure. * @@ -80,7 +78,7 @@ * Ensure the PDO driver is supported by the version of PHP in use. */ protected function hasPdoDriver() { - return in_array($this->pdoDriver, PDO::getAvailableDrivers()); + return in_array($this->pdoDriver, \PDO::getAvailableDrivers()); } /** diff --git a/core/lib/Drupal/Core/Database/IntegrityConstraintViolationException.php b/core/lib/Drupal/Core/Database/IntegrityConstraintViolationException.php index 7b8ac43..b9208ee 100644 --- a/core/lib/Drupal/Core/Database/IntegrityConstraintViolationException.php +++ b/core/lib/Drupal/Core/Database/IntegrityConstraintViolationException.php @@ -7,12 +7,10 @@ namespace Drupal\Core\Database; -use RuntimeException; - /** * Exception thrown if a query would violate an integrity constraint. * * This exception is thrown e.g. when trying to insert a row that would violate * a unique key constraint. */ -class IntegrityConstraintViolationException extends RuntimeException implements DatabaseException { } +class IntegrityConstraintViolationException extends \RuntimeException implements DatabaseException { } diff --git a/core/lib/Drupal/Core/Database/Query/Condition.php b/core/lib/Drupal/Core/Database/Query/Condition.php index 1b21545..3b5fe9e 100644 --- a/core/lib/Drupal/Core/Database/Query/Condition.php +++ b/core/lib/Drupal/Core/Database/Query/Condition.php @@ -9,12 +9,10 @@ use Drupal\Core\Database\Connection; -use Countable; - /** * Generic class for a series of conditions in a query. */ -class Condition implements ConditionInterface, Countable { +class Condition implements ConditionInterface, \Countable { /** * Array of conditions. diff --git a/core/lib/Drupal/Core/Database/Query/FieldsOverlapException.php b/core/lib/Drupal/Core/Database/Query/FieldsOverlapException.php index f9d9372..ffefd4b 100644 --- a/core/lib/Drupal/Core/Database/Query/FieldsOverlapException.php +++ b/core/lib/Drupal/Core/Database/Query/FieldsOverlapException.php @@ -9,12 +9,10 @@ use Drupal\Core\Database\DatabaseException; -use InvalidArgumentException; - /** * Exception thrown if an insert query specifies a field twice. * * It is not allowed to specify a field as default and insert field, this * exception is thrown if that is the case. */ -class FieldsOverlapException extends InvalidArgumentException implements DatabaseException {} +class FieldsOverlapException extends \InvalidArgumentException implements DatabaseException {} diff --git a/core/lib/Drupal/Core/Database/Query/InvalidMergeQueryException.php b/core/lib/Drupal/Core/Database/Query/InvalidMergeQueryException.php index 59ad1c9..1fd52f2 100644 --- a/core/lib/Drupal/Core/Database/Query/InvalidMergeQueryException.php +++ b/core/lib/Drupal/Core/Database/Query/InvalidMergeQueryException.php @@ -9,12 +9,10 @@ use Drupal\Core\Database\DatabaseException; -use InvalidArgumentException; - /** * Exception thrown for merge queries that do not make semantic sense. * * There are many ways that a merge query could be malformed. They should all * throw this exception and set an appropriately descriptive message. */ -class InvalidMergeQueryException extends InvalidArgumentException implements DatabaseException {} +class InvalidMergeQueryException extends \InvalidArgumentException implements DatabaseException {} diff --git a/core/lib/Drupal/Core/Database/Query/NoFieldsException.php b/core/lib/Drupal/Core/Database/Query/NoFieldsException.php index 18851fd..805543f 100644 --- a/core/lib/Drupal/Core/Database/Query/NoFieldsException.php +++ b/core/lib/Drupal/Core/Database/Query/NoFieldsException.php @@ -9,9 +9,7 @@ use Drupal\Core\Database\DatabaseException; -use InvalidArgumentException; - /** * Exception thrown if an insert query doesn't specify insert or default fields. */ -class NoFieldsException extends InvalidArgumentException implements DatabaseException {} +class NoFieldsException extends \InvalidArgumentException implements DatabaseException {} diff --git a/core/lib/Drupal/Core/Database/SchemaException.php b/core/lib/Drupal/Core/Database/SchemaException.php index 3ae72b4..a73e7eb 100644 --- a/core/lib/Drupal/Core/Database/SchemaException.php +++ b/core/lib/Drupal/Core/Database/SchemaException.php @@ -7,9 +7,7 @@ namespace Drupal\Core\Database; -use RuntimeException; - /** * Base exception for Schema-related errors. */ -class SchemaException extends RuntimeException implements DatabaseException { } +class SchemaException extends \RuntimeException implements DatabaseException { } diff --git a/core/lib/Drupal/Core/Database/Statement.php b/core/lib/Drupal/Core/Database/Statement.php index cad8b30..e7463b3 100644 --- a/core/lib/Drupal/Core/Database/Statement.php +++ b/core/lib/Drupal/Core/Database/Statement.php @@ -7,13 +7,10 @@ namespace Drupal\Core\Database; -use PDO; -use PDOStatement; - /** * Default implementation of StatementInterface. * - * PDO allows us to extend the PDOStatement class to provide additional + * \PDO allows us to extend the \PDOStatement class to provide additional * functionality beyond that offered by default. We do need extra * functionality. By default, this class is not driver-specific. If a given * driver needs to set a custom statement class, it may do so in its @@ -21,12 +18,12 @@ * * @see http://php.net/pdostatement */ -class Statement extends PDOStatement implements StatementInterface { +class Statement extends \PDOStatement implements StatementInterface { /** * Reference to the database connection object for this statement. * - * The name $dbh is inherited from PDOStatement. + * The name $dbh is inherited from \PDOStatement. * * @var \Drupal\Core\Database\Connection */ @@ -34,15 +31,15 @@ class Statement extends PDOStatement implements StatementInterface { protected function __construct(Connection $dbh) { $this->dbh = $dbh; - $this->setFetchMode(PDO::FETCH_OBJ); + $this->setFetchMode(\PDO::FETCH_OBJ); } public function execute($args = array(), $options = array()) { if (isset($options['fetch'])) { if (is_string($options['fetch'])) { - // PDO::FETCH_PROPS_LATE tells __construct() to run before properties + // \PDO::FETCH_PROPS_LATE tells __construct() to run before properties // are added to the object. - $this->setFetchMode(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, $options['fetch']); + $this->setFetchMode(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, $options['fetch']); } else { $this->setFetchMode($options['fetch']); @@ -69,14 +66,14 @@ public function getQueryString() { } public function fetchCol($index = 0) { - return $this->fetchAll(PDO::FETCH_COLUMN, $index); + return $this->fetchAll(\PDO::FETCH_COLUMN, $index); } public function fetchAllAssoc($key, $fetch = NULL) { $return = array(); if (isset($fetch)) { if (is_string($fetch)) { - $this->setFetchMode(PDO::FETCH_CLASS, $fetch); + $this->setFetchMode(\PDO::FETCH_CLASS, $fetch); } else { $this->setFetchMode($fetch); @@ -93,7 +90,7 @@ public function fetchAllAssoc($key, $fetch = NULL) { public function fetchAllKeyed($key_index = 0, $value_index = 1) { $return = array(); - $this->setFetchMode(PDO::FETCH_NUM); + $this->setFetchMode(\PDO::FETCH_NUM); foreach ($this as $record) { $return[$record[$key_index]] = $record[$value_index]; } @@ -101,12 +98,12 @@ public function fetchAllKeyed($key_index = 0, $value_index = 1) { } public function fetchField($index = 0) { - // Call PDOStatement::fetchColumn to fetch the field. + // Call \PDOStatement::fetchColumn to fetch the field. return $this->fetchColumn($index); } public function fetchAssoc() { - // Call PDOStatement::fetch to fetch the row. - return $this->fetch(PDO::FETCH_ASSOC); + // Call \PDOStatement::fetch to fetch the row. + return $this->fetch(\PDO::FETCH_ASSOC); } } diff --git a/core/lib/Drupal/Core/Database/StatementEmpty.php b/core/lib/Drupal/Core/Database/StatementEmpty.php index 4336fa1..d290361 100644 --- a/core/lib/Drupal/Core/Database/StatementEmpty.php +++ b/core/lib/Drupal/Core/Database/StatementEmpty.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Database; -use Iterator; /** * Empty implementation of a database statement. @@ -20,7 +19,7 @@ * * @see Drupal\search\SearchQuery */ -class StatementEmpty implements Iterator, StatementInterface { +class StatementEmpty implements \Iterator, StatementInterface { public function execute($args = array(), $options = array()) { return FALSE; diff --git a/core/lib/Drupal/Core/Database/StatementInterface.php b/core/lib/Drupal/Core/Database/StatementInterface.php index b3d356c..18c2923 100644 --- a/core/lib/Drupal/Core/Database/StatementInterface.php +++ b/core/lib/Drupal/Core/Database/StatementInterface.php @@ -7,8 +7,6 @@ namespace Drupal\Core\Database; -use Traversable; - /** * Represents a prepared statement. * @@ -28,7 +26,7 @@ * class Drupal\Core\Database\Driver\oracle\Statement implements Iterator, Drupal\Core\Database\StatementInterface {} * @endcode */ -interface StatementInterface extends Traversable { +interface StatementInterface extends \Traversable { /** * Constructs a new PDOStatement object. diff --git a/core/lib/Drupal/Core/Database/StatementPrefetch.php b/core/lib/Drupal/Core/Database/StatementPrefetch.php index 9ea13f4..bedf12e 100644 --- a/core/lib/Drupal/Core/Database/StatementPrefetch.php +++ b/core/lib/Drupal/Core/Database/StatementPrefetch.php @@ -8,17 +8,14 @@ namespace Drupal\Core\Database; use Drupal\Core\Database\Connection; -use Iterator; -use PDO; -use PDOException; /** * An implementation of StatementInterface that prefetches all data. * - * This class behaves very similar to a PDOStatement but as it always fetches + * This class behaves very similar to a \PDOStatement but as it always fetches * every row it is possible to manipulate those results. */ -class StatementPrefetch implements Iterator, StatementInterface { +class StatementPrefetch implements \Iterator, StatementInterface { /** * The query string. @@ -37,9 +34,9 @@ class StatementPrefetch implements Iterator, StatementInterface { /** * Reference to the database connection object for this statement. * - * This is part of the public interface of PDOStatement. + * This is part of the public interface of \PDOStatement. * - * @var PDO + * @var \PDO */ public $dbh; @@ -58,7 +55,7 @@ class StatementPrefetch implements Iterator, StatementInterface { protected $data = array(); /** - * The current row, retrieved in PDO::FETCH_ASSOC format. + * The current row, retrieved in \PDO::FETCH_ASSOC format. * * @var Array */ @@ -94,11 +91,11 @@ class StatementPrefetch implements Iterator, StatementInterface { /** * Holds the current fetch style (which will be used by the next fetch). - * @see PDOStatement::fetch() + * @see \PDOStatement::fetch() * * @var int */ - protected $fetchStyle = PDO::FETCH_OBJ; + protected $fetchStyle = \PDO::FETCH_OBJ; /** * Holds supplementary current fetch options (which will be used by the next fetch). @@ -117,7 +114,7 @@ class StatementPrefetch implements Iterator, StatementInterface { * * @var int */ - protected $defaultFetchStyle = PDO::FETCH_OBJ; + protected $defaultFetchStyle = \PDO::FETCH_OBJ; /** * Holds supplementary default fetch options. @@ -131,7 +128,7 @@ class StatementPrefetch implements Iterator, StatementInterface { 'column' => 0, ); - public function __construct(PDO $dbh, Connection $connection, $query, array $driver_options = array()) { + public function __construct(\PDO $dbh, Connection $connection, $query, array $driver_options = array()) { $this->dbh = $dbh; $this->connection = $connection; $this->queryString = $query; @@ -154,7 +151,7 @@ public function execute($args = array(), $options = array()) { // Default to an object. Note: db fields will be added to the object // before the constructor is run. If you need to assign fields after // the constructor is run, see http://drupal.org/node/315092. - $this->setFetchMode(PDO::FETCH_CLASS, $options['fetch']); + $this->setFetchMode(\PDO::FETCH_CLASS, $options['fetch']); } else { $this->setFetchMode($options['fetch']); @@ -180,7 +177,7 @@ public function execute($args = array(), $options = array()) { // Fetch all the data from the reply, in order to release any lock // as soon as possible. $this->rowCount = $statement->rowCount(); - $this->data = $statement->fetchAll(PDO::FETCH_ASSOC); + $this->data = $statement->fetchAll(\PDO::FETCH_ASSOC); // Destroy the statement as soon as possible. See // DatabaseConnection_sqlite::PDOPrepare() for explanation. unset($statement); @@ -211,7 +208,7 @@ public function execute($args = array(), $options = array()) { protected function throwPDOException() { $error_info = $this->dbh->errorInfo(); // We rebuild a message formatted in the same way as PDO. - $exception = new PDOException("SQLSTATE[" . $error_info[0] . "]: General error " . $error_info[1] . ": " . $error_info[2]); + $exception = new \PDOException("SQLSTATE[" . $error_info[0] . "]: General error " . $error_info[1] . ": " . $error_info[2]); $exception->errorInfo = $error_info; throw $exception; } @@ -241,21 +238,21 @@ public function getQueryString() { } /** - * @see PDOStatement::setFetchMode() + * @see \PDOStatement::setFetchMode() */ public function setFetchMode($fetchStyle, $a2 = NULL, $a3 = NULL) { $this->defaultFetchStyle = $fetchStyle; switch ($fetchStyle) { - case PDO::FETCH_CLASS: + case \PDO::FETCH_CLASS: $this->defaultFetchOptions['class'] = $a2; if ($a3) { $this->defaultFetchOptions['constructor_args'] = $a3; } break; - case PDO::FETCH_COLUMN: + case \PDO::FETCH_COLUMN: $this->defaultFetchOptions['column'] = $a2; break; - case PDO::FETCH_INTO: + case \PDO::FETCH_INTO: $this->defaultFetchOptions['object'] = $a2; break; } @@ -278,23 +275,23 @@ public function setFetchMode($fetchStyle, $a2 = NULL, $a3 = NULL) { public function current() { if (isset($this->currentRow)) { switch ($this->fetchStyle) { - case PDO::FETCH_ASSOC: + case \PDO::FETCH_ASSOC: return $this->currentRow; - case PDO::FETCH_BOTH: - // PDO::FETCH_BOTH returns an array indexed by both the column name + case \PDO::FETCH_BOTH: + // \PDO::FETCH_BOTH returns an array indexed by both the column name // and the column number. return $this->currentRow + array_values($this->currentRow); - case PDO::FETCH_NUM: + case \PDO::FETCH_NUM: return array_values($this->currentRow); - case PDO::FETCH_LAZY: + case \PDO::FETCH_LAZY: // We do not do lazy as everything is fetched already. Fallback to - // PDO::FETCH_OBJ. - case PDO::FETCH_OBJ: + // \PDO::FETCH_OBJ. + case \PDO::FETCH_OBJ: return (object) $this->currentRow; - case PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE: + case \PDO::FETCH_CLASS | \PDO::FETCH_CLASSTYPE: $class_name = array_unshift($this->currentRow); // Deliberate no break. - case PDO::FETCH_CLASS: + case \PDO::FETCH_CLASS: if (!isset($class_name)) { $class_name = $this->fetchOptions['class']; } @@ -309,12 +306,12 @@ public function current() { $result->$k = $v; } return $result; - case PDO::FETCH_INTO: + case \PDO::FETCH_INTO: foreach ($this->currentRow as $k => $v) { $this->fetchOptions['object']->$k = $v; } return $this->fetchOptions['object']; - case PDO::FETCH_COLUMN: + case \PDO::FETCH_COLUMN: if (isset($this->columnNames[$this->fetchOptions['column']])) { return $this->currentRow[$k][$this->columnNames[$this->fetchOptions['column']]]; } @@ -356,7 +353,7 @@ public function rowCount() { return $this->rowCount; } - public function fetch($fetch_style = NULL, $cursor_orientation = PDO::FETCH_ORI_NEXT, $cursor_offset = NULL) { + public function fetch($fetch_style = NULL, $cursor_orientation = \PDO::FETCH_ORI_NEXT, $cursor_offset = NULL) { if (isset($this->currentRow)) { // Set the fetch parameter. $this->fetchStyle = isset($fetch_style) ? $fetch_style : $this->defaultFetchStyle; @@ -400,7 +397,7 @@ public function fetchObject($class_name = NULL, $constructor_args = array()) { $result = (object) $this->currentRow; } else { - $this->fetchStyle = PDO::FETCH_CLASS; + $this->fetchStyle = \PDO::FETCH_CLASS; $this->fetchOptions = array('constructor_args' => $constructor_args); // Grab the row in the format specified above. $result = $this->current(); @@ -491,7 +488,7 @@ public function fetchAllAssoc($key, $fetch_style = NULL) { $result = array(); // Traverse the array as PHP would have done. while (isset($this->currentRow)) { - // Grab the row in its raw PDO::FETCH_ASSOC format. + // Grab the row in its raw \PDO::FETCH_ASSOC format. $result_row = $this->current(); $result[$this->currentRow[$key]] = $result_row; $this->next(); diff --git a/core/lib/Drupal/Core/Database/TransactionException.php b/core/lib/Drupal/Core/Database/TransactionException.php index 25079f5..79e2f1a 100644 --- a/core/lib/Drupal/Core/Database/TransactionException.php +++ b/core/lib/Drupal/Core/Database/TransactionException.php @@ -7,9 +7,7 @@ namespace Drupal\Core\Database; -use RuntimeException; - /** * Exception thrown by an error in a database transaction. */ -class TransactionException extends RuntimeException implements DatabaseException { } +class TransactionException extends \RuntimeException implements DatabaseException { } diff --git a/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterKernelListenersPass.php b/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterKernelListenersPass.php index e580c31..9601f4d 100644 --- a/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterKernelListenersPass.php +++ b/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterKernelListenersPass.php @@ -7,8 +7,6 @@ namespace Drupal\Core\DependencyInjection\Compiler; -use InvalidArgumentException; -use ReflectionClass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; @@ -25,10 +23,10 @@ public function process(ContainerBuilder $container) { // We must assume that the class value has been correcly filled, even if the service is created by a factory $class = $container->getDefinition($id)->getClass(); - $refClass = new ReflectionClass($class); + $refClass = new \ReflectionClass($class); $interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface'; if (!$refClass->implementsInterface($interface)) { - throw new InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface)); + throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface)); } $definition->addMethodCall('addSubscriberService', array($id, $class)); } diff --git a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php index 42ea348..86ed508 100644 --- a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php +++ b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php @@ -9,8 +9,6 @@ use Drupal\Core\Language\Language; use Drupal\field\FieldInfo; -use PDO; - use Drupal\Core\Entity\Query\QueryInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\DatabaseStorageController; @@ -268,7 +266,7 @@ protected function attachPropertyData(array &$entities, $revision_id = FALSE) { // If a revision table is available, we need all the properties of the // latest revision. Otherwise we fall back to the data table. $table = $this->revisionTable ?: $this->dataTable; - $query = $this->database->select($table, 'data', array('fetch' => PDO::FETCH_ASSOC)) + $query = $this->database->select($table, 'data', array('fetch' => \PDO::FETCH_ASSOC)) ->fields('data') ->condition($this->idKey, array_keys($entities)) ->orderBy('data.' . $this->idKey); diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 68404ba..730f890 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -11,7 +11,6 @@ use Drupal\Core\Language\Language; use Drupal\Core\TypedData\TranslatableInterface; use Drupal\Core\TypedData\TypedDataInterface; -use IteratorAggregate; use Drupal\Core\Session\AccountInterface; /** @@ -22,7 +21,7 @@ * This class can be used as-is by simple entity types. Entity types requiring * special handling can extend the class. */ -class Entity implements IteratorAggregate, EntityInterface { +class Entity implements \IteratorAggregate, EntityInterface { /** * The language code of the entity's default language. diff --git a/core/lib/Drupal/Core/Entity/EntityBCDecorator.php b/core/lib/Drupal/Core/Entity/EntityBCDecorator.php index bfb13ee..d52549c 100644 --- a/core/lib/Drupal/Core/Entity/EntityBCDecorator.php +++ b/core/lib/Drupal/Core/Entity/EntityBCDecorator.php @@ -8,7 +8,6 @@ namespace Drupal\Core\Entity; use Drupal\Core\Language\Language; -use IteratorAggregate; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\TypedData\TypedDataInterface; use Drupal\Core\Session\AccountInterface; @@ -38,7 +37,7 @@ * * @todo: Remove once everything is converted to use the new entity field API. */ -class EntityBCDecorator implements IteratorAggregate, EntityInterface { +class EntityBCDecorator implements \IteratorAggregate, EntityInterface { /** * The EntityInterface object being decorated. diff --git a/core/lib/Drupal/Core/Entity/EntityNG.php b/core/lib/Drupal/Core/Entity/EntityNG.php index d0b6b4c..dbbf6a0 100644 --- a/core/lib/Drupal/Core/Entity/EntityNG.php +++ b/core/lib/Drupal/Core/Entity/EntityNG.php @@ -10,8 +10,6 @@ use Drupal\Core\Language\Language; use Drupal\Core\Session\AccountInterface; use Drupal\Core\TypedData\TypedDataInterface; -use ArrayIterator; -use InvalidArgumentException; /** * Implements Entity Field API specific enhancements to the Entity class. @@ -296,7 +294,7 @@ protected function getTranslatedField($property_name, $langcode) { if (!isset($this->fields[$property_name][$langcode])) { $definition = $this->getPropertyDefinition($property_name); if (!$definition) { - throw new InvalidArgumentException('Field ' . check_plain($property_name) . ' is unknown.'); + throw new \InvalidArgumentException('Field ' . check_plain($property_name) . ' is unknown.'); } // Non-translatable fields are always stored with // Language::LANGCODE_DEFAULT as key. @@ -347,7 +345,7 @@ public function getProperties($include_computed = FALSE) { * Implements \IteratorAggregate::getIterator(). */ public function getIterator() { - return new ArrayIterator($this->getProperties()); + return new \ArrayIterator($this->getProperties()); } /** diff --git a/core/lib/Drupal/Core/FileTransfer/FileTransfer.php b/core/lib/Drupal/Core/FileTransfer/FileTransfer.php index 823e17e..d94e9c7 100644 --- a/core/lib/Drupal/Core/FileTransfer/FileTransfer.php +++ b/core/lib/Drupal/Core/FileTransfer/FileTransfer.php @@ -7,9 +7,6 @@ namespace Drupal\Core\FileTransfer; -use RecursiveIteratorIterator; -use RecursiveDirectoryIterator; - /** * Defines the base FileTransfer class. * @@ -280,7 +277,7 @@ protected function copyDirectoryJailed($source, $destination) { $destination = $destination . '/' . drupal_basename($source); } $this->createDirectory($destination); - foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST) as $filename => $file) { + foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $filename => $file) { $relative_path = substr($filename, strlen($source)); if ($file->isDir()) { $this->createDirectory($destination . $relative_path); diff --git a/core/lib/Drupal/Core/FileTransfer/FileTransferException.php b/core/lib/Drupal/Core/FileTransfer/FileTransferException.php index bc32af8..a9ac919 100644 --- a/core/lib/Drupal/Core/FileTransfer/FileTransferException.php +++ b/core/lib/Drupal/Core/FileTransfer/FileTransferException.php @@ -7,12 +7,10 @@ namespace Drupal\Core\FileTransfer; -use RuntimeException; - /** * FileTransferException class. */ -class FileTransferException extends RuntimeException { +class FileTransferException extends \RuntimeException { /** * Arguments to be used in this exception. diff --git a/core/lib/Drupal/Core/FileTransfer/Local.php b/core/lib/Drupal/Core/FileTransfer/Local.php index 92ddcd9..a0973be 100644 --- a/core/lib/Drupal/Core/FileTransfer/Local.php +++ b/core/lib/Drupal/Core/FileTransfer/Local.php @@ -7,9 +7,6 @@ namespace Drupal\Core\FileTransfer; -use RecursiveIteratorIterator; -use RecursiveDirectoryIterator; - /** * Defines the local connection class for copying files as the httpd user. */ @@ -55,7 +52,7 @@ protected function removeDirectoryJailed($directory) { // Programmer error assertion, not something we expect users to see. throw new FileTransferException('removeDirectoryJailed() called with a path (%directory) that is not a directory.', NULL, array('%directory' => $directory)); } - foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST) as $filename => $file) { + foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST) as $filename => $file) { if ($file->isDir()) { if (@!drupal_rmdir($filename)) { throw new FileTransferException('Cannot remove directory %directory.', NULL, array('%directory' => $filename)); diff --git a/core/lib/Drupal/Core/Queue/Memory.php b/core/lib/Drupal/Core/Queue/Memory.php index 1c59d8c..eb25f9a 100644 --- a/core/lib/Drupal/Core/Queue/Memory.php +++ b/core/lib/Drupal/Core/Queue/Memory.php @@ -7,8 +7,6 @@ namespace Drupal\Core\Queue; -use stdClass; - /** * Static queue implementation. * @@ -46,7 +44,7 @@ public function __construct($name) { * Implements Drupal\Core\Queue\QueueInterface::createItem(). */ public function createItem($data) { - $item = new stdClass(); + $item = new \stdClass(); $item->item_id = $this->idSequence++; $item->data = $data; $item->created = time(); diff --git a/core/lib/Drupal/Core/Routing/GeneratorNotInitializedException.php b/core/lib/Drupal/Core/Routing/GeneratorNotInitializedException.php index ab2922c..194e577 100644 --- a/core/lib/Drupal/Core/Routing/GeneratorNotInitializedException.php +++ b/core/lib/Drupal/Core/Routing/GeneratorNotInitializedException.php @@ -6,9 +6,7 @@ namespace Drupal\Core\Routing; -use Exception; - /** * Class for exceptions thrown when the generator has not been initialized. */ -class GeneratorNotInitializedException extends Exception { } +class GeneratorNotInitializedException extends \Exception { } diff --git a/core/lib/Drupal/Core/TypedData/ComplexDataInterface.php b/core/lib/Drupal/Core/TypedData/ComplexDataInterface.php index a681ffe..8acfaa3 100644 --- a/core/lib/Drupal/Core/TypedData/ComplexDataInterface.php +++ b/core/lib/Drupal/Core/TypedData/ComplexDataInterface.php @@ -7,8 +7,6 @@ namespace Drupal\Core\TypedData; -use Traversable; - /** * Interface for complex data; i.e. data containing named and typed properties. * @@ -21,7 +19,7 @@ * When implementing this interface which extends Traversable, make sure to list * IteratorAggregate or Iterator before this interface in the implements clause. */ -interface ComplexDataInterface extends Traversable, TypedDataInterface { +interface ComplexDataInterface extends \Traversable, TypedDataInterface { /** * Gets a property object. diff --git a/core/lib/Drupal/Core/TypedData/ListInterface.php b/core/lib/Drupal/Core/TypedData/ListInterface.php index 451e1af..2088c2d 100644 --- a/core/lib/Drupal/Core/TypedData/ListInterface.php +++ b/core/lib/Drupal/Core/TypedData/ListInterface.php @@ -7,10 +7,6 @@ namespace Drupal\Core\TypedData; -use ArrayAccess; -use Countable; -use Traversable; - /** * Interface for a list of typed data. * @@ -20,7 +16,7 @@ * When implementing this interface which extends Traversable, make sure to list * IteratorAggregate or Iterator before this interface in the implements clause. */ -interface ListInterface extends TypedDataInterface, ArrayAccess, Countable, Traversable { +interface ListInterface extends TypedDataInterface, \ArrayAccess, \Countable, \Traversable { /** * Determines whether the list contains any non-empty items. diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php index 87d0bdf..5ba5b0f 100644 --- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php +++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php @@ -9,7 +9,6 @@ use Drupal\Core\TypedData\Annotation\DataType; use Drupal\Core\Annotation\Translation; -use InvalidArgumentException; use Drupal\Core\Language\Language as LanguageObject; use Drupal\Core\TypedData\IdentifiableInterface; use Drupal\Core\TypedData\TypedData; @@ -65,7 +64,7 @@ public function setValue($value, $notify = TRUE) { $this->language = $value; } elseif (isset($value) && !is_scalar($value)) { - throw new InvalidArgumentException('Value is no valid langcode or language object.'); + throw new \InvalidArgumentException('Value is no valid langcode or language object.'); } else { $this->id = $value; diff --git a/core/lib/Drupal/Core/TypedData/TypedDataManager.php b/core/lib/Drupal/Core/TypedData/TypedDataManager.php index 0e786bd..bbc0d7f 100644 --- a/core/lib/Drupal/Core/TypedData/TypedDataManager.php +++ b/core/lib/Drupal/Core/TypedData/TypedDataManager.php @@ -12,7 +12,6 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Language\LanguageManager; use Drupal\Core\Plugin\DefaultPluginManager; -use InvalidArgumentException; use Drupal\Core\TypedData\Validation\MetadataFactory; use Drupal\Core\Validation\ConstraintManager; use Drupal\Core\Validation\DrupalTranslator; @@ -74,7 +73,7 @@ public function createInstance($plugin_id, array $configuration, $name = NULL, $ $type_definition = $this->getDefinition($plugin_id); if (!isset($type_definition)) { - throw new InvalidArgumentException(format_string('Invalid data type %plugin_id has been given.', array('%plugin_id' => $plugin_id))); + throw new \InvalidArgumentException(format_string('Invalid data type %plugin_id has been given.', array('%plugin_id' => $plugin_id))); } // Allow per-data definition overrides of the used classes, i.e. take over @@ -236,11 +235,11 @@ public function getPropertyInstance(TypedDataInterface $object, $property_name, $definition = $object->getItemDefinition(); } else { - throw new InvalidArgumentException("The passed object has to either implement the ComplexDataInterface or the ListInterface."); + throw new \InvalidArgumentException("The passed object has to either implement the ComplexDataInterface or the ListInterface."); } // Make sure we have got a valid definition. if (!$definition) { - throw new InvalidArgumentException('Property ' . check_plain($property_name) . ' is unknown.'); + throw new \InvalidArgumentException('Property ' . check_plain($property_name) . ' is unknown.'); } // Now create the prototype using the definition, but do not pass the // given value as it will serve as prototype for any further instance. diff --git a/core/lib/Drupal/Core/Utility/CacheArray.php b/core/lib/Drupal/Core/Utility/CacheArray.php index 9748753..b3fa316 100644 --- a/core/lib/Drupal/Core/Utility/CacheArray.php +++ b/core/lib/Drupal/Core/Utility/CacheArray.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Utility; -use ArrayAccess; use Drupal\Core\Cache\CacheBackendInterface; /** @@ -66,7 +65,7 @@ * * @see SchemaCache */ -abstract class CacheArray implements ArrayAccess { +abstract class CacheArray implements \ArrayAccess { /** * A cid to pass to cache()->set() and cache()->get(). diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php index 302fcc9..6ed2d3a 100644 --- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php +++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Validation\Plugin\Validation\Constraint; -use DateInterval; use Drupal\Core\TypedData\Type\BinaryInterface; use Drupal\Core\TypedData\Type\BooleanInterface; use Drupal\Core\TypedData\Type\DateTimeInterface; @@ -58,7 +57,7 @@ public function validate($value, Constraint $constraint) { if ($typed_data instanceof DateTimeInterface && $typed_data->getDateTime()->hasErrors()) { $valid = FALSE; } - if ($typed_data instanceof DurationInterface && !($typed_data->getDuration() instanceof DateInterval)) { + if ($typed_data instanceof DurationInterface && !($typed_data->getDuration() instanceof \DateInterval)) { $valid = FALSE; } } diff --git a/core/modules/comment/lib/Drupal/comment/CommentStorageController.php b/core/modules/comment/lib/Drupal/comment/CommentStorageController.php index 3dc7f2c..6068ce9 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentStorageController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentStorageController.php @@ -10,7 +10,6 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\DatabaseStorageControllerNG; use Drupal\Component\Uuid\Uuid; -use LogicException; /** * Defines the controller class for comments. diff --git a/core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php b/core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php index 9f68a34..2ccef59 100644 --- a/core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php +++ b/core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php @@ -10,7 +10,6 @@ use Drupal\Core\Language\Language; use Drupal\dblog\Controller\DbLogController; use Drupal\simpletest\WebTestBase; -use SimpleXMLElement; /** * Tests logging messages to the database. @@ -590,13 +589,13 @@ protected function getSeverityConstant($class) { /** * Extracts the text contained by the XHTML element. * - * @param SimpleXMLElement $element + * @param \SimpleXMLElement $element * Element to extract text from. * * @return string * Extracted text. */ - protected function asText(SimpleXMLElement $element) { + protected function asText(\SimpleXMLElement $element) { if (!is_object($element)) { return $this->fail('The element is not an element.'); } diff --git a/core/modules/field/lib/Drupal/field/FieldException.php b/core/modules/field/lib/Drupal/field/FieldException.php index b653109..e54fa39 100644 --- a/core/modules/field/lib/Drupal/field/FieldException.php +++ b/core/modules/field/lib/Drupal/field/FieldException.php @@ -7,12 +7,10 @@ namespace Drupal\field; -use RuntimeException; - /** * Base class for all exceptions thrown by Field API functions. * * This class has no functionality of its own other than allowing all * Field API exceptions to be caught by a single catch block. */ -class FieldException extends RuntimeException {} +class FieldException extends \RuntimeException {} diff --git a/core/modules/locale/lib/Drupal/locale/PoDatabaseReader.php b/core/modules/locale/lib/Drupal/locale/PoDatabaseReader.php index 019ce95..e545fe1 100644 --- a/core/modules/locale/lib/Drupal/locale/PoDatabaseReader.php +++ b/core/modules/locale/lib/Drupal/locale/PoDatabaseReader.php @@ -11,7 +11,6 @@ use Drupal\Component\Gettext\PoItem; use Drupal\Component\Gettext\PoReaderInterface; use Drupal\locale\TranslationString; -use PDO; /** * Gettext PO reader working with the locale module database. diff --git a/core/modules/locale/lib/Drupal/locale/SourceString.php b/core/modules/locale/lib/Drupal/locale/SourceString.php index 40254f4..fec6b31 100644 --- a/core/modules/locale/lib/Drupal/locale/SourceString.php +++ b/core/modules/locale/lib/Drupal/locale/SourceString.php @@ -8,7 +8,6 @@ namespace Drupal\locale; use Drupal\locale\LocaleString; -use PDO; /** * Defines the locale source string object. diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php index c0a9102..f3ddbbb 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -18,8 +18,6 @@ use Drupal\Core\DrupalKernel; use Drupal\Core\Language\Language; use Drupal\Core\StreamWrapper\PublicStream; -use ReflectionMethod; -use ReflectionObject; /** * Base class for Drupal tests. @@ -741,7 +739,7 @@ public function run(array $methods = array()) { } $missing_requirements = $this->checkRequirements(); if (!empty($missing_requirements)) { - $missing_requirements_object = new ReflectionObject($this); + $missing_requirements_object = new \ReflectionObject($this); $caller = array( 'file' => $missing_requirements_object->getFileName(), ); @@ -755,7 +753,7 @@ public function run(array $methods = array()) { if (strtolower(substr($method, 0, 4)) == 'test') { // Insert a fail record. This will be deleted on completion to ensure // that testing completed. - $method_info = new ReflectionMethod($class, $method); + $method_info = new \ReflectionMethod($class, $method); $caller = array( 'file' => $method_info->getFileName(), 'line' => $method_info->getStartLine(), diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php index 1588b64..11de754 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php @@ -8,7 +8,6 @@ namespace Drupal\simpletest\Tests; use Drupal\simpletest\WebTestBase; -use SimpleXMLElement; class SimpleTestTest extends WebTestBase { @@ -325,7 +324,7 @@ function getResultFieldSet() { * @return * Extracted text. */ - function asText(SimpleXMLElement $element) { + function asText(\SimpleXMLElement $element) { if (!is_object($element)) { return $this->fail('The element is not an element.'); } diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 52ca231..642dc1e 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -17,11 +17,6 @@ use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\UserSession; use Drupal\Core\StreamWrapper\PublicStream; -use PDO; -use stdClass; -use DOMDocument; -use DOMXPath; -use SimpleXMLElement; use Drupal\Core\Datetime\DrupalDateTime; use Symfony\Component\HttpFoundation\Request; @@ -94,7 +89,7 @@ /** * The parsed version of the page. * - * @var SimpleXMLElement + * @var \SimpleXMLElement */ protected $elements = NULL; @@ -1231,7 +1226,7 @@ protected function parse() { if (!$this->elements) { // DOM can load HTML soup. But, HTML soup can throw warnings, suppress // them. - $htmlDom = new DOMDocument(); + $htmlDom = new \DOMDocument(); @$htmlDom->loadHTML('' . $this->drupalGetContent()); if ($htmlDom) { $this->pass(t('Valid HTML found on "@path"', array('@path' => $this->getUrl())), t('Browser')); @@ -1597,10 +1592,10 @@ protected function drupalPostAjaxForm($path, $edit, $triggering_element, $ajax_p ); // DOM can load HTML soup. But, HTML soup can throw warnings, suppress // them. - $dom = new DOMDocument(); + $dom = new \DOMDocument(); @$dom->loadHTML($content); // XPath allows for finding wrapper nodes better than DOM does. - $xpath = new DOMXPath($dom); + $xpath = new \DOMXPath($dom); foreach ($return as $command) { switch ($command['command']) { case 'settings': @@ -1622,7 +1617,7 @@ protected function drupalPostAjaxForm($path, $edit, $triggering_element, $ajax_p } if ($wrapperNode) { // ajax.js adds an enclosing DIV to work around a Safari bug. - $newDom = new DOMDocument(); + $newDom = new \DOMDocument(); @$newDom->loadHTML('
' . $command['data'] . '
'); $newNode = $dom->importNode($newDom->documentElement->firstChild->firstChild, TRUE); $method = isset($command['method']) ? $command['method'] : $ajax_settings['method']; @@ -2063,7 +2058,7 @@ protected function xpath($xpath, array $arguments = array()) { * @return * Option elements in select. */ - protected function getAllOptions(SimpleXMLElement $element) { + protected function getAllOptions(\SimpleXMLElement $element) { $options = array(); // Add all options items. foreach ($element->option as $option) { @@ -2889,7 +2884,7 @@ protected function assertFieldByXPath($xpath, $value = NULL, $message = '', $gro * @return * The selected value or FALSE. */ - protected function getSelectedItem(SimpleXMLElement $element) { + protected function getSelectedItem(\SimpleXMLElement $element) { foreach ($element->children() as $item) { if (isset($item['selected'])) { return $item['value']; diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php index 5c8fbbb..29a482b 100644 --- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php +++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php @@ -8,7 +8,6 @@ namespace Drupal\statistics\Tests; use Drupal\simpletest\WebTestBase; -use PDO; /** * Tests that logging via statistics_exit() works for all pages. diff --git a/core/modules/system/lib/Drupal/system/Tests/Cache/GenericCacheBackendUnitTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Cache/GenericCacheBackendUnitTestBase.php index 06f3fc0..9f2afc1 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Cache/GenericCacheBackendUnitTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Cache/GenericCacheBackendUnitTestBase.php @@ -10,8 +10,6 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\simpletest\DrupalUnitTestBase; -use stdClass; - /** * Tests any cache backend. * diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/AlterTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/AlterTest.php index c2f1595..3f6b30c 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/AlterTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/AlterTest.php @@ -8,7 +8,6 @@ namespace Drupal\system\Tests\Common; use Drupal\simpletest\WebTestBase; -use stdClass; /** * Tests alteration of arguments passed to drupal_alter(). @@ -41,7 +40,7 @@ function testDrupalAlter() { $base_theme_info = array(); $array = array('foo' => 'bar'); - $entity = new stdClass(); + $entity = new \stdClass(); $entity->foo = 'bar'; // Verify alteration of a single argument. diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/WriteRecordTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/WriteRecordTest.php index 628dad9..ee4fe4d 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/WriteRecordTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/WriteRecordTest.php @@ -8,7 +8,6 @@ namespace Drupal\system\Tests\Common; use Drupal\simpletest\WebTestBase; -use stdClass; /** * Tests writing of data records with drupal_write_record(). @@ -40,7 +39,7 @@ function testDrupalWriteRecord() { $this->assertTrue($insert_result == SAVED_NEW, 'Correct value returned when an empty record is inserted with drupal_write_record().'); // Insert a record - no columns allow NULL values. - $person = new stdClass(); + $person = new \stdClass(); $person->name = 'John'; $person->unknown_column = 123; $insert_result = drupal_write_record('test', $person); @@ -70,7 +69,7 @@ function testDrupalWriteRecord() { $this->assertIdentical($result->job, '', 'Job field set and cast to string.'); // Try to insert NULL in columns that does not allow this. - $person = new stdClass(); + $person = new \stdClass(); $person->name = 'Ringo'; $person->age = NULL; $person->job = NULL; @@ -82,7 +81,7 @@ function testDrupalWriteRecord() { $this->assertIdentical($result->job, '', 'Job field set.'); // Insert a record - the "age" column allows NULL. - $person = new stdClass(); + $person = new \stdClass(); $person->name = 'Paul'; $person->age = NULL; $insert_result = drupal_write_record('test_null', $person); @@ -92,7 +91,7 @@ function testDrupalWriteRecord() { $this->assertIdentical($result->age, NULL, 'Age field set.'); // Insert a record - do not specify the value of a column that allows NULL. - $person = new stdClass(); + $person = new \stdClass(); $person->name = 'Meredith'; $insert_result = drupal_write_record('test_null', $person); $this->assertTrue(isset($person->id), 'Primary key is set on record created with drupal_write_record().'); @@ -110,7 +109,7 @@ function testDrupalWriteRecord() { $this->assertIdentical($result->age, NULL, 'Age field set.'); // Insert a record - the "data" column should be serialized. - $person = new stdClass(); + $person = new \stdClass(); $person->name = 'Dave'; $update_result = drupal_write_record('test_serialized', $person); $result = db_query("SELECT * FROM {test_serialized} WHERE id = :id", array(':id' => $person->id))->fetchObject(); @@ -136,7 +135,7 @@ function testDrupalWriteRecord() { $this->assertTrue($update_result == SAVED_UPDATED, 'Correct value returned when a valid update is run without changing any values.'); // Insert an object record for a table with a multi-field primary key. - $node_access = new stdClass(); + $node_access = new \stdClass(); $node_access->nid = mt_rand(); $node_access->gid = mt_rand(); $node_access->realm = $this->randomName(); diff --git a/core/modules/system/lib/Drupal/system/Tests/Database/FetchTest.php b/core/modules/system/lib/Drupal/system/Tests/Database/FetchTest.php index db24ba9..0116063 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Database/FetchTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Database/FetchTest.php @@ -8,7 +8,6 @@ namespace Drupal\system\Tests\Database; use Drupal\Core\Database\StatementInterface; -use PDO; /** * Tests fetch actions. @@ -46,7 +45,7 @@ function testQueryFetchDefault() { */ function testQueryFetchObject() { $records = array(); - $result = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 25), array('fetch' => PDO::FETCH_OBJ)); + $result = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 25), array('fetch' => \PDO::FETCH_OBJ)); foreach ($result as $record) { $records[] = $record; $this->assertTrue(is_object($record), 'Record is an object.'); @@ -61,7 +60,7 @@ function testQueryFetchObject() { */ function testQueryFetchArray() { $records = array(); - $result = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 25), array('fetch' => PDO::FETCH_ASSOC)); + $result = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 25), array('fetch' => \PDO::FETCH_ASSOC)); foreach ($result as $record) { $records[] = $record; if ($this->assertTrue(is_array($record), 'Record is an array.')) { @@ -95,7 +94,7 @@ function testQueryFetchClass() { */ function testQueryFetchNum() { $records = array(); - $result = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 25), array('fetch' => PDO::FETCH_NUM)); + $result = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 25), array('fetch' => \PDO::FETCH_NUM)); foreach ($result as $record) { $records[] = $record; if ($this->assertTrue(is_array($record), 'Record is an array.')) { @@ -111,7 +110,7 @@ function testQueryFetchNum() { */ function testQueryFetchBoth() { $records = array(); - $result = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 25), array('fetch' => PDO::FETCH_BOTH)); + $result = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 25), array('fetch' => \PDO::FETCH_BOTH)); foreach ($result as $record) { $records[] = $record; if ($this->assertTrue(is_array($record), 'Record is an array.')) { diff --git a/core/modules/system/lib/Drupal/system/Tests/Database/SelectOrderedTest.php b/core/modules/system/lib/Drupal/system/Tests/Database/SelectOrderedTest.php index 54b0379..62d4d2a 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Database/SelectOrderedTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Database/SelectOrderedTest.php @@ -7,8 +7,6 @@ namespace Drupal\system\Tests\Database; -use PDO; - /** * Tests SELECT with ORDER BY clauses. */ @@ -62,7 +60,7 @@ function testSimpleSelectMultiOrdered() { array('George', 27, 'Singer'), array('Paul', 26, 'Songwriter'), ); - $results = $result->fetchAll(PDO::FETCH_NUM); + $results = $result->fetchAll(\PDO::FETCH_NUM); foreach ($expected as $k => $record) { $num_records++; foreach ($record as $kk => $col) { diff --git a/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/DrupalKernelTest.php b/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/DrupalKernelTest.php index f73d4ef..2639f3b 100644 --- a/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/DrupalKernelTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/DrupalKernelTest.php @@ -11,7 +11,6 @@ use Drupal\Component\PhpStorage\MTimeProtectedFastFileStorage; use Drupal\Component\PhpStorage\FileReadOnlyStorage; use Drupal\simpletest\UnitTestBase; -use ReflectionClass; /** * Tests compilation of the DIC. @@ -58,7 +57,7 @@ function testCompileDIC() { $kernel->updateModules($module_enabled); $kernel->boot(); $container = $kernel->getContainer(); - $refClass = new ReflectionClass($container); + $refClass = new \ReflectionClass($container); $is_compiled_container = $refClass->getParentClass()->getName() == 'Drupal\Core\DependencyInjection\Container' && !$refClass->isSubclassOf('Symfony\Component\DependencyInjection\ContainerBuilder'); @@ -72,14 +71,14 @@ function testCompileDIC() { $kernel->updateModules($module_enabled); $kernel->boot(); $container = $kernel->getContainer(); - $refClass = new ReflectionClass($container); + $refClass = new \ReflectionClass($container); $is_compiled_container = $refClass->getParentClass()->getName() == 'Drupal\Core\DependencyInjection\Container' && !$refClass->isSubclassOf('Symfony\Component\DependencyInjection\ContainerBuilder'); $this->assertTrue($is_compiled_container); // Test that our synthetic services are there. $classloader = $container->get('class_loader'); - $refClass = new ReflectionClass($classloader); + $refClass = new \ReflectionClass($classloader); $this->assertTrue($refClass->hasMethod('loadClass'), 'Container has a classloader'); // We make this assertion here purely to show that the new container below @@ -100,14 +99,14 @@ function testCompileDIC() { $kernel->updateModules($module_enabled); $kernel->boot(); $container = $kernel->getContainer(); - $refClass = new ReflectionClass($container); + $refClass = new \ReflectionClass($container); $is_container_builder = $refClass->isSubclassOf('Symfony\Component\DependencyInjection\ContainerBuilder'); $this->assertTrue($is_container_builder); // Assert that the new module's bundle was registered to the new container. $this->assertTrue($container->has('service_provider_test_class')); // Test that our synthetic services are there. $classloader = $container->get('class_loader'); - $refClass = new ReflectionClass($classloader); + $refClass = new \ReflectionClass($classloader); $this->assertTrue($refClass->hasMethod('loadClass'), 'Container has a classloader'); // Check that the location of the new module is registered. $modules = $container->getParameter('container.modules'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php index dc2fb1f..9c91b7e 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php @@ -9,7 +9,6 @@ use Drupal\Core\Language\Language; use Drupal\Core\TypedData\TranslatableInterface; -use InvalidArgumentException; /** * Tests entity translation. @@ -168,7 +167,7 @@ protected function _testEntityLanguageMethods($entity_type) { $entity->getTranslation('invalid')->get($this->field_name)->value; $this->fail('Getting a translation for an invalid language is NULL.'); } - catch (InvalidArgumentException $e) { + catch (\InvalidArgumentException $e) { $this->pass('A translation for an invalid language is NULL.'); } @@ -177,7 +176,7 @@ protected function _testEntityLanguageMethods($entity_type) { $entity->getTranslation('invalid')->set($this->field_name, NULL); $this->fail(format_string('%entity_type: Setting a translation for an invalid language throws an exception.', array('%entity_type' => $entity_type))); } - catch (InvalidArgumentException $e) { + catch (\InvalidArgumentException $e) { $this->pass(format_string('%entity_type: Setting a translation for an invalid language throws an exception.', array('%entity_type' => $entity_type))); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/FieldSqlStorageTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/FieldSqlStorageTest.php index 140bde8..d4a61f2 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/FieldSqlStorageTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/FieldSqlStorageTest.php @@ -12,7 +12,6 @@ use Drupal\field\FieldException; use Drupal\field\Entity\Field; use Drupal\system\Tests\Entity\EntityUnitTestBase; -use PDO; /** * Tests field storage. @@ -179,7 +178,7 @@ function testFieldWrite() { $entity->save(); // Read the tables and check the correct values have been stored. - $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC); + $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', \PDO::FETCH_ASSOC); $this->assertEqual(count($rows), $this->field['cardinality']); foreach ($rows as $delta => $row) { $expected = array( @@ -202,7 +201,7 @@ function testFieldWrite() { } $entity->{$this->field_name} = $values; $entity->save(); - $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC); + $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', \PDO::FETCH_ASSOC); $this->assertEqual(count($rows), count($values)); foreach ($rows as $delta => $row) { $expected = array( @@ -230,7 +229,7 @@ function testFieldWrite() { // Check that data for both revisions are in the revision table. foreach ($revision_values as $revision_id => $values) { - $rows = db_select($this->revision_table, 't')->fields('t')->condition('revision_id', $revision_id)->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC); + $rows = db_select($this->revision_table, 't')->fields('t')->condition('revision_id', $revision_id)->execute()->fetchAllAssoc('delta', \PDO::FETCH_ASSOC); $this->assertEqual(count($rows), min(count($values), $this->field['cardinality'])); foreach ($rows as $delta => $row) { $expected = array( @@ -249,7 +248,7 @@ function testFieldWrite() { // Test emptying the field. $entity->{$this->field_name} = NULL; $entity->save(); - $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC); + $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', \PDO::FETCH_ASSOC); $this->assertEqual(count($rows), 0); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php index e9ece26..61aa89a 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php @@ -7,7 +7,6 @@ namespace Drupal\system\Tests\Menu; -use PDO; use Drupal\simpletest\WebTestBase; /** diff --git a/core/modules/system/lib/Drupal/system/Tests/Pager/PagerTest.php b/core/modules/system/lib/Drupal/system/Tests/Pager/PagerTest.php index bb27fa0..dc8ead4 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Pager/PagerTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Pager/PagerTest.php @@ -8,7 +8,6 @@ namespace Drupal\system\Tests\Pager; use Drupal\simpletest\WebTestBase; -use SimpleXMLElement; /** * Tests pager functionality. @@ -138,14 +137,14 @@ protected function assertPagerItems($current_page) { /** * Asserts that an element has a given class. * - * @param SimpleXMLElement $element + * @param \SimpleXMLElement $element * The element to test. * @param string $class * The class to assert. * @param string $message * (optional) A verbose message to output. */ - protected function assertClass(SimpleXMLElement $element, $class, $message = NULL) { + protected function assertClass(\SimpleXMLElement $element, $class, $message = NULL) { if (!isset($message)) { $message = "Class .$class found."; } @@ -155,14 +154,14 @@ protected function assertClass(SimpleXMLElement $element, $class, $message = NUL /** * Asserts that an element does not have a given class. * - * @param SimpleXMLElement $element + * @param \SimpleXMLElement $element * The element to test. * @param string $class * The class to assert. * @param string $message * (optional) A verbose message to output. */ - protected function assertNoClass(SimpleXMLElement $element, $class, $message = NULL) { + protected function assertNoClass(\SimpleXMLElement $element, $class, $message = NULL) { if (!isset($message)) { $message = "Class .$class not found."; } diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/FunctionsTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/FunctionsTest.php index 9330299..635883c 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/FunctionsTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/FunctionsTest.php @@ -8,7 +8,6 @@ namespace Drupal\system\Tests\Theme; use Drupal\simpletest\WebTestBase; -use DOMDocument; /** * Tests for common theme functions. @@ -264,7 +263,7 @@ function testDrupalPreRenderLinks() { // it. $render_array = $base_array; $html = drupal_render($render_array); - $dom = new DOMDocument(); + $dom = new \DOMDocument(); $dom->loadHTML($html); $this->assertEqual($dom->getElementsByTagName('ul')->length, 1, 'One "ul" tag found in the rendered HTML.'); $list_elements = $dom->getElementsByTagName('li'); @@ -282,7 +281,7 @@ function testDrupalPreRenderLinks() { $child_html = drupal_render($render_array['first_child']); $parent_html = drupal_render($render_array); // First check the child HTML. - $dom = new DOMDocument(); + $dom = new \DOMDocument(); $dom->loadHTML($child_html); $this->assertEqual($dom->getElementsByTagName('ul')->length, 1, 'One "ul" tag found in the rendered child HTML.'); $list_elements = $dom->getElementsByTagName('li'); @@ -290,7 +289,7 @@ function testDrupalPreRenderLinks() { $this->assertEqual($list_elements->item(0)->nodeValue, 'Parent link copy', 'First expected link found.'); $this->assertEqual($list_elements->item(1)->nodeValue, 'First child link', 'Second expected link found.'); // Then check the parent HTML. - $dom = new DOMDocument(); + $dom = new \DOMDocument(); $dom->loadHTML($parent_html); $this->assertEqual($dom->getElementsByTagName('ul')->length, 1, 'One "ul" tag found in the rendered parent HTML.'); $list_elements = $dom->getElementsByTagName('li'); diff --git a/core/modules/system/lib/Drupal/system/Tests/TypedData/TypedDataTest.php b/core/modules/system/lib/Drupal/system/Tests/TypedData/TypedDataTest.php index c8e3cac..a0e4eb3 100644 --- a/core/modules/system/lib/Drupal/system/Tests/TypedData/TypedDataTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/TypedData/TypedDataTest.php @@ -10,7 +10,6 @@ use Drupal\Component\Utility\String; use Drupal\simpletest\DrupalUnitTestBase; use Drupal\Core\Datetime\DrupalDateTime; -use DateInterval; /** * Tests primitive data types. @@ -194,8 +193,8 @@ public function testGetAndSet() { $this->assertEqual($typed_data->validate()->count(), 1, 'Validation detected invalid value.'); // Check implementation of DurationInterface. $typed_data = $this->createTypedData(array('type' => 'duration_iso8601'), 'PT20S'); - $this->assertTrue($typed_data->getDuration() instanceof DateInterval); - $typed_data->setDuration(new DateInterval('P40D')); + $this->assertTrue($typed_data->getDuration() instanceof \DateInterval); + $typed_data->setDuration(new \DateInterval('P40D')); // @todo: Should we make this "nicer"? $this->assertEqual($typed_data->getValue(), 'P0Y0M40DT0H0M0S'); $typed_data->setValue(NULL); @@ -218,8 +217,8 @@ public function testGetAndSet() { $this->assertEqual($typed_data->validate()->count(), 1, 'Validation detected invalid value.'); // Check implementation of DurationInterface. $typed_data = $this->createTypedData(array('type' => 'timespan'), 20); - $this->assertTrue($typed_data->getDuration() instanceof DateInterval); - $typed_data->setDuration(new DateInterval('PT4H')); + $this->assertTrue($typed_data->getDuration() instanceof \DateInterval); + $typed_data->setDuration(new \DateInterval('PT4H')); $this->assertEqual($typed_data->getValue(), 60 * 60 * 4); $typed_data->setValue(NULL); $this->assertNull($typed_data->getDuration()); diff --git a/core/modules/text/lib/Drupal/text/TextProcessed.php b/core/modules/text/lib/Drupal/text/TextProcessed.php index c7a9215..f3c65e2 100644 --- a/core/modules/text/lib/Drupal/text/TextProcessed.php +++ b/core/modules/text/lib/Drupal/text/TextProcessed.php @@ -10,7 +10,6 @@ use Drupal\Core\TypedData\TypedDataInterface; use Drupal\Core\TypedData\TypedData; use Drupal\Core\TypedData\ReadOnlyException; -use InvalidArgumentException; /** * A computed property for processing text with a format. @@ -34,7 +33,7 @@ public function __construct(array $definition, $name = NULL, TypedDataInterface parent::__construct($definition, $name, $parent); if (!isset($definition['settings']['text source'])) { - throw new InvalidArgumentException("The definition's 'source' key has to specify the name of the text property to be processed."); + throw new \InvalidArgumentException("The definition's 'source' key has to specify the name of the text property to be processed."); } }