From 261b71d29ceaf3b36df944689f1b87caff623319 Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole Date: Thu, 16 May 2013 09:15:22 +0100 Subject: [PATCH] Issue #1992950 by xjm: Stop use-ing Exception. --- .../Drupal/Component/Archiver/ArchiveTar.php | 6 ++---- .../Component/Archiver/ArchiverException.php | 6 ++---- .../Plugin/Exception/ContextException.php | 4 +--- .../Plugin/Exception/PluginException.php | 4 +--- core/lib/Drupal/Core/Config/DatabaseStorage.php | 3 +-- .../Core/Database/Driver/mysql/Schema.php | 6 ++---- .../Database/Driver/pgsql/Install/Tasks.php | 10 ++++------ .../Core/Database/Driver/pgsql/Schema.php | 2 -- .../Core/Database/Driver/sqlite/Connection.php | 3 +-- .../Database/Driver/sqlite/Install/Tasks.php | 4 +--- .../Core/Database/Driver/sqlite/Schema.php | 5 +---- core/lib/Drupal/Core/Database/Install/Tasks.php | 5 ++--- core/lib/Drupal/Core/Database/Query/Insert.php | 4 +--- .../Core/Entity/EntityMalformedException.php | 4 +--- .../Core/Entity/EntityStorageException.php | 4 +--- .../Core/Executable/ExecutableException.php | 4 +--- .../Core/TypedData/MissingContextException.php | 6 +----- .../Drupal/Core/TypedData/ReadOnlyException.php | 6 +----- .../Drupal/Core/Updater/UpdaterException.php | 5 +---- .../lib/Drupal/Core/Utility/UpdateException.php | 4 +--- .../field/lib/Drupal/field/Tests/CrudTest.php | 3 +-- .../Tests/FieldSqlStorageTest.php | 3 +-- .../locale/lib/Drupal/locale/Gettext.php | 7 +++---- .../Drupal/locale/StringStorageException.php | 4 +--- .../lib/Drupal/node/Tests/NodeCreationTest.php | 3 +-- .../Drupal/node/Tests/NodeQueryAlterTest.php | 12 +++++------- .../lib/Drupal/simpletest/TestBase.php | 3 +-- .../system/Tests/Database/InvalidDataTest.php | 1 - .../Drupal/system/Tests/Database/SchemaTest.php | 8 +++----- .../system/Tests/Database/TransactionTest.php | 7 +++---- .../Tests/Entity/EntityTranslationFormTest.php | 2 -- .../system/Tests/Plugin/AlterDecoratorTest.php | 1 - .../Drupal/system/Tests/Plugin/FactoryTest.php | 5 ++--- .../system/Tests/Routing/RouteProviderTest.php | 4 +--- .../Tests/Upgrade/UpgradePathTestBase.php | 17 ++++++++--------- 35 files changed, 56 insertions(+), 119 deletions(-) diff --git a/core/lib/Drupal/Component/Archiver/ArchiveTar.php b/core/lib/Drupal/Component/Archiver/ArchiveTar.php index 180422a476e..462fa7070cf 100644 --- a/core/lib/Drupal/Component/Archiver/ArchiveTar.php +++ b/core/lib/Drupal/Component/Archiver/ArchiveTar.php @@ -42,8 +42,6 @@ namespace Drupal\Component\Archiver; -use Exception; - //require_once 'PEAR.php'; // // @@ -636,7 +634,7 @@ class ArchiveTar // extends PEAR { // ----- To be completed // $this->raiseError($p_message); - throw new Exception($p_message); + throw new \Exception($p_message); } // }}} @@ -645,7 +643,7 @@ class ArchiveTar // extends PEAR { // ----- To be completed // $this->raiseError($p_message); - throw new Exception($p_message); + throw new \Exception($p_message); } // }}} diff --git a/core/lib/Drupal/Component/Archiver/ArchiverException.php b/core/lib/Drupal/Component/Archiver/ArchiverException.php index 12af470491d..0ef91b5310f 100644 --- a/core/lib/Drupal/Component/Archiver/ArchiverException.php +++ b/core/lib/Drupal/Component/Archiver/ArchiverException.php @@ -7,10 +7,8 @@ namespace Drupal\Component\Archiver; -use Exception; - /** * Defines an exception class for Drupal\Component\Archiver\ArchiverInterface. */ -class ArchiverException extends Exception { -} +class ArchiverException extends \Exception {} + diff --git a/core/lib/Drupal/Component/Plugin/Exception/ContextException.php b/core/lib/Drupal/Component/Plugin/Exception/ContextException.php index 061825118de..a494ea517a8 100644 --- a/core/lib/Drupal/Component/Plugin/Exception/ContextException.php +++ b/core/lib/Drupal/Component/Plugin/Exception/ContextException.php @@ -7,9 +7,7 @@ namespace Drupal\Component\Plugin\Exception; -use Exception; - /** * An exception class to be thrown for context plugin exceptions. */ -class ContextException extends Exception implements ExceptionInterface { } +class ContextException extends \Exception implements ExceptionInterface { } diff --git a/core/lib/Drupal/Component/Plugin/Exception/PluginException.php b/core/lib/Drupal/Component/Plugin/Exception/PluginException.php index f83bdad3d29..707955e4a91 100644 --- a/core/lib/Drupal/Component/Plugin/Exception/PluginException.php +++ b/core/lib/Drupal/Component/Plugin/Exception/PluginException.php @@ -6,10 +6,8 @@ namespace Drupal\Component\Plugin\Exception; -use Exception; - /** * Generic Plugin exception class to be thrown when no more specific class * is applicable. */ -class PluginException extends Exception implements ExceptionInterface { } +class PluginException extends \Exception implements ExceptionInterface { } diff --git a/core/lib/Drupal/Core/Config/DatabaseStorage.php b/core/lib/Drupal/Core/Config/DatabaseStorage.php index 3d43a8cce7d..cc595a6e089 100644 --- a/core/lib/Drupal/Core/Config/DatabaseStorage.php +++ b/core/lib/Drupal/Core/Config/DatabaseStorage.php @@ -9,7 +9,6 @@ namespace Drupal\Core\Config; use Drupal\Core\Database\Database; use Drupal\Core\Database\Connection; -use Exception; /** * Defines the Database storage controller. @@ -81,7 +80,7 @@ class DatabaseStorage implements StorageInterface { $data = $this->decode($raw); } } - catch (Exception $e) { + catch (\Exception $e) { } return $data; } diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php index 73785fde7d5..5788bef330d 100644 --- a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php +++ b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php @@ -13,8 +13,6 @@ use Drupal\Core\Database\SchemaObjectExistsException; use Drupal\Core\Database\SchemaObjectDoesNotExistException; use Drupal\Core\Database\Schema as DatabaseSchema; -use Exception; - /** * @addtogroup schemaapi * @{ @@ -516,7 +514,7 @@ class Schema extends DatabaseSchema { $this->connection->queryRange("SELECT 1 FROM {" . $table . "}", 0, 1); return TRUE; } - catch (Exception $e) { + catch (\Exception $e) { return FALSE; } } @@ -533,7 +531,7 @@ class Schema extends DatabaseSchema { $this->connection->queryRange("SELECT $column FROM {" . $table . "}", 0, 1); return TRUE; } - catch (Exception $e) { + catch (\Exception $e) { return FALSE; } } diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php index 78b7d06601b..1a053c0543a 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php @@ -12,8 +12,6 @@ use Drupal\Core\Database\Install\Tasks as InstallTasks; use Drupal\Core\Database\Driver\pgsql\Connection; use Drupal\Core\Database\DatabaseNotFoundException; -use Exception; - /** * PostgreSQL specific install functions */ @@ -55,7 +53,7 @@ class Tasks extends InstallTasks { Database::getConnection(); $this->pass('Drupal can CONNECT to the database ok.'); } - catch (Exception $e) { + catch (\Exception $e) { // Attempt to create the database if it is not found. if ($e->getCode() == Connection::DATABASE_NOT_FOUND) { // Remove the database string from connection info. @@ -118,7 +116,7 @@ class Tasks extends InstallTasks { $this->fail(st($text, $replacements)); } } - catch (Exception $e) { + catch (\Exception $e) { $this->fail(st('Drupal could not determine the encoding of the database was set to UTF-8')); } } @@ -145,7 +143,7 @@ class Tasks extends InstallTasks { try { db_query($query); } - catch (Exception $e) { + catch (\Exception $e) { // Ignore possible errors when the user doesn't have the necessary // privileges to ALTER the database. } @@ -233,7 +231,7 @@ class Tasks extends InstallTasks { $this->pass(st('PostgreSQL has initialized itself.')); } - catch (Exception $e) { + catch (\Exception $e) { $this->fail(st('Drupal could not be correctly setup with the existing database. Revise any errors.')); } } diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php index 0b65280ad17..e2798e19145 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php @@ -13,8 +13,6 @@ use Drupal\Core\Database\SchemaObjectExistsException; use Drupal\Core\Database\SchemaObjectDoesNotExistException; use Drupal\Core\Database\Schema as DatabaseSchema; -use Exception; - /** * @addtogroup schemaapi * @{ diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php index 7d05b1fad68..5aaf7da2c96 100644 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php +++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php @@ -16,7 +16,6 @@ use Drupal\Core\Database\Driver\sqlite\Statement; use Drupal\Core\Database\Connection as DatabaseConnection; use PDO; -use Exception; use SplFileInfo; /** @@ -161,7 +160,7 @@ class Connection extends DatabaseConnection { unlink($this->connectionOptions['database'] . '-' . $prefix); } } - catch (Exception $e) { + catch (\Exception $e) { // Ignore the exception and continue. There is nothing we can do here // to report the error or fail safe. } diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php index 5bf2642cc30..ab12bcca5e1 100644 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php +++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php @@ -12,8 +12,6 @@ use Drupal\Core\Database\Driver\sqlite\Connection; use Drupal\Core\Database\DatabaseNotFoundException; use Drupal\Core\Database\Install\Tasks as InstallTasks; -use Exception; - class Tasks extends InstallTasks { protected $pdoDriver = 'sqlite'; @@ -56,7 +54,7 @@ class Tasks extends InstallTasks { Database::getConnection(); $this->pass('Drupal can CONNECT to the database ok.'); } - catch (Exception $e) { + catch (\Exception $e) { // Attempt to create the database if it is not found. if ($e->getCode() == Connection::DATABASE_NOT_FOUND) { // Remove the database string from connection info. diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php index 91105e7e364..f8050cd7adb 100644 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php +++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php @@ -11,9 +11,6 @@ use Drupal\Core\Database\SchemaObjectExistsException; use Drupal\Core\Database\SchemaObjectDoesNotExistException; use Drupal\Core\Database\Schema as DatabaseSchema; -use Exception; - - /** * @ingroup schemaapi * @{ @@ -451,7 +448,7 @@ class Schema extends DatabaseSchema { } } else { - new Exception("Unable to parse the column type " . $row->type); + new \Exception("Unable to parse the column type " . $row->type); } } $indexes = array(); diff --git a/core/lib/Drupal/Core/Database/Install/Tasks.php b/core/lib/Drupal/Core/Database/Install/Tasks.php index ab1f771d2f3..b051c75f306 100644 --- a/core/lib/Drupal/Core/Database/Install/Tasks.php +++ b/core/lib/Drupal/Core/Database/Install/Tasks.php @@ -10,7 +10,6 @@ namespace Drupal\Core\Database\Install; use Drupal\Core\Database\Database; use PDO; -use Exception; /** * Database installer structure. @@ -166,7 +165,7 @@ abstract class Tasks { Database::getConnection(); $this->pass('Drupal can CONNECT to the database ok.'); } - catch (Exception $e) { + catch (\Exception $e) { $this->fail(st('Failed to connect to your database server. The server reports the following message: %error.', array('%error' => $e->getMessage()))); return FALSE; } @@ -181,7 +180,7 @@ abstract class Tasks { db_query($query); $this->pass(st($pass)); } - catch (Exception $e) { + catch (\Exception $e) { $this->fail(st($fail, array('%query' => $query, '%error' => $e->getMessage(), '%name' => $this->name()))); return !$fatal; } diff --git a/core/lib/Drupal/Core/Database/Query/Insert.php b/core/lib/Drupal/Core/Database/Query/Insert.php index b3c4c0e40a7..78624368459 100644 --- a/core/lib/Drupal/Core/Database/Query/Insert.php +++ b/core/lib/Drupal/Core/Database/Query/Insert.php @@ -9,8 +9,6 @@ namespace Drupal\Core\Database\Query; use Drupal\Core\Database\Database; -use Exception; - /** * General class for an abstracted INSERT query. */ @@ -220,7 +218,7 @@ class Insert extends Query { $last_insert_id = $this->connection->query($sql, $insert_values, $this->queryOptions); } } - catch (Exception $e) { + catch (\Exception $e) { // One of the INSERTs failed, rollback the whole batch. $transaction->rollback(); // Rethrow the exception for the calling code. diff --git a/core/lib/Drupal/Core/Entity/EntityMalformedException.php b/core/lib/Drupal/Core/Entity/EntityMalformedException.php index cc327962fe2..ab144486c89 100644 --- a/core/lib/Drupal/Core/Entity/EntityMalformedException.php +++ b/core/lib/Drupal/Core/Entity/EntityMalformedException.php @@ -7,9 +7,7 @@ namespace Drupal\Core\Entity; -use Exception; - /** * Defines an exception thrown when a malformed entity is passed. */ -class EntityMalformedException extends Exception { } +class EntityMalformedException extends \Exception { } diff --git a/core/lib/Drupal/Core/Entity/EntityStorageException.php b/core/lib/Drupal/Core/Entity/EntityStorageException.php index 1798f722d2b..082a2e2214c 100644 --- a/core/lib/Drupal/Core/Entity/EntityStorageException.php +++ b/core/lib/Drupal/Core/Entity/EntityStorageException.php @@ -7,9 +7,7 @@ namespace Drupal\Core\Entity; -use Exception; - /** * Defines an exception thrown when storage operations fail. */ -class EntityStorageException extends Exception { } +class EntityStorageException extends \Exception { } diff --git a/core/lib/Drupal/Core/Executable/ExecutableException.php b/core/lib/Drupal/Core/Executable/ExecutableException.php index ae9b135eb2e..8defc8a9fbc 100644 --- a/core/lib/Drupal/Core/Executable/ExecutableException.php +++ b/core/lib/Drupal/Core/Executable/ExecutableException.php @@ -6,11 +6,9 @@ namespace Drupal\Core\Executable; -use Exception; use Drupal\Component\Plugin\Exception\ExceptionInterface; /** * Generic executable plugin exception class. */ -class ExecutableException extends Exception implements ExceptionInterface { -} +class ExecutableException extends \Exception implements ExceptionInterface {} diff --git a/core/lib/Drupal/Core/TypedData/MissingContextException.php b/core/lib/Drupal/Core/TypedData/MissingContextException.php index 6ef2f8f2e56..b4a7c8e30e4 100644 --- a/core/lib/Drupal/Core/TypedData/MissingContextException.php +++ b/core/lib/Drupal/Core/TypedData/MissingContextException.php @@ -7,11 +7,7 @@ namespace Drupal\Core\TypedData; -use Exception; - /** * Exception thrown when data wrappers miss contextual information. */ -class MissingContextException extends Exception { - -} +class MissingContextException extends \Exception {} diff --git a/core/lib/Drupal/Core/TypedData/ReadOnlyException.php b/core/lib/Drupal/Core/TypedData/ReadOnlyException.php index 9e80a5962fe..2486a1659b8 100644 --- a/core/lib/Drupal/Core/TypedData/ReadOnlyException.php +++ b/core/lib/Drupal/Core/TypedData/ReadOnlyException.php @@ -7,11 +7,7 @@ namespace Drupal\Core\TypedData; -use Exception; - /** * Exception thrown when trying to write or set ready-only data. */ -class ReadOnlyException extends Exception { - -} +class ReadOnlyException extends \Exception {} diff --git a/core/lib/Drupal/Core/Updater/UpdaterException.php b/core/lib/Drupal/Core/Updater/UpdaterException.php index aee43a660d6..577620eed25 100644 --- a/core/lib/Drupal/Core/Updater/UpdaterException.php +++ b/core/lib/Drupal/Core/Updater/UpdaterException.php @@ -7,8 +7,6 @@ namespace Drupal\Core\Updater; -use Exception; - /** * Defines a Exception class for the Drupal\Core\Updater\Updater class * hierarchy. @@ -17,5 +15,4 @@ use Exception; * specific name so that call sites that want to tell the difference can * specifically catch these exceptions and treat them differently. */ -class UpdaterException extends Exception { -} +class UpdaterException extends \Exception {} diff --git a/core/lib/Drupal/Core/Utility/UpdateException.php b/core/lib/Drupal/Core/Utility/UpdateException.php index 4fa2b671f3e..358aa01d5ed 100644 --- a/core/lib/Drupal/Core/Utility/UpdateException.php +++ b/core/lib/Drupal/Core/Utility/UpdateException.php @@ -7,9 +7,7 @@ namespace Drupal\Core\Utility; -use Exception; - /** * Exception class used to throw error if a module update fails. */ -class UpdateException extends Exception { } +class UpdateException extends \Exception { } diff --git a/core/modules/field/lib/Drupal/field/Tests/CrudTest.php b/core/modules/field/lib/Drupal/field/Tests/CrudTest.php index 9ee6019ee21..125ed971647 100644 --- a/core/modules/field/lib/Drupal/field/Tests/CrudTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/CrudTest.php @@ -8,7 +8,6 @@ namespace Drupal\field\Tests; use Drupal\field\FieldException; -use Exception; class CrudTest extends FieldUnitTestBase { @@ -168,7 +167,7 @@ class CrudTest extends FieldUnitTestBase { $field = field_create_field($field_definition); $this->assertTrue(FALSE, 'Field creation (correctly) fails.'); } - catch (Exception $e) { + catch (\Exception $e) { $this->assertTrue(TRUE, 'Field creation (correctly) fails.'); } diff --git a/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php b/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php index 5263787384f..b7cf45e02f4 100644 --- a/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php +++ b/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php @@ -10,7 +10,6 @@ namespace Drupal\field_sql_storage\Tests; use Drupal\Core\Database\Database; use Drupal\field\FieldException; use Drupal\system\Tests\Entity\EntityUnitTestBase; -use Exception; use PDO; /** @@ -339,7 +338,7 @@ class FieldSqlStorageTest extends EntityUnitTestBase { field_update_field($field); $this->fail(t('Update succeeded.')); } - catch (Exception $e) { + catch (\Exception $e) { $this->pass(t('Update properly failed.')); } diff --git a/core/modules/locale/lib/Drupal/locale/Gettext.php b/core/modules/locale/lib/Drupal/locale/Gettext.php index 40472f085a3..859e4a767cf 100644 --- a/core/modules/locale/lib/Drupal/locale/Gettext.php +++ b/core/modules/locale/lib/Drupal/locale/Gettext.php @@ -10,7 +10,6 @@ namespace Drupal\locale; use Drupal\Component\Gettext\PoStreamReader; use Drupal\Component\Gettext\PoMemoryWriter; use Drupal\locale\PoDatabaseWriter; -use Exception; /** * Static class providing Drupal specific Gettext functionality. @@ -89,13 +88,13 @@ class Gettext { try { $reader->open(); } - catch (Exception $exception) { + catch (\Exception $exception) { throw $exception; } $header = $reader->getHeader(); if (!$header) { - throw new Exception('Missing or malformed header.'); + throw new \Exception('Missing or malformed header.'); } // Initialize the database writer. @@ -115,7 +114,7 @@ class Gettext { } $writer->writeItems($reader, $options['items']); } - catch (Exception $exception) { + catch (\Exception $exception) { throw $exception; } diff --git a/core/modules/locale/lib/Drupal/locale/StringStorageException.php b/core/modules/locale/lib/Drupal/locale/StringStorageException.php index c6f1b40d44c..96df9a68a33 100644 --- a/core/modules/locale/lib/Drupal/locale/StringStorageException.php +++ b/core/modules/locale/lib/Drupal/locale/StringStorageException.php @@ -7,9 +7,7 @@ namespace Drupal\locale; -use Exception; - /** * Defines an exception thrown when storage operations fail. */ -class StringStorageException extends Exception { } +class StringStorageException extends \Exception { } diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php index 36baad256d5..55ab2817d2f 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php @@ -8,7 +8,6 @@ namespace Drupal\node\Tests; use Drupal\Core\Database\Database; -use Exception; /** * Tests creating and saving a node. @@ -75,7 +74,7 @@ class NodeCreationTest extends NodeTestBase { entity_create('node', $edit)->save(); $this->fail(t('Expected exception has not been thrown.')); } - catch (Exception $e) { + catch (\Exception $e) { $this->pass(t('Expected exception has been thrown.')); } diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php index cb2b329c1d8..03eb4e3b29e 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php @@ -7,8 +7,6 @@ namespace Drupal\node\Tests; -use Exception; - /** * Tests node_query_node_access_alter(). */ @@ -100,7 +98,7 @@ class NodeQueryAlterTest extends NodeTestBase { $result = $query->execute()->fetchAll(); $this->assertEqual(count($result), 4, 'User with access can see correct nodes'); } - catch (Exception $e) { + catch (\Exception $e) { $this->fail(t('Altered query is malformed')); } } @@ -123,7 +121,7 @@ class NodeQueryAlterTest extends NodeTestBase { $result = $query->execute()->fetchAll(); $this->assertEqual(count($result), 0, 'User with no access cannot see nodes'); } - catch (Exception $e) { + catch (\Exception $e) { $this->fail(t('Altered query is malformed')); } } @@ -146,7 +144,7 @@ class NodeQueryAlterTest extends NodeTestBase { $result = $query->execute()->fetchAll(); $this->assertEqual(count($result), 0, 'User with view-only access cannot edit nodes'); } - catch (Exception $e) { + catch (\Exception $e) { $this->fail($e->getMessage()); $this->fail((string) $query); $this->fail(t('Altered query is malformed')); @@ -186,7 +184,7 @@ class NodeQueryAlterTest extends NodeTestBase { $result = $query->execute()->fetchAll(); $this->assertEqual(count($result), 0, 'User view privileges are not overridden'); } - catch (Exception $e) { + catch (\Exception $e) { $this->fail(t('Altered query is malformed')); } @@ -208,7 +206,7 @@ class NodeQueryAlterTest extends NodeTestBase { $result = $query->execute()->fetchAll(); $this->assertEqual(count($result), 4, 'User view privileges are overridden'); } - catch (Exception $e) { + catch (\Exception $e) { $this->fail(t('Altered query is malformed')); } state()->delete('node_access_test.no_access_uid'); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php index a67d0912a96..259d2750990 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -14,7 +14,6 @@ use Drupal\Core\Database\ConnectionNotDefinedException; use Drupal\Core\DrupalKernel; use ReflectionMethod; use ReflectionObject; -use Exception; /** * Base class for Drupal tests. @@ -733,7 +732,7 @@ abstract class TestBase { $this->$method(); // Finish up. } - catch (Exception $e) { + catch (\Exception $e) { $this->exceptionHandler($e); } $this->tearDown(); diff --git a/core/modules/system/lib/Drupal/system/Tests/Database/InvalidDataTest.php b/core/modules/system/lib/Drupal/system/Tests/Database/InvalidDataTest.php index c60b6d0b2d4..00bf68f26cf 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Database/InvalidDataTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Database/InvalidDataTest.php @@ -8,7 +8,6 @@ namespace Drupal\system\Tests\Database; use Drupal\Core\Database\IntegrityConstraintViolationException; -use Exception; /** * Tests invalid data handling. diff --git a/core/modules/system/lib/Drupal/system/Tests/Database/SchemaTest.php b/core/modules/system/lib/Drupal/system/Tests/Database/SchemaTest.php index fb4d2a1f993..4845751362f 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Database/SchemaTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Database/SchemaTest.php @@ -10,8 +10,6 @@ namespace Drupal\system\Tests\Database; use Drupal\Core\Database\Database; use Drupal\simpletest\UnitTestBase; -use Exception; - /** * Tests the Schema API. */ @@ -141,7 +139,7 @@ class SchemaTest extends UnitTestBase { try { db_create_table('test_timestamp', $table_specification); } - catch (Exception $e) {} + catch (\Exception $e) {} $this->assertTrue(db_table_exists('test_timestamp'), 'Table with database specific datatype was created.'); } @@ -161,7 +159,7 @@ class SchemaTest extends UnitTestBase { ->execute(); return TRUE; } - catch (Exception $e) { + catch (\Exception $e) { return FALSE; } } @@ -233,7 +231,7 @@ class SchemaTest extends UnitTestBase { ->execute(); return TRUE; } - catch (Exception $e) { + catch (\Exception $e) { return FALSE; } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Database/TransactionTest.php b/core/modules/system/lib/Drupal/system/Tests/Database/TransactionTest.php index 4d5ecf1d1cd..f2257ebdca6 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Database/TransactionTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Database/TransactionTest.php @@ -10,7 +10,6 @@ namespace Drupal\system\Tests\Database; use Drupal\Core\Database\Database; use Drupal\Core\Database\TransactionOutOfOrderException; use Drupal\Core\Database\TransactionNoActiveException; -use Exception; /** * Tests transaction support, particularly nesting. @@ -176,7 +175,7 @@ class TransactionTest extends DatabaseTestBase { $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'DanielB'))->fetchField(); $this->assertNotIdentical($saved_age, '19', 'Cannot retrieve DanielB row after commit.'); } - catch (Exception $e) { + catch (\Exception $e) { $this->fail($e->getMessage()); } } @@ -202,7 +201,7 @@ class TransactionTest extends DatabaseTestBase { $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'DanielB'))->fetchField(); $this->assertIdentical($saved_age, '19', 'DanielB not rolled back, since transactions are not supported.'); } - catch (Exception $e) { + catch (\Exception $e) { $this->fail($e->getMessage()); } } @@ -224,7 +223,7 @@ class TransactionTest extends DatabaseTestBase { $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'DanielA'))->fetchField(); $this->assertIdentical($saved_age, '19', 'Can retrieve DanielA row after commit.'); } - catch (Exception $e) { + catch (\Exception $e) { $this->fail($e->getMessage()); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php index 7672fbe5e98..012b909d282 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php @@ -7,8 +7,6 @@ namespace Drupal\system\Tests\Entity; -use Exception; -use InvalidArgumentException; use Drupal\simpletest\WebTestBase; use Drupal\Core\Language\Language; diff --git a/core/modules/system/lib/Drupal/system/Tests/Plugin/AlterDecoratorTest.php b/core/modules/system/lib/Drupal/system/Tests/Plugin/AlterDecoratorTest.php index a8030e99a7d..c6676ecffba 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Plugin/AlterDecoratorTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Plugin/AlterDecoratorTest.php @@ -8,7 +8,6 @@ namespace Drupal\system\Tests\Plugin; use Drupal\Component\Plugin\Exception\ExceptionInterface; -use Exception; use Drupal\plugin_test\Plugin\AlterDecoratorTestPluginManager; use Drupal\plugin_test\Plugin\TestPluginManager; use Drupal\simpletest\WebTestBase; diff --git a/core/modules/system/lib/Drupal/system/Tests/Plugin/FactoryTest.php b/core/modules/system/lib/Drupal/system/Tests/Plugin/FactoryTest.php index 55c160f974e..20bbf9ee881 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Plugin/FactoryTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Plugin/FactoryTest.php @@ -8,7 +8,6 @@ namespace Drupal\system\Tests\Plugin; use Drupal\Component\Plugin\Exception\ExceptionInterface; -use Exception; /** * Tests that plugins are correctly instantiated. @@ -41,7 +40,7 @@ class FactoryTest extends PluginTestBase { catch (ExceptionInterface $e) { $this->pass('Drupal\Component\Plugin\Exception\ExceptionInterface expected and caught.'); } - catch (Exception $e) { + catch (\Exception $e) { $this->fail('Drupal\Component\Plugin\Exception\ExceptionInterface expected, but ' . get_class($e) . ' was thrown.'); } } @@ -78,7 +77,7 @@ class FactoryTest extends PluginTestBase { catch (ExceptionInterface $e) { $this->pass('Drupal\Component\Plugin\Exception\ExceptionInterface expected and caught.'); } - catch (Exception $e) { + catch (\Exception $e) { $this->fail('An unexpected Exception of type "' . get_class($e) . '" was thrown with message ' . $e->getMessage()); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Routing/RouteProviderTest.php b/core/modules/system/lib/Drupal/system/Tests/Routing/RouteProviderTest.php index 2a4be2ff350..9afdb0546a0 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Routing/RouteProviderTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Routing/RouteProviderTest.php @@ -18,8 +18,6 @@ use Drupal\Core\Routing\RouteProvider; use Drupal\Core\Database\Database; use Drupal\Core\Routing\MatcherDumper; -use Exception; - /** * Basic tests for the RouteProvider. */ @@ -329,7 +327,7 @@ class RouteProviderTest extends UnitTestBase { $routes = $provider->getRouteCollectionForRequest($request); $this->fail(t('No exception was thrown.')); } - catch (Exception $e) { + catch (\Exception $e) { $this->assertTrue($e instanceof ResourceNotFoundException, 'The correct exception was thrown.'); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php index 00df52d6011..8c045fe3442 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php @@ -10,7 +10,6 @@ namespace Drupal\system\Tests\Upgrade; use Drupal\Component\Utility\Crypt; use Drupal\Core\Database\Database; use Drupal\simpletest\WebTestBase; -use Exception; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\HttpFoundation\Request; @@ -188,7 +187,7 @@ abstract class UpgradePathTestBase extends WebTestBase { } // Since cache_bootstrap won't exist in a Drupal 6 site, ignore the // exception if the above fails. - catch (Exception $e) {} + catch (\Exception $e) {} } /** @@ -220,12 +219,12 @@ abstract class UpgradePathTestBase extends WebTestBase { // Load the first update screen. $this->getUpdatePhp(); if (!$this->assertResponse(200)) { - throw new Exception('Initial GET to update.php did not return HTTP 200 status.'); + throw new \Exception('Initial GET to update.php did not return HTTP 200 status.'); } // Ensure that the first update screen appeared correctly. if (!$this->assertFieldByXPath('//input[@type="submit"]')) { - throw new Exception('An error was encountered during the first access to update.php.'); + throw new \Exception('An error was encountered during the first access to update.php.'); } // Initialize config directories and rebuild the service container after @@ -236,7 +235,7 @@ abstract class UpgradePathTestBase extends WebTestBase { // Continue. $this->drupalPost(NULL, array(), t('Continue')); if (!$this->assertResponse(200)) { - throw new Exception('POST to continue update.php did not return HTTP 200 status.'); + throw new \Exception('POST to continue update.php did not return HTTP 200 status.'); } // The test should pass if there are no pending updates. @@ -250,12 +249,12 @@ abstract class UpgradePathTestBase extends WebTestBase { // Go! $this->drupalPost(NULL, array(), t('Apply pending updates')); if (!$this->assertResponse(200)) { - throw new Exception('POST to update.php to apply pending updates did not return HTTP 200 status.'); + throw new \Exception('POST to update.php to apply pending updates did not return HTTP 200 status.'); } if (!$this->assertNoText(t('An unrecoverable error has occurred.'))) { // Error occured during update process. - throw new Exception('POST to update.php to apply pending updates detected an unrecoverable error.'); + throw new \Exception('POST to update.php to apply pending updates detected an unrecoverable error.'); } // Check for errors during the update process. @@ -269,7 +268,7 @@ abstract class UpgradePathTestBase extends WebTestBase { if (!empty($this->upgradeErrors)) { // Upgrade failed, the installation might be in an inconsistent state, // don't process. - throw new Exception('Errors during update process.'); + throw new \Exception('Errors during update process.'); } // Allow tests to check the completion page. @@ -279,7 +278,7 @@ abstract class UpgradePathTestBase extends WebTestBase { $this->getUpdatePhp(); $this->drupalPost(NULL, array(), t('Continue')); if (!$this->assertText(t('No pending updates.'), 'No pending updates at the end of the update process.')) { - throw new Exception('update.php still shows pending updates after execution.'); + throw new \Exception('update.php still shows pending updates after execution.'); } // Upgrade succeed, rebuild the environment so that we can call the API