diff --git a/core/lib/Drupal/Core/Field/FieldDefinition.php b/core/lib/Drupal/Core/Field/FieldDefinition.php
index cfeccf8..7b695f1 100644
--- a/core/lib/Drupal/Core/Field/FieldDefinition.php
+++ b/core/lib/Drupal/Core/Field/FieldDefinition.php
@@ -475,7 +475,16 @@ public function getSchema() {
     if (!isset($this->schema)) {
       // Get the schema from the field item class.
       $definition = \Drupal::service('plugin.manager.field.field_type')->getDefinition($this->getType());
+      if (!isset($definition['class'])) {
+        throw new \Exception("\$definition['class'] is not set.");
+      }
       $class = $definition['class'];
+      if (!class_exists($class)) {
+        throw new \Exception(var_export($class, TRUE) . " is not a class.");
+      }
+      if (!is_subclass_of($class, 'Drupal\Core\Field\FieldItemInterface')) {
+        throw new \Exception("class $class must implement FieldItemInterface.");
+      }
       $schema = $class::schema($this);
       // Fill in default values.
       $schema += array(
diff --git a/core/modules/path/tests/src/Field/PathFieldDefinitionTest.php b/core/modules/path/tests/src/Field/PathFieldDefinitionTest.php
index fb99b82..89d4f6c 100644
--- a/core/modules/path/tests/src/Field/PathFieldDefinitionTest.php
+++ b/core/modules/path/tests/src/Field/PathFieldDefinitionTest.php
@@ -42,7 +42,12 @@ protected function getPluginId() {
    * {@inheritdoc}
    */
   protected function getNamespacePath() {
-    return dirname(dirname(dirname(__DIR__))) . '/lib/Drupal/path';
+    // @todo Remove this distinction after issue #2247991.
+    return is_dir($dir_psr4 = dirname(__DIR__) . '/src')
+      // After the PSR-4 transition.
+      ? $dir_psr4
+      // Before the PSR-4 transition.
+      : dirname(dirname(dirname(__DIR__))) . '/lib/Drupal/path';
   }
 
   /**
diff --git a/core/scripts/switch-psr4.sh b/core/scripts/switch-psr4.sh
index 07b6826..f460647 100644
--- a/core/scripts/switch-psr4.sh
+++ b/core/scripts/switch-psr4.sh
@@ -187,7 +187,9 @@ function process_candidate_dir($dir) {
 function process_extension($name, $dir) {
 
   if (!is_dir($source = "$dir/lib/Drupal/$name")) {
-    // Nothing to do in this module.
+    // No PSR-0 class files to be moved, but there could still be a remaining
+    // empty "lib" directory.
+    remove_empty_directory_tree_if_exists("$dir/lib");
     return;
   }
 
@@ -199,8 +201,7 @@ function process_extension($name, $dir) {
   move_directory_contents($source, $destination);
 
   // Clean up.
-  require_dir_empty("$dir/lib/Drupal");
-  rmdir("$dir/lib/Drupal");
+  remove_empty_directory_tree("$dir/lib");
 }
 
 /**
@@ -218,6 +219,9 @@ function process_extension_phpunit($name, $dir) {
 
   if (!is_dir($source = "$dir/tests/Drupal/$name/Tests")) {
     // Nothing to do in this module.
+    // No PSR-0 PHPUnit class files to be moved, but there could still be a
+    // remaining empty "tests/lib" directory.
+    remove_empty_directory_tree_if_exists("$dir/tests/lib");
     return;
   }
 
@@ -229,10 +233,7 @@ function process_extension_phpunit($name, $dir) {
   move_directory_contents($source, $dest);
 
   // Clean up.
-  require_dir_empty("$dir/tests/Drupal/$name");
-  rmdir("$dir/tests/Drupal/$name");
-  require_dir_empty("$dir/tests/Drupal");
-  rmdir("$dir/tests/Drupal");
+  remove_empty_directory_tree("$dir/tests/Drupal");
 }
 
 /**
@@ -284,6 +285,63 @@ function move_directory_contents($source, $destination) {
 }
 
 /**
+ * Removes a directory tree, if it exists and it contains no files.
+ *
+ * Throws an exception, if the given path is a file instead of a directory, or
+ * if the directory tree contains any files.
+ *
+ * @param string $dir
+ *   Path to the directory tree to be removed.
+ *
+ * @throws \Exception
+ */
+function remove_empty_directory_tree_if_exists($dir) {
+
+  if (!file_exists($dir)) {
+    // The path is neither a file nor a directory.
+    return;
+  }
+
+  // Recursively remove the directory and subfolders, and throw an exception if
+  // any file is found.
+  remove_empty_directory_tree($dir);
+}
+
+/**
+ * Removes a directory tree, if it contains only subdirectories and no files.
+ *
+ * Throws an exception if any file is found.
+ *
+ * @param string $dir
+ *   Path to the directory tree to be removed.
+ *
+ * @throws \Exception
+ */
+function remove_empty_directory_tree($dir) {
+
+  // Throw an exception if the directory does not exist.
+  require_is_readable_dir($dir);
+
+  // Recursively remove subdirectories, and verify that no files exist anywhere
+  // in the directory tree.
+  foreach (new \DirectoryIterator($dir) as $fileinfo) {
+    if ($fileinfo->isDot()) {
+      continue;
+    }
+    $path = $fileinfo->getPathname();
+    if ($fileinfo->isFile()) {
+      throw new \Exception("File '$path' found in a directory that is expected to not contain any files.");
+    }
+    if ($fileinfo->isDir()) {
+      remove_empty_directory_tree($path);
+    }
+  }
+
+  // Remove the parent directory.
+  rmdir($dir);
+}
+
+/**
  * Throws an exception if a directory is not empty.
  *
  * @param string $dir
@@ -292,18 +350,11 @@ function move_directory_contents($source, $destination) {
  * @throws \Exception
  */
 function require_dir_empty($dir) {
-  if (is_file($dir)) {
-    throw new \Exception("The path '$dir' is a file, when it should be a directory.");
-  }
-  if (!is_dir($dir)) {
-    throw new \Exception("The directory '$dir' does not exist.");
-  }
-  if (!is_readable($dir)) {
-    throw new \Exception("The directory '$dir' is not readable.");
-  }
-  /**
-   * @var \DirectoryIterator $fileinfo
-   */
+
+  // Throw an exception if the directory does not exist.
+  require_is_readable_dir($dir);
+
+  // Verify that no files or subfolders exist anywhere in the directory.
   foreach (new \DirectoryIterator($dir) as $fileinfo) {
     if ($fileinfo->isDot()) {
       continue;
@@ -317,3 +368,22 @@ function require_dir_empty($dir) {
     }
   }
 }
+
+/**
+ * Throws an exception if a given path is not a readable directory.
+ *
+ * @param $dir
+ *
+ * @throws \Exception
+ */
+function require_is_readable_dir($dir) {
+  if (is_file($dir)) {
+    throw new \Exception("The path '$dir' is a file, when it should be a directory.");
+  }
+  if (!is_dir($dir)) {
+    throw new \Exception("The directory '$dir' does not exist.");
+  }
+  if (!is_readable($dir)) {
+    throw new \Exception("The directory '$dir' is not readable.");
+  }
+}
diff --git a/core/vendor/guzzlehttp/guzzle/src/functions.php b/core/vendor/guzzlehttp/guzzle/src/functions.php
index 852c6db..0ebd8a1 100644
--- a/core/vendor/guzzlehttp/guzzle/src/functions.php
+++ b/core/vendor/guzzlehttp/guzzle/src/functions.php
@@ -17,7 +17,7 @@
  *
  * @return ResponseInterface
  */
-function request($method, $url, array $options = [])
+function request($method, $url, array $options = array())
 {
     static $client;
     if (!$client) {
@@ -35,7 +35,7 @@ function request($method, $url, array $options = [])
  *
  * @return ResponseInterface
  */
-function get($url, array $options = [])
+function get($url, array $options = array())
 {
     return request('GET', $url, $options);
 }
@@ -48,7 +48,7 @@ function get($url, array $options = [])
  *
  * @return ResponseInterface
  */
-function head($url, array $options = [])
+function head($url, array $options = array())
 {
     return request('HEAD', $url, $options);
 }
