diff --git a/core/lib/Drupal/Core/Cache/ApcuBackend.php b/core/lib/Drupal/Core/Cache/ApcuBackend.php
index 9bac79e..f04e240 100644
--- a/core/lib/Drupal/Core/Cache/ApcuBackend.php
+++ b/core/lib/Drupal/Core/Cache/ApcuBackend.php
@@ -53,6 +53,9 @@ class ApcuBackend implements CacheBackendInterface {
    *   The cache tags checksum provider.
    */
   public function __construct($bin, $site_prefix, CacheTagsChecksumInterface $checksum_provider) {
+    assert('is_string($bin)');
+    assert('is_string($site_prefix)');
+
     $this->bin = $bin;
     $this->sitePrefix = $site_prefix;
     $this->checksumProvider = $checksum_provider;
@@ -69,6 +72,7 @@ public function __construct($bin, $site_prefix, CacheTagsChecksumInterface $chec
    *   The APCu key for the cache item ID.
    */
   protected function getApcuKey($cid) {
+    assert('is_string($cid)');
     return $this->binPrefix . $cid;
   }
 
@@ -76,6 +80,7 @@ protected function getApcuKey($cid) {
    * {@inheritdoc}
    */
   public function get($cid, $allow_invalid = FALSE) {
+    assert('is_string($cid)');
     $cache = apc_fetch($this->getApcuKey($cid));
     return $this->prepareItem($cache, $allow_invalid);
   }
@@ -84,6 +89,7 @@ public function get($cid, $allow_invalid = FALSE) {
    * {@inheritdoc}
    */
   public function getMultiple(&$cids, $allow_invalid = FALSE) {
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $cids)');
     // Translate the requested cache item IDs to APCu keys.
     $map = array();
     foreach ($cids as $cid) {
@@ -166,7 +172,8 @@ protected function prepareItem($cache, $allow_invalid) {
    * {@inheritdoc}
    */
   public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) {
-    Cache::validateTags($tags);
+    assert('is_string($cid)');
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $tags)');
     $tags = array_unique($tags);
     $cache = new \stdClass();
     $cache->cid = $cid;
@@ -201,6 +208,7 @@ public function setMultiple(array $items = array()) {
    * {@inheritdoc}
    */
   public function delete($cid) {
+    assert('is_string($cid)');
     apc_delete($this->getApcuKey($cid));
   }
 
@@ -208,6 +216,7 @@ public function delete($cid) {
    * {@inheritdoc}
    */
   public function deleteMultiple(array $cids) {
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $cids)');
     apc_delete(array_map(array($this, 'getApcuKey'), $cids));
   }
 
@@ -236,6 +245,7 @@ public function removeBin() {
    * {@inheritdoc}
    */
   public function invalidate($cid) {
+    assert('is_string($cid)');
     $this->invalidateMultiple(array($cid));
   }
 
@@ -243,6 +253,7 @@ public function invalidate($cid) {
    * {@inheritdoc}
    */
   public function invalidateMultiple(array $cids) {
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $cids)');
     foreach ($this->getMultiple($cids) as $cache) {
       $this->set($cache->cid, $cache, REQUEST_TIME - 1);
     }
diff --git a/core/lib/Drupal/Core/Cache/Cache.php b/core/lib/Drupal/Core/Cache/Cache.php
index d149592..587d4e2 100644
--- a/core/lib/Drupal/Core/Cache/Cache.php
+++ b/core/lib/Drupal/Core/Cache/Cache.php
@@ -37,7 +37,7 @@ public static function mergeContexts() {
       $cache_contexts = array_merge($cache_contexts, $contexts);
     }
     $cache_contexts = array_unique($cache_contexts);
-    \Drupal::service('cache_contexts_manager')->validateTokens($cache_contexts);
+    assert('\\Drupal::service(\'cache_contexts_manager\')->assertValidTokens($cache_contexts)');
     sort($cache_contexts);
     return $cache_contexts;
   }
@@ -66,7 +66,7 @@ public static function mergeTags() {
       $cache_tags = array_merge($cache_tags, $tags);
     }
     $cache_tags = array_unique($cache_tags);
-    static::validateTags($cache_tags);
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $cache_tags)');
     sort($cache_tags);
     return $cache_tags;
   }
@@ -110,6 +110,8 @@ public static function mergeMaxAges() {
    *   An array of cache tags.
    *
    * @throws \LogicException
+   *
+   * @deprecated use assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $tags)');
    */
   public static function validateTags(array $tags) {
     if (empty($tags)) {
@@ -139,10 +141,14 @@ public static function validateTags(array $tags) {
    *   An array of cache tags.
    */
   public static function buildTags($prefix, array $suffixes, $glue = ':') {
+    assert('is_string($prefix)');
+    assert('is_string($glue)');
+
     $tags = [];
     foreach ($suffixes as $suffix) {
       $tags[] = $prefix . $glue . $suffix;
     }
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $tags)');
     return $tags;
   }
 
@@ -153,6 +159,7 @@ public static function buildTags($prefix, array $suffixes, $glue = ':') {
    *   The list of tags to invalidate cache items for.
    */
   public static function invalidateTags(array $tags) {
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $tags)');
     \Drupal::service('cache_tags.invalidator')->invalidateTags($tags);
   }
 
diff --git a/core/lib/Drupal/Core/Cache/CacheCollector.php b/core/lib/Drupal/Core/Cache/CacheCollector.php
index a6d8ab5..4f833d6 100644
--- a/core/lib/Drupal/Core/Cache/CacheCollector.php
+++ b/core/lib/Drupal/Core/Cache/CacheCollector.php
@@ -115,7 +115,7 @@
    *   (optional) The tags to specify for the cache item.
    */
   public function __construct($cid, CacheBackendInterface $cache, LockBackendInterface $lock, array $tags = array()) {
-    Cache::validateTags($tags);
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $tags)');
     $this->cid = $cid;
     $this->cache = $cache;
     $this->tags = $tags;
@@ -135,6 +135,7 @@ protected function getCid() {
    * {@inheritdoc}
    */
   public function has($key) {
+    assert('is_string($key)');
     // Make sure the value is loaded.
     $this->get($key);
     return isset($this->storage[$key]) || array_key_exists($key, $this->storage);
@@ -144,6 +145,7 @@ public function has($key) {
    * {@inheritdoc}
    */
   public function get($key) {
+    assert('is_string($key)');
     $this->lazyLoadCache();
     if (isset($this->storage[$key]) || array_key_exists($key, $this->storage)) {
       return $this->storage[$key];
@@ -163,6 +165,8 @@ public function get($key) {
    * this behavior, for example by adding a call to persist().
    */
   public function set($key, $value) {
+    assert('is_string($key)');
+
     $this->lazyLoadCache();
     $this->storage[$key] = $value;
     // The key might have been marked for deletion.
@@ -175,6 +179,8 @@ public function set($key, $value) {
    * {@inheritdoc}
    */
   public function delete($key) {
+    assert('is_string($key)');
+
     $this->lazyLoadCache();
     unset($this->storage[$key]);
     $this->keysToRemove[$key] = $key;
diff --git a/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php b/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php
index 64a8eb0..10038b1 100644
--- a/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php
+++ b/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php
@@ -27,8 +27,7 @@ class CacheTagsInvalidator implements CacheTagsInvalidatorInterface {
    * {@inheritdoc}
    */
   public function invalidateTags(array $tags) {
-    // Validate the tags.
-    Cache::validateTags($tags);
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $tags)');
 
     // Notify all added cache tags invalidators.
     foreach ($this->invalidators as $invalidator) {
diff --git a/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php b/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php
index 27b012a..8b2e6ec 100644
--- a/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php
+++ b/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php
@@ -105,6 +105,8 @@ public function getLabels($include_calculated_cache_contexts = FALSE) {
    * @throws \InvalidArgumentException
    */
   public function convertTokensToKeys(array $context_tokens) {
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $context_tokens)');
+
     $context_tokens = $this->optimizeTokens($context_tokens);
     sort($context_tokens);
     $keys = [];
@@ -115,6 +117,8 @@ public function convertTokensToKeys(array $context_tokens) {
       }
       $keys[] = $this->getService($context_id)->getContext($parameter);
     }
+
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $keys)');
     return $keys;
   }
 
@@ -148,6 +152,8 @@ public function convertTokensToKeys(array $context_tokens) {
    *   A representative subset of the given set of cache context tokens..
    */
   public function optimizeTokens(array $context_tokens) {
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $context_tokens)');
+
     $optimized_content_tokens = [];
     foreach ($context_tokens as $context_token) {
       // Context tokens without:
@@ -178,6 +184,8 @@ public function optimizeTokens(array $context_tokens) {
         }
       }
     }
+
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $optimized_content_tokens)');
     return $optimized_content_tokens;
   }
 
@@ -209,6 +217,8 @@ protected function getService($context_id) {
    *     there is no parameter.
    */
   public static function parseTokens(array $context_tokens) {
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $context_tokens)');
+
     $contexts_with_parameters = [];
     foreach ($context_tokens as $context) {
       $context_id = $context;
@@ -231,6 +241,9 @@ public static function parseTokens(array $context_tokens) {
    *
    * @throws \LogicException
    *
+   * @deprecated Direct invocation of this method is deprecated.
+   *   Use the assert statement to invoke ::assertValidTokens in this class.
+   *
    * @see \Drupal\Core\Cache\Context\CacheContextsManager::parseTokens()
    */
   public function validateTokens(array $context_tokens = []) {
@@ -271,4 +284,19 @@ public function validateTokens(array $context_tokens = []) {
     }
   }
 
+  /**
+   * Assert statement wrapper for ::validateTokens()
+   *
+   * @param string[] $context_tokens
+   *   An array of cache context tokens.
+   */
+  public function assertValidTokens(array $context_tokens = []) {
+    try {
+      $this->validateTokens($context_tokens);
+    } catch ( \LogicException $e) {
+      return FALSE;
+    }
+    return TRUE;
+  }
+
 }
diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php
index ff12845..56d164a 100644
--- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php
+++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php
@@ -52,6 +52,8 @@ class DatabaseBackend implements CacheBackendInterface {
    *   The cache bin for which the object is created.
    */
   public function __construct(Connection $connection, CacheTagsChecksumInterface $checksum_provider, $bin) {
+    assert('is_string($bin)');
+
     // All cache tables should be prefixed with 'cache_'.
     $bin = 'cache_' . $bin;
 
@@ -64,6 +66,7 @@ public function __construct(Connection $connection, CacheTagsChecksumInterface $
    * Implements Drupal\Core\Cache\CacheBackendInterface::get().
    */
   public function get($cid, $allow_invalid = FALSE) {
+    assert('is_string($cid)');
     $cids = array($cid);
     $cache = $this->getMultiple($cids, $allow_invalid);
     return reset($cache);
@@ -73,6 +76,7 @@ public function get($cid, $allow_invalid = FALSE) {
    * Implements Drupal\Core\Cache\CacheBackendInterface::getMultiple().
    */
   public function getMultiple(&$cids, $allow_invalid = FALSE) {
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $cids)');
     $cid_mapping = array();
     foreach ($cids as $cid) {
       $cid_mapping[$this->normalizeCid($cid)] = $cid;
@@ -120,6 +124,7 @@ public function getMultiple(&$cids, $allow_invalid = FALSE) {
    *   whether the item is valid, or FALSE if there is no valid item to load.
    */
   protected function prepareItem($cache, $allow_invalid) {
+    assert('is_object($cache)');
     if (!isset($cache->data)) {
       return FALSE;
     }
@@ -150,7 +155,8 @@ protected function prepareItem($cache, $allow_invalid) {
    * Implements Drupal\Core\Cache\CacheBackendInterface::set().
    */
   public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) {
-    Cache::validateTags($tags);
+    assert('is_string($cid)');
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $tags)');
     $tags = array_unique($tags);
     // Sort the cache tags so that they are stored consistently in the database.
     sort($tags);
@@ -210,7 +216,7 @@ public function setMultiple(array $items) {
         'tags' => array(),
       );
 
-      Cache::validateTags($item['tags']);
+      assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $item[\'tags\'])');
       $item['tags'] = array_unique($item['tags']);
       // Sort the cache tags so that they are stored consistently in the DB.
       sort($item['tags']);
@@ -268,6 +274,7 @@ public function setMultiple(array $items) {
    * Implements Drupal\Core\Cache\CacheBackendInterface::delete().
    */
   public function delete($cid) {
+    assert('is_string($cid)');
     $this->deleteMultiple(array($cid));
   }
 
@@ -275,6 +282,7 @@ public function delete($cid) {
    * Implements Drupal\Core\Cache\CacheBackendInterface::deleteMultiple().
    */
   public function deleteMultiple(array $cids) {
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $cids)');
     $cids = array_values(array_map(array($this, 'normalizeCid'), $cids));
     try {
       // Delete in chunks when a large array is passed.
@@ -315,6 +323,7 @@ public function deleteAll() {
    * Implements Drupal\Core\Cache\CacheBackendInterface::invalidate().
    */
   public function invalidate($cid) {
+    assert('is_string($cid)');
     $this->invalidateMultiple(array($cid));
   }
 
@@ -322,6 +331,7 @@ public function invalidate($cid) {
    * Implements Drupal\Core\Cache\CacheBackendInterface::invalidateMultiple().
    */
   public function invalidateMultiple(array $cids) {
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $cids)');
     $cids = array_values(array_map(array($this, 'normalizeCid'), $cids));
     try {
       // Update in chunks when a large array is passed.
@@ -431,6 +441,7 @@ protected function catchException(\Exception $e, $table_name = NULL) {
    *   An ASCII-encoded cache ID that is at most 255 characters long.
    */
   protected function normalizeCid($cid) {
+    assert('is_string($cid)');
     // Nothing to do if the ID is a US ASCII string of 255 characters or less.
     $cid_is_ascii = mb_check_encoding($cid, 'ASCII');
     if (strlen($cid) <= 255 && $cid_is_ascii) {
diff --git a/core/lib/Drupal/Core/Cache/MemoryBackend.php b/core/lib/Drupal/Core/Cache/MemoryBackend.php
index 63b56c2..a63e14c 100644
--- a/core/lib/Drupal/Core/Cache/MemoryBackend.php
+++ b/core/lib/Drupal/Core/Cache/MemoryBackend.php
@@ -37,6 +37,8 @@ public function __construct($bin) {
    * Implements Drupal\Core\Cache\CacheBackendInterface::get().
    */
   public function get($cid, $allow_invalid = FALSE) {
+    assert('is_string($cid)');
+
     if (isset($this->cache[$cid])) {
       return $this->prepareItem($this->cache[$cid], $allow_invalid);
     }
@@ -49,6 +51,8 @@ public function get($cid, $allow_invalid = FALSE) {
    * Implements Drupal\Core\Cache\CacheBackendInterface::getMultiple().
    */
   public function getMultiple(&$cids, $allow_invalid = FALSE) {
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $cids)');
+
     $ret = array();
 
     $items = array_intersect_key($this->cache, array_flip($cids));
@@ -107,7 +111,9 @@ protected function prepareItem($cache, $allow_invalid) {
    * Implements Drupal\Core\Cache\CacheBackendInterface::set().
    */
   public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) {
-    Cache::validateTags($tags);
+    assert('is_string($cid)');
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $tags)');
+
     $tags = array_unique($tags);
     // Sort the cache tags so that they are stored consistently in the database.
     sort($tags);
@@ -133,6 +139,8 @@ public function setMultiple(array $items = array()) {
    * Implements Drupal\Core\Cache\CacheBackendInterface::delete().
    */
   public function delete($cid) {
+    assert('is_string($cid)');
+
     unset($this->cache[$cid]);
   }
 
@@ -140,6 +148,7 @@ public function delete($cid) {
    * Implements Drupal\Core\Cache\CacheBackendInterface::deleteMultiple().
    */
   public function deleteMultiple(array $cids) {
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $cids)');
     $this->cache = array_diff_key($this->cache, array_flip($cids));
   }
 
@@ -154,6 +163,8 @@ public function deleteAll() {
    * Implements Drupal\Core\Cache\CacheBackendInterface::invalidate().
    */
   public function invalidate($cid) {
+    assert('is_string($cid)');
+
     if (isset($this->cache[$cid])) {
       $this->cache[$cid]->expire = $this->getRequestTime() - 1;
     }
@@ -163,6 +174,8 @@ public function invalidate($cid) {
    * Implements Drupal\Core\Cache\CacheBackendInterface::invalidateMultiple().
    */
   public function invalidateMultiple(array $cids) {
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $cids)');
+
     foreach ($cids as $cid) {
       $this->cache[$cid]->expire = $this->getRequestTime() - 1;
     }
@@ -172,6 +185,7 @@ public function invalidateMultiple(array $cids) {
    * {@inheritdoc}
    */
   public function invalidateTags(array $tags) {
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $tags)');
     foreach ($this->cache as $cid => $item) {
       if (array_intersect($tags, $item->tags)) {
         $this->cache[$cid]->expire = $this->getRequestTime() - 1;
diff --git a/core/lib/Drupal/Core/Cache/PhpBackend.php b/core/lib/Drupal/Core/Cache/PhpBackend.php
index 761e394..77f637a 100644
--- a/core/lib/Drupal/Core/Cache/PhpBackend.php
+++ b/core/lib/Drupal/Core/Cache/PhpBackend.php
@@ -51,6 +51,8 @@ class PhpBackend implements CacheBackendInterface {
    *   The cache tags checksum provider.
    */
   public function __construct($bin, CacheTagsChecksumInterface $checksum_provider) {
+    assert('is_string($bin)');
+
     $this->bin = 'cache_' . $bin;
     $this->checksumProvider = $checksum_provider;
   }
@@ -59,6 +61,7 @@ public function __construct($bin, CacheTagsChecksumInterface $checksum_provider)
    * {@inheritdoc}
    */
   public function get($cid, $allow_invalid = FALSE) {
+    assert('is_string($cid)');
     return $this->getByHash($this->normalizeCid($cid), $allow_invalid);
   }
 
@@ -74,6 +77,8 @@ public function get($cid, $allow_invalid = FALSE) {
    * @return bool|mixed
    */
   protected function getByHash($cidhash, $allow_invalid = FALSE) {
+    assert('is_string($cidhash)');
+
     if ($file = $this->storage()->getFullPath($cidhash)) {
       $cache = @include $file;
     }
@@ -96,6 +101,7 @@ public function setMultiple(array $items) {
    * {@inheritdoc}
    */
   public function getMultiple(&$cids, $allow_invalid = FALSE) {
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $cids)');
     $ret = array();
 
     foreach ($cids as $cid) {
@@ -125,6 +131,8 @@ public function getMultiple(&$cids, $allow_invalid = FALSE) {
    *   valid item to load.
    */
   protected function prepareItem($cache, $allow_invalid) {
+    assert('is_object($cache)');
+
     if (!isset($cache->data)) {
       return FALSE;
     }
@@ -148,7 +156,9 @@ protected function prepareItem($cache, $allow_invalid) {
    * {@inheritdoc}
    */
   public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) {
-    Cache::validateTags($tags);
+    assert('is_string($cid)');
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $tags)');
+
     $item = (object) array(
       'cid' => $cid,
       'data' => $data,
@@ -164,6 +174,8 @@ public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array
    * {@inheritdoc}
    */
   public function delete($cid) {
+    assert('is_string($cid)');
+
     $this->storage()->delete($this->normalizeCid($cid));
   }
 
@@ -171,6 +183,8 @@ public function delete($cid) {
    * {@inheritdoc}
    */
   public function deleteMultiple(array $cids) {
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $cids)');
+
     foreach ($cids as $cid) {
       $this->delete($cid);
     }
@@ -187,6 +201,8 @@ public function deleteAll() {
    * {@inheritdoc}
    */
   public function invalidate($cid) {
+    assert('is_string($cid)');
+
     $this->invalidatebyHash($this->normalizeCid($cid));
   }
 
@@ -207,6 +223,8 @@ protected function invalidatebyHash($cidhash) {
    * {@inheritdoc}
    */
   public function invalidateMultiple(array $cids) {
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $cids)');
+
     foreach ($cids as $cid) {
       $this->invalidate($cid);
     }
diff --git a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php
index e4e05bd..7fe3429 100644
--- a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php
+++ b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php
@@ -104,6 +104,9 @@ class DefaultPluginManager extends PluginManagerBase implements PluginManagerInt
    *   Defaults to 'Drupal\Component\Annotation\Plugin'.
    */
   public function __construct($subdir, \Traversable $namespaces, ModuleHandlerInterface $module_handler, $plugin_interface = NULL, $plugin_definition_annotation_name = 'Drupal\Component\Annotation\Plugin') {
+    assert('is_string($subdir) || is_bool($subdir)');
+    assert('is_null($plugin_interface) || interface_exists($plugin_interface)');
+
     $this->subdir = $subdir;
     $this->discovery = new AnnotatedClassDiscovery($subdir, $namespaces, $plugin_definition_annotation_name);
     $this->discovery = new ContainerDerivativeDiscoveryDecorator($this->discovery);
@@ -132,7 +135,9 @@ public function __construct($subdir, \Traversable $namespaces, ModuleHandlerInte
    *   definitions should be cleared along with other, related cache entries.
    */
   public function setCacheBackend(CacheBackendInterface $cache_backend, $cache_key, array $cache_tags = array()) {
-    Cache::validateTags($cache_tags);
+    assert('is_string($cache_key)');
+    assert('\\Drupal\\Component\\Assertion\\Assertion::allMembersAre(\'string\', $cache_tags)');
+
     $this->cacheBackend = $cache_backend;
     $this->cacheKey = $cache_key;
     $this->cacheTags = $cache_tags;
@@ -146,6 +151,7 @@ public function setCacheBackend(CacheBackendInterface $cache_backend, $cache_key
    *   hook_mymodule_data_alter() pass in "mymodule_data".
    */
   protected function alterInfo($alter_hook) {
+    assert('is_string($alter_hook)');
     $this->alterHook = $alter_hook;
   }
 
@@ -190,6 +196,7 @@ protected function getCachedDefinitions() {
     if (!isset($this->definitions) && $cache = $this->cacheGet($this->cacheKey)) {
       $this->definitions = $cache->data;
     }
+    assert('is_null($this->definitions) || is_array($this->definitions)');
     return $this->definitions;
   }
 
@@ -199,7 +206,7 @@ protected function getCachedDefinitions() {
    * @param array $definitions
    *   List of definitions to store in cache.
    */
-  protected function setCachedDefinitions($definitions) {
+  protected function setCachedDefinitions(array $definitions) {
     $this->cacheSet($this->cacheKey, $definitions, Cache::PERMANENT, $this->cacheTags);
     $this->definitions = $definitions;
   }
@@ -275,6 +282,7 @@ protected function findDefinitions() {
         unset($definitions[$plugin_id]);
       }
     }
+    assert('is_array($definitions)');
     return $definitions;
   }
 
diff --git a/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php b/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php
index 76d72b5..1a1e4cc 100644
--- a/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php
+++ b/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php
@@ -60,9 +60,12 @@ protected function setUp() {
     $cache_contexts_manager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager')
       ->disableOriginalConstructor()
       ->getMock();
+    $cache_contexts_manager->method('assertValidTokens')->willReturn(TRUE);
     $container = new ContainerBuilder();
     $container->set('cache_contexts_manager', $cache_contexts_manager);
+
     \Drupal::setContainer($container);
+
   }
 
   /**
diff --git a/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php b/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php
index cc0d9df..11c7316 100644
--- a/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php
+++ b/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php
@@ -10,6 +10,8 @@
 use Drupal\Core\Cache\Cache;
 use Drupal\Core\Cache\CacheBackendInterface;
 use Drupal\simpletest\KernelTestBase;
+use Drupal\simpletest\AssertionTestingTrait;
+use Drupal\Component\Assertion\AssertionException;
 
 /**
  * Tests any cache backend.
@@ -22,6 +24,7 @@
  *   For a full working implementation.
  */
 abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
+  use AssertionTestingTrait;
 
   /**
    * Array of objects implementing Drupal\Core\Cache\CacheBackendInterface.
@@ -107,6 +110,7 @@ protected function getCacheBackend($bin = null) {
   }
 
   protected function setUp() {
+    $this->startAssertionHandling();
     $this->cachebackends = array();
     $this->defaultValue = $this->randomMachineName(10);
 
@@ -116,6 +120,8 @@ protected function setUp() {
   }
 
   protected function tearDown() {
+    $this->stopAssertionHandling();
+    $this->assertAssertionNotRaised();
     // Destruct the registered backend, each test will get a fresh instance,
     // properly emptying it here ensure that on persistent data backends they
     // will come up empty the next test.
@@ -219,12 +225,14 @@ public function testSetGet() {
     $this->assertFalse($backend->get('test8'));
 
     // Calling ::set() with invalid cache tags.
+    $this->dieOnRaise = TRUE;
     try {
       $backend->set('exception_test', 'value', Cache::PERMANENT, ['node' => [3, 5, 7]]);
-      $this->fail('::set() was called with invalid cache tags, no exception was thrown.');
+      $this->fail('::set() was called with invalid cache tags, no assertion raised.');
     }
-    catch (\LogicException $e) {
-      $this->pass('::set() was called with invalid cache tags, an exception was thrown.');
+    catch (AssertionException $e) {
+      $this->pass('::set() was called with invalid cache tags, an assertion was raised.');
+      $this->dieOnRaise = FALSE;
     }
   }
 
@@ -413,6 +421,7 @@ public function testSetMultiple() {
     $this->assertEqual($cached['cid_5']->data, $items['cid_5']['data'], 'New cache item set correctly.');
 
     // Calling ::setMultiple() with invalid cache tags.
+    $this->dieOnRaise = TRUE;
     try {
       $items = [
         'exception_test_1' => array('data' => 1, 'tags' => []),
@@ -420,10 +429,11 @@ public function testSetMultiple() {
         'exception_test_3' => array('data' => 3, 'tags' => ['node' => [3, 5, 7]]),
       ];
       $backend->setMultiple($items);
-      $this->fail('::setMultiple() was called with invalid cache tags, no exception was thrown.');
+      $this->fail('::setMultiple() was called with invalid cache tags, no assertion was raised.');
     }
-    catch (\LogicException $e) {
-      $this->pass('::setMultiple() was called with invalid cache tags, an exception was thrown.');
+    catch (AssertionException $e) {
+      $this->pass('::setMultiple() was called with invalid cache tags, an assertion was raised.');
+      $this->dieOnRaise = FALSE;
     }
   }
 
diff --git a/core/tests/Drupal/Tests/Core/Cache/CacheTagsInvalidatorTest.php b/core/tests/Drupal/Tests/Core/Cache/CacheTagsInvalidatorTest.php
index 27c70e5..f650412 100644
--- a/core/tests/Drupal/Tests/Core/Cache/CacheTagsInvalidatorTest.php
+++ b/core/tests/Drupal/Tests/Core/Cache/CacheTagsInvalidatorTest.php
@@ -19,17 +19,6 @@ class CacheTagsInvalidatorTest extends UnitTestCase {
 
   /**
    * @covers ::invalidateTags
-   *
-   * @expectedException \LogicException
-   * @expectedExceptionMessage Cache tags must be strings, array given.
-   */
-  public function testInvalidateTagsWithInvalidTags() {
-    $cache_tags_invalidator = new CacheTagsInvalidator();
-    $cache_tags_invalidator->invalidateTags(['node' => [2, 3, 5, 8, 13]]);
-  }
-
-  /**
-   * @covers ::invalidateTags
    * @covers ::addInvalidator
    */
   public function testInvalidateTags() {
diff --git a/core/tests/Drupal/Tests/Core/Cache/CacheTest.php b/core/tests/Drupal/Tests/Core/Cache/CacheTest.php
index c2e61a1..2cdc030 100644
--- a/core/tests/Drupal/Tests/Core/Cache/CacheTest.php
+++ b/core/tests/Drupal/Tests/Core/Cache/CacheTest.php
@@ -18,48 +18,6 @@
 class CacheTest extends UnitTestCase {
 
   /**
-   * Provides a list of cache tags arrays.
-   *
-   * @return array
-   */
-  public function validateTagsProvider() {
-    return [
-      [[], FALSE],
-      [['foo'], FALSE],
-      [['foo', 'bar'], FALSE],
-      [['foo', 'bar', 'llama:2001988', 'baz', 'llama:14031991'], FALSE],
-      // Invalid.
-      [[FALSE], 'Cache tags must be strings, boolean given.'],
-      [[TRUE], 'Cache tags must be strings, boolean given.'],
-      [['foo', FALSE], 'Cache tags must be strings, boolean given.'],
-      [[NULL], 'Cache tags must be strings, NULL given.'],
-      [['foo', NULL], 'Cache tags must be strings, NULL given.'],
-      [[1337], 'Cache tags must be strings, integer given.'],
-      [['foo', 1337], 'Cache tags must be strings, integer given.'],
-      [[3.14], 'Cache tags must be strings, double given.'],
-      [['foo', 3.14], 'Cache tags must be strings, double given.'],
-      [[[]], 'Cache tags must be strings, array given.'],
-      [['foo', []], 'Cache tags must be strings, array given.'],
-      [['foo', ['bar']], 'Cache tags must be strings, array given.'],
-      [[new \stdClass()], 'Cache tags must be strings, object given.'],
-      [['foo', new \stdClass()], 'Cache tags must be strings, object given.'],
-    ];
-  }
-
-  /**
-   * @covers ::validateTags
-   *
-   * @dataProvider validateTagsProvider
-   */
-  public function testValidateTags(array $tags, $expected_exception_message) {
-    if ($expected_exception_message !== FALSE) {
-      $this->setExpectedException('LogicException', $expected_exception_message);
-    }
-    // If it doesn't throw an exception, validateTags() returns NULL.
-    $this->assertNull(Cache::validateTags($tags));
-  }
-
-  /**
    * Provides a list of pairs of cache tags arrays to be merged.
    *
    * @return array
diff --git a/core/tests/Drupal/Tests/Core/Cache/CacheableMetadataTest.php b/core/tests/Drupal/Tests/Core/Cache/CacheableMetadataTest.php
index f2dbd3e..e02613a 100644
--- a/core/tests/Drupal/Tests/Core/Cache/CacheableMetadataTest.php
+++ b/core/tests/Drupal/Tests/Core/Cache/CacheableMetadataTest.php
@@ -35,6 +35,7 @@ public function testMerge(CacheableMetadata $a, CacheableMetadata $b, CacheableM
     $cache_contexts_manager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager')
       ->disableOriginalConstructor()
       ->getMock();
+    $cache_contexts_manager->method('assertValidTokens')->willReturn(TRUE);
     $container = new ContainerBuilder();
     $container->set('cache_contexts_manager', $cache_contexts_manager);
     \Drupal::setContainer($container);
diff --git a/core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php b/core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php
index 644df8a..6cc6655 100644
--- a/core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php
+++ b/core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php
@@ -56,6 +56,7 @@ public function testMerge(BubbleableMetadata $a, CacheableMetadata $b, Bubbleabl
     $cache_contexts_manager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager')
       ->disableOriginalConstructor()
       ->getMock();
+    $cache_contexts_manager->method('assertValidTokens')->willReturn(TRUE);
     $container = new ContainerBuilder();
     $container->set('cache_contexts_manager', $cache_contexts_manager);
     $container->set('renderer', $renderer);
diff --git a/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php b/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php
index 7388c61..27d7187 100644
--- a/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php
+++ b/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php
@@ -104,6 +104,7 @@ protected function setUp() {
     $this->cacheContextsManager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager')
       ->disableOriginalConstructor()
       ->getMock();
+    $this->cacheContextsManager->method('assertValidTokens')->willReturn(TRUE);
     $this->cacheContextsManager->expects($this->any())
       ->method('convertTokensToKeys')
       ->willReturnCallback(function($context_tokens) {
diff --git a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
index f4e90de..23cd20b 100644
--- a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
+++ b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
@@ -62,6 +62,7 @@ protected function setUp() {
     $cache_contexts_manager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager')
       ->disableOriginalConstructor()
       ->getMock();
+    $cache_contexts_manager->method('assertValidTokens')->willReturn(TRUE);
     $container = new ContainerBuilder();
     $container->set('cache_contexts_manager', $cache_contexts_manager);
     \Drupal::setContainer($container);
